/* ============================================================
   سامانه برنامه‌ریزی و پایش تولید — ماهان سرام میبد
   ============================================================ */
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f2f4f8;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, #e7ecff 0%, transparent 60%), radial-gradient(900px 500px at 0% 0%, #f6efe3 0%, transparent 55%), #f2f4f8;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --surface-3: #eef1f6;
  --ink: #0e1726;
  --ink-2: #334155;
  --muted: #6b7789;
  --line: #e5e9f0;
  --line-2: #d8dee8;
  --brand: #2f6bff;
  --brand-2: #6a4dff;
  --brand-soft: #eaf0ff;
  --brand-grad: linear-gradient(135deg, #2f6bff 0%, #6a4dff 100%);
  --gold: #c39a5a;
  --gold-soft: #f7efe1;
  --navy: #0a1630;
  --navy-2: #12224a;
  --ok: #10a36e;
  --ok-soft: #e4f7ee;
  --warn: #e69515;
  --warn-soft: #fff3de;
  --bad: #e5484d;
  --bad-soft: #fdeaea;
  --info: #0ea5e9;
  --info-soft: #e2f4fd;
  --idle: #94a3b8;
  --idle-soft: #eef1f5;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -8px rgba(16, 24, 40, .10);
  --shadow-lg: 0 24px 60px -20px rgba(10, 22, 48, .35);
  --sidebar-w: 272px;
  --top-h: 72px;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0a0f1c;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, #152349 0%, transparent 60%), radial-gradient(900px 500px at 0% 0%, #1d1a14 0%, transparent 55%), #0a0f1c;
  --surface: #111a2e;
  --surface-2: #0e1628;
  --surface-3: #18233c;
  --ink: #e8edf7;
  --ink-2: #c3cddd;
  --muted: #8b98ae;
  --line: #1f2b45;
  --line-2: #2a3856;
  --brand-soft: #1a2750;
  --gold-soft: #2a2418;
  --ok-soft: #0f2c24;
  --warn-soft: #30240e;
  --bad-soft: #351619;
  --info-soft: #0e2737;
  --idle-soft: #1b2438;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -10px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
svg { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Vazirmatn", Tahoma, sans-serif;
  font-feature-settings: "ss01";
  background: var(--bg-grad);
  background-attachment: fixed;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
::selection { background: #2f6bff33; }
.num, .ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.bold { font-weight: 700; }
.hidden { display: none !important; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.gap-lg { gap: 18px; }
.mt { margin-top: 18px; }
.mt-s { margin-top: 10px; }

/* ---------- scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }

/* ---------- boot ---------- */
.boot { height: 100vh; display: grid; place-content: center; justify-items: center; gap: 18px; }
.boot-logo { width: 64px; height: 64px; background: url(../img/logo.svg) center/contain no-repeat; animation: pulse 1.4s ease-in-out infinite; }
.boot-text { color: var(--muted); }
@keyframes pulse { 50% { transform: scale(.92); opacity: .7; } }

/* ============================ LAYOUT ============================ */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background:
    linear-gradient(180deg, rgba(10, 22, 48, .0) 0%, rgba(10, 22, 48, .6) 100%),
    repeating-linear-gradient(45deg, rgba(255,255,255,.018) 0 1px, transparent 1px 22px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,.018) 0 1px, transparent 1px 22px),
    linear-gradient(180deg, #0c1a3a 0%, #081227 100%);
  color: #d5def0;
  display: flex; flex-direction: column;
  z-index: 40;
  border-left: 1px solid rgba(255,255,255,.04);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 22px 18px; }
.brand-logo { width: 44px; height: 44px; background: url(../img/logo.svg) center/contain no-repeat; flex: none; filter: drop-shadow(0 6px 14px rgba(47,107,255,.45)); }
.brand-name { font-weight: 800; font-size: 16px; color: #fff; letter-spacing: -.2px; }
.brand-sub { font-size: 11px; color: #8ea0c4; letter-spacing: .3px; direction: ltr; text-align: right; }
.nav { padding: 8px 14px; overflow-y: auto; flex: 1; }
.nav-label { font-size: 11px; color: #6f81a8; padding: 14px 12px 6px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin: 2px 0;
  border-radius: 12px; color: #c7d2ea; font-weight: 500;
  transition: background .15s, color .15s;
  position: relative;
}
.nav a svg { width: 20px; height: 20px; opacity: .85; flex: none; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active {
  background: linear-gradient(135deg, rgba(47,107,255,.95), rgba(106,77,255,.9));
  color: #fff; box-shadow: 0 10px 24px -10px rgba(47,107,255,.8);
}
.nav a.active::before { content: ""; position: absolute; right: -14px; top: 10px; bottom: 10px; width: 4px; border-radius: 4px 0 0 4px; background: var(--gold); }
.nav .badge-count { margin-right: auto; background: var(--gold); color: #1b1408; font-size: 11px; font-weight: 800; min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-content: center; padding: 0 6px; }
.side-foot { padding: 16px; margin: 12px; border-radius: 16px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06); }
.side-foot .t { color: #fff; font-weight: 700; font-size: 13px; }
.side-foot .s { color: #8ea0c4; font-size: 11.5px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--top-h);
  display: flex; align-items: center; gap: 14px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 800; letter-spacing: -.3px; }
.topbar .crumb { font-size: 12px; color: var(--muted); margin-top: -2px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-content: center;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; position: relative;
  transition: all .15s; color: var(--ink-2);
}
.icon-btn:hover { border-color: var(--line-2); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn .dot { position: absolute; top: 8px; left: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--bad); border: 2px solid var(--surface); }
.today-chip { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; font-size: 13px; }
.today-chip svg { width: 18px; height: 18px; color: var(--brand); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 5px 6px 5px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); cursor: pointer; position: relative; }
.avatar { width: 34px; height: 34px; border-radius: 10px; background: var(--brand-grad); color: #fff; display: grid; place-content: center; font-weight: 800; font-size: 14px; flex: none; }
.user-chip .n { font-weight: 700; font-size: 13px; line-height: 1.3; }
.user-chip .r { font-size: 11px; color: var(--muted); line-height: 1.3; }
.menu {
  position: absolute; top: calc(100% + 8px); left: 0; min-width: 220px; z-index: 60;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
  padding: 6px; animation: pop .14s ease-out;
}
.menu button { display: flex; width: 100%; gap: 10px; align-items: center; padding: 9px 12px; border: 0; background: none; border-radius: 10px; cursor: pointer; text-align: right; }
.menu button:hover { background: var(--surface-3); }
.menu button svg { width: 18px; height: 18px; color: var(--muted); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

.content { padding: 26px 28px 60px; max-width: 1680px; width: 100%; margin: 0 auto; }
.page-enter { animation: enter .28s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } }

.burger { display: none; }

/* ============================ CARDS ============================ */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 12px; padding: 18px 20px 0; }
.card-h h3 { margin: 0; font-size: 15px; font-weight: 800; letter-spacing: -.2px; }
.card-h .sub { font-size: 12px; color: var(--muted); }
.card-b { padding: 18px 20px 20px; }
.card-ico { width: 36px; height: 36px; border-radius: 11px; display: grid; place-content: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.card-ico svg { width: 19px; height: 19px; }

.grid { display: grid; gap: 18px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-kpi { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 22px; padding: 26px 28px;
  background:
    radial-gradient(600px 260px at 12% 0%, rgba(195,154,90,.35), transparent 60%),
    radial-gradient(500px 300px at 90% 120%, rgba(106,77,255,.55), transparent 60%),
    linear-gradient(135deg, #0c1a3a 0%, #13275a 55%, #1b2f72 100%);
  color: #fff; box-shadow: var(--shadow-lg);
}
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.05) 0 1px, transparent 1px 64px),
    repeating-linear-gradient(0deg, rgba(255,255,255,.05) 0 1px, transparent 1px 64px);
  mask-image: linear-gradient(270deg, #000 0%, transparent 55%);
  -webkit-mask-image: linear-gradient(270deg, #000 0%, transparent 55%);
}
.hero > * { position: relative; z-index: 1; }
.hero .eyebrow { font-size: 12px; color: #c9d5f2; display: flex; gap: 8px; align-items: center; }
.hero h2 { margin: 6px 0 4px; font-size: 26px; font-weight: 900; letter-spacing: -.5px; }
.hero .meta { color: #b9c6e6; font-size: 13px; display: flex; gap: 16px; flex-wrap: wrap; }
.hero .meta b { color: #fff; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero .btn-glass { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); color: #fff; }
.hero .btn-glass:hover { background: rgba(255,255,255,.18); }
.hero .btn-gold { background: linear-gradient(135deg, #f0d7a6, #c39a5a); color: #1d1405; border: 0; }
.hero-progress { margin-top: 22px; display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: end; }
.bar-xl { height: 12px; border-radius: 8px; background: rgba(255,255,255,.12); overflow: hidden; position: relative; }
.bar-xl i { display: block; height: 100%; border-radius: 8px; background: linear-gradient(90deg, #f0d7a6, #c39a5a); box-shadow: 0 0 20px rgba(240,215,166,.6); transition: width .8s cubic-bezier(.2,.8,.2,1); }
.bar-xl .pace { position: absolute; top: -4px; bottom: -4px; width: 2px; background: #fff; border-radius: 2px; box-shadow: 0 0 0 3px rgba(255,255,255,.18); }
.hero .big { font-size: 44px; font-weight: 900; line-height: 1; letter-spacing: -1px; }
.hero .big small { font-size: 18px; color: #c9d5f2; font-weight: 600; }

/* ---------- KPI ---------- */
.kpi { padding: 18px 18px 16px; position: relative; overflow: hidden; }
.kpi .top { display: flex; align-items: center; justify-content: space-between; }
.kpi .lbl { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi .val { font-size: 26px; font-weight: 900; letter-spacing: -.6px; margin-top: 8px; line-height: 1.2; }
.kpi .val small { font-size: 13px; color: var(--muted); font-weight: 600; margin-right: 4px; }
.kpi .foot { margin-top: 8px; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.kpi .ico { width: 42px; height: 42px; border-radius: 13px; display: grid; place-content: center; }
.kpi .ico svg { width: 21px; height: 21px; }
.kpi::after { content: ""; position: absolute; left: -30px; bottom: -40px; width: 120px; height: 120px; border-radius: 50%; background: currentColor; opacity: .04; }
.tone-blue .ico { background: var(--brand-soft); color: var(--brand); }
.tone-green .ico { background: var(--ok-soft); color: var(--ok); }
.tone-amber .ico { background: var(--warn-soft); color: var(--warn); }
.tone-red .ico { background: var(--bad-soft); color: var(--bad); }
.tone-violet .ico { background: #f0ebff; color: #7c5cff; }
html[data-theme="dark"] .tone-violet .ico { background: #231c44; }
.tone-gold .ico { background: var(--gold-soft); color: var(--gold); }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.idle { background: var(--idle-soft); color: var(--muted); }
.pill.brand { background: var(--brand-soft); color: var(--brand); }
.pill.gold { background: var(--gold-soft); color: #9a7638; }
.pill svg { width: 13px; height: 13px; }

/* ---------- Line cards ---------- */
.line-card { padding: 18px; display: flex; flex-direction: column; gap: 14px; position: relative; overflow: hidden; }
.line-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--lc); }
.line-card .lh { display: flex; align-items: center; gap: 12px; }
.line-card .ln { font-weight: 800; font-size: 15px; }
.line-card .ls { font-size: 12px; color: var(--muted); }
.ring { --p: 0; --c: var(--brand); width: 76px; height: 76px; border-radius: 50%; flex: none; display: grid; place-content: center;
  background: radial-gradient(closest-side, var(--surface) 76%, transparent 77% 100%), conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-3) 0); }
.ring b { font-size: 16px; font-weight: 900; }
.line-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.line-stats div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.line-stats span { display: block; font-size: 11px; color: var(--muted); }
.line-stats b { font-size: 14px; font-weight: 800; }
.now-prod { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: var(--surface-2); border: 1px dashed var(--line-2); }
.now-prod .t { font-size: 11px; color: var(--muted); }
.now-prod .n { font-weight: 700; font-size: 13px; }
.live { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(16,163,110,.6); animation: live 1.8s infinite; flex: none; }
@keyframes live { 70% { box-shadow: 0 0 0 8px rgba(16,163,110,0); } 100% { box-shadow: 0 0 0 0 rgba(16,163,110,0); } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); font-weight: 700; font-size: 13px; cursor: pointer;
  transition: transform .12s, box-shadow .15s, background .15s, border-color .15s; white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:hover { border-color: var(--muted); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand-grad); color: #fff; border: 0; box-shadow: 0 10px 22px -10px rgba(47,107,255,.8); }
.btn.primary:hover { box-shadow: 0 14px 28px -10px rgba(47,107,255,.9); filter: brightness(1.05); }
.btn.success { background: linear-gradient(135deg, #14b67c, #0e9365); color: #fff; border: 0; }
.btn.danger { background: var(--bad); color: #fff; border: 0; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.soft { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.btn.sm { height: 32px; padding: 0 11px; font-size: 12px; border-radius: 10px; }
.btn.icon { width: 34px; height: 34px; padding: 0; border-radius: 10px; }
.btn.icon svg { width: 17px; height: 17px; }
.btn-group { display: inline-flex; border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; background: var(--surface); }
.btn-group .btn { border: 0; border-radius: 0; }
.btn-group .btn + .btn { border-right: 1px solid var(--line); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.field .hint { font-size: 11.5px; color: var(--muted); }
.input, select.input, textarea.input {
  height: 42px; padding: 0 13px; border: 1px solid var(--line-2); background: var(--surface); border-radius: 12px; width: 100%;
  transition: border-color .15s, box-shadow .15s; outline: none;
}
textarea.input { height: auto; min-height: 80px; padding: 10px 13px; resize: vertical; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(47,107,255,.14); }
.input.sm { height: 34px; border-radius: 10px; font-size: 13px; }
.input.num-in { direction: ltr; text-align: right; font-weight: 700; }
select.input { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7789' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 10px center; background-size: 16px; padding-left: 34px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.search { position: relative; }
.search svg { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search .input { padding-right: 38px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-weight: 600; font-size: 13px; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line-2); border-radius: 20px; transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { right: 21px; }

/* ---------- Toolbar & tabs ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-3); border: 1px solid var(--line); }
.tabs button { border: 0; background: transparent; padding: 8px 16px; border-radius: 10px; cursor: pointer; font-weight: 700; font-size: 13px; color: var(--muted); display: inline-flex; gap: 8px; align-items: center; }
.tabs button svg { width: 17px; height: 17px; }
.tabs button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-2); background: var(--surface); padding: 6px 13px; border-radius: 20px; font-size: 12.5px; font-weight: 700; cursor: pointer; display: inline-flex; gap: 7px; align-items: center; color: var(--ink-2); }
.chip .cd { width: 9px; height: 9px; border-radius: 50%; }
.chip.active { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.month-nav { display: inline-flex; align-items: center; background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px; height: 40px; }
.month-nav button { border: 0; background: none; width: 38px; height: 38px; cursor: pointer; display: grid; place-content: center; color: var(--muted); }
.month-nav button:hover { color: var(--ink); }
.month-nav button svg { width: 18px; height: 18px; }
.month-nav span { min-width: 112px; text-align: center; font-weight: 800; font-size: 13.5px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.t th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-weight: 700; font-size: 12px; text-align: right; padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; z-index: 1; }
.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tbody tr { transition: background .12s; }
.t tbody tr:hover { background: var(--surface-2); }
.t tbody tr:last-child td { border-bottom: 0; }
.t .c { text-align: center; }
.t .n { direction: ltr; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t tfoot td { background: var(--surface-2); font-weight: 800; padding: 12px; border-top: 1px solid var(--line); }
.t .idx { width: 44px; color: var(--muted); font-weight: 700; text-align: center; }
.t .actions { white-space: nowrap; text-align: left; }
.t .actions .btn { opacity: .55; }
.t tr:hover .actions .btn { opacity: 1; }
.t tr.done td:not(.actions) { }
.t tr.clickable { cursor: pointer; }
.design-cell { display: flex; align-items: center; gap: 10px; min-width: 170px; }
.design-cell .dn { font-weight: 700; line-height: 1.3; }
.design-cell .dc { font-size: 11px; color: var(--muted); direction: ltr; text-align: right; }
.progress { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.progress .bar { flex: 1; height: 7px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; border-radius: 6px; transition: width .6s; }
.progress b { font-size: 12px; min-width: 38px; text-align: left; direction: ltr; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 54px; height: 54px; opacity: .35; margin-bottom: 8px; }
.empty h4 { margin: 4px 0; color: var(--ink); font-size: 16px; }

/* ---------- Swatches ---------- */
.sw { width: 40px; height: 40px; border-radius: 10px; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.08); overflow: hidden; position: relative; }
.sw img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sw.lg { width: 100%; height: 150px; border-radius: 14px 14px 0 0; box-shadow: none; }
.sw.md { width: 64px; height: 64px; border-radius: 14px; }
.sw::after { content: ""; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(255,255,255,.35) 0%, transparent 40%, transparent 70%, rgba(0,0,0,.06) 100%); pointer-events: none; }

/* ---------- Plan line section ---------- */
.line-sec { margin-top: 18px; overflow: hidden; }
.line-sec-h { display: flex; align-items: center; gap: 14px; padding: 16px 20px; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--lc) 7%, transparent)); flex-wrap: wrap; }
.line-badge { width: 40px; height: 40px; border-radius: 12px; display: grid; place-content: center; color: #fff; font-weight: 900; background: var(--lc); box-shadow: 0 8px 18px -8px var(--lc); }
.line-sec-h .tt { font-weight: 800; font-size: 15px; }
.line-sec-h .st { font-size: 12px; color: var(--muted); }
.line-sec-h .stats { display: flex; gap: 22px; margin-right: auto; align-items: center; flex-wrap: wrap; }
.line-sec-h .stats div span { display: block; font-size: 11px; color: var(--muted); }
.line-sec-h .stats div b { font-size: 15px; font-weight: 900; }
.collapse-btn svg { transition: transform .2s; }
.line-sec.collapsed .collapse-btn svg { transform: rotate(90deg); }
.line-sec.collapsed .table-wrap, .line-sec.collapsed .line-foot { display: none; }
.line-foot { padding: 10px 20px; display: flex; justify-content: space-between; align-items: center; background: var(--surface-2); border-top: 1px solid var(--line); }

.lock-banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 14px; background: var(--warn-soft); color: #8a5a06; border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); font-weight: 600; font-size: 13px; }
html[data-theme="dark"] .lock-banner { color: #f3c776; }
.lock-banner svg { width: 20px; height: 20px; flex: none; }
.lock-banner.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.lock-banner.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.lock-banner.info { background: var(--info-soft); color: #0b7bb0; border-color: color-mix(in srgb, var(--info) 30%, transparent); }

/* ---------- Timeline (gantt-like) ---------- */
.tl { overflow-x: auto; }
.tl table { border-collapse: separate; border-spacing: 2px; font-size: 11.5px; }
.tl th { font-weight: 700; color: var(--muted); padding: 4px 0; min-width: 24px; text-align: center; }
.tl th.fri { color: var(--bad); }
.tl td.nm { white-space: nowrap; padding: 2px 10px; font-weight: 700; position: sticky; right: 0; background: var(--surface); z-index: 1; min-width: 170px; }
.tl td.cell { width: 24px; height: 26px; border-radius: 6px; background: var(--surface-3); }
.tl td.cell.on { background: var(--lc); }
.tl td.today { outline: 2px solid var(--gold); outline-offset: -1px; }
.tl .tl-line { padding: 14px 6px 6px; font-weight: 900; display: flex; align-items: center; gap: 8px; }

/* ---------- Approvals / signatures ---------- */
.sign-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.sign { border: 1px solid var(--line); border-radius: 16px; padding: 14px; background: var(--surface-2); position: relative; overflow: hidden; }
.sign .role { font-weight: 800; font-size: 13.5px; }
.sign .who { font-size: 12px; color: var(--muted); }
.sign .state { margin-top: 10px; display: flex; align-items: center; gap: 8px; }
.sign.approved { border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-soft); }
.sign.rejected { border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: var(--bad-soft); }
.sign.mine { box-shadow: 0 0 0 2px var(--brand); }
.sign .stamp { position: absolute; left: 10px; top: 10px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-content: center; }
.sign.approved .stamp { background: var(--ok); color: #fff; }
.sign.rejected .stamp { background: var(--bad); color: #fff; }
.sign .stamp svg { width: 18px; height: 18px; }
.sign .cm { font-size: 12px; margin-top: 6px; color: var(--ink-2); }

/* ---------- Activity feed ---------- */
.feed { display: flex; flex-direction: column; }
.feed .it { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.feed .it:last-child { border-bottom: 0; }
.feed .ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-content: center; background: var(--surface-3); color: var(--muted); flex: none; }
.feed .ic svg { width: 16px; height: 16px; }
.feed .tx { font-size: 12.5px; line-height: 1.6; }
.feed .tm { font-size: 11px; color: var(--muted); }

/* ---------- Design catalog ---------- */
.design-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.dcard { overflow: hidden; display: flex; flex-direction: column; transition: transform .18s, box-shadow .18s; cursor: pointer; }
.dcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.dcard .body { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.dcard .nm { font-weight: 800; font-size: 15px; }
.dcard .cd { font-size: 11.5px; color: var(--muted); direction: ltr; text-align: right; }
.dcard .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.dcard .st { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; }
.dcard .st b { color: var(--ink); }
.dcard.inactive { opacity: .55; }
.pattern-pick { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.pattern-pick button { border: 2px solid transparent; border-radius: 12px; padding: 0; background: none; cursor: pointer; }
.pattern-pick button.active { border-color: var(--brand); }
.pattern-pick .sw { width: 100%; height: 48px; }

/* ---------- Modal & drawer ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8, 14, 30, .5); backdrop-filter: blur(4px); z-index: 100; display: grid; place-items: center; padding: 20px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-lg); width: min(640px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; animation: pop .18s ease-out; border: 1px solid var(--line); }
.modal.wide { width: min(980px, 100%); }
.modal.narrow { width: min(440px, 100%); }
.modal-h { display: flex; align-items: center; gap: 12px; padding: 20px 22px 14px; border-bottom: 1px solid var(--line); }
.modal-h h3 { margin: 0; font-size: 17px; font-weight: 800; flex: 1; }
.modal-b { padding: 20px 22px; overflow-y: auto; }
.modal-f { display: flex; gap: 10px; justify-content: flex-start; padding: 14px 22px 18px; border-top: 1px solid var(--line); }
.drawer-ov { place-items: stretch start; padding: 0; }
.drawer { width: min(560px, 100vw); height: 100vh; background: var(--surface); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .22s ease-out; }
@keyframes slide { from { transform: translateX(-30px); opacity: 0; } }

/* ---------- Toasts ---------- */
#toasts { position: fixed; bottom: 22px; left: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { display: flex; align-items: center; gap: 12px; min-width: 280px; max-width: 420px; padding: 13px 16px; border-radius: 14px; background: var(--navy); color: #fff; box-shadow: var(--shadow-lg); animation: toastIn .25s ease-out; font-weight: 600; font-size: 13px; }
.toast svg { width: 20px; height: 20px; flex: none; }
.toast.ok svg { color: #4ade80; }
.toast.err svg { color: #fb7185; }
.toast.out { animation: toastOut .25s ease-in forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px); } }

/* ---------- Datepicker ---------- */
.dp { position: absolute; z-index: 150; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 12px; width: 280px; animation: pop .14s; }
.dp-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-weight: 800; }
.dp-h button { border: 0; background: var(--surface-3); width: 30px; height: 30px; border-radius: 8px; cursor: pointer; }
.dp-g { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; }
.dp-g .w { font-size: 11px; color: var(--muted); font-weight: 700; padding: 4px 0; }
.dp-g button { border: 0; background: none; height: 32px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.dp-g button:hover { background: var(--surface-3); }
.dp-g button.sel { background: var(--brand); color: #fff; }
.dp-g button.today { box-shadow: inset 0 0 0 1.5px var(--gold); }
.dp-g button.fri { color: var(--bad); }
.dp-f { display: flex; justify-content: space-between; margin-top: 8px; }

/* ---------- Entry form ---------- */
.entry-line { display: grid; grid-template-columns: 170px minmax(0, 1.6fr) 150px minmax(0, 1fr); gap: 12px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.entry-line:last-child { border-bottom: 0; }
.entry-line .lname { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.entry-line .lname .line-badge { width: 34px; height: 34px; border-radius: 10px; font-size: 13px; }
.entry-line .rem { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(420px, .9fr); }
.auth-art {
  position: relative; overflow: hidden; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(700px 400px at 20% 10%, rgba(195,154,90,.35), transparent 60%),
    radial-gradient(600px 500px at 90% 100%, rgba(106,77,255,.55), transparent 60%),
    linear-gradient(145deg, #081227 0%, #102454 60%, #182f74 100%);
}
.tiles { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(6, 1fr); grid-auto-rows: 1fr; gap: 10px; padding: 10px; transform: rotate(-8deg) scale(1.3); opacity: .16; }
.tiles i { border-radius: 10px; background: linear-gradient(135deg, rgba(255,255,255,.5), rgba(255,255,255,.05)); }
.auth-art > * { position: relative; }
.auth-art h1 { font-size: 40px; font-weight: 900; line-height: 1.35; margin: 0; letter-spacing: -1px; }
.auth-art p { color: #c3cfee; max-width: 520px; font-size: 15px; }
.auth-feats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-width: 560px; }
.auth-feats div { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 14px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); font-weight: 600; font-size: 13px; backdrop-filter: blur(6px); }
.auth-feats svg { width: 20px; height: 20px; color: #f0d7a6; flex: none; }
.auth-form { display: grid; place-items: center; padding: 40px; background: var(--surface); }
.auth-box { width: min(400px, 100%); }
.auth-box h2 { font-size: 26px; font-weight: 900; margin: 18px 0 4px; letter-spacing: -.5px; }
.auth-box .field { margin-top: 16px; }
.auth-box .btn { width: 100%; height: 48px; margin-top: 22px; font-size: 15px; }
.err-box { margin-top: 14px; padding: 10px 14px; border-radius: 12px; background: var(--bad-soft); color: var(--bad); font-weight: 600; font-size: 13px; }
.checks { margin-top: 14px; display: grid; gap: 6px; font-size: 12.5px; }
.checks div { display: flex; gap: 8px; align-items: center; }
.checks svg { width: 16px; height: 16px; }

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 290px; }
.chart-box.sm { height: 220px; }
.legend { display: flex; flex-direction: column; gap: 10px; }
.legend .li { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.legend .li i { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.legend .li b { margin-right: auto; font-weight: 800; }
.donut-wrap { display: grid; grid-template-columns: 170px 1fr; gap: 18px; align-items: center; }
.donut-wrap .chart-box { height: 170px; width: 170px; max-width: 100%; }
.center-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.center-label b { font-size: 22px; font-weight: 900; }
.center-label span { font-size: 11px; color: var(--muted); }

/* ---------- Print sheet ---------- */
.print-page { background: #fff; color: #000; max-width: 1100px; margin: 0 auto; padding: 24px; font-size: 11px; }
.print-tools { display: flex; gap: 10px; justify-content: center; padding: 16px; }
.ps-head { display: grid; grid-template-columns: 1fr 2fr 1fr; align-items: center; border: 1.5px solid #000; border-bottom: 0; }
.ps-head > div { padding: 8px 12px; }
.ps-head .ttl { text-align: center; font-size: 16px; font-weight: 900; border-right: 1px solid #000; border-left: 1px solid #000; }
.ps-head .lg { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.ps-head .lg img { width: 34px; height: 34px; }
.ps-grid { display: grid; grid-template-columns: 1fr 1fr; border: 1.5px solid #000; }
.ps-grid > div { border-bottom: 1px solid #000; }
.ps-grid > div:nth-child(odd) { border-left: 1px solid #000; }
.ps-grid h4 { margin: 0; text-align: center; padding: 4px; background: #eee; border-bottom: 1px solid #000; font-size: 12px; }
.ps-grid table { width: 100%; border-collapse: collapse; }
.ps-grid th, .ps-grid td { border: 1px solid #999; padding: 2px 4px; text-align: center; font-size: 10.5px; }
.ps-grid th { background: #f3f3f3; }
.ps-grid td.nm { text-align: right; font-weight: 700; }
.ps-grid tfoot td { font-weight: 900; background: #f3f3f3; }
.ps-sign { display: grid; grid-template-columns: repeat(7, 1fr); border: 1.5px solid #000; border-top: 0; }
.ps-sign div { border-left: 1px solid #000; padding: 6px; min-height: 70px; text-align: center; font-size: 10.5px; }
.ps-sign div:last-child { border-left: 0; }
.ps-sign b { display: block; margin-bottom: 4px; }
.ps-sign .ok { color: #0a7a50; font-weight: 800; }
.ps-foot { display: flex; justify-content: space-between; margin-top: 6px; font-size: 10px; color: #444; }

@media print {
  @page { size: A4 portrait; margin: 8mm; }
  body { background: #fff !important; }
  .print-tools, #toasts { display: none !important; }
  .print-page { padding: 0; max-width: none; }
}

/* ============================ RESPONSIVE ============================ */
@media (max-width: 1400px) {
  .g-kpi { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; right: 0; top: 0; width: var(--sidebar-w); transform: translateX(100%); transition: transform .25s; }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .shell.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
  .burger { display: grid; }
  .g-main, .g-3, .g-2 { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .entry-line { grid-template-columns: 1fr 1fr; }
  .today-chip { display: none; }
}
@media (max-width: 680px) {
  .content { padding: 16px 14px 40px; }
  .topbar { padding: 0 14px; }
  .g-kpi, .g-4 { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .user-chip .n, .user-chip .r { display: none; }
  .hero h2 { font-size: 21px; }
  .entry-line { grid-template-columns: 1fr; }
  .donut-wrap { grid-template-columns: 1fr; }
  .topbar .crumb, #fs { display: none; }
  .topbar h1 { font-size: 15px; white-space: nowrap; }
  .topbar { gap: 8px; }
  .icon-btn { width: 38px; height: 38px; }
}
