@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@300;400;500;600&display=swap');

/* mox.css — MoxSuite Design System v1.0
   Layers: reset → tokens → base → layout → components → utilities
   Mobile-first. !important yasak (.hidden utility hariç). Hex sadece :root ve [data-theme="light"].
*/

@layer reset, tokens, base, layout, components, utilities;

/* ─── RESET ─────────────────────────────────────────────────────── */
@layer reset {
  * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }

  html,
  body {
    height: 100%;
  }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--ff-sans);
    font-size: var(--fs-md);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  button {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    cursor: pointer;
  }

  input,
  select,
  textarea {
    font: inherit;
    color: inherit;
  }

  img {
    max-width: 100%;
    display: block;
  }

  svg {
    display: block;
  }
}

/* ─── TOKENS ─────────────────────────────────────────────────────── */
@layer tokens {
  :root {
    /* Surfaces */
    --bg: #1a1917;
    --surface: #21201c;
    --surface2: #282723;
    --surface3: #2f2d28;

    /* Borders */
    --border: #3a3730;
    --borderL: #46433a;

    /* Text */
    --text: #e5e0d5;
    --muted: #7a7468;
    --muted2: #9a9488;
    --dim: #9a9488;

    /* Accent (gold) */
    --accent: #e8bc42;
    --accentD: rgba(232, 188, 66, 0.12);

    /* Semantic */
    --green: #5aad7a;
    --greenD: rgba(90, 173, 122, 0.12);
    --red: #d45e5e;
    --redD: rgba(212, 94, 94, 0.12);
    --blue: #6a9ae0;
    --blueD: rgba(106, 154, 224, 0.12);
    --purple: #9a7dd4;
    --purpleD: rgba(154, 125, 212, 0.12);
    --orange: #e89950;
    --orangeD: rgba(232, 153, 80, 0.12);

    /* Layout */
    --topbar-h: 52px;
    --sidebar-w: 220px;
    --sidebar-w-c: 48px;
    --bnav-h: 60px;

    /* Breakpoints (referans — JS için; CSS @media'da literal yaz) */
    --bp-sm: 480px;
    --bp-md: 768px;
    --bp-lg: 1024px;

    /* Radius */
    --r-sm: 4px;
    --r: 6px;
    --r-md: 8px;
    --r-lg: 12px;
    --r-xl: 14px;

    /* Transitions */
    --t-fast: 0.12s;
    --t: 0.18s;
    --t-slow: 0.24s;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);

    /* Fonts */
    --ff-sans: 'IBM Plex Sans', -apple-system, system-ui, sans-serif;
    --ff-mono: 'IBM Plex Mono', ui-monospace, monospace;

    /* Font sizes */
    --fs-xs: 10px;
    --fs-sm: 12px;
    --fs: 13px;
    --fs-md: 14px;
    --fs-lg: 16px;
    --fs-xl: 20px;

    /* Z-index */
    --z-sidebar: 200;
    --z-topbar: 300;
    --z-bnav: 300;
    --z-drawer: 400;
    --z-modal: 500;
    --z-toast: 9999;
  }

  [data-theme="light"] {
    --bg: #f2f0eb;
    --surface: #faf9f6;
    --surface2: #f0ede8;
    --surface3: #e8e4de;
    --border: #d8d4cc;
    --borderL: #c8c4bc;
    --text: #1c1a17;
    --muted: #78746c;
    --muted2: #585248;
    --dim: #9a9488;
    --accent: #c9a020;
    --accentD: rgba(201, 160, 32, 0.10);
    --green: #3e8f5e;
    --greenD: rgba(62, 143, 94, 0.10);
    --red: #b84040;
    --redD: rgba(184, 64, 64, 0.10);
    --blue: #4a7ac0;
    --blueD: rgba(74, 122, 192, 0.10);
    --purple: #7a5db4;
    --purpleD: rgba(122, 93, 180, 0.10);
    --orange: #c07030;
    --orangeD: rgba(192, 112, 48, 0.10);
  }
}

/* ─── BASE ───────────────────────────────────────────────────────── */
@layer base {
  @keyframes mox-spin {
    to { transform: rotate(360deg); }
  }

  @keyframes mox-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  @keyframes mox-slide-up {
    from { transform: translateY(8px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }

  @keyframes mox-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.25; }
  }

  .hidden { display: none !important; }
}

/* ─── LAYOUT ─────────────────────────────────────────────────────── */
@layer layout {

  /* ── layout-app ─────────────────────────────────────────────────
     envanter, cari, sevkiyat, panel, prim, pdks, istatistik,
     cari_mudur, envanter-personel
     DOM: body.layout-app > aside.sidebar + header.topbar +
          div.drawer-mask + nav.bottom-nav + main.main
  ─────────────────────────────────────────────────────────────── */

  /* MOBILE default */
  .layout-app .sidebar {
    display: none;
  }

  .layout-app .topbar {
    display: flex;
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-topbar);
    align-items: center;
    padding: 0 14px;
    gap: 10px;
    padding-top: env(safe-area-inset-top);
  }

  .layout-app .bottom-nav {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: var(--z-bnav);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .layout-app .main {
    margin-left: 0;
    padding-top: calc(var(--topbar-h) + env(safe-area-inset-top));
  }

  .layout-app .page {
    display: none;
    padding: 16px;
    padding-bottom: calc(var(--bnav-h) + env(safe-area-inset-bottom) + 16px);
  }

  .layout-app .page.active {
    display: block;
    animation: mox-fade-in var(--t);
  }

  /* Drawer — mobile */
  .layout-app .drawer-mask {
    position: fixed;
    inset: 0;
    z-index: var(--z-drawer);
    display: none;
  }

  .layout-app .drawer-mask.open {
    display: block;
  }

  .layout-app .drawer-panel {
    transform: translateX(-100%);
    transition: transform var(--t-slow) var(--ease);
    width: 260px;
  }

  .layout-app .drawer-mask.open .drawer-panel {
    transform: translateX(0);
  }

  /* DESKTOP override */
  @media (min-width: 768px) {
    .layout-app .sidebar {
      display: flex;
      flex-direction: column;
      position: fixed;
      top: 0;
      left: 0;
      bottom: 0;
      width: var(--sidebar-w);
      z-index: var(--z-sidebar);
      background: var(--surface);
      border-right: 1px solid var(--border);
      transition: width var(--t) var(--ease);
    }

    .layout-app .sidebar.collapsed {
      width: var(--sidebar-w-c);
    }

    .layout-app .topbar {
      display: none;
    }

    .layout-app .bottom-nav {
      display: none;
    }

    .layout-app .drawer-mask {
      display: none;
    }

    .layout-app .main {
      margin-left: var(--sidebar-w);
      transition: margin-left var(--t) var(--ease);
    }

    .layout-app .main.collapsed {
      margin-left: var(--sidebar-w-c);
    }

    .layout-app .page {
      padding: 24px;
      padding-bottom: 48px;
    }
  }

  /* Sidebar detail classes */
  .sb-logo {
    height: var(--topbar-h);
    padding: 0 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--ff-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--accent);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    flex-shrink: 0;
  }

  .sb-nav {
    flex: 1;
    padding: 8px;
    overflow-y: auto;
  }

  .sb-sec {
    font-size: 9px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 10px 10px 4px;
  }

  .sb-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 10px;
  }

  .sb-footer {
    padding: 8px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
  }

  .sb-collapse {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--r-sm);
    color: var(--muted);
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast);
  }

  .sb-collapse:hover {
    background: var(--surface2);
    color: var(--text);
  }

  .sb-collapse svg {
    transition: transform var(--t-slow);
  }

  .sidebar.collapsed .sb-collapse svg {
    transform: rotate(180deg);
  }

  .sidebar.collapsed .nav-label,
  .sidebar.collapsed .nav-badge,
  .sidebar.collapsed .sb-sec,
  .sidebar.collapsed .sb-logo span {
    display: none;
  }

  /* Topbar detail */
  .tb-logo {
    font-family: var(--ff-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--accent);
    text-transform: uppercase;
    flex: 1;
  }

  /* Drawer detail */
  .drawer-bg {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.70);
  }

  .drawer-panel {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding-top: env(safe-area-inset-top);
  }

  .drawer-hd {
    height: var(--topbar-h);
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  .drawer-nav {
    flex: 1;
    padding: 8px;
    overflow-y: auto;
  }

  .drawer-footer {
    padding: 8px;
    border-top: 1px solid var(--border);
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  /* Bottom-nav detail */
  .bnav-inner {
    display: flex;
    justify-content: space-around;
    padding: 4px 0 2px;
  }

  /* Page header */
  .page-hd {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
  }

  .page-title {
    font-family: var(--ff-mono);
    font-size: 16px;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.5px;
  }

  .page-sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 3px;
  }

  /* ── layout-static ───────────────────────────────────────────────
     index, mudur, dataguard, kapanis
     DOM: body.layout-static > header.static-header + main.static-main
  ─────────────────────────────────────────────────────────────── */

  .static-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 12px;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: env(safe-area-inset-top);
    position: sticky;
    top: 0;
    z-index: var(--z-topbar);
  }

  .static-main {
    padding: 16px 12px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    max-width: 100%;
  }

  @media (min-width: 768px) {
    .static-header {
      min-height: 52px;
      padding: 0 24px;
    }

    .static-main {
      padding: 32px 24px;
      max-width: 1200px;
      margin: 0 auto;
    }
  }

  @media (max-width: 768px) {
    .static-header.toolbar {
      flex-wrap: wrap;
      height: auto;
      min-height: 44px;
      padding-top: calc(8px + env(safe-area-inset-top));
      padding-bottom: 8px;
      row-gap: 8px;
    }
    .static-header.toolbar .toolbar-spacer {
      display: none;
    }
  }

  /* ── layout-mobile ───────────────────────────────────────────────
     resim ve diğer mobile-only modüller
     DOM: body.layout-mobile > header.mob-header + main.mob-main
  ─────────────────────────────────────────────────────────────── */

  .mob-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 16px;
    padding-top: calc(14px + env(safe-area-inset-top));
    display: flex;
    align-items: center;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: var(--z-topbar);
  }

  .mob-main {
    padding: 12px 16px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
}

/* ─── COMPONENTS ─────────────────────────────────────────────────── */
@layer components {

  /* ── Buttons ─────────────────────────────────────────────────── */

  .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    min-height: 38px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    font-family: inherit;
    font-size: var(--fs);
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    transition: border-color var(--t-fast), background var(--t-fast), opacity var(--t-fast);
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
  }

  .btn:hover {
    border-color: var(--borderL);
  }

  .btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  .btn:active {
    opacity: 0.8;
  }

  .btn:disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
  }

  .btn svg {
    width: 13px;
    height: 13px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    flex-shrink: 0;
  }

  .btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #000000;
    font-weight: 600;
  }

  .btn-primary:hover {
    opacity: 0.9;
    border-color: var(--accent);
  }

  .btn-danger {
    color: var(--red);
    border-color: rgba(212, 94, 94, 0.30);
  }

  .btn-danger:hover {
    background: var(--redD);
  }

  .btn-orange {
    color: var(--orange);
    border-color: rgba(232, 153, 80, 0.30);
    font-weight: 500;
  }

  .btn-orange:hover {
    background: var(--orangeD);
  }

  .btn-success {
    color: var(--green);
    border-color: rgba(90, 173, 122, 0.30);
    background: var(--greenD);
    font-weight: 500;
  }

  .btn-success:hover {
    background: rgba(90, 173, 122, 0.20);
  }

  .btn .spin {
    display: none;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(128,128,128,.3);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: mox-spin .6s linear infinite;
  }
  .btn.loading {
    pointer-events: none;
  }
  .btn.loading .spin {
    display: inline-block;
  }
  .btn.loading .lbl {
    display: none;
  }

  .btn-sm {
    padding: 5px 10px;
    font-size: var(--fs-sm);
    min-height: 30px;
  }

  .btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }

  /* Icon button */
  .icon-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--r);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: border-color var(--t-fast), color var(--t-fast);
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
  }

  .icon-btn:hover {
    border-color: var(--borderL);
    color: var(--text);
  }

  .icon-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  .icon-btn:active {
    opacity: 0.8;
  }

  .icon-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    flex-shrink: 0;
  }

  .ib-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--red);
    color: #ffffff;
    font-family: var(--ff-mono);
    font-size: 9px;
    font-weight: 600;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--bg);
  }

  /* ── Inputs ──────────────────────────────────────────────────── */

  .input {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    color: var(--text);
    font-family: inherit;
    font-size: 16px;
    line-height: 1.4;
    outline: none;
    transition: border-color var(--t-fast);
    -webkit-appearance: none;
    appearance: none;
  }

  .input:focus {
    border-color: var(--accent);
  }

  .input:focus-visible {
    border-color: var(--accent);
  }

  .input::placeholder {
    color: var(--muted);
  }

  .input:disabled {
    opacity: 0.5;
    cursor: default;
  }

  .form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
  }

  .form-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-family: var(--ff-mono);
  }

  /* Search bar */
  .search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
  }

  .search-wrap {
    flex: 1;
    position: relative;
  }

  .search-wrap svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    width: 15px;
    height: 15px;
    pointer-events: none;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
  }

  .filter-bar > .search-input,
  .filter-bar > .search-wrap {
    flex: 1;
    min-width: 180px;
  }

  .search-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    color: var(--text);
    font-family: inherit;
    font-size: 16px;
    line-height: 1.4;
    outline: none;
    transition: border-color var(--t-fast);
    -webkit-appearance: none;
    appearance: none;
  }

  .search-wrap .search-input {
    padding-left: 36px;
  }

  .search-input:focus {
    border-color: var(--accent);
  }

  .search-input::placeholder {
    color: var(--muted);
  }

  /* Filter bar */
  .filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
  }
  .filter-bar.scroll {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .filter-bar.scroll > * { flex-shrink: 0; }
  .filter-bar.dense {
    gap: 4px;
  }

  .filter-select {
    padding: 8px 28px 8px 12px;
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%237a7468' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
    font-family: var(--ff-mono);
    font-size: 12px;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    min-height: 36px;
    transition: border-color var(--t-fast);
  }

  .filter-select:focus,
  .filter-select:focus-visible {
    border-color: var(--accent);
  }

  .filter-select.active {
    border-color: var(--accent);
    background-color: var(--accentD);
  }

  /* ── Cards ───────────────────────────────────────────────────── */

  .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
  }

  .card-head {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
  }

  .card-body {
    padding: 14px 16px;
  }

  .card-foot {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface2);
  }

  /* ── KPI Grid ───────────────────────────────────────────────────── */

  .kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 8px;
  }
  .kpi-grid.compact {
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 6px;
  }
  .kpi-grid.tight {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
  }

  @media (max-width: 480px) {
    .kpi-grid {
      grid-template-columns: repeat(2, 1fr);
    }
    .kpi-grid.compact {
      grid-template-columns: repeat(3, 1fr);
    }
    .kpi-grid.tight {
      grid-template-columns: 1fr;
    }
  }

  .kpi-cell {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 14px 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .kpi-grid.compact .kpi-cell {
    padding: 10px 8px;
    gap: 2px;
  }

  .kpi-val {
    font-family: var(--ff-mono);
    font-size: clamp(18px, 4vw, 28px);
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
  }
  .kpi-grid.compact .kpi-val {
    font-size: clamp(14px, 3vw, 18px);
  }
  .kpi-val.accent { color: var(--accent); }
  .kpi-val.green  { color: var(--green); }
  .kpi-val.red    { color: var(--red); }
  .kpi-val.blue   { color: var(--blue); }
  .kpi-val.orange { color: var(--orange); }
  .kpi-val.purple { color: var(--purple); }
  .kpi-val.muted  { color: var(--muted); }

  .kpi-lbl {
    font-family: var(--ff-mono);
    font-size: 10px;
    color: var(--muted);
    letter-spacing: .08em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .kpi-delta {
    font-family: var(--ff-mono);
    font-size: 10px;
    font-weight: 600;
  }
  .kpi-delta.up   { color: var(--green); }
  .kpi-delta.down { color: var(--red); }
  .kpi-delta.flat { color: var(--dim); }

  /* ── Toolbar ─────────────────────────────────────────────────────── */

  .toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }
  .toolbar.compact {
    padding: 6px 10px;
    gap: 6px;
  }
  .toolbar.scroll {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .toolbar.scroll > * { flex-shrink: 0; }

  .toolbar-title {
    font-family: var(--ff-mono);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text);
  }
  .toolbar-title.accent { color: var(--accent); }

  .toolbar-meta {
    font-family: var(--ff-mono);
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
  }

  .toolbar-spacer {
    margin-left: auto;
  }

  .toolbar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
  }

  .section-refresh {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: var(--dim);
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 6px;
    padding: 5px 14px;
    cursor: pointer;
    transition: all .15s;
    min-height: 30px;
    letter-spacing: 0.5px;
  }
  .section-refresh:hover { color: var(--accent); border-color: var(--accent); background: rgba(240,192,64,.06); }
  .section-refresh:active { transform: scale(.97); }

  /* Topbar içinde mobilde icon-only — date-nav-btn ile aynı boyut */
  @media (max-width: 767px) {
    .topbar .section-refresh {
      padding: 0;
      width: 26px;
      height: 26px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }
  }

  @media (max-width: 480px) {
    .toolbar { padding: 8px 10px; }
    .toolbar-title { font-size: 11px; letter-spacing: .8px; }
    .toolbar-meta { font-size: 10px; }
  }

  /* ── Modal & Sheet ───────────────────────────────────────────── */

  .modal-bg {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: var(--z-modal);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
  }

  .modal-bg.open {
    display: flex;
  }

  .modal {
    background: var(--surface);
    border: 1px solid var(--borderL);
    border-radius: var(--r-md);
    width: 100%;
    max-width: 720px;
    max-height: 90vh;
    overflow-y: auto;
    animation: mox-slide-up var(--t);
  }

  .modal-hd {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .modal-bd {
    padding: 18px;
  }

  .modal-ft {
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
  }

  /* Mobile bottom sheet */
  @media (max-width: 767px) {
    .modal-bg.sheet {
      align-items: flex-end;
      padding: 0;
    }

    .modal-bg.sheet .modal {
      max-height: 92vh;
      border-radius: var(--r-xl) var(--r-xl) 0 0;
      transform: translateY(100%);
      animation: none;
      transition: transform var(--t-slow) var(--ease);
    }

    .modal-bg.sheet.open .modal {
      transform: translateY(0);
    }
  }

  /* ── Toast ───────────────────────────────────────────────────── */

  #toast-root {
    position: fixed;
    top: calc(16px + env(safe-area-inset-top));
    right: 16px;
    left: auto;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
  }

  @media (max-width: 767px) {
    #toast-root {
      top: auto;
      bottom: calc(var(--bnav-h) + 16px + env(safe-area-inset-bottom));
      right: 16px;
      left: 16px;
    }
  }

  .toast {
    background: var(--surface);
    border: 1px solid var(--borderL);
    border-radius: var(--r-md);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    min-width: 220px;
    max-width: 360px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.40);
    animation: mox-slide-up var(--t);
    pointer-events: auto;
  }

  .toast .tdot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--blue);
  }

  .toast.success .tdot {
    background: var(--green);
  }

  .toast.error .tdot {
    background: var(--red);
  }

  .toast.info .tdot {
    background: var(--blue);
  }

  /* ── Spinner ─────────────────────────────────────────────────── */

  .spinner-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    background: rgba(0, 0, 0, 0.50);
    display: none;
    align-items: center;
    justify-content: center;
  }

  .spinner-overlay:not(.hidden) {
    display: flex;
  }

  .spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: mox-spin 0.7s linear infinite;
  }

  /* ── Nav items ───────────────────────────────────────────────── */

  .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    min-height: 38px;
    border-radius: var(--r);
    color: var(--muted);
    font-size: var(--fs);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    transition: background var(--t-fast), color var(--t-fast);
    -webkit-tap-highlight-color: transparent;
  }

  .nav-item:hover {
    background: var(--surface2);
    color: var(--text);
  }

  .nav-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
  }

  .nav-item.active {
    background: var(--accentD);
    color: var(--accent);
  }

  .nav-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .nav-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
  }

  .nav-label {
    flex: 1;
  }

  .nav-badge {
    margin-left: auto;
    background: var(--accentD);
    color: var(--accent);
    font-family: var(--ff-mono);
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 3px;
    border: 1px solid rgba(232, 188, 66, 0.20);
  }

  .nav-badge.red {
    background: var(--redD);
    color: var(--red);
    border-color: rgba(212, 94, 94, 0.20);
  }

  /* Bottom nav items */
  .bnav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 2px 10px 15px;
    min-width: 48px;
    min-height: 52px;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: color var(--t-fast);
    -webkit-tap-highlight-color: transparent;
    background: none;
    border: none;
  }

  .bnav-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
  }

  .bnav-item.active {
    color: var(--accent);
  }

  .bnav-item svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
  }

  .bnav-lbl {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-family: var(--ff-mono);
  }

  .bnav-badge {
    position: absolute;
    top: 0;
    right: 8px;
    background: var(--red);
    color: #ffffff;
    font-family: var(--ff-mono);
    font-size: 9px;
    font-weight: 600;
    min-width: 15px;
    height: 15px;
    padding: 0 3px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--bg);
  }

  /* ── Tabs ────────────────────────────────────────────────────── */

  .tab-nav {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab-btn {
    padding: 12px 18px;
    font-family: var(--ff-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--muted);
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: color var(--t-fast), border-color var(--t-fast);
    min-height: 44px;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    -webkit-tap-highlight-color: transparent;
  }

  .tab-btn:hover {
    color: var(--text);
  }

  .tab-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
  }

  .tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
  }

  /* ── Chips / Badges / Pills ──────────────────────────────────── */

  .chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-family: var(--ff-mono);
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--dim);
    transition: all var(--t-fast);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  .chip:hover {
    border-color: var(--borderL);
  }

  .chip:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  .chip.on {
    border-color: currentColor;
    background: currentColor;
    color: var(--bg);
    font-weight: 500;
  }

  .badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: var(--r-sm);
    font-family: var(--ff-mono);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
  }

  .badge.accent {
    background: var(--accentD);
    color: var(--accent);
  }

  .badge.green {
    background: var(--greenD);
    color: var(--green);
  }

  .badge.red {
    background: var(--redD);
    color: var(--red);
  }

  .badge.blue {
    background: var(--blueD);
    color: var(--blue);
  }

  .badge.orange {
    background: var(--orangeD);
    color: var(--orange);
  }

  .pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-family: var(--ff-mono);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    border: 1px solid var(--border);
    background: var(--surface);
  }

  /* ── Tables ──────────────────────────────────────────────────── */

  .table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    position: relative;
  }

  .table-wrap table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs);
  }

  .table-wrap th {
    padding: 10px 12px;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-family: var(--ff-mono);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
  }

  .table-wrap td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    white-space: nowrap;
  }

  .table-wrap tr:last-child td {
    border-bottom: none;
  }

  .table-wrap tr:hover td {
    background: var(--surface2);
  }

  .table-wrap.wrap th,
  .table-wrap.wrap td {
    white-space: normal;
  }
  .table-wrap td.wrap,
  .table-wrap th.wrap {
    white-space: normal;
  }

  @media (max-width: 768px) {
    .table-wrap::after {
      content: '';
      position: absolute;
      top: 0; right: 0; bottom: 0;
      width: 16px;
      background: linear-gradient(to right, transparent, var(--surface));
      pointer-events: none;
      opacity: .35;
    }
    .table-wrap.no-hint::after { display: none; }
  }

  /* ── Section label ───────────────────────────────────────────── */

  .sec-lbl {
    font-size: 9px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .sec-lbl::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
  }

  /* ── Theme toggle ────────────────────────────────────────────── */

  .mox-theme-toggle {
    position: fixed;
    bottom: calc(16px + env(safe-area-inset-bottom));
    right: 16px;
    z-index: var(--z-toast);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--dim);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color var(--t), color var(--t);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.30);
    padding: 0;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
  }

  .mox-theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
  }

  .mox-theme-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  /* Sits above bottom-nav — only layout-app has a bottom-nav */
  @media (max-width: 767px) {
    .layout-app .mox-theme-toggle {
      bottom: calc(var(--bnav-h) + 16px + env(safe-area-inset-bottom));
    }
  }

  /* ── Version badge ─────────────────────────────────────────────── */

  .mox-version {
    position: fixed;
    bottom: calc(8px + env(safe-area-inset-bottom));
    left: 12px;
    font-family: var(--ff-mono);
    font-size: 10px;
    color: var(--accent);
    opacity: .45;
    pointer-events: none;
    z-index: var(--z-toast);
    letter-spacing: .04em;
  }

  @media (max-width: 767px) {
    .layout-app .mox-version {
      bottom: calc(var(--bnav-h) + 8px + env(safe-area-inset-bottom));
    }
  }
}

/* ─── UTILITIES ──────────────────────────────────────────────────── */
@layer utilities {
  .truncate    { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .scroll-x    { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .flex        { display: flex; }
  .flex-col    { display: flex; flex-direction: column; }
  .flex-1      { flex: 1; min-width: 0; }
  .gap-1       { gap: 4px; }
  .gap-2       { gap: 8px; }
  .gap-3       { gap: 12px; }
  .gap-4       { gap: 16px; }
  .mt-1        { margin-top: 4px; }
  .mt-2        { margin-top: 8px; }
  .mt-3        { margin-top: 12px; }
  .mt-4        { margin-top: 16px; }
  .mb-1        { margin-bottom: 4px; }
  .mb-2        { margin-bottom: 8px; }
  .mb-3        { margin-bottom: 12px; }
  .mb-4        { margin-bottom: 16px; }
  .text-center { text-align: center; }
  .text-right  { text-align: right; }
  .text-mono   { font-family: var(--ff-mono); }
  .money { font-family: var(--ff-mono); font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
  .text-sm     { font-size: var(--fs-sm); }
  .text-xs     { font-size: var(--fs-xs); }
  .text-muted  { color: var(--muted); }
  .text-dim    { color: var(--dim); }
  .text-accent { color: var(--accent); }
  .text-green  { color: var(--green); }
  .text-red    { color: var(--red); }
  .text-blue   { color: var(--blue); }
  .text-orange { color: var(--orange); }
  .text-purple { color: var(--purple); }

  /* Responsive visibility */
  .show-md-up { display: none; }

  @media (max-width: 767px) {
    .hide-sm { display: none; }
  }

  @media (min-width: 768px) {
    .hide-md-up  { display: none; }
    .show-md-up  { display: initial; }
  }
}

/* === MOX LOADER ============================================================
   Tek primitif: logonun 3 barı = tek loading animasyonu.
   Kural: mox-bar-pulse dışında loading animation yok. Spinner yok.
   ========================================================================= */
@layer components {
  :root { --mox-ease: cubic-bezier(0.4, 0, 0.2, 1); }

  @keyframes mox-bar-pulse {
    0%, 100% { opacity: 0.15; }
    50%       { opacity: 1; }
  }

  @keyframes mox-shimmer {
    0%, 100% { opacity: 0.05; }
    50%       { opacity: 0.18; }
  }

  /* SVG animasyonu — <svg class="mox-loader"> içindeki rect'lere */
  .mox-loader rect:nth-child(1) { animation: mox-bar-pulse 1.2s var(--mox-ease) infinite; }
  .mox-loader rect:nth-child(2) { animation: mox-bar-pulse 1.2s var(--mox-ease) 0.2s infinite; }
  .mox-loader rect:nth-child(3) { animation: mox-bar-pulse 1.2s var(--mox-ease) 0.4s infinite; }

  @media (prefers-reduced-motion: reduce) {
    .mox-loader rect { animation: none; opacity: 1; }
    .mox-skeleton-row, .mox-skeleton-card > div { animation: none; opacity: 0.12; }
  }

  /* Page load — position:fixed, tam ekran overlay */
  .mox-loader-page {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 15, 15, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 14px;
  }

  /* Section load — container position:relative içinde absolute ortalanmış */
  .mox-loader-section {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
  }

  /* Progress — mark sol, context text sağ */
  .mox-loader-progress {
    display: flex;
    align-items: center;
    gap: 14px;
  }

  .mox-loader-ctx {
    font-family: var(--ff-mono);
    font-size: 13px;
    color: var(--muted);
    transition: opacity 0.3s;
  }

  /* Skeleton — row */
  .mox-skeleton-row {
    height: 14px;
    border-radius: 5px;
    background: #f0c040;
    animation: mox-shimmer 2.4s var(--mox-ease) infinite;
    margin: 8px 0;
  }

  /* Skeleton — card (3 satır, azalan genişlik) */
  .mox-skeleton-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .mox-skeleton-card > div {
    height: 14px;
    border-radius: 5px;
    background: #f0c040;
    animation: mox-shimmer 2.4s var(--mox-ease) infinite;
  }
  .mox-skeleton-card > div:nth-child(2) { width: 70%; animation-delay: 0.3s; }
  .mox-skeleton-card > div:nth-child(3) { width: 45%; animation-delay: 0.6s; }
}
