/* Toucan ERP 1.7 design system — LTR English UI, Persian data rendered with Noto Arabic (unicode-range).
   Brand palette (owner, logo sheet): Leaf Green #8DB960 · Natural Yellow #E7C94A · Pistachio Beige #F4C78F · Gold #C8752D ·
   Deep Green #1E3D2B. Everything below is driven by the tokens in :root (light) and [data-theme="dark"]. */
@font-face { font-family: "Noto Arabic"; src: url("../assets/noto-arabic-regular.woff2") format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: "Noto Arabic"; src: url("../assets/noto-arabic-bold.woff2") format("woff2"); font-weight: 600 800; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }

/* ================================================================== tokens */
:root {
  /* brand (fixed) */
  --leaf: #8DB960; --yellow: #E7C94A; --beige: #F4C78F; --gold: #C8752D; --deep: #1E3D2B;
  --font: "Noto Arabic", "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-num: "Inter", "Segoe UI", system-ui, Roboto, Arial, sans-serif;

  /* surfaces & text — light */
  --bg: #F5F4EE; --surface: #FFFFFF; --surface-2: #FAF9F4; --surface-3: #F1EEE4;
  --border: #E7E3D7; --border-strong: #D4CEBD;
  --text: #17271D; --muted: #5C695E; --faint: #8A9488;

  /* roles */
  --brand: #1E3D2B; --brand-hover: #2A5139; --on-brand: #FFFFFF;
  --brand-soft: #EAF2E1; --brand-deep: #1E3D2B; --brand-line: #8DB960;
  --accent: #C8752D; --on-accent: #FFFFFF; --accent-soft: #FBF0E3; --accent-text: #9A5A1F;
  --highlight-soft: #FBF5D9;
  --ok: #2E7A47; --ok-soft: #E5F2E6; --warn: #9C6410; --warn-soft: #FCF1D9; --bad: #B23A2E; --bad-soft: #FBE9E6;
  --info: #2B6A88; --info-soft: #E4F0F5;

  /* sidebar (deep green in both themes) */
  --side-bg: #1E3D2B; --side-bg-2: #19341F; --side-text: #DCE7D5; --side-muted: #9DB49A; --side-hover: rgba(255,255,255,.07);
  --side-active: rgba(141,185,96,.18); --side-border: rgba(255,255,255,.08);

  /* shape */
  --radius-sm: 6px; --radius: 10px; --radius-lg: 14px; --radius-pill: 999px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
  --shadow-sm: 0 1px 2px rgba(23, 39, 29, .05);
  --shadow: 0 1px 2px rgba(23, 39, 29, .05), 0 6px 18px -6px rgba(23, 39, 29, .08);
  --shadow-lg: 0 24px 64px -12px rgba(15, 30, 20, .35);
  --focus: 0 0 0 3px color-mix(in srgb, var(--leaf) 45%, transparent);
  --overlay: rgba(12, 24, 16, .48);

  --sidebar: 264px; --rail: 68px; --nav-offset: var(--sidebar); --topbar-h: 60px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0E1611; --surface: #152019; --surface-2: #19261E; --surface-3: #1F2E24;
  --border: #26372C; --border-strong: #36493C;
  --text: #E6ECE3; --muted: #A2AFA1; --faint: #76847A;
  --brand: #8DB960; --brand-hover: #A0C878; --on-brand: #0E1A12;
  --brand-soft: #1F3324; --brand-deep: #B7D78E; --brand-line: #8DB960;
  --accent: #DE9150; --on-accent: #1A0F05; --accent-soft: #33241A; --accent-text: #EBAA70;
  --highlight-soft: #2E2A16;
  --ok: #72C48D; --ok-soft: #173022; --warn: #E6B24E; --warn-soft: #33280F; --bad: #F08B7E; --bad-soft: #3A1B17;
  --info: #7DB8D6; --info-soft: #14283299;
  --side-bg: #112218; --side-bg-2: #0D1C13; --side-text: #D6E2D0; --side-muted: #8EA58C; --side-hover: rgba(255,255,255,.06);
  --side-active: rgba(141,185,96,.16); --side-border: rgba(255,255,255,.06);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 8px 24px -8px rgba(0,0,0,.45);
  --shadow-lg: 0 24px 64px -12px rgba(0,0,0,.7);
  --overlay: rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ================================================================== base */
* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font: 14px/1.55 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow-x: hidden; }
[hidden] { display: none !important; }
a { color: var(--brand-deep); text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.3; letter-spacing: -.005em; }
h1 { font-size: 20px; font-weight: 650; }
h2 { font-size: 15.5px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0 0 .5em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
[dir="auto"], [dir="rtl"] { unicode-bidi: plaintext; }
:focus-visible { outline: 2px solid var(--leaf); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--leaf) 35%, transparent); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; font: 600 11px/1 var(--font-num);
  border: 1px solid var(--border-strong); border-bottom-width: 2px; color: var(--muted); background: var(--surface); }
.theme-dark-only { display: none !important; }
:root[data-theme="dark"] .theme-dark-only { display: revert !important; }
:root[data-theme="dark"] .login-card .logo.theme-dark-only { display: block !important; }
:root[data-theme="dark"] .theme-light-only { display: none !important; }

/* ================================================================== login */
.login { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--bg); }
.login-aside { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: 24px; padding: 48px 56px;
  color: #EEF3E8; background:
    radial-gradient(900px 520px at 85% 110%, rgba(200,117,45,.28), transparent 60%),
    radial-gradient(700px 480px at -10% -10%, rgba(141,185,96,.30), transparent 60%),
    linear-gradient(160deg, #22462F 0%, #1E3D2B 45%, #142B1D 100%); }
.login-aside::after { content: ""; position: absolute; inset: auto -220px -300px auto; width: 560px; height: 560px; border-radius: 50%;
  border: 1.5px solid rgba(244,199,143,.35); pointer-events: none; }
.login-aside .aside-mark { width: 92px; height: auto; filter: drop-shadow(0 6px 16px rgba(0,0,0,.25)); }
.login-aside h2 { font-size: clamp(26px, 3vw, 38px); font-weight: 700; line-height: 1.15; letter-spacing: -.01em; max-width: 16ch; color: #fff; }
.login-aside .lead { color: rgba(238,243,232,.78); font-size: 15px; max-width: 42ch; margin-top: 14px; }
.login-aside .fa { font-size: 17px; color: var(--beige); margin-top: 18px; max-width: 42ch; text-align: left; }
.login-aside .pills { display: flex; flex-wrap: wrap; gap: 8px; }
.login-aside .pills span { padding: 5px 12px; border-radius: 999px; font-size: 12px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); color: #E3EBDD; }
.login-aside .palette { display: flex; gap: 6px; }
.login-aside .palette i { width: 22px; height: 6px; border-radius: 3px; }
.login-main { display: grid; place-items: center; padding: 32px 24px; }
.login-card { width: min(380px, 100%); }
.login-card .logo { display: block; width: 176px; height: auto; margin: 0 auto 26px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card p { margin: 0 0 24px; }
.login-card form { display: grid; gap: 16px; }
.login-card .btn.primary { height: 42px; font-size: 14.5px; margin-top: 4px; }
.login-card input { height: 42px; }
.login-foot { margin-top: 28px; text-align: center; font-size: 12px; color: var(--faint); }
@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-aside { display: none; }
}

/* ================================================================== shell layout */
.shell { min-height: 100vh; }
.shell.nav-rail { --nav-offset: var(--rail); }
.main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; padding-left: var(--nav-offset); transition: padding-left .2s ease; }

/* ---------- sidebar */
.sidebar { position: fixed; z-index: 60; inset: 0 auto 0 0; width: var(--sidebar); display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--side-bg) 0%, var(--side-bg-2) 100%); color: var(--side-text);
  border-right: 1px solid var(--side-border); transition: width .2s ease, transform .22s ease, box-shadow .2s ease; }
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 12px 12px 16px; min-height: var(--topbar-h); }
.brand img { width: 38px; height: auto; flex: 0 0 38px; }
.brand .brand-text { min-width: 0; flex: 1; line-height: 1.15; }
.brand strong { display: block; font-size: 15.5px; font-weight: 750; letter-spacing: .12em; color: #fff; white-space: nowrap; }
.brand strong em { font-style: normal; font-weight: 500; letter-spacing: .04em; color: var(--leaf); margin-left: 4px; }
.brand span { display: block; font-size: 9.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--side-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.side-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: 0 0 32px; border-radius: 8px; border: 0; background: transparent;
  color: var(--side-muted); cursor: pointer; transition: background .15s, color .15s; }
.side-btn:hover { background: var(--side-hover); color: #fff; }
.side-btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.pin-btn[aria-pressed="true"] { color: var(--yellow); }
.pin-btn[aria-pressed="true"] svg { fill: color-mix(in srgb, var(--yellow) 30%, transparent); }
.nav-close { display: none; }
.nav-find { position: relative; margin: 2px 12px 8px; }
.nav-find svg { position: absolute; left: 10px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%); stroke: var(--side-muted); fill: none; stroke-width: 2; pointer-events: none; }
.nav-find input { height: 34px; padding: 0 34px 0 32px; border-radius: 8px; font-size: 13px; color: var(--side-text);
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); }
.nav-find input::placeholder { color: var(--side-muted); }
.nav-find input:focus { border-color: rgba(141,185,96,.6); box-shadow: 0 0 0 3px rgba(141,185,96,.18); background: rgba(255,255,255,.09); }
.nav-find kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: transparent; color: var(--side-muted); border-color: rgba(255,255,255,.18); }
.nav-find input:focus + kbd, .nav-find input:not(:placeholder-shown) + kbd { display: none; }
.nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 10px 20px; scrollbar-color: rgba(255,255,255,.18) transparent; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); background-clip: content-box; }
.nav-section { margin-top: 2px; }
.nav-section + .nav-section { margin-top: 4px; }
.nav-group { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 8px 6px 10px; margin-top: 6px; border: 0; background: none; cursor: pointer;
  font-size: 11px; font-weight: 650; letter-spacing: .09em; text-transform: uppercase; color: var(--side-muted); border-radius: 8px; text-align: left; }
.nav-group:hover { color: #fff; }
.nav-group .gi { width: 16px; height: 16px; flex: 0 0 16px; stroke: currentColor; fill: none; stroke-width: 1.8; display: none; }
.nav-group .glabel { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-group .gcount { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--gold); color: #fff; font-size: 10.5px; letter-spacing: 0; display: grid; place-items: center; }
.nav-group .chev { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; transition: transform .18s; opacity: .7; }
.nav-section.collapsed .chev { transform: rotate(-90deg); }
.nav-items { display: grid; gap: 1px; }
.nav-section.collapsed .nav-items { display: none; }
.nav a { position: relative; display: flex; align-items: center; gap: 11px; padding: 7px 10px; border-radius: 8px; color: var(--side-text); text-decoration: none;
  font-size: 13.5px; font-weight: 500; line-height: 1.35; transition: background .12s, color .12s; }
.nav a .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a:hover { background: var(--side-hover); color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; font-weight: 600; }
.nav a.active::before { content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--yellow); }
.nav a.active svg { stroke: var(--yellow); opacity: 1; }
.nav a .count { margin-left: auto; min-width: 20px; height: 19px; padding: 0 6px; border-radius: 10px; background: var(--gold); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; font-family: var(--font-num); }
.nav svg { width: 18px; height: 18px; flex: 0 0 18px; stroke: currentColor; fill: none; stroke-width: 1.7; opacity: .82; }
.nav-top a { margin-bottom: 2px; }
.nav-empty { padding: 14px 10px; font-size: 12.5px; color: var(--side-muted); }
.nav.filtering .nav-section .nav-items { display: grid; }
.nav.filtering .chev { visibility: hidden; }
.nav a mark { background: color-mix(in srgb, var(--yellow) 40%, transparent); color: #fff; border-radius: 3px; padding: 0 1px; }
.side-foot { display: flex; align-items: center; gap: 8px; padding: 10px 16px 14px; border-top: 1px solid var(--side-border); font-size: 11.5px; color: var(--side-muted); white-space: nowrap; overflow: hidden; }
.side-foot .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--leaf); box-shadow: 0 0 0 3px rgba(141,185,96,.2); flex: 0 0 7px; }

/* ---------- rail (unpinned) mode: icons only, expands on hover / keyboard focus */
.nav-rail .sidebar { width: var(--rail); }
.nav-rail .sidebar:hover, .nav-rail .sidebar:focus-within { width: var(--sidebar); box-shadow: var(--shadow-lg); }
.nav-rail .sidebar:not(:hover):not(:focus-within) .brand { justify-content: center; padding-left: 12px; padding-right: 12px; }
.nav-rail .sidebar:not(:hover):not(:focus-within) .brand-text,
.nav-rail .sidebar:not(:hover):not(:focus-within) .pin-btn,
.nav-rail .sidebar:not(:hover):not(:focus-within) .nav-find,
.nav-rail .sidebar:not(:hover):not(:focus-within) .lbl,
.nav-rail .sidebar:not(:hover):not(:focus-within) .glabel,
.nav-rail .sidebar:not(:hover):not(:focus-within) .chev,
.nav-rail .sidebar:not(:hover):not(:focus-within) .side-foot span { display: none; }
.nav-rail .sidebar:not(:hover):not(:focus-within) .nav a { justify-content: center; padding: 9px 0; }
.nav-rail .sidebar:not(:hover):not(:focus-within) .nav a .count { position: absolute; top: 2px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; font-size: 9.5px; }
.nav-rail .sidebar:not(:hover):not(:focus-within) .nav-group { justify-content: center; padding: 9px 0; margin-top: 2px; border-radius: 8px; color: var(--side-muted); }
.nav-rail .sidebar:not(:hover):not(:focus-within) .nav-group .gi { display: block; width: 18px; height: 18px; }
.nav-rail .sidebar:not(:hover):not(:focus-within) .nav-section:not(.collapsed):not(.nav-top) { background: rgba(255,255,255,.04); border-radius: 10px; padding-bottom: 2px; }
.nav-rail .sidebar:not(:hover):not(:focus-within) .nav-section:not(.collapsed) .nav-group { color: var(--yellow); }
.nav-rail .sidebar:not(:hover):not(:focus-within) .nav a.active::before { left: -10px; }
.nav-rail .sidebar:not(:hover):not(:focus-within) .nav-group .gcount { display: none; }
.nav-rail .sidebar:not(:hover):not(:focus-within) .side-foot { justify-content: center; padding-left: 0; padding-right: 0; }

/* ---------- topbar */
.topbar { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 10px; min-height: var(--topbar-h); padding: 10px 24px;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border); }
.topbar .title { flex: 1; min-width: 0; }
.topbar .title .crumb { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--accent-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title .crumb:empty { display: none; }
.topbar h1 { font-size: 18px; font-weight: 700; margin: 0; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; flex: 0 0 36px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.icon-btn:hover { background: var(--surface); border-color: var(--border); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-switch .moon { display: none; }
:root[data-theme="dark"] .theme-switch .moon { display: block; }
:root[data-theme="dark"] .theme-switch .sun { display: none; }
.global-search { position: relative; flex: 0 1 360px; min-width: 120px; }
.global-search > svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); stroke: var(--faint); fill: none; stroke-width: 2; pointer-events: none; }
.global-search input { width: 100%; height: 38px; border-radius: 10px; padding: 0 56px 0 36px; background: var(--surface); border-color: var(--border); }
.global-search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 10px; pointer-events: none; }
.global-search input:focus + kbd, .global-search input:not(:placeholder-shown) + kbd { display: none; }
.search-results { position: absolute; top: 44px; left: 0; right: 0; max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 50; padding: 6px; min-width: 300px; }
.search-results button { display: flex; width: 100%; gap: 10px; align-items: baseline; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--text); }
.search-results button:hover, .search-results button:focus { background: var(--brand-soft); outline: none; }
.search-results .kind { font-size: 10.5px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--accent-text); min-width: 110px; }
.clock { color: var(--muted); font-size: 12px; white-space: nowrap; padding: 0 4px; }
.userchip { display: flex; align-items: center; gap: 4px; padding: 3px 4px 3px 3px; border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--surface); }
.avatar { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; letter-spacing: .02em;
  background: linear-gradient(140deg, var(--leaf), #5E8D3E); color: #fff; }
.userchip .name { font-size: 13px; font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 4px; }
.userchip .btn { border-radius: var(--radius-pill); }
.menu-toggle { display: none; }
.content { padding: 24px 28px 56px; display: grid; gap: 20px; align-content: start; width: 100%; max-width: 1680px; }
.nav-backdrop { display: none; }

/* ================================================================== components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2 { flex: 1; min-width: 0; }
.card-body { padding: 18px; }
.grid { display: grid; gap: 16px; }
.grid > *, .content > * { min-width: 0; }
.grid.kpis { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

/* KPI cards */
.kpi { position: relative; padding: 16px 18px 14px; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand-line); opacity: .9; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.kpi .value { font-size: clamp(18px, 1.7vw, 25px); font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; letter-spacing: -.01em; font-family: var(--font); }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.warn::before { background: var(--yellow); } .kpi.bad::before { background: var(--bad); } .kpi.ok::before { background: var(--ok); } .kpi.info::before { background: var(--info); }
.kpi.warn .value { color: var(--warn); } .kpi.bad .value { color: var(--bad); } .kpi.ok .value { color: var(--ok); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 15px; border-radius: 9px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); cursor: pointer; font-weight: 600; font-size: 13.5px; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, filter .15s; box-shadow: var(--shadow-sm); }
.btn:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--brand-line) 50%, var(--border-strong)); }
.btn:active { transform: translateY(.5px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.secondary { background: var(--brand-soft); border-color: transparent; color: var(--brand-deep); box-shadow: none; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
.btn.danger:hover { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 55%, var(--border)); }
.btn.primary.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; filter: grayscale(.3); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* forms */
label.field { display: grid; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
label.field.req > span:first-child::after { content: " *"; color: var(--accent); }
input, select, textarea { width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); outline: none;
  font-size: 14px; color: var(--text); transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; width: 14px; height: 14px; cursor: pointer; opacity: .7;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238A9488' stroke-width='2.6' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E") center / 14px no-repeat; }
input[type="search"]::-webkit-search-cancel-button:hover { opacity: 1; }
select { padding-right: 30px; appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238A9488' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 15px; }
select[multiple] { background-image: none; height: auto; padding: 6px; }
textarea { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; line-height: 1.55; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--brand); box-shadow: none; flex: 0 0 auto; }
input[type="file"] { height: auto; padding: 6px; }
input[type="color"] { padding: 2px; width: 48px; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--brand-line) 45%, var(--border-strong)); }
input:focus, select:focus, textarea:focus { border-color: var(--brand-line); box-shadow: var(--focus); }
input:disabled, select:disabled, textarea:disabled, input[readonly] { background: var(--surface-2); color: var(--muted); }
input[type="number"], input.num { font-variant-numeric: tabular-nums; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); font-weight: 500; }
.form-grid { display: grid; gap: 14px 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); align-items: start; }
.form-grid .wide { grid-column: 1 / -1; }
.form-section { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; margin-top: 8px; padding-top: 2px; font-size: 12px; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase; color: var(--accent-text); }
.form-section::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.error-text { color: var(--bad); font-size: 13px; }
.error-text:empty { display: none; }
.card.error-text { border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); background: var(--bad-soft); }

/* toolbars & tables */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.toolbar .search { flex: 1 1 220px; max-width: 360px; padding-left: 34px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238A9488' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E") no-repeat 11px center / 15px; }
.toolbar select { width: auto; min-width: 150px; }
.toolbar input, .toolbar select { height: 34px; font-size: 13px; }
td select { width: auto; min-width: 140px; }
.table-wrap { overflow-x: auto; }
.toolbar + .table-wrap { max-height: max(420px, calc(100vh - 230px)); overflow: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { position: sticky; top: 0; z-index: 2; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650;
  background: var(--surface-2); white-space: nowrap; box-shadow: inset 0 -1px 0 var(--border); border-bottom-color: transparent; }
th.sortable { cursor: pointer; user-select: none; } th.sortable:hover { color: var(--text); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.num { font-family: var(--font); letter-spacing: -.005em; }
tbody tr { transition: background .1s; }
tbody tr:nth-child(even) > td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
tbody tr:hover > td { background: color-mix(in srgb, var(--brand-soft) 70%, var(--surface)); }
tbody tr:last-child > td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover > td:first-child { box-shadow: inset 3px 0 0 var(--brand-line); }
td .strong { font-weight: 600; }
.toolbar + .table-wrap td:first-child { white-space: nowrap; }   /* record numbers stay on one line */
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
td.empty { background: none !important; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 16px; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; border-top: 1px solid var(--border); }
.card > .table-wrap:last-child table tbody tr:last-child > td:first-child { border-bottom-left-radius: var(--radius-lg); }

/* badges / pills */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: var(--radius-pill); font-size: 11.5px; font-weight: 600;
  background: var(--surface-3); border: 1px solid transparent; color: var(--muted); white-space: nowrap; line-height: 1; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand-deep); }
.badge.gold, .badge.accent { background: var(--accent-soft); color: var(--accent-text); }

/* definition lists, tabs, timeline */
.dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px 20px; margin: 0; }
.dl div { min-width: 0; }
.dl dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 650; }
.dl dd { margin: 3px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 12px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { position: relative; border: 0; background: none; padding: 12px 12px 11px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13.5px; white-space: nowrap; border-radius: 8px 8px 0 0; transition: color .15s, background .15s; }
.tabs button:hover { color: var(--text); background: var(--surface-2); }
.tabs button.active { color: var(--brand-deep); }
.tabs button.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2.5px; border-radius: 2px 2px 0 0; background: var(--accent); }
.timeline { display: grid; gap: 10px; }
.timeline .item { position: relative; padding: 10px 14px 10px 26px; background: var(--surface-2); border-radius: 8px; }
.timeline .item::before { content: ""; position: absolute; left: 11px; top: 16px; width: 7px; height: 7px; border-radius: 50%; background: var(--brand-line); }

.bars { display: grid; gap: 9px; }
.bar { display: grid; grid-template-columns: 160px 1fr auto; gap: 12px; align-items: center; font-size: 12.5px; }
.bar .track { height: 8px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.bar .fill { height: 100%; background: linear-gradient(90deg, var(--brand-line), color-mix(in srgb, var(--brand-line) 70%, var(--yellow))); border-radius: 6px; }

/* ================================================================== modal / toast */
.overlay { position: fixed; inset: 0; background: var(--overlay); backdrop-filter: blur(2px); display: grid; place-items: center; padding: 20px; z-index: 100; animation: fade .14s ease-out; }
.modal { width: min(760px, 100%); max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); display: flex; flex-direction: column; background: var(--surface); border-radius: 16px;
  border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: pop .16s ease-out; overflow: hidden; }
.modal.wide { width: min(1080px, 100%); }
.modal.narrow { width: min(460px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 16px 14px 22px; border-bottom: 1px solid var(--border); }
.modal-head h2 { flex: 1; font-size: 16.5px; min-width: 0; }
.modal-head .btn.ghost { width: 32px; padding: 0; }
.modal-body { padding: 20px 22px; overflow-y: auto; display: grid; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); }
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 200; }
.toast { min-width: 260px; max-width: 420px; padding: 11px 16px 11px 14px; border-radius: 12px; background: var(--deep); color: #EEF3E8; box-shadow: var(--shadow-lg);
  border: 1px solid var(--leaf); animation: slide .2s ease-out; font-size: 13.5px; }
:root[data-theme="dark"] .toast { background: #23362A; }
.toast.bad { border-color: #F08B7E; background: #4A1D18; color: #FBE9E6; }
.toast.ok { border-color: var(--leaf); }
.toast.warn { border-color: var(--yellow); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--brand-line); border-radius: 50%; animation: spin .7s linear infinite; }
.loading { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 36px; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.985); } }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ================================================================== responsive shell */
@media (max-width: 960px) {
  .main, .shell.nav-rail .main { padding-left: 0; }
  .sidebar, .nav-rail .sidebar { width: min(var(--sidebar), 86vw); transform: translateX(-100%); box-shadow: none; }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .shell.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: var(--overlay); animation: fade .15s; }
  /* the drawer always shows labels (rail rules do not apply) */
  .nav-rail .sidebar .brand-text, .nav-rail .sidebar .nav-find, .nav-rail .sidebar .lbl, .nav-rail .sidebar .glabel, .nav-rail .sidebar .chev, .nav-rail .sidebar .side-foot span { display: revert !important; }
  .nav-rail .sidebar .nav a { justify-content: flex-start !important; padding: 7px 10px !important; }
  .nav-rail .sidebar .nav a .count { position: static !important; }
  .nav-rail .sidebar .nav-group { justify-content: flex-start !important; padding: 8px 8px 6px 10px !important; border-top: 0 !important; }
  .nav-rail .sidebar .brand { justify-content: flex-start !important; }
  .nav-rail .sidebar .lbl, .nav-rail .sidebar .glabel { display: block !important; }
  .pin-btn { display: none !important; }
  .nav-close { display: inline-grid; }
  .menu-toggle { display: inline-grid; }
  .content { padding: 18px 16px 44px; gap: 16px; }
  .topbar { padding: 8px 14px; }
  .userchip .name { display: none; }
  .bar { grid-template-columns: 100px 1fr auto; }
  .grid.two, .grid.kpis { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .grid.two { grid-template-columns: 1fr; }
  .clock { display: none; }
  .toolbar .search { max-width: none; }
  .toolbar select { flex: 1 1 140px; min-width: 0; }
}
@media print {
  .sidebar, .topbar, .toolbar, .pager, .btn, .nav-backdrop { display: none !important; }
  .main { padding-left: 0 !important; }
  .card { box-shadow: none; }
  .toolbar + .table-wrap { max-height: none; overflow: visible; }
  th { position: static; }
}

/* ================================================================== 1.1 – workflow UI */
.view-tabs { padding: 0 12px; background: var(--surface-2); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.btn-row.nowrap { flex-wrap: nowrap; }
.grid.tight { gap: 2px; }
.chip { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.checklist li { display: flex; gap: 10px; align-items: baseline; }
.checklist .mark { font-weight: 700; width: 1.2em; text-align: center; }
.checklist li.ok .mark { color: var(--ok); }
.checklist li.bad .mark { color: var(--bad); }
.task-cards { display: grid; gap: 10px; }
.task-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 6px; background: var(--surface); box-shadow: var(--shadow-sm); }
.task-card.urgent { border-color: color-mix(in srgb, var(--bad) 55%, var(--border)); box-shadow: inset 3px 0 0 var(--bad); }

/* ================================================================== 1.2 – quick create, order journey, workbench */
#quick-create { gap: 4px; }
.menu-pop { position: absolute; z-index: 60; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; min-width: 210px; }
.menu-pop button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 12px; border-radius: 8px; cursor: pointer; color: var(--text); }
.menu-pop button:hover { background: var(--brand-soft); }
.draft-note { background: var(--highlight-soft); border: 1px solid color-mix(in srgb, var(--yellow) 35%, var(--border)); border-radius: 9px; padding: 6px 10px; font-size: 13px; }
tr.row-bad > td { background: var(--bad-soft) !important; }
tr.row-warn > td { background: var(--warn-soft) !important; }
/* order journey */
.journey { display: flex; gap: 0; overflow-x: auto; padding: 14px 6px 6px; }
.journey .stp { flex: 1 0 86px; text-align: center; position: relative; cursor: pointer; border: 0; background: none; color: var(--text); padding: 0 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; }
.journey .stp::before { content: ""; position: absolute; top: 15px; left: -50%; width: 100%; height: 2px; background: var(--border-strong); z-index: 0; }
.journey .stp:first-child::before { display: none; }
.journey .stp.done::before, .journey .stp.current::before, .journey .stp.review::before { background: var(--ok); }
.journey .dot { position: relative; z-index: 1; width: 30px; height: 30px; margin: 0 auto 6px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12.5px; font-weight: 700; background: var(--surface); border: 2px solid var(--border-strong); color: var(--faint); font-family: var(--font-num); }
.journey .done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.journey .current .dot { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.journey .review .dot { background: var(--info); border-color: var(--info); color: #fff; }
.journey .blocked .dot { background: var(--bad); border-color: var(--bad); color: #fff; }
.journey .locked .dot { opacity: .6; }
.journey .lbl { font-size: 11.5px; line-height: 1.25; color: var(--muted); display: block; }
.journey .current .lbl, .journey .blocked .lbl { color: var(--text); font-weight: 600; }
.journey .delay { display: block; font-size: 10.5px; color: var(--bad); font-weight: 600; }
.order-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.next-action { border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border)); background: linear-gradient(135deg, var(--accent-soft), var(--surface) 80%); box-shadow: inset 4px 0 0 var(--accent); }
.next-action h3 { margin: 0 0 4px; }
.progressbar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 8px; }
.progressbar > div { height: 100%; background: linear-gradient(90deg, var(--leaf), var(--yellow)); border-radius: 99px; }
.step-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.step-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface); display: grid; gap: 4px; }
.step-card.done { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); } .step-card.current { border-color: var(--accent); background: var(--accent-soft); }
.step-card.review { border-color: color-mix(in srgb, var(--info) 50%, var(--border)); } .step-card.blocked { border-color: var(--bad); background: var(--bad-soft); }
.step-card.locked { opacity: .72; }
.step-card .meta { font-size: 12px; color: var(--muted); }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.tile { position: relative; display: grid; gap: 4px; text-decoration: none; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--surface);
  text-align: left; cursor: pointer; color: var(--text); box-shadow: var(--shadow-sm); transition: border-color .15s, transform .15s, box-shadow .15s; font: inherit; }
.tile:hover { border-color: var(--brand-line); box-shadow: var(--shadow); transform: translateY(-1px); }
.tile .v { font-size: 22px; line-height: 1.25; font-weight: 700; display: block; margin-top: 2px; font-variant-numeric: tabular-nums; color: var(--brand-deep); }
.tile.warn .v { color: var(--warn); } .tile.bad .v { color: var(--bad); }
.empty-state { text-align: center; padding: 36px 16px; display: grid; gap: 10px; justify-items: center; color: var(--muted); }
.field-designer .field-row { display: grid; grid-template-columns: 1fr 1fr 140px auto 1fr auto auto; gap: 6px; align-items: center; margin-bottom: 6px; }
@media (max-width: 960px) {
  .order-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .global-search { flex: 1 1 auto; }
  .hide-sm { display: none !important; }
  .field-designer .field-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .journey { display: grid; grid-template-columns: 1fr; gap: 6px; overflow: visible; }
  .journey .stp { display: flex; flex-direction: row; align-items: center; gap: 10px; text-align: left; flex: none; }
  .journey .stp::before { display: none; }
  .journey .dot { margin: 0; flex: 0 0 26px; width: 26px; height: 26px; }
  .journey .stp.locked { display: none; }
  .order-cards { grid-template-columns: 1fr; }
  .topbar { padding: 8px 10px; gap: 6px; flex-wrap: wrap; }
  .topbar .title { order: 1; flex: 1 1 0; }
  .topbar .menu-toggle { order: 0; }
  .topbar .theme-switch, .topbar .userchip, #quick-create { order: 2; }
  .global-search { order: 3; flex: 1 0 100%; min-width: 0; }
  .global-search kbd { display: none; }
  .tile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 10px 12px; }
  .tile .v { font-size: 19px; }
  .grid.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 12px 14px; }
  .topbar h1 { font-size: 16px; }
  .userchip { padding: 0; border: 0; background: none; }
  .userchip .btn { padding: 0 8px; }
  #quick-create .qc-label { display: none; }
  #quick-create { width: 34px; padding: 0; }
  .card-head, .card-body { padding-left: 14px; padding-right: 14px; }
  .modal-body { padding: 16px; } .modal-head { padding-left: 16px; } .modal-foot { padding: 12px 16px; }
  .overlay { padding: 10px; align-items: end; }
  .modal { max-height: calc(100dvh - 20px); }
  .toasts { left: 12px; right: 12px; }
  .toast { min-width: 0; max-width: none; }
}

/* ================================================================== 1.3 – uploads, KPI, workflow */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.drop-zone { border: 1.5px dashed var(--border-strong); border-radius: 12px; padding: 12px 14px; display: grid; gap: 8px; background: var(--surface-2); }
.drop-zone.over { border-color: var(--brand-line); background: var(--brand-soft); }
.upload-list { display: grid; gap: 6px; max-height: 300px; overflow: auto; }
.upload-item { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(80px, 1fr) minmax(0, 1.2fr) auto; gap: 8px; align-items: center;
  font-size: 13px; padding: 4px 6px; border-radius: 8px; background: var(--surface); }
.upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item .progress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.upload-item .bar-fill { height: 100%; width: 0; background: var(--brand-line); transition: width .15s; }
.upload-item.done .bar-fill { background: var(--ok); } .upload-item.failed .bar-fill, .upload-item.invalid .bar-fill { background: var(--bad); width: 100%; }
.upload-item.failed .upload-state, .upload-item.invalid .upload-state { color: var(--bad); }
.upload-item.done .upload-state { color: var(--ok); }
.voided a { text-decoration: line-through; color: var(--muted); }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.kpi-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--surface);
  display: grid; gap: 3px; cursor: pointer; text-align: left; color: var(--text); font: inherit; box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; }
.kpi-card:hover { border-color: var(--brand-line); box-shadow: var(--shadow); }
.kpi-card.green { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); } .kpi-card.yellow { border-color: color-mix(in srgb, var(--yellow) 60%, var(--border)); } .kpi-card.red { border-color: color-mix(in srgb, var(--bad) 50%, var(--border)); background: var(--bad-soft); }
.kpi-card.grey { border-color: var(--border); background: var(--surface-2); color: var(--muted); }
.kpi-card .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-card .meta { font-size: 11.5px; color: var(--muted); }
.kpi-card .up { color: var(--ok); } .kpi-card .down { color: var(--bad); }
.area-score { display: inline-flex; gap: 6px; align-items: center; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 70px; }
.spark > div { flex: 1; background: linear-gradient(180deg, var(--leaf), color-mix(in srgb, var(--leaf) 55%, var(--deep))); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.perm-tree .top { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.perm-tree .top .state { font-size: 12px; }
.perm-tree .sub { padding: 6px 10px 10px 34px; background: var(--surface-2); }
.history { display: grid; gap: 6px; }
.history .h-row { position: relative; font-size: 13px; padding: 7px 10px 7px 24px; background: var(--surface-2); border-radius: 8px; }
.history .h-row::before { content: ""; position: absolute; left: 10px; top: 13px; width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); }
.history .h-row.return::before, .history .h-row.reject::before, .history .h-row.returned::before, .history .h-row.rejected::before { background: var(--bad); }
.history .h-row.approve::before, .history .h-row.approved::before, .history .h-row.paid::before { background: var(--ok); }
.reason-box { border: 1px solid color-mix(in srgb, var(--bad) 35%, var(--border)); background: var(--bad-soft); padding: 9px 13px; border-radius: 10px; }
@media (max-width: 640px) { .upload-item { grid-template-columns: 1fr auto; } .upload-item .progress { grid-column: 1 / -1; } }
.group-row td { background: var(--surface-3) !important; border-top: 1px solid var(--border-strong); font-weight: 600; }
.kpi-legend.green { border-color: var(--ok); } .kpi-legend.yellow { border-color: var(--yellow); } .kpi-legend.red { border-color: var(--bad); }

/* ================================================================== 1.4 – pricing, steppers, accordions */
.reason-box.bad { border-color: color-mix(in srgb, var(--bad) 50%, var(--border)); background: var(--bad-soft); }
.reason-box.info { border-color: color-mix(in srgb, var(--info) 40%, var(--border)); background: var(--info-soft); }
.reason-box.ok { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); background: var(--ok-soft); }
.ok-text { color: var(--ok); }
.bad-text { color: var(--bad); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.pricing-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; box-shadow: inset 4px 0 0 var(--accent), var(--shadow-sm); }
.pricing-head h2 { font-size: 20px; letter-spacing: .2px; }
.pricing-cards .kpi::before { background: var(--border-strong); }
.pricing-cards .kpi.ok::before { background: var(--ok); }
.pricing-cards .kpi.warn::before { background: var(--yellow); }
.pdf-menu { align-items: center; padding: 4px 6px; border: 1px dashed var(--border-strong); border-radius: 10px; }
details.accordion { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
details.accordion + details.accordion { margin-top: 4px; }
details.accordion > summary { list-style: none; cursor: pointer; padding: 12px 14px; display: flex; gap: 10px; align-items: baseline; border-radius: var(--radius); }
details.accordion > summary:hover { background: var(--surface-2); }
details.accordion > summary::-webkit-details-marker { display: none; }
details.accordion > summary::before { content: '▸'; color: var(--accent); transition: transform .15s; display: inline-block; }
details.accordion[open] > summary::before { transform: rotate(90deg); }
details.accordion[open] > summary { border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; background: var(--surface-2); }
details.accordion > form { padding: 12px 14px 14px; }
.input-field:not(:disabled) { background: var(--highlight-soft); border-color: color-mix(in srgb, var(--yellow) 50%, var(--border)); }
.input-field:disabled { background: var(--surface-2); color: var(--muted); }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; padding: 10px; margin: 0 -4px; background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(6px); border-top: 1px solid var(--border); align-items: center; }
.stepper { list-style: none; display: flex; gap: 0; padding: 0; margin: 0; flex-wrap: wrap; counter-reset: s; }
.stepper .step { flex: 1 1 140px; display: flex; flex-direction: column; align-items: center; gap: 5px; position: relative; padding: 8px 4px;
  font-size: 12.5px; color: var(--muted); text-align: center; }
.stepper .step::after { content: ''; position: absolute; top: 22px; left: calc(50% + 18px); right: calc(-50% + 18px); height: 2px; border-radius: 2px; background: var(--border); }
.stepper .step:last-child::after { display: none; }
.stepper .dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; font-family: var(--font-num);
  border: 2px solid var(--border-strong); background: var(--surface); color: var(--muted); z-index: 1; }
.stepper .step.done { color: var(--text); }
.stepper .step.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.stepper .step.done::after { background: var(--ok); }
.stepper .step.current { color: var(--brand-deep); font-weight: 650; }
.stepper .step.current .dot { border-color: var(--accent); background: var(--accent); color: var(--on-accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.stepper .step.skipped .dot { border-style: dashed; }
.stepper .step.bad .dot { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.stepper .step small { color: var(--faint); font-size: 11px; }
.stepper .step.skipped { color: var(--faint); }
.stepper .step.bad { color: var(--bad); }
.stepper .step.clickable { cursor: pointer; border-radius: 10px; }
.stepper .step.clickable:hover, .stepper .step.clickable:focus-visible { background: var(--accent-soft); outline: none; }
@media (max-width: 720px) { .stepper .step::after { display: none; } .pricing-head { align-items: flex-start; } }

/* 1.4 – e-mail composer & documents */
.email-compose { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .email-compose { grid-template-columns: 1fr; } }
.email-preview { border: 1px solid var(--border); border-radius: 10px; padding: 16px; background: #fff; color: #1f2a24; min-height: 220px;
  font: 14px/1.55 Arial, "Noto Arabic", sans-serif; overflow: auto; max-height: 520px; }
.recipient-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border: 1px solid var(--border-strong); border-radius: 9px; padding: 4px 6px; background: var(--surface); }
.recipient-input input { border: 0; flex: 1 1 180px; min-width: 140px; background: transparent; box-shadow: none; padding: 6px 4px; height: 30px; }
.recipient-input input:focus { outline: none; box-shadow: none; }
.chips { display: contents; }
.recipient-input .chip, .chips .chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--brand-soft);
  color: var(--brand-deep); font-size: 13px; border-color: transparent; }
.chip-x { border: 0; background: transparent; cursor: pointer; font-size: 15px; line-height: 1; padding: 0 4px; color: inherit; }
.compact-inputs input { width: 100%; min-width: 60px; padding: 5px 6px; height: 32px; }
.btn-row.spread { justify-content: space-between; }

/* 1.4 – long process steppers (payments: 11 steps) stay on one row and scroll on small screens */
.stepper-scroll { overflow-x: auto; padding-bottom: 4px; }
.stepper.long { flex-wrap: nowrap; min-width: 1050px; }
.stepper.long .step { flex: 1 0 92px; }
.stepper .step.hold .dot { border-color: var(--yellow); background: var(--highlight-soft); color: var(--warn); }

/* 1.4 – accounting */
.coa-l1 { font-weight: 700; } .coa-l2 { padding-left: 14px; font-weight: 600; } .coa-l3 { padding-left: 30px; }
.journal-grid td { vertical-align: top; } .journal-grid td:nth-child(2) select { min-width: 240px; }
.journal-grid td:nth-child(5) input, .journal-grid td:nth-child(6) input { text-align: right; min-width: 120px; }
.table td.num, .table th.num { white-space: nowrap; }

/* 1.4 – profit & loss */
.pnl-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.pnl-chart { width: 100%; height: auto; max-height: 280px; }
.pnl-chart .axis { stroke: var(--border-strong); stroke-width: 1; }
.pnl-chart .bar.sales { fill: var(--leaf); } .pnl-chart .bar.costs { fill: var(--beige); }
:root[data-theme="dark"] .pnl-chart .bar.costs { fill: #C99A62; }
.pnl-chart .line.profit { fill: none; stroke: var(--gold); stroke-width: 2.2; }
.pnl-chart .dot.profit { fill: var(--gold); stroke: var(--surface); stroke-width: 2; }
.pnl-chart .lbl { fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend .key::before { content: ''; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .key.sales::before { background: var(--leaf); } .legend .key.costs::before { background: var(--beige); }
.legend .key.profit::before { background: var(--gold); border-radius: 50%; }

/* 1.6 idle sign-out countdown */
.idle-count { text-align: center; margin: 6px 0; }
.idle-countdown { display: inline-block; min-width: 4ch; padding: 6px 18px; font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; font-family: var(--font-num);
  color: var(--accent-text); background: var(--accent-soft); border-radius: 12px; }

/* ================================================================== 1.7 – generic helpers for pages */
.section-title { font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--accent-text); }
.surface-soft { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.callout { border-radius: var(--radius); padding: 10px 14px; background: var(--highlight-soft); border: 1px solid color-mix(in srgb, var(--yellow) 35%, var(--border)); }
.callout.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, var(--border)); }
.callout.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, var(--border)); }
.callout.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, var(--border)); }
