/**
 * MoneyFlow Central — Sovereign Design System (mf-design-system.css)
 * Swiss Quantitative Architecture × Modern High-Frequency Fintech
 * Pure, high-contrast, institutional Light Theme
 */

@layer reset, base, theme, components, utilities;

@layer reset {
  *, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }
  img, svg, picture, video {
    display: block;
    max-width: 100%;
  }
  input, button, textarea, select {
    font: inherit;
  }
}

@layer theme {
  :root {
    color-scheme: light;

    /* Backgrounds & Surfaces (Swiss Titanium & Porcelain Scale) */
    --mf-bg: #f8fafc;
    --mf-bg-surface: #ffffff;
    --mf-bg-card: #ffffff;
    --mf-bg-card-hover: #f8fafc;
    --mf-bg-elevated: #ffffff;
    --mf-bg-subtle: #f1f5f9;

    /* Borders & Dividers */
    --mf-border: #e2e8f0;
    --mf-border-subtle: #f1f5f9;
    --mf-border-strong: #cbd5e1;
    --mf-border-focus: #0f4c3a;

    /* Signature Quant Accents (Institutional Racing Green) */
    --mf-emerald: #0f4c3a;
    --mf-emerald-hover: #14532d;
    --mf-emerald-dim: #ecfdf5;
    --mf-emerald-border: #a7f3d0;
    --mf-emerald-text: #065f46;

    --mf-blue: #2563eb;
    --mf-blue-hover: #1d4ed8;
    --mf-blue-dim: #eff6ff;
    --mf-blue-border: #bfdbfe;
    --mf-blue-text: #1e40af;

    --mf-purple: #7c3aed;
    --mf-purple-dim: #f5f3ff;
    --mf-purple-border: #ddd6fe;

    --mf-amber: #d97706;
    --mf-amber-dim: #fffbeb;
    --mf-amber-border: #fde68a;
    --mf-amber-text: #92400e;

    --mf-red: #dc2626;
    --mf-red-hover: #b91c1c;
    --mf-red-dim: #fef2f2;
    --mf-red-border: #fecaca;
    --mf-red-text: #991b1b;

    /* Typographic Hierarchy */
    --mf-text-heading: #0f172a;
    --mf-text-body: #334155;
    --mf-text-muted: #64748b;
    --mf-text-dim: #94a3b8;

    /* Font Families */
    --mf-font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
    --mf-font-mono: "JetBrains Mono", "SF Mono", Consolas, monospace;

    /* Radii & Shadows */
    --mf-radius-xs: 4px;
    --mf-radius-sm: 6px;
    --mf-radius-md: 10px;
    --mf-radius-lg: 16px;
    --mf-radius-pill: 9999px;

    --mf-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --mf-shadow-md: 0 4px 16px -2px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.03);
    --mf-shadow-lg: 0 12px 32px -4px rgba(15, 23, 42, 0.12);
  }
}

@layer base {
  body {
    background-color: var(--mf-bg);
    color: var(--mf-text-body);
    font-family: var(--mf-font-sans);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
  }

  h1, h2, h3, h4, h5, h6 {
    color: var(--mf-text-heading);
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.02em;
  }

  code, pre, .mono, [data-mono] {
    font-family: var(--mf-font-mono);
    font-variant-numeric: tabular-nums;
  }

  a {
    color: var(--mf-emerald);
    text-decoration: none;
    transition: color 0.15s ease;
  }
  a:hover {
    color: var(--mf-emerald-hover);
  }
}

@layer components {
  /* ==========================================================================
     Top Navigation & Header
     ========================================================================== */
  .mf-nav {
    position: sticky;
    top: 0;
    z-index: 999;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--mf-border);
    padding: 0 32px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
  }

  .mf-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
  }
  .mf-brand-mark {
    width: 34px;
    height: 34px;
    border-radius: var(--mf-radius-sm);
    background: var(--mf-emerald);
    color: #ffffff;
    font-family: var(--mf-font-mono);
    font-weight: 800;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(15, 76, 58, 0.25);
  }
  .mf-brand-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--mf-text-heading);
    letter-spacing: -0.015em;
  }
  .mf-brand-sub {
    font-size: 11px;
    color: var(--mf-text-muted);
    font-weight: 500;
  }

  /* Telemetry Status Pill */
  .mf-telemetry {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: var(--mf-radius-pill);
    background: #ffffff;
    border: 1px solid var(--mf-border);
    font-size: 11.5px;
    color: var(--mf-text-muted);
    font-weight: 600;
    font-family: var(--mf-font-mono);
  }
  .mf-telemetry-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
  }

  /* ==========================================================================
     Cards & Container Surfaces
     ========================================================================== */
  .mf-card {
    background: var(--mf-bg-card);
    border: 1px solid var(--mf-border);
    border-radius: var(--mf-radius-lg);
    padding: 28px 32px;
    box-shadow: var(--mf-shadow-md);
    transition: all 0.2s ease;
  }
  .mf-card:hover {
    border-color: var(--mf-border-strong);
    box-shadow: var(--mf-shadow-lg);
  }

  .mf-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 16px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--mf-border-subtle);
  }
  .mf-card-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--mf-text-heading);
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .mf-card-desc {
    font-size: 13px;
    color: var(--mf-text-muted);
    margin-top: 3px;
  }

  /* ==========================================================================
     Clean Tables (Sticky Headers, Tabular Numbers, Zero Jitter)
     ========================================================================== */
  .mf-table-container {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--mf-border);
    border-radius: var(--mf-radius-md);
    background: #ffffff;
  }
  .mf-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
  }
  .mf-table th {
    background: var(--mf-bg-subtle);
    color: var(--mf-text-muted);
    font-weight: 700;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 12px 16px;
    border-bottom: 1px solid var(--mf-border);
    white-space: nowrap;
  }
  .mf-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--mf-border-subtle);
    color: var(--mf-text-body);
    vertical-align: middle;
  }
  .mf-table tr:hover td {
    background: #f8fafc;
  }
  .mf-table tr:last-child td {
    border-bottom: none;
  }
  .mf-table .num {
    font-family: var(--mf-font-mono);
    font-variant-numeric: tabular-nums;
    text-align: right;
  }

  /* ==========================================================================
     Buttons
     ========================================================================== */
  .mf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--mf-radius-sm);
    border: 1px solid var(--mf-border-strong);
    background: #ffffff;
    color: var(--mf-text-heading);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    text-decoration: none;
    box-shadow: var(--mf-shadow-sm);
  }
  .mf-btn:hover {
    background: var(--mf-bg-subtle);
    border-color: var(--mf-text-muted);
  }
  .mf-btn-primary {
    background: var(--mf-emerald);
    border-color: var(--mf-emerald);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(15, 76, 58, 0.25);
  }
  .mf-btn-primary:hover {
    background: var(--mf-emerald-hover);
    color: #ffffff;
  }
  .mf-btn-danger {
    background: var(--mf-red-dim);
    border-color: var(--mf-red-border);
    color: var(--mf-red-text);
  }
  .mf-btn-danger:hover {
    background: var(--mf-red);
    color: #ffffff;
  }

  /* ==========================================================================
     Badges & Pills
     ========================================================================== */
  .mf-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--mf-radius-xs);
    white-space: nowrap;
  }
  .mf-badge-emerald {
    background: var(--mf-emerald-dim);
    color: var(--mf-emerald-text);
    border: 1px solid var(--mf-emerald-border);
  }
  .mf-badge-blue {
    background: var(--mf-blue-dim);
    color: var(--mf-blue-text);
    border: 1px solid var(--mf-blue-border);
  }
  .mf-badge-amber {
    background: var(--mf-amber-dim);
    color: var(--mf-amber-text);
    border: 1px solid var(--mf-amber-border);
  }
  .mf-badge-red {
    background: var(--mf-red-dim);
    color: var(--mf-red-text);
    border: 1px solid var(--mf-red-border);
  }

  /* ==========================================================================
     Form Inputs
     ========================================================================== */
  .mf-input, .mf-select, .mf-textarea {
    width: 100%;
    padding: 10px 14px;
    background: #ffffff;
    border: 1px solid var(--mf-border-strong);
    border-radius: var(--mf-radius-sm);
    color: var(--mf-text-heading);
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
  }
  .mf-input:focus, .mf-select:focus, .mf-textarea:focus {
    border-color: var(--mf-emerald);
    box-shadow: 0 0 0 3px rgba(15, 76, 58, 0.12);
  }

  /* ==========================================================================
     Institutional Dialogs & Modals (<dialog>)
     ========================================================================== */
  dialog.mf-modal {
    margin: auto;
    background: #ffffff;
    border: 1px solid var(--mf-border);
    border-radius: var(--mf-radius-lg);
    color: var(--mf-text-heading);
    padding: 0;
    max-width: 520px;
    width: 90%;
    box-shadow: var(--mf-shadow-lg);
    outline: none;
  }
  dialog.mf-modal::backdrop {
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }
}
