/* ============================================================
   Global Books — theme.css
   Loaded after style.css. Token-based light/dark design system
   for a data-dense production tracking UI.
   ============================================================ */

/* ---------- 1. Tokens: light (default) ---------- */
:root{
  color-scheme: light;

  /* surfaces */
  --bg:#F4F6FA;
  --surface:#FFFFFF;
  --surface-2:#F1F4F9;
  --surface-3:#E6EBF3;
  --border:#DCE3EE;
  --border-strong:#C3CDDC;

  /* text */
  --text:#0F172A;
  --text-muted:#475569;
  --text-subtle:#64748B;

  /* brand */
  --primary:#1E5FD6;
  --primary-hover:#174FB8;
  --primary-contrast:#FFFFFF;
  --primary-soft:#E8F0FD;
  --focus:#2563EB;
  --danger:#C81E3A;
  --danger-soft:#FDE8EC;

  /* sidebar (dark navy in both themes) */
  --sidebar-bg:#0B1730;
  --sidebar-border:rgba(255,255,255,.08);
  --sidebar-text:#B8C5DD;
  --sidebar-text-strong:#FFFFFF;
  --sidebar-hover:rgba(255,255,255,.07);
  --sidebar-active:rgba(96,165,250,.18);
  --sidebar-accent:#60A5FA;

  /* status: bg (tint) / fg (text on tint) / solid (fill) / on (text on solid) */
  --st-kutilmoqda-bg:#EEF1F6; --st-kutilmoqda-fg:#475569; --st-kutilmoqda-solid:#94A3B8; --st-kutilmoqda-on:#0F172A;
  --st-navbatda-bg:#FEF3E2;   --st-navbatda-fg:#92400E;   --st-navbatda-solid:#F59E0B;   --st-navbatda-on:#1F1300;
  --st-jarayonda-bg:#E6EFFE;  --st-jarayonda-fg:#1D4ED8;  --st-jarayonda-solid:#2563EB;  --st-jarayonda-on:#FFFFFF;
  --st-pauza-bg:#FEF3C7;      --st-pauza-fg:#8A4B05;      --st-pauza-solid:#F5B915;      --st-pauza-on:#2B1D00;
  --st-muammo-bg:#FDE8EC;     --st-muammo-fg:#B4152F;     --st-muammo-solid:#DC2626;     --st-muammo-on:#FFFFFF;
  --st-bajarildi-bg:#DDF5EA;  --st-bajarildi-fg:#0B6B47;  --st-bajarildi-solid:#16A34A;  --st-bajarildi-on:#FFFFFF;
  --st-tayyor-bg:#E8E9FE;     --st-tayyor-fg:#3730A3;     --st-tayyor-solid:#4F46E5;     --st-tayyor-on:#FFFFFF;

  /* shape & depth */
  --r-sm:8px;
  --r-md:12px;
  --r-lg:16px;
  --r-pill:999px;
  --shadow-1:0 1px 2px rgba(15,23,42,.06);
  --shadow-2:0 1px 3px rgba(15,23,42,.08), 0 4px 12px rgba(15,23,42,.05);
  --shadow-3:0 12px 32px rgba(15,23,42,.18);
  --backdrop:rgba(15,23,42,.45);

  /* spacing */
  --sp-1:4px; --sp-2:8px; --sp-3:12px; --sp-4:16px; --sp-5:20px; --sp-6:24px; --sp-8:32px;

  /* z-index scale */
  --z-dropdown:10;
  --z-sticky:20;
  --z-overlay:30;
  --z-modal:50;
  --z-toast:60;

  /* typography */
  --font-body:Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --font-head:Manrope, Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;

  /* motion */
  --t-fast:150ms;
  --t-med:220ms;
  --ease-out:cubic-bezier(.2,.7,.2,1);

  /* legacy style.css variables remapped so untouched rules follow the theme */
  --ink:var(--text);
  --ink-soft:var(--text-muted);
  --line:var(--border);
  --white:var(--surface);
  --blue-50:var(--surface-2);
  --blue-100:var(--primary-soft);
  --navy-900:var(--text);
  --navy-800:var(--text);
  --navy-700:var(--primary);
  --amber-soft:var(--st-navbatda-bg);
  --green-soft:var(--st-bajarildi-bg);
  --red-soft:var(--st-muammo-bg);
  --radius:var(--r-lg);
  --radius-sm:var(--r-sm);
  --shadow-sm:var(--shadow-1);
  --shadow-md:var(--shadow-2);
  --shadow-lg:var(--shadow-3);
}

/* ---------- 2. Tokens: dark ---------- */
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    color-scheme: dark;
    --bg:#0B1120;
    --surface:#111A2E;
    --surface-2:#16213A;
    --surface-3:#1E2B47;
    --border:#24324F;
    --border-strong:#33456B;
    --text:#E6ECF5;
    --text-muted:#A3B1C8;
    --text-subtle:#8796AF;
    --primary:#60A5FA;
    --primary-hover:#93C5FD;
    --primary-contrast:#0B1120;
    --primary-soft:rgba(96,165,250,.14);
    --focus:#93C5FD;
    --danger:#F87171;
    --danger-soft:rgba(248,113,113,.14);
    --sidebar-bg:#070D1A;
    --st-kutilmoqda-bg:#1F2A40; --st-kutilmoqda-fg:#C3CDDD; --st-kutilmoqda-solid:#475569; --st-kutilmoqda-on:#F1F5F9;
    --st-navbatda-bg:#3A2A0E;   --st-navbatda-fg:#FCD38A;   --st-navbatda-solid:#D97706;   --st-navbatda-on:#FFFFFF;
    --st-jarayonda-bg:#13294F;  --st-jarayonda-fg:#A8C8FF;  --st-jarayonda-solid:#2563EB;  --st-jarayonda-on:#FFFFFF;
    --st-pauza-bg:#3B2F0A;      --st-pauza-fg:#FDE68A;      --st-pauza-solid:#EAB308;      --st-pauza-on:#1A1300;
    --st-muammo-bg:#3F1520;     --st-muammo-fg:#FDA4AF;     --st-muammo-solid:#DC2626;     --st-muammo-on:#FFFFFF;
    --st-bajarildi-bg:#0F3324;  --st-bajarildi-fg:#86EFAC;  --st-bajarildi-solid:#16A34A;  --st-bajarildi-on:#FFFFFF;
    --st-tayyor-bg:#24224F;     --st-tayyor-fg:#C4C2FF;     --st-tayyor-solid:#6366F1;     --st-tayyor-on:#FFFFFF;
    --shadow-1:0 1px 2px rgba(0,0,0,.4);
    --shadow-2:0 1px 3px rgba(0,0,0,.45), 0 6px 16px rgba(0,0,0,.25);
    --shadow-3:0 16px 40px rgba(0,0,0,.55);
    --backdrop:rgba(2,6,16,.65);
  }
}
:root[data-theme="dark"]{
  color-scheme: dark;
  --bg:#0B1120;
  --surface:#111A2E;
  --surface-2:#16213A;
  --surface-3:#1E2B47;
  --border:#24324F;
  --border-strong:#33456B;
  --text:#E6ECF5;
  --text-muted:#A3B1C8;
  --text-subtle:#8796AF;
  --primary:#60A5FA;
  --primary-hover:#93C5FD;
  --primary-contrast:#0B1120;
  --primary-soft:rgba(96,165,250,.14);
  --focus:#93C5FD;
  --danger:#F87171;
  --danger-soft:rgba(248,113,113,.14);
  --sidebar-bg:#070D1A;
  --st-kutilmoqda-bg:#1F2A40; --st-kutilmoqda-fg:#C3CDDD; --st-kutilmoqda-solid:#475569; --st-kutilmoqda-on:#F1F5F9;
  --st-navbatda-bg:#3A2A0E;   --st-navbatda-fg:#FCD38A;   --st-navbatda-solid:#D97706;   --st-navbatda-on:#FFFFFF;
  --st-jarayonda-bg:#13294F;  --st-jarayonda-fg:#A8C8FF;  --st-jarayonda-solid:#2563EB;  --st-jarayonda-on:#FFFFFF;
  --st-pauza-bg:#3B2F0A;      --st-pauza-fg:#FDE68A;      --st-pauza-solid:#EAB308;      --st-pauza-on:#1A1300;
  --st-muammo-bg:#3F1520;     --st-muammo-fg:#FDA4AF;     --st-muammo-solid:#DC2626;     --st-muammo-on:#FFFFFF;
  --st-bajarildi-bg:#0F3324;  --st-bajarildi-fg:#86EFAC;  --st-bajarildi-solid:#16A34A;  --st-bajarildi-on:#FFFFFF;
  --st-tayyor-bg:#24224F;     --st-tayyor-fg:#C4C2FF;     --st-tayyor-solid:#6366F1;     --st-tayyor-on:#FFFFFF;
  --shadow-1:0 1px 2px rgba(0,0,0,.4);
  --shadow-2:0 1px 3px rgba(0,0,0,.45), 0 6px 16px rgba(0,0,0,.25);
  --shadow-3:0 16px 40px rgba(0,0,0,.55);
  --backdrop:rgba(2,6,16,.65);
}

/* ---------- 3. Base ---------- */
:root{ font-size:15px; }
body{
  font-family:var(--font-body);
  background:var(--bg);
  color:var(--text);
  line-height:1.5;
  font-feature-settings:"cv11","ss01";
}
h1,h2,h3,h4{ font-family:var(--font-head); color:var(--text); }
table, .stat-value, .status-cell, .clock, input[type="number"]{ font-variant-numeric:tabular-nums; }
a{ color:var(--primary); }
a:hover{ color:var(--primary-hover); }
::selection{ background:var(--primary-soft); }

::-webkit-scrollbar-thumb{ background:var(--border-strong); border-radius:var(--r-pill); }
::-webkit-scrollbar-thumb:hover{ background:var(--text-subtle); filter:none; }

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

@media (max-width:640px){
  :root{ font-size:16px; }
}

/* ---------- 4. Shell: sidebar, topbar ---------- */
.sidebar{
  width:248px;
  background:var(--sidebar-bg);
  color:var(--sidebar-text);
  box-shadow:none;
  border-right:1px solid var(--sidebar-border);
  padding:20px 12px;
  z-index:var(--z-overlay);
}
.brand{
  color:var(--sidebar-text-strong);
  font-family:var(--font-head);
  border-bottom:1px solid var(--sidebar-border);
}
.menu-item, .submenu-item{
  color:var(--sidebar-text);
  border-radius:var(--r-sm);
  transition:background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.menu-item{ min-height:40px; padding:9px 12px; font-size:14px; font-weight:500; }
.menu-item:hover, .submenu-item:hover{
  background:var(--sidebar-hover);
  color:var(--sidebar-text-strong);
  padding-left:12px;
}
.submenu-item:hover{ padding-left:12px; }
.menu-item.active, .submenu-item.active{
  background:var(--sidebar-active);
  color:var(--sidebar-text-strong);
  font-weight:600;
  box-shadow:inset 3px 0 0 var(--sidebar-accent);
}
.submenu{ padding-left:12px; }
.submenu-item{ padding:8px 12px; font-size:13.5px; min-height:36px; }
.menu-item:focus-visible, .submenu-item:focus-visible, .logout-btn:focus-visible{
  outline:2px solid var(--sidebar-accent); outline-offset:-2px;
}
.logout-btn{
  background:transparent;
  color:#FCA5B5;
  border:1px solid rgba(252,165,181,.35);
  border-radius:var(--r-sm);
  min-height:40px;
}
.logout-btn:hover{ background:rgba(252,165,181,.12); }

.topbar{
  background:color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter:saturate(1.4) blur(10px);
  border-bottom:1px solid var(--border);
  padding:14px 28px;
  z-index:var(--z-sticky);
  gap:var(--sp-3);
}
.topbar h1{
  background:none;
  -webkit-background-clip:border-box;
  background-clip:border-box;
  color:var(--text);
  font-family:var(--font-head);
  font-weight:700;
  font-size:20px;
}
.topbar-right{ display:flex; align-items:center; gap:var(--sp-2); margin-left:auto; }
.clock{
  background:var(--surface-2);
  color:var(--text-muted);
  border:1px solid var(--border);
  font-weight:600;
}
.menu-toggle, .theme-toggle{
  display:inline-flex; align-items:center; justify-content:center;
  width:40px; height:40px; flex-shrink:0;
  border-radius:var(--r-sm);
  border:1px solid var(--border);
  background:var(--surface);
  color:var(--text);
  cursor:pointer;
  transition:background var(--t-fast), border-color var(--t-fast);
}
.menu-toggle{ display:none; }
.menu-toggle:hover, .theme-toggle:hover{ background:var(--surface-2); border-color:var(--border-strong); }
.theme-toggle svg{ width:19px; height:19px; }
.sidebar-overlay{ background:var(--backdrop); z-index:calc(var(--z-overlay) - 1); }
.worker-logout-btn{
  background:var(--danger-soft);
  color:var(--danger);
  border:1px solid color-mix(in srgb, var(--danger) 35%, transparent);
}
.worker-logout-btn:hover{ background:color-mix(in srgb, var(--danger) 20%, transparent); }
.view-body{ padding:24px 28px 56px; }

/* ---------- 5. Buttons ---------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:var(--sp-2);
  min-height:40px;
  padding:9px 16px;
  border-radius:var(--r-sm);
  font-family:var(--font-body);
  font-size:14px;
  font-weight:600;
  border:1px solid transparent;
  box-shadow:none;
  transition:background var(--t-fast) var(--ease-out), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
  text-decoration:none;
}
.btn:active{ transform:translateY(1px); }
.btn:disabled, .btn[disabled]{ opacity:.55; cursor:not-allowed; transform:none; }
.btn-primary{
  background:var(--primary);
  color:var(--primary-contrast);
  box-shadow:var(--shadow-1);
}
.btn-primary:hover{ background:var(--primary-hover); filter:none; transform:none; box-shadow:var(--shadow-1); }
.btn-primary::after{ display:none; }
.btn-outline{
  background:var(--surface);
  color:var(--text);
  border:1px solid var(--border-strong);
}
.btn-outline:hover{ background:var(--surface-2); border-color:var(--primary); color:var(--primary); }
.btn-ghost{ background:transparent; color:var(--primary); }
.btn-ghost:hover{ background:var(--primary-soft); }
.btn-sm{ min-height:32px; padding:5px 12px; font-size:13px; border-radius:var(--r-sm); }
.btn:focus-visible{ outline:2px solid var(--focus); outline-offset:2px; }

/* ---------- 6. Worker status buttons (tablet-first) ---------- */
.status-btn{
  position:relative;
  min-height:64px;
  padding:14px 12px;
  border-radius:var(--r-md);
  font-family:var(--font-head);
  font-size:18px;
  font-weight:700;
  letter-spacing:.2px;
  border:2px solid transparent;
  box-shadow:var(--shadow-1);
  transition:filter var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.status-btn.start{ background:var(--st-jarayonda-solid); color:var(--st-jarayonda-on); }
.status-btn.pause{ background:var(--st-pauza-solid); color:var(--st-pauza-on); }
.status-btn.done{ background:var(--st-bajarildi-solid); color:var(--st-bajarildi-on); }
.status-btn.problem{ background:var(--st-muammo-solid); color:var(--st-muammo-on); }
.status-btn:hover{ transform:none; filter:brightness(1.07); }
.status-btn:active{ transform:scale(.98); }
.status-btn.active{
  box-shadow:0 0 0 3px var(--surface), 0 0 0 6px currentColor;
  border-color:rgba(255,255,255,.6);
}
.status-btn.pause.active{ box-shadow:0 0 0 3px var(--surface), 0 0 0 6px var(--st-pauza-solid); }
.status-btn.active::after{
  content:"";
  position:absolute; top:8px; right:10px;
  width:10px; height:16px;
  border:solid currentColor; border-width:0 3px 3px 0;
  transform:rotate(45deg);
}
.status-btn:disabled{ opacity:.45; cursor:not-allowed; filter:grayscale(.3); transform:none; }
.status-btn:focus-visible{ outline:3px solid var(--focus); outline-offset:3px; }

/* ---------- 7. Forms ---------- */
input, select, textarea{ font-family:inherit; color:var(--text); }
.field label{ color:var(--text-muted); font-weight:600; font-size:13px; }
.field input, .field select, .field textarea,
.reason-row-input, .search-input, #loginForm input, .warehouse-draft input, .warehouse-draft select{
  background:var(--surface);
  border:1px solid var(--border-strong);
  border-radius:var(--r-sm);
  color:var(--text);
  transition:border-color var(--t-fast), box-shadow var(--t-fast);
}
.field input, .field select{ min-height:40px; padding:8px 12px; font-size:14px; }
.field textarea{ padding:10px 12px; font-size:14px; }
.field input:hover, .field select:hover{ border-color:var(--text-subtle); }
.field input:focus, .field select:focus, .field textarea:focus,
.reason-row-input:focus, .search-input:focus, #loginForm input:focus{
  outline:none;
  border-color:var(--focus);
  background:var(--surface);
  box-shadow:0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent);
}
.field input[readonly], .field textarea[readonly]{
  background:var(--surface-2);
  color:var(--text-muted);
  border-style:solid;
  border-color:var(--border);
  font-weight:600;
}
.field input[type="file"]{ background:var(--surface); }
.auto-badge{ background:var(--primary-soft); color:var(--primary); }
.file-current{ background:var(--surface-2); border-color:var(--border); color:var(--text-muted); }
.form-section{ border-bottom:1px dashed var(--border); }
.form-section h3{ color:var(--danger); font-family:var(--font-head); }
.search-input{ min-height:40px; border-radius:var(--r-sm); width:300px; }
.date-row{ color:var(--text-muted); }
.date-row input{
  background:var(--surface);
  border:1px solid var(--border-strong);
  border-radius:var(--r-md);
  color:var(--text);
}
.date-row input:focus{ border-color:var(--focus); background:var(--surface); }

/* ---------- 8. Panels & tables ---------- */
.panel{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--r-lg);
  box-shadow:var(--shadow-1);
}
.panel-header{
  background:var(--surface);
  color:var(--text);
  border-bottom:1px solid var(--border);
  padding:14px 20px;
}
.panel-header h2{ color:var(--text); font-size:15px; font-weight:700; letter-spacing:0; }
.panel-body{ padding:18px 20px; }
.panel-header.muammo-color-header{ background:var(--st-muammo-bg); }
.panel-header.muammo-color-header h2{ color:var(--st-muammo-fg); }
.panel-header.yechim-color-header{ background:var(--st-bajarildi-bg); }
.panel-header.yechim-color-header h2{ color:var(--st-bajarildi-fg); }

table{ font-size:14px; color:var(--text); }
thead th{
  position:sticky; top:0; z-index:var(--z-sticky);
  background:var(--surface-2);
  color:var(--text-muted);
  font-size:12px;
  font-weight:600;
  letter-spacing:.3px;
  padding:10px 12px;
  border-bottom:1px solid var(--border);
}
tbody td{ padding:10px 12px; border-bottom:1px solid var(--border); color:var(--text); }
tbody tr{ transition:background var(--t-fast); }
tbody tr:hover{ background:var(--surface-2); cursor:pointer; }
.status-table tbody tr:hover, .empty-row:hover{ background:transparent; cursor:default; }
.empty-row td{ color:var(--text-subtle); }
.stage-orders-table th:not(:last-child), .stage-orders-table td:not(:last-child),
.compact-list-table th:not(:last-child), .compact-list-table td:not(:last-child){
  border-right:1px solid var(--border);
}
.status-table th, .status-table td, .hisobot-table th, .hisobot-table td{ border-right:1px solid var(--border); }
.status-table th:last-child, .status-table td:last-child,
.hisobot-table th:last-child, .hisobot-table td:last-child{ border-right:none; }
#muammoTableWrap thead th, #stageProblemsTable thead th:nth-child(2){ background:var(--st-muammo-bg); color:var(--st-muammo-fg); }
#yechimTableWrap thead th, #stageProblemsTable thead th:nth-child(3){ background:var(--st-bajarildi-bg); color:var(--st-bajarildi-fg); }
.editable-cell:hover{ background:var(--surface-2); }

/* ---------- 9. Badges ---------- */
.badge{
  padding:3px 10px;
  border-radius:var(--r-pill);
  font-size:12px;
  font-weight:600;
  letter-spacing:0;
  border:1px solid transparent;
}
.badge.kutilmoqda{ background:var(--st-kutilmoqda-bg); color:var(--st-kutilmoqda-fg); }
.badge.navbatda{ background:var(--st-navbatda-bg); color:var(--st-navbatda-fg); }
.badge.jarayonda{ background:var(--st-jarayonda-bg); color:var(--st-jarayonda-fg); }
.badge.pauza{ background:var(--st-pauza-bg); color:var(--st-pauza-fg); }
.badge.muammo{ background:var(--st-muammo-bg); color:var(--st-muammo-fg); }
.badge.bajarildi{ background:var(--st-bajarildi-bg); color:var(--st-bajarildi-fg); }
.badge.tayyor{ background:var(--st-tayyor-bg); color:var(--st-tayyor-fg); }
.muammo-badge{ background:var(--st-muammo-bg); color:var(--st-muammo-fg); }
.yechim-badge{ background:var(--st-bajarildi-bg); color:var(--st-bajarildi-fg); }
.grade-alo{ color:var(--st-bajarildi-fg); }
.grade-qoniqarli{ color:var(--st-navbatda-fg); }
.grade-qoniqarsiz{ color:var(--st-muammo-fg); }
.grade-dash{ color:var(--text-subtle); }
.eval-panel tr.row-bad td{ color:var(--st-muammo-fg); }

/* ---------- 10. Status matrix ---------- */
.status-cell{ border-radius:6px; color:var(--text); }
.status-cell-empty{ background:transparent; color:var(--text-subtle); }
.status-cell.jarayonda{ background:var(--st-jarayonda-solid); color:var(--st-jarayonda-on); }
.status-cell.pauza{ background:var(--st-pauza-solid); color:var(--st-pauza-on); }
.status-cell.bajarildi{ background:var(--st-bajarildi-solid); color:var(--st-bajarildi-on); }
.status-cell.muammo{ background:var(--st-muammo-solid); color:var(--st-muammo-on); }
.status-cell-brak{
  background:var(--st-muammo-bg);
  color:var(--st-muammo-fg);
  border-radius:var(--r-pill);
  padding:1px 7px;
  font-size:11.5px;
  font-weight:700;
}
.status-cell.pauza .status-cell-brak, .status-cell.jarayonda .status-cell-brak,
.status-cell.bajarildi .status-cell-brak, .status-cell.muammo .status-cell-brak{
  background:var(--surface); color:var(--st-muammo-fg);
}
.legend-badge{ box-shadow:none; border-radius:var(--r-pill); font-weight:600; }
.legend-badge.jarayonda{ background:var(--st-jarayonda-solid); color:var(--st-jarayonda-on); }
.legend-badge.pauza{ background:var(--st-pauza-solid); color:var(--st-pauza-on); }
.legend-badge.bajarildi{ background:var(--st-bajarildi-solid); color:var(--st-bajarildi-on); }
.legend-badge.muammo{ background:var(--st-muammo-solid); color:var(--st-muammo-on); }

/* ---------- 11. Stat cards & dashboard tiles ---------- */
.stats-row{ gap:var(--sp-4); }
.stat-card{
  background:var(--surface);
  border:1px solid var(--border);
  border-left:4px solid var(--st-jarayonda-solid);
  border-radius:var(--r-md);
  box-shadow:var(--shadow-1);
  padding:18px 20px;
}
.stat-card:hover{ transform:none; box-shadow:var(--shadow-2); }
.stat-card.green{ border-left-color:var(--st-bajarildi-solid); }
.stat-card.amber{ border-left-color:var(--st-navbatda-solid); }
.stat-card .stat-label{ color:var(--text-muted); font-size:12px; font-weight:600; letter-spacing:.5px; }
.stat-card .stat-value{ color:var(--text); font-family:var(--font-head); font-size:34px; font-weight:700; margin-top:4px; }

.process-stat{ background:var(--surface-2); border:1px solid var(--border); border-radius:var(--r-md); }
.process-stat-label{ color:var(--text-muted); }
.process-stat-value{ color:var(--text); }

.stage-tile{
  background:var(--surface);
  border:1px solid var(--border);
  border-top:3px solid var(--primary) !important;
  border-radius:var(--r-md);
  box-shadow:var(--shadow-1);
}
.stage-tile:hover{ transform:none; border-color:var(--primary); box-shadow:var(--shadow-2); }
.stage-tile .stage-name{ color:var(--text); }

.readonly-banner{ background:var(--surface-2); border:1px solid var(--border); }
.readonly-banner div b{ color:var(--text); }
.readonly-banner span{ color:var(--text-muted); }

/* ---------- 12. Accounts page, pickers, reason rows ---------- */
.acc-heading{ color:var(--text); font-family:var(--font-head); }
.acc-col{ background:var(--surface); border:1px solid var(--border); border-radius:var(--r-md); box-shadow:var(--shadow-1); }
.acc-col-head{ color:var(--text); border-bottom:1px solid var(--border); }
.acc-col-item{ color:var(--text); border-bottom:1px dashed var(--border); }
.acc-col-item:hover{ color:var(--primary); }
.acc-col-empty{ color:var(--text-subtle); }
.jamoa-pick-item, .jamoa-pick-check, .reason-row{
  border:1px solid var(--border-strong);
  border-radius:var(--r-sm);
  color:var(--text);
  min-height:44px;
}
.jamoa-pick-item:hover, .jamoa-pick-check:hover{ background:var(--surface-2); border-color:var(--primary); color:var(--text); }
.reason-row:hover{ border-color:var(--primary); }
.reason-row.selected{ background:var(--primary-soft); border-color:var(--primary); box-shadow:0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.reason-row-label{ color:var(--text); }
.jamoa-pick-check input[type="checkbox"]{ accent-color:var(--primary); }

/* ---------- 13. Orders tabs, warehouse, hisobot ---------- */
.orders-tab{
  color:var(--text-muted);
  border-bottom:2px solid transparent;
  min-height:44px;
}
.orders-tab:hover{ background:var(--surface-2); color:var(--text); }
.orders-tab[aria-selected="true"]{ background:transparent; color:var(--primary); border-bottom-color:var(--primary); }
.orders-tab:focus-visible{ outline:2px solid var(--focus); outline-offset:-4px; }

.hisobot-date-filter{ color:var(--text-muted); }
.hisobot-date-filter input{
  background:var(--surface);
  border:1px solid var(--border-strong);
  color:var(--text);
  border-radius:var(--r-sm);
  min-height:36px;
}
.hisobot-total-row td{
  background:var(--surface-3);
  color:var(--text);
  border-right-color:var(--border) !important;
}
.hisobot-total-row .grade-alo{ color:var(--st-bajarildi-fg); }
.hisobot-total-row .grade-qoniqarsiz{ color:var(--st-muammo-fg); }
.hisobot-total-row .grade-dash{ color:var(--text-subtle); }
.eval-order-title{ color:var(--text); }

.stock-document{ background:var(--surface); border-color:var(--border); color:var(--text); }
.stock-document th, .stock-document td{ border-color:var(--border); }
.warehouse-draft input:focus-visible, .warehouse-draft select:focus-visible{ box-shadow:0 1px 0 var(--focus); }

/* ---------- 14. Read-only view & master karta sheet ---------- */
.view-section h3{ color:var(--primary); border-bottom:1px solid var(--border); }
.view-field{ border-bottom:1px dashed var(--border); }
.view-label{ color:var(--text-muted); }
.view-value{ color:var(--text); }

/* The sheet keeps its flat "paper" structure, now in theme colors. */
.mk-sheet{
  background:var(--surface);
  border:1px solid var(--border-strong);
  border-radius:var(--r-md);
  box-shadow:var(--shadow-1);
}
.mk-sheet .panel-header{
  background:var(--surface-2);
  border-bottom:1px solid var(--border);
}
.mk-sheet .panel-header h2, .mk-stage-title, .mk-stage-back{ color:var(--text); }
.mk-stage-back{ color:var(--primary); }
.mk-sheet .panel-body{ background:var(--surface); }
.mk-sheet .field label, .mk-sheet .view-label{ color:var(--text-muted); }
.mk-sheet .field input, .mk-sheet .field select, .mk-sheet .field textarea,
.mkcard.mk-sheet .field textarea{
  background:var(--surface);
  border:1px solid var(--border-strong);
  border-radius:6px;
  color:var(--text);
}
.mk-sheet .field input:focus, .mk-sheet .field select:focus, .mkcard.mk-sheet .field textarea:focus{
  border-color:var(--focus);
  background:var(--surface);
  box-shadow:0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent);
}
.mk-sheet .field input:hover{ border-color:var(--text-subtle); }
.mk-sheet .field input[readonly]{ background:var(--surface-2); color:var(--text); border-color:var(--border); }
.mk-sheet .auto-badge{ background:var(--surface); color:var(--text-muted); border-color:var(--border); }
.mk-sheet .form-section{ border-bottom:1px solid var(--border); }
.mk-sheet .form-section h3, .mk-sheet .view-section h3{ color:var(--danger); border-bottom-color:var(--border); }
.mk-sheet .file-current{ background:var(--surface-2); border-color:var(--border); color:var(--text-muted); }
.mk-sheet .field-col:not(:first-child), .mkcard.mk-sheet .field-col:not(:first-child){ border-left-color:var(--border); }
.mk-sheet .view-value{ background:var(--surface-2); border:1px solid var(--border); border-radius:6px; color:var(--text); }
.mk-sheet .view-value.is-empty{ background:transparent; color:var(--text-subtle); }
.mkcard.mk-sheet .field input.computed-field{ background:var(--primary-soft); color:var(--primary); }
.mkcard.mk-sheet .field input.big-date-input{ background:var(--surface); color:var(--text); border-color:var(--border-strong); }
.stage-meta-row{ color:var(--text); border-bottom-color:var(--border); }

/* ---------- 15. Modals & toast ---------- */
.modal-overlay{
  background:var(--backdrop);
  backdrop-filter:blur(4px);
  z-index:var(--z-modal);
}
.modal-box{
  background:var(--surface);
  color:var(--text);
  border:1px solid var(--border);
  border-top:1px solid var(--border);
  border-image:none;
  border-radius:var(--r-lg);
  width:440px;
  max-width:calc(100vw - 32px);
  max-height:calc(100dvh - 32px);
  overflow-y:auto;
  box-shadow:var(--shadow-3);
  padding:24px;
}
.modal-box h3{ color:var(--text); font-weight:700; }
.modal-box p{ color:var(--text-muted); }
.toast{
  background:var(--text);
  color:var(--surface);
  border-radius:var(--r-md);
  box-shadow:var(--shadow-3);
  font-weight:600;
  z-index:var(--z-toast);
  max-width:min(420px, calc(100vw - 32px));
}

/* ---------- 16. Misc ---------- */
.muted{ color:var(--text-muted); }
.login-error{ color:var(--danger); }
.login-hint{ color:var(--text-muted); }

/* ---------- 17. Login ---------- */
.login-screen{ background:var(--bg); }
.login-screen::before, .login-screen::after{ display:none; }
.login-card{
  background:var(--surface);
  color:var(--text);
  border:1px solid var(--border);
  border-image:none;
  border-radius:var(--r-lg);
  box-shadow:var(--shadow-2);
  padding:36px 32px 28px;
}
.login-card h1{ font-family:var(--font-head); font-weight:700; font-size:24px; margin:0 0 4px; color:var(--text); }
.login-subtitle{ color:var(--text-muted); margin:0 0 24px; font-size:14px; }
.login-card .field{ flex-direction:column; align-items:stretch; gap:6px; margin-bottom:14px; }
.login-card .field label{ flex:none; max-width:none; }
.login-logo h1{ background:none; color:var(--text); }
.login-logo p{ color:var(--text-muted); }
#loginForm label{ color:var(--text-muted); }
#loginForm input{ min-height:44px; }

/* ---------- 18. Responsive ---------- */
@media (max-width:880px){
  .menu-toggle{ display:inline-flex; }
  .sidebar{ width:260px; z-index:calc(var(--z-overlay) + 1); }
  .sidebar-overlay{ z-index:var(--z-overlay); }
  .topbar{ padding:12px 16px; }
  .view-body{ padding:16px 16px 48px; }
}
@media (max-width:1024px){
  .status-btn{ min-height:56px; font-size:16px; padding:10px 8px; }
}
@media (max-width:640px){
  .search-input{ width:100%; }
  .stat-card .stat-value{ font-size:28px; }
  .status-btn{ min-height:64px; font-size:17px; }
  .toast{ left:16px; right:16px; max-width:none; }
}

/* ---------- 19. Touch / coarse pointers ---------- */
@media (pointer: coarse){
  .btn, .menu-item, .submenu-item, .logout-btn, .orders-tab,
  .field input, .field select, .search-input, .reason-row-input,
  .menu-toggle, .theme-toggle{ min-height:48px; }
  .btn-sm{ min-height:44px; }
  .menu-toggle, .theme-toggle{ width:48px; }
  .status-btn{ min-height:72px; }
}

/* ---------- 20. Reduced motion ---------- */
@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{
    animation:none !important;
    transition:none !important;
    scroll-behavior:auto !important;
  }
}

/* ---------- 21. Print: always light ---------- */
@media print{
  :root, :root[data-theme="dark"]{
    color-scheme: light;
    --bg:#FFFFFF; --surface:#FFFFFF; --surface-2:#F1F4F9; --surface-3:#E6EBF3;
    --border:#C3CDDC; --border-strong:#9AA8BD;
    --text:#000000; --text-muted:#333333; --text-subtle:#555555;
    --primary:#1E5FD6; --danger:#C81E3A;
    --st-jarayonda-solid:#2563EB; --st-pauza-solid:#F5B915; --st-bajarildi-solid:#16A34A; --st-muammo-solid:#DC2626;
  }
  body{ background:#FFFFFF !important; color:#000; }
  .theme-toggle, .topbar-right{ display:none !important; }
}

/* ---------- Navigation links rendered by js/layout.js (anchors, not buttons) ---------- */
a.menu-item, a.submenu-item { text-decoration: none; display: flex; align-items: center; }
a.submenu-item { display: block; }
.logout-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.logout-btn svg, .menu-item svg { width: 18px; height: 18px; flex: none; }
.chev svg { width: 16px; height: 16px; transition: transform var(--t-fast, .15s); }
.stage-tile[role="button"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* ---------- Stage timeline (stage detail page) ---------- */
.stage-timeline { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.stage-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--r-pill, 999px);
  font-size: 12.5px; font-weight: 600; background: var(--st-kutilmoqda-bg); color: var(--st-kutilmoqda-fg); border: 1px solid transparent; }
.stage-chip-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .85; }
.stage-chip.jarayonda { background: var(--st-jarayonda-bg); color: var(--st-jarayonda-fg); }
.stage-chip.pauza { background: var(--st-pauza-bg); color: var(--st-pauza-fg); }
.stage-chip.muammo { background: var(--st-muammo-bg); color: var(--st-muammo-fg); }
.stage-chip.bajarildi { background: var(--st-bajarildi-bg); color: var(--st-bajarildi-fg); }
.stage-chip.current { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 25%, transparent); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* ---------- Master karta: section nav + draft banner ---------- */
.form-nav { position: sticky; top: 64px; z-index: var(--z-sticky, 20); display: flex; gap: 6px; flex-wrap: wrap;
  padding: 8px; margin-bottom: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md, 12px); box-shadow: var(--shadow-1); }
.form-nav a { padding: 6px 12px; border-radius: var(--r-pill, 999px); color: var(--text-muted); text-decoration: none; font-weight: 600; font-size: 13px; }
.form-nav a:hover { background: var(--surface-2); color: var(--text); }
.form-nav a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[id^="sec-"] { scroll-margin-top: 130px; }
.draft-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 12px;
  border-radius: var(--r-md, 12px); background: var(--st-pauza-bg); color: var(--st-pauza-fg); font-weight: 600; }
@media (max-width: 640px) { .form-nav { top: 56px; overflow-x: auto; flex-wrap: nowrap; } .form-nav a { white-space: nowrap; } }
/* ---------- Analytics page ---------- */
.viz-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.viz-kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.viz-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; transition: opacity var(--t-med, .2s); }
.viz-grid.viz-loading { opacity: .55; }
.viz-wide { grid-column: 1 / -1; }
.viz-card { margin: 0; min-width: 0; }
.viz-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.viz-head h2 { font-size: 15px; }
.viz-canvas { position: relative; width: 100%; }
.viz-empty { padding: 24px 0; text-align: center; }
.viz-table { overflow-x: auto; }
.viz-table td, .viz-table th { font-variant-numeric: tabular-nums; }
.viz-table tbody th { font-weight: 600; text-align: left; }
@media (max-width: 1024px) { .viz-grid { grid-template-columns: 1fr; } }
/* ---------- Worker app (ishchi.html): phone/tablet first ---------- */
body.worker-app { background: var(--bg); min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }
.w-header { position: sticky; top: 0; z-index: var(--z-sticky, 20); display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--sidebar-bg); color: var(--sidebar-text-strong, #fff); }
.w-who { display: flex; flex-direction: column; min-width: 0; }
.w-who strong { font-family: var(--font-head); font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-who .muted { color: var(--sidebar-text); font-size: 13px; }
.w-header-actions { display: flex; align-items: center; gap: 8px; }
.w-header .theme-toggle { color: var(--sidebar-text-strong, #fff); }
.w-sync { font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: var(--r-pill); background: var(--st-pauza-solid); color: var(--st-pauza-on); }
.w-main { max-width: 760px; margin: 0 auto; padding: 14px 14px 32px; }
.w-toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.w-toolbar input { flex: 1; min-height: 48px; font-size: 16px; padding: 0 14px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.w-scan { min-width: 64px; min-height: 48px; font-weight: 800; }
.w-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.w-tab { flex: 1; min-height: 44px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); font-weight: 700; font-size: 15px; cursor: pointer; }
.w-tab.active { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.w-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.w-empty { text-align: center; color: var(--text-muted); padding: 40px 0; }
.w-card { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border-radius: var(--r-lg);
  border: 1px solid var(--border); border-left: 6px solid var(--st-kutilmoqda-solid, var(--border-strong)); background: var(--surface); color: var(--text); cursor: pointer; box-shadow: var(--shadow-1); font: inherit; }
.w-card:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.w-card.jarayonda { border-left-color: var(--st-jarayonda-solid); }
.w-card.pauza { border-left-color: var(--st-pauza-solid); }
.w-card.muammo { border-left-color: var(--st-muammo-solid); }
.w-card.bajarildi { border-left-color: var(--st-bajarildi-solid); }
.w-card-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.w-card-top .badge { margin-left: auto; }
.w-num { font-family: var(--font-head); font-weight: 800; font-size: 18px; }
.w-part, .w-flag { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: var(--r-pill); background: var(--surface-3); color: var(--text-muted); }
.w-flag { background: var(--st-pauza-bg); color: var(--st-pauza-fg); }
.w-title { font-size: 16px; font-weight: 600; line-height: 1.35; }
.w-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.w-late { color: var(--st-muammo-fg); font-weight: 700; }
.w-sheet { position: fixed; inset: 0; z-index: var(--z-modal, 50); background: var(--backdrop, rgba(2,6,23,.55)); display: flex; align-items: flex-end; justify-content: center; }
.w-sheet.hidden { display: none; }
.w-sheet-box { width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; background: var(--surface); color: var(--text);
  border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-3); }
@media (min-width: 700px) { .w-sheet { align-items: center; } .w-sheet-box { border-radius: var(--r-lg); } }
.w-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.w-sheet-head h2 { font-size: 18px; margin: 0; }
.w-sheet-book { margin: 6px 0 12px; font-weight: 600; color: var(--text-muted); }
.w-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0 0 12px; }
.w-facts div { background: var(--surface-2); border-radius: var(--r-md); padding: 8px 10px; }
.w-facts dt { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.w-facts dd { margin: 2px 0 0; font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums; }
@media (max-width: 420px) { .w-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.w-problem { background: var(--st-muammo-bg); color: var(--st-muammo-fg); border-radius: var(--r-md); padding: 10px 12px; }
.w-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0 14px; }
.w-actions .status-btn { min-height: 72px; font-size: 19px; width: 100%; }
.w-brak { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; border-top: 1px solid var(--border); padding-top: 12px; }
.w-brak label { font-weight: 700; }
.w-brak input { width: 120px; min-height: 44px; font-size: 16px; padding: 0 10px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.w-brak-list { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.w-brak-list .badge { border: 0; cursor: pointer; min-height: 32px; }
.w-count-fields, .w-type { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.w-count { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px 14px; min-height: 72px; border-radius: var(--r-md);
  border: 2px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; font: inherit; }
.w-count span { font-size: 13px; color: var(--text-muted); font-weight: 700; }
.w-count strong { font-size: 26px; font-family: var(--font-head); font-variant-numeric: tabular-nums; }
.w-count.active { border-color: var(--primary); background: var(--primary-soft, var(--surface-3)); }
.w-type .w-count strong { font-size: 18px; }
.w-keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.w-keypad button { min-height: 60px; font-size: 24px; font-weight: 700; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
.w-keypad button:active { background: var(--surface-3); }
.w-save { width: 100%; min-height: 56px; font-size: 18px; }
.w-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.w-suggest .badge { border: 0; cursor: pointer; min-height: 32px; background: var(--surface-3); color: var(--text); }
.w-label { display: block; font-weight: 700; margin: 10px 0 6px; }
.w-sheet-box textarea, .w-sheet-box input[type="number"] { width: 100%; font-size: 16px; padding: 10px 12px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); color: var(--text); margin-bottom: 8px; }
#wScanner video { width: 100%; border-radius: var(--r-md); background: #000; margin: 10px 0; }
/* ---------- Order QR (order view + print) ---------- */
.order-qr { display: flex; align-items: center; gap: 14px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.order-qr-code { width: 112px; height: 112px; flex: none; background: #fff; padding: 4px; border-radius: 8px; }
.order-qr-code svg { width: 100%; height: 100%; display: block; }
@media print { .order-qr { border-bottom: 1px solid #ccc; } .order-qr-code { width: 30mm; height: 30mm; } }
/* ---------- Reja (kanban) ---------- */
.kb-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.kb-toolbar select { min-width: 200px; }
.kb-board { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.kb-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 10px; min-height: 200px; }
.kb-col-head { font-size: 14px; margin: 2px 4px 10px; display: flex; justify-content: space-between; }
.kb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kb-empty { color: var(--text-muted); text-align: center; padding: 18px 0; font-size: 13px; }
.kb-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--st-kutilmoqda-solid, var(--border-strong));
  border-radius: var(--r-md); padding: 10px 12px; box-shadow: var(--shadow-1); display: flex; flex-direction: column; gap: 4px; }
.kb-card[draggable="true"] { cursor: grab; }
.kb-card.dragging { opacity: .5; }
.kb-card.jarayonda { border-left-color: var(--st-jarayonda-solid); }
.kb-card.pauza { border-left-color: var(--st-pauza-solid); }
.kb-card.muammo { border-left-color: var(--st-muammo-solid); }
.kb-card.bajarildi { border-left-color: var(--st-bajarildi-solid); }
.kb-card-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kb-pos { min-width: 22px; height: 22px; border-radius: 50%; background: var(--surface-3); color: var(--text-muted); font-size: 12px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.kb-num { font-weight: 800; color: var(--text); text-decoration: none; }
.kb-num:hover { color: var(--primary); }
.kb-title { font-weight: 600; font-size: 14px; line-height: 1.35; }
.kb-meta { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 12.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.kb-move { display: flex; gap: 4px; justify-content: flex-end; }
.kb-move .btn { min-height: 32px; min-width: 36px; padding: 0 8px; }
/* ---------- Settings, stock, cost ---------- */
.settings-form { display: flex; flex-direction: column; gap: 16px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-top: 12px; }
.settings-grid .field, .modal-box .field { display: flex; flex-direction: column; gap: 6px; align-items: stretch; margin-bottom: 10px; }
.settings-grid .field span, .modal-box .field span { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.settings-check { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.settings-check input { width: 20px; height: 20px; }
.settings-sub { margin: 18px 0 0; font-size: 14px; }
.stock-low { color: var(--st-muammo-fg); }
.cost-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.cost-grid > div { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); }
.cost-grid span { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.cost-grid strong { font-size: 17px; font-family: var(--font-head); }
.cost-grid small { color: var(--text-muted); }
.cost-grid .cost-total { background: var(--primary-soft, var(--surface-3)); }
.settings-grid .field select, .settings-grid .field input, .modal-box .field input { height: 40px; min-height: 40px; flex: none; width: 100%; }
/* ---------- Status board v2: chips, cells, drawer ---------- */
.st-toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.st-toolbar .search-input { flex: 1; min-width: 220px; }
.st-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.st-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.st-chip strong { font-variant-numeric: tabular-nums; padding: 1px 8px; border-radius: var(--r-pill); background: var(--surface-3); }
.st-chip:hover { border-color: var(--border-strong); }
.st-chip:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.st-chip.jarayonda strong { background: var(--st-jarayonda-bg); color: var(--st-jarayonda-fg); }
.st-chip.pauza strong { background: var(--st-pauza-bg); color: var(--st-pauza-fg); }
.st-chip.muammo strong { background: var(--st-muammo-bg); color: var(--st-muammo-fg); }
.st-chip.tayyor strong { background: var(--st-tayyor-bg); color: var(--st-tayyor-fg); }
.st-chip.active.jarayonda { background: var(--st-jarayonda-solid); border-color: var(--st-jarayonda-solid); color: var(--st-jarayonda-on); }
.st-chip.active.pauza { background: var(--st-pauza-solid); border-color: var(--st-pauza-solid); color: var(--st-pauza-on); }
.st-chip.active.muammo { background: var(--st-muammo-solid); border-color: var(--st-muammo-solid); color: var(--st-muammo-on); }
.st-chip.active.navbatda { background: var(--text-muted); border-color: var(--text-muted); color: var(--surface); }
.st-chip.active.tayyor { background: var(--st-tayyor-solid); border-color: var(--st-tayyor-solid); color: var(--st-tayyor-on); }
.st-chip.active strong { background: rgba(255,255,255,.25); color: inherit; }

.st-scroll { padding: 0 !important; overflow: auto; max-height: calc(100vh - 250px); }
.st-table { border-collapse: separate; border-spacing: 0; width: 100%; }
.st-table thead th { position: sticky; top: 0; z-index: 3; background: var(--surface-2); white-space: nowrap; }
.st-table .sticky-col { position: sticky; left: 0; z-index: 2; background: var(--surface); font-weight: 700; }
.st-table thead .sticky-col { z-index: 4; background: var(--surface-2); }
.st-table .sticky-col a { color: var(--text); text-decoration: none; }
.st-table .sticky-col a:hover { color: var(--primary); }
.st-table td { vertical-align: middle; padding: 6px; }
.st-name { max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-qty { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sc-cell { min-width: 112px; }
.sc-stack { display: flex; flex-direction: column; gap: 4px; }
.sc-none { display: block; height: 1px; }
.sc { width: 100%; min-height: 44px; display: flex; flex-direction: column; justify-content: center; gap: 3px; padding: 6px 8px; border-radius: var(--r-sm);
  border: 1px solid transparent; font: inherit; text-align: left; cursor: pointer; transition: transform var(--t-fast, .15s), box-shadow var(--t-fast, .15s); }
.sc:hover { box-shadow: var(--shadow-2); }
.sc:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sc-empty { align-items: center; background: transparent; border-color: var(--border); border-style: dashed; color: var(--text-subtle); min-height: 36px; }
.sc-top { display: flex; align-items: center; gap: 6px; }
.sc-icon { font-size: 12px; width: 14px; text-align: center; }
.sc-num { font-weight: 800; font-size: 13.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sc-of { font-weight: 500; opacity: .75; font-size: 12px; }
.sc-meta { font-size: 11.5px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-part { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; opacity: .75; }
.sc-bar { display: block; height: 4px; border-radius: 4px; background: color-mix(in srgb, currentColor 20%, transparent); overflow: hidden; }
.sc-bar > span { display: block; height: 100%; border-radius: 4px; background: currentColor; }
.sc-jarayonda { background: var(--st-jarayonda-bg); color: var(--st-jarayonda-fg); border-color: color-mix(in srgb, var(--st-jarayonda-solid) 35%, transparent); }
.sc-pauza { background: var(--st-pauza-bg); color: var(--st-pauza-fg); border-color: color-mix(in srgb, var(--st-pauza-solid) 35%, transparent); }
.sc-muammo { background: var(--st-muammo-bg); color: var(--st-muammo-fg); border-color: var(--st-muammo-solid); }
.sc-bajarildi { background: var(--st-bajarildi-bg); color: var(--st-bajarildi-fg); border-color: color-mix(in srgb, var(--st-bajarildi-solid) 35%, transparent); }
.sc-kutilmoqda { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }
.sc.dim { opacity: .25; }

.st-drawer-backdrop { position: fixed; inset: 0; z-index: calc(var(--z-modal, 50) - 2); background: var(--backdrop, rgba(2,6,23,.45)); }
.st-drawer-backdrop.hidden, .st-drawer.hidden { display: none; }
.st-drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: calc(var(--z-modal, 50) - 1); width: min(460px, 100vw);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-3); display: flex; flex-direction: column;
  transform: translateX(16px); opacity: 0; transition: transform var(--t-med, .2s) var(--ease-out, ease), opacity var(--t-med, .2s); }
.st-drawer.open { transform: none; opacity: 1; }
.st-drawer:focus { outline: none; }
.st-drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 18px 20px 12px; border-bottom: 1px solid var(--border); }
.st-drawer-head h2 { margin: 2px 0; font-size: 19px; }
.st-drawer-head p { margin: 0; }
.st-drawer-book { font-weight: 600; color: var(--text-muted); }
.st-drawer-body { flex: 1; overflow: auto; padding: 14px 20px; display: flex; flex-direction: column; gap: 16px; }
.st-drawer-body h3 { font-size: 14px; margin: 0 0 6px; }
.st-progress-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 8px; }
.st-progress-nums div { background: var(--surface-2); border-radius: var(--r-md); padding: 8px 10px; }
.st-progress-nums span { display: block; font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.st-progress-nums strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.sc-bar-lg { height: 8px; color: var(--primary); }
.st-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 0; }
.st-facts dt { font-size: 12px; color: var(--text-muted); }
.st-facts dd { margin: 2px 0 0; font-weight: 600; }
.st-problem { background: var(--st-muammo-bg); color: var(--st-muammo-fg); border-radius: var(--r-md); padding: 12px 14px; }
.st-problem p { margin: 0 0 10px; }
.st-brak { display: flex; flex-wrap: wrap; gap: 6px; }
.st-history { width: 100%; font-size: 13px; }
.st-history td, .st-history th { padding: 6px 8px; font-variant-numeric: tabular-nums; }
.st-drawer-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
@media (max-width: 520px) { .st-progress-nums { grid-template-columns: repeat(2, 1fr); } .st-facts { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .st-drawer { transition: none; } }
.sc-empty { border: 0; background: transparent; min-height: 28px; padding: 2px 6px; flex-direction: row; justify-content: center; gap: 6px; }
.sc-empty:hover { background: var(--surface-2); box-shadow: none; }
.sc-empty .sc-part { opacity: .55; }
/* Status board: one compact label per stage */
.st-table td.sc-cell { min-width: 96px; padding: 4px 6px; text-align: center; }
.st-table tbody tr { height: 40px; }
.st-table tbody tr:hover td { background: var(--surface-2); }
.st-table tbody tr:hover .sticky-col { background: var(--surface-2); }
.sc-stack { display: flex; flex-direction: column; gap: 3px; align-items: center; }
.sc-pill { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 26px; padding: 2px 10px; border-radius: var(--r-pill);
  border: 1px solid transparent; font: inherit; font-size: 12.5px; font-weight: 700; white-space: nowrap; cursor: pointer; }
.sc-pill:hover { filter: brightness(1.08); box-shadow: var(--shadow-1); }
.sc-pill:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sc-pill.jarayonda { background: var(--st-jarayonda-bg); color: var(--st-jarayonda-fg); }
.sc-pill.pauza { background: var(--st-pauza-bg); color: var(--st-pauza-fg); }
.sc-pill.muammo { background: var(--st-muammo-solid); color: var(--st-muammo-on); }
.sc-pill.bajarildi { background: var(--st-bajarildi-bg); color: var(--st-bajarildi-fg); }
.sc-pill.dim { opacity: .2; }
/* Status board: full grid lines so every cell reads as its own box */
.st-table { border: 1px solid var(--border-strong); border-radius: 0; }
.st-table th, .st-table td { border-right: 1px solid var(--border-strong); border-bottom: 1px solid var(--border-strong); }
.st-table th:last-child, .st-table td:last-child { border-right: 0; }
.st-table tbody tr:last-child td { border-bottom: 0; }
.st-table thead th { border-bottom: 2px solid var(--border-strong); text-align: center; }
.st-table thead th:nth-child(-n+4) { text-align: left; }
.st-table td.sc-cell { width: 104px; min-width: 104px; }
.st-table .sticky-col { box-shadow: 1px 0 0 var(--border-strong); }
.sc-dash { color: var(--text-subtle); opacity: .6; }

.st-chip.bajarildi strong { background: var(--st-bajarildi-bg); color: var(--st-bajarildi-fg); }
.st-chip.active.bajarildi { background: var(--st-bajarildi-solid); border-color: var(--st-bajarildi-solid); color: var(--st-bajarildi-on); }
/* ---------- Tech card templates ---------- */
.tpl-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); }
.tpl-bar select { min-width: 220px; height: 36px; }
.tpl-sep { flex: 1; }
/* ---------- File links + preview ---------- */
.file-link { display: inline-flex; align-items: center; gap: 6px; color: var(--primary); text-decoration: none; font-weight: 600; word-break: break-all; }
.file-link:hover { text-decoration: underline; }
.file-icon { width: 16px; height: 16px; flex: none; }
.modal-box.modal-wide { max-width: min(1100px, 96vw); width: 96vw; height: 90vh; display: flex; flex-direction: column; padding: 12px 14px; }
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 10px; }
.preview-head h3 { margin: 0; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-actions { display: flex; gap: 6px; flex: none; }
.preview-body { flex: 1; min-height: 0; background: var(--surface-2); border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; overflow: auto; }
.preview-body iframe { width: 100%; height: 100%; border: 0; border-radius: var(--r-md); background: #fff; }
.preview-body img { max-width: 100%; max-height: 100%; object-fit: contain; }
/* ---------- Notification bell ---------- */
.bell-wrap { position: relative; }
.bell-btn { position: relative; }
.bell-badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--st-muammo-solid); color: var(--st-muammo-on); font-size: 11px; font-weight: 800; line-height: 18px; text-align: center; }
.bell-panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: var(--z-dropdown, 10); width: min(380px, 92vw); max-height: 70vh; overflow: auto;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-3); }
.bell-panel[hidden] { display: none; }
.bell-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.bell-list { list-style: none; margin: 0; padding: 0; }
.bell-list li { border-bottom: 1px solid var(--border); }
.bell-list li:last-child { border-bottom: 0; }
.bell-list a { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px 10px 18px; color: var(--text); text-decoration: none; position: relative; }
.bell-list a:hover { background: var(--surface-2); }
.bell-list li.unread a::before { content: ""; position: absolute; left: 6px; top: 16px; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }
.bell-list li.unread .bell-text { font-weight: 700; }
.bell-list li.problem .bell-text { color: var(--st-muammo-fg); }
.bell-text { font-size: 13.5px; line-height: 1.4; }
.bell-time { font-size: 12px; color: var(--text-muted); }
.bell-empty { padding: 24px 14px; text-align: center; color: var(--text-muted); }
/* ---------- History page ---------- */
.hist-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.hist-filters .field { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.hist-filters .field span { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.hist-filters select, .hist-filters input { height: 38px; min-width: 150px; }
.hist-table td { vertical-align: top; }
.hist-time { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.hist-table a { color: var(--text); }
.hist-table a:hover { color: var(--primary); }
.hist-pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; }
.hist-filters .field select, .hist-filters .field input { height: 38px; min-height: 38px; flex: none; }

/* Login form controls: normal height */
.login-card .field input { height: 44px; min-height: 44px; flex: none; }
.login-card .field { gap: 6px; }

/* Toasts are informational only: never block taps on buttons underneath (seen on the phone keypad). */
.toast { pointer-events: none; }

.w-help { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; font-weight: 800; color: var(--sidebar-text-strong, #fff); }
.login-help { text-align: center; margin-top: 14px; font-size: 14px; }
.login-help a { color: var(--primary); }

/* ---------- Clickable KPI tiles + drill-down banner ---------- */
a.stat-link { display: block; text-decoration: none; color: inherit; cursor: pointer; position: relative; transition: box-shadow var(--t-fast, .15s), border-color var(--t-fast, .15s), transform var(--t-fast, .15s); }
a.stat-link:hover { box-shadow: var(--shadow-2); border-color: var(--primary); transform: translateY(-1px); }
a.stat-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.stat-go { position: absolute; right: 14px; bottom: 10px; font-size: 12px; font-weight: 700; color: var(--primary); opacity: 0; transition: opacity var(--t-fast, .15s); }
a.stat-link:hover .stat-go, a.stat-link:focus-visible .stat-go { opacity: 1; }
.st-view-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 12px; border-radius: var(--r-md);
  background: var(--primary-soft, var(--surface-3)); border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent); }
.st-view-bar span { flex: 1; min-width: 200px; }
/* ---------- Worker app v2: header buttons readable in both themes, new orders, filters, sort ---------- */
/* The header is always navy (sidebar colour), so its buttons use translucent white instead of the page surface. */
.w-header .theme-toggle, .w-header .w-help { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.22); color: #fff; }
.w-header .theme-toggle:hover, .w-header .w-help:hover { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.4); }
.w-header .theme-toggle svg { stroke: currentColor; }
.w-header .btn-outline { background: transparent; border-color: rgba(255,255,255,.35); color: #fff; }
.w-header .btn-outline:hover { background: rgba(255,255,255,.12); }
.w-header .theme-toggle:focus-visible, .w-header .btn-outline:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.w-who strong { color: #fff; }
.w-who .muted { color: rgba(255,255,255,.72); }
.w-today { margin: 0 0 10px; padding: 10px 14px; border-radius: var(--r-md); background: var(--st-bajarildi-bg); color: var(--st-bajarildi-fg); font-size: 14.5px; }
.w-tab { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.w-new-count { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--st-muammo-solid); color: #fff; font-size: 12.5px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.w-new-count[hidden] { display: none; }
.w-filters { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 10px; flex-wrap: wrap; }
.w-chips { display: flex; gap: 6px; flex: 1 1 260px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.w-chips::-webkit-scrollbar { display: none; }
.w-chip { flex: none; min-height: 38px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.w-chip strong { margin-left: 4px; color: var(--text-muted); }
.w-chip.active { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.w-chip.active strong { color: inherit; }
.w-chip.late:not(.active) strong { color: var(--st-muammo-fg); }
.w-sort select { min-height: 38px; padding: 0 30px 0 12px; border-radius: var(--r-md); border: 1px solid var(--border); background-color: var(--surface); color: var(--text); font: inherit; font-size: 14px; }
.w-sort select option { background: var(--surface); color: var(--text); }
.w-new-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; padding: 8px 12px; border-radius: var(--r-md); background: var(--surface-2); color: var(--text-muted); font-size: 13.5px; }
.w-new-bar[hidden] { display: none; }
.w-new { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--st-muammo-solid); color: #fff; }
.w-sub { font-size: 13.5px; color: var(--text-muted); }
.w-progress { display: block; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.w-progress span { display: block; height: 100%; border-radius: inherit; background: var(--st-bajarildi-solid); }
.w-specs { margin: 0 0 12px; border: 1px solid var(--border); border-radius: var(--r-md); padding: 8px 12px; }
.w-specs summary { cursor: pointer; font-weight: 700; min-height: 32px; display: flex; align-items: center; }
.w-specs dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; margin: 8px 0 4px; }
.w-specs dt { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.w-specs dd { margin: 2px 0 0; font-weight: 600; word-break: break-word; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* ---------- Worker app: cards in a responsive grid instead of one long column ---------- */
.w-main { max-width: 1280px; }
.w-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 12px; align-items: stretch; }
.w-list > li { display: flex; min-width: 0; }
.w-list > li.w-empty { grid-column: 1 / -1; display: block; }
.w-card { height: 100%; justify-content: flex-start; }
.w-card .w-progress { margin-top: auto; }
.w-title { overflow-wrap: anywhere; }
/* Toolbar rows: search + tabs stay compact on wide screens; filters wrap instead of hiding chips under the sort box. */
.w-toolbar, .w-tabs, .w-today, .w-new-bar { max-width: 760px; }
.w-filters { flex-wrap: wrap; }
.w-chips { flex: 1 1 auto; flex-wrap: wrap; overflow: visible; }
.w-sort { flex: 0 0 auto; margin-left: auto; }
@media (max-width: 560px) {
  .w-chips { flex-wrap: nowrap; overflow-x: auto; width: 100%; }
  .w-sort { width: 100%; margin-left: 0; }
  .w-sort select { width: 100%; }
}
.w-toolbar, .w-tabs, .w-today, .w-new-bar { max-width: none; }

/* ---------- Tannarx page ---------- */
.tn-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.tn-tabs { display: flex; flex-wrap: wrap; gap: 4px; background: none; border: 0; padding: 0; }
.tn-tabs .orders-tab { flex: none; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); padding: 8px 12px; }
.tn-tabs .orders-tab[aria-selected="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.tn-tabs .orders-tab[aria-selected="true"] .muted { color: inherit; opacity: .8; }
.tn-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tn-filters select, .tn-filters .search-input { height: 38px; min-height: 38px; }
.tn-filters .search-input { width: 260px; max-width: 100%; }
.tn-kpis { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.stat-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
button.tn-warn-tile { text-align: left; font: inherit; color: inherit; cursor: pointer; }
.tn-dash { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tn-card .panel-header h2 { font-size: 15px; }
.tn-list { list-style: none; margin: 0; padding: 6px 16px 12px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
ol.tn-list { list-style: decimal; padding-left: 34px; }
.tn-list li { display: flex; gap: 8px; justify-content: space-between; align-items: baseline; font-variant-numeric: tabular-nums; }
ol.tn-list li { display: list-item; }
ol.tn-list li > span { float: right; margin-left: 8px; }
.tn-link { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; text-align: left; }
.tn-link:hover { text-decoration: underline; }
.tn-neg { color: var(--st-muammo-fg); font-weight: 700; }
.tn-flag { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; margin-left: 6px; border-radius: 50%; background: var(--st-pauza-solid); color: var(--st-pauza-on, #111); font-size: 12px; font-weight: 800; vertical-align: middle; }
.tn-manual { color: var(--primary); font-weight: 700; }
.tn-table-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tn-groups { display: flex; gap: 6px; flex-wrap: wrap; }
.tn-scroll { overflow: auto; max-height: 70vh; }
.tn-table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 13px; }
.tn-table th, .tn-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); white-space: nowrap; }
.tn-table thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); font-weight: 700; text-align: left; }
.tn-table thead th[data-sort] { cursor: pointer; }
.tn-table tfoot th { position: sticky; bottom: 0; background: var(--surface-2); font-weight: 800; }
.tn-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.tn-table .tn-sticky { position: sticky; left: 0; z-index: 1; background: var(--surface); }
.tn-table thead .tn-sticky, .tn-table tfoot .tn-sticky { z-index: 3; background: var(--surface-2); }
.tn-table tbody tr { cursor: pointer; }
.tn-table tbody tr:hover td { background: var(--surface-2); }
.tn-table tbody tr:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.tn-table .tn-book { max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.tn-table .tn-strong { font-weight: 700; }
.tn-drawer { width: min(640px, 100vw); }
.tn-note, .tn-warn { margin: 0; padding: 8px 12px; border-radius: var(--r-md); font-size: 13.5px; }
.tn-note { background: var(--st-tayyor-bg, var(--surface-2)); color: var(--st-tayyor-fg, var(--text)); }
.tn-warn { background: var(--st-pauza-bg); color: var(--st-pauza-fg); }
.tn-warn + .tn-warn { margin-top: 6px; }
.tn-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tn-summary div { background: var(--surface-2); border-radius: var(--r-md); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.tn-summary span { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.tn-summary strong { font-size: 19px; font-variant-numeric: tabular-nums; }
.tn-summary small { font-size: 11.5px; color: var(--text-muted); }
@media (max-width: 560px) { .tn-summary { grid-template-columns: 1fr; } }
.tn-lines { width: 100%; border-collapse: collapse; font-size: 13px; }
.tn-lines th, .tn-lines td { padding: 6px 4px; border-bottom: 1px solid var(--border); vertical-align: top; text-align: left; }
.tn-lines th { font-weight: 600; white-space: nowrap; }
.tn-lines .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 700; }
.tn-formula { color: var(--text-muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.tn-lines-total th, .tn-lines-total td { border-top: 2px solid var(--border-strong); font-weight: 800; }
.tn-ov details summary { cursor: pointer; font-weight: 600; margin: 10px 0 6px; }
.tn-ov .settings-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
/* Sozlamalar: tannarx rates editor */
.cost-paper-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.cost-paper { border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.cost-paper h4 { margin: 0; font-size: 14px; }
.cost-rates { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.cost-rates th, .cost-rates td { padding: 5px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.cost-rates thead th { background: var(--surface-2); position: sticky; top: 0; }
.cost-rates-group th { background: var(--surface-2); font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); }
.cost-rates input, .cost-rates select { width: 110px; height: 34px; min-height: 34px; padding: 0 8px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.cost-format-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.cost-format-row input { flex: 1; max-width: 420px; height: 36px; padding: 0 10px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 13px ui-monospace, Consolas, monospace; }
.cost-format-row select { height: 36px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.table-scroll { overflow-x: auto; }
.tn-kpis .stat-value { font-size: clamp(20px, 1.9vw, 28px); white-space: nowrap; }
.tn-banner:not(:empty) { margin-bottom: 12px; }
.tn-banner a { color: inherit; font-weight: 700; }

.cost-paper .field { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
.cost-paper .field input, .cost-paper .field select { width: 100%; height: 38px; }

/* Master karta: admin-only live cost estimate */
.mk-cost { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 0; padding: 12px 14px; border-radius: var(--r-md); border: 1px dashed var(--border-strong); background: var(--surface-2); }
.mk-cost > div { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; }
.mk-cost strong { font-size: 18px; font-variant-numeric: tabular-nums; }

/* ---------- Tannarx v2: plain-language helpers ---------- */
.tn-intro { padding: 16px 18px; margin-bottom: 14px; }
.tn-intro-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.tn-intro-head h2 { margin: 0; font-size: 17px; }
.tn-steps { list-style: none; counter-reset: tn; margin: 12px 0 8px; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.tn-steps li { counter-increment: tn; position: relative; padding: 12px 12px 12px 50px; border-radius: var(--r-md); background: var(--surface-2); display: flex; flex-direction: column; gap: 4px; font-size: 14px; line-height: 1.45; }
.tn-steps li::before { content: counter(tn); position: absolute; left: 12px; top: 12px; width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: var(--primary-contrast); display: flex; align-items: center; justify-content: center; font-weight: 800; }
.tn-steps strong { font-size: 15px; }
.tn-intro-foot { margin: 6px 0 0; font-size: 13.5px; }
.tn-intro-foot a { color: var(--primary); }
.tn-count { display: inline-block; min-width: 22px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: color-mix(in srgb, currentColor 14%, transparent); font-size: 12px; text-align: center; }
.stat-card.red { border-left-color: var(--st-muammo-solid); }
.tn-kpi .stat-sub { line-height: 1.35; }
.tn-info { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-left: 5px; border-radius: 50%; border: 1px solid currentColor; font-size: 10.5px; font-weight: 800; opacity: .6; cursor: help; position: relative; vertical-align: middle; text-transform: none; letter-spacing: 0; }
.tn-info:hover, .tn-info:focus { opacity: 1; outline: none; }
.tn-info[data-tip]:hover::after, .tn-info[data-tip]:focus::after { content: attr(data-tip); position: absolute; top: calc(100% + 6px); right: -10px; z-index: 20; width: 260px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--text); color: var(--bg); font-size: 12.5px; font-weight: 500; line-height: 1.4; text-align: left; white-space: normal; box-shadow: var(--shadow-3); }
.tn-table thead th { overflow: visible; }
.tn-table .tn-book { max-width: 320px; white-space: normal; }
.tn-book-name { display: block; font-weight: 600; }
.tn-book small { display: block; color: var(--text-muted); font-size: 12px; }
.tn-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 13px; align-items: center; }
.tn-legend > span { display: inline-flex; gap: 6px; align-items: center; }
.tn-legend .tn-flag { margin-left: 0; }
.tn-step { border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 14px; }
.tn-step h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; font-size: 15px; }
.tn-step p { margin: 0 0 6px; font-size: 13px; }
.tn-step-n { width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: var(--primary-contrast); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; flex: none; }
.tn-lines-group th { padding-top: 10px; font-weight: 800; }
.tn-lines-group .num { color: var(--text); }
.tn-ov-wrap > summary { cursor: pointer; font-weight: 700; padding: 8px 0; }
#tnHelp[hidden] { display: none !important; }

.tn-kpis .stat-value { font-size: clamp(19px, 1.7vw, 26px); white-space: normal; overflow-wrap: anywhere; }
.tn-kpis .stat-value small { font-size: .55em; font-weight: 600; color: var(--text-muted); }
.tn-table.tn-simple { width: 100%; }
.tn-table.tn-simple .tn-book { max-width: none; min-width: 220px; }
.tn-table.tn-simple th, .tn-table.tn-simple td { padding: 8px 9px; }

.cost-paper .field input, .cost-paper .field select { flex: none !important; height: 38px !important; min-height: 38px; max-height: 38px; padding: 0 10px; }

/* Tannarx: per-part Excel buttons */
.tn-part-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0 0 6px; font-weight: 700; font-size: 14px; }
.tn-card .panel-header { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.tn-xls { white-space: nowrap; font-size: 12.5px; }
.tn-table-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
