/* Licence panel. One font file, bundled: no network font requests. */
@font-face {
  font-family: 'Vazir';
  src: url('/fonts/vazir.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --brand: #4f46e5;
  --brand-2: #6366f1;
  --brand-soft: #eef2ff;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --bad: #dc2626;
  --bad-soft: #fef2f2;
  --side: #0b1220;
  --side-2: #111a2e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Vazir', Tahoma, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
[hidden] { display: none !important; }

#app { height: 100%; }
.boot { display: grid; place-items: center; }
.boot-mark { font-weight: 800; color: var(--muted); letter-spacing: .5px; }

/* ---------- buttons, fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--card); font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .08s;
}
.btn:hover { border-color: #94a3b8; background: #f8fafc; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); border-color: transparent; color: #fff; box-shadow: 0 6px 16px rgba(79, 70, 229, .28); }
.btn.primary:hover { filter: brightness(1.05); background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.btn.danger { color: var(--bad); border-color: #fecaca; background: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.field > small { font-size: 11.5px; color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 60px; padding: 9px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 4px rgba(99, 102, 241, .14); }
input[dir=ltr], textarea[dir=ltr] { direction: ltr; text-align: left; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; }

/* ---------- login ---------- */
.auth {
  width: 100%; height: 100%; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(99, 102, 241, .22), transparent 60%),
    radial-gradient(800px 500px at 95% 110%, rgba(16, 185, 129, .14), transparent 60%),
    linear-gradient(160deg, #0b1220, #111a2e);
}
.auth-card { width: 420px; max-width: 100%; background: #fff; border-radius: 20px; padding: 34px 32px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
.auth-logo { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 20px;
  background: linear-gradient(135deg, var(--brand), #22c55e); margin-bottom: 16px; }
.auth-card h1 { font-size: 20px; font-weight: 800; }
.auth-card .sub { color: var(--muted); font-size: 13px; margin: 4px 0 22px; }
.auth-card form { display: grid; gap: 14px; }
.notice { border-radius: 10px; padding: 10px 12px; font-size: 13px; border: 1px solid; }
.notice.bad { background: var(--bad-soft); color: #991b1b; border-color: #fecaca; }
.notice.ok { background: var(--ok-soft); color: #065f46; border-color: #a7f3d0; }
.notice.warn { background: var(--warn-soft); color: #92400e; border-color: #fde68a; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); height: 100%; }
.side {
  background: linear-gradient(180deg, var(--side), var(--side-2)); color: #cbd5e1;
  display: flex; flex-direction: column; padding: 20px 14px; gap: 22px; min-height: 0;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 800;
  background: linear-gradient(135deg, var(--brand), #22c55e); box-shadow: 0 8px 20px rgba(34, 197, 94, .25); }
.brand-t { color: #fff; font-weight: 800; font-size: 15px; }
.brand-s { font-size: 11.5px; color: #64748b; }
.nav-h { font-size: 11px; color: #64748b; padding: 0 10px 4px; font-weight: 700; letter-spacing: .3px; }
.nav { display: grid; gap: 4px; }
.nav button {
  display: flex; align-items: center; gap: 12px; width: 100%; height: 42px; padding: 0 12px; border-radius: 11px;
  background: transparent; border: 1px solid transparent; color: #cbd5e1; cursor: pointer; text-align: start; font-weight: 700;
}
.nav button:hover { background: rgba(148, 163, 184, .08); color: #fff; }
.nav button.on { background: rgba(99, 102, 241, .18); border-color: rgba(99, 102, 241, .4); color: #fff; }
.nav .ico { width: 18px; height: 18px; flex: none; opacity: .9; }
.side-foot { margin-top: auto; display: grid; gap: 10px; }
.me { background: rgba(148, 163, 184, .08); border: 1px solid rgba(148, 163, 184, .12); border-radius: 12px; padding: 12px; }
.me b { color: #fff; font-size: 13.5px; display: block; }
.me small { color: #94a3b8; font-size: 11.5px; }
.me-actions { display: flex; gap: 6px; margin-top: 10px; }
.me-actions .btn { flex: 1; height: 30px; font-size: 12.5px; background: transparent; color: #cbd5e1; border-color: rgba(148, 163, 184, .25); }
.me-actions .btn:hover { background: rgba(148, 163, 184, .1); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top { display: flex; align-items: center; gap: 14px; padding: 18px 26px 14px; flex: none; }
.top h1 { font-size: 19px; font-weight: 800; }
.top p { color: var(--muted); font-size: 12.5px; }
.top .grow { flex: 1; }
.pill { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: var(--ok-soft); color: var(--ok); border: 1px solid #a7f3d0; }
.content { flex: 1; min-height: 0; padding: 0 26px 22px; display: flex; flex-direction: column; gap: 14px; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: center; gap: 10px; padding: 11px 18px; border-bottom: 1px solid var(--line); }
.card-h h2 { font-size: 14.5px; font-weight: 800; }
.card-h .grow { flex: 1; }
.card-b { padding: 12px 18px; }
.muted { color: var(--muted); }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 12px; }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }

/* ---------- build mode ---------- */
.build { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 14px; min-height: 0; flex: 1; }
.build-form { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow: auto; padding-inline-end: 2px; }
.products { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.prod {
  text-align: start; padding: 11px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .08s; display: grid; gap: 4px;
}
.prod:hover { border-color: #a5b4fc; }
.prod:active { transform: translateY(1px); }
.prod.on { border-color: var(--brand-2); box-shadow: 0 0 0 4px rgba(99, 102, 241, .14); }
.prod .dot { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 13px; }
.prod b { font-size: 14.5px; }
.prod small { color: var(--muted); font-size: 12px; }
.section-t { font-size: 12.5px; font-weight: 800; color: var(--ink-2); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.section-t::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.feat { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 14px; }
.feat .check { font-size: 13px; }
.form-foot { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); background: #fbfcfe; border-radius: 0 0 var(--radius) var(--radius); }
.form-foot .grow { flex: 1; }

.result { position: sticky; top: 0; align-self: start; }
.result-empty { text-align: center; padding: 40px 18px; color: var(--muted); display: grid; gap: 10px; place-items: center; }
.result-empty .big { width: 56px; height: 56px; border-radius: 16px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: 22px; }
.out { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px; direction: ltr; text-align: left; background: #0f172a; color: #e2e8f0;
  border-radius: 12px; padding: 12px; max-height: 300px; overflow: auto; white-space: pre-wrap; word-break: break-all; }
.kv { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 7px 12px; font-size: 13px; margin: 12px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 99px; border: 1px solid; white-space: nowrap; }
.badge.active { background: var(--ok-soft); color: var(--ok); border-color: #a7f3d0; }
.badge.expired { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.badge.revoked { background: var(--bad-soft); color: var(--bad); border-color: #fecaca; }
.badge.replaced { background: #f1f5f9; color: var(--muted); border-color: var(--line-2); }
.badge.erp { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.badge.fic { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.badge.nm { background: #fffbeb; color: #b45309; border-color: #fde68a; }

/* ---------- reports ---------- */
.reports { display: flex; flex-direction: column; gap: 14px; min-height: 0; flex: 1; }
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: #e9edf5; border-radius: 12px; width: fit-content; flex-wrap: wrap; }
.tabs button { height: 34px; padding: 0 14px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; }
.tabs button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(15, 23, 42, .1); }
.filters { display: grid; grid-template-columns: 150px 150px minmax(200px, 1fr) 150px 150px auto; gap: 10px; align-items: end; padding: 14px 16px; }
.table-wrap { flex: 1; min-height: 0; overflow: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
th { position: sticky; top: 0; z-index: 1; background: #f8fafc; color: var(--muted); font-weight: 700; text-align: start; font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid #eef2f7; vertical-align: middle; }
tbody tr { cursor: pointer; transition: background .12s; }
tbody tr:hover { background: #f8fafc; }
td.num { font-variant-numeric: tabular-nums; direction: ltr; text-align: start; }
td.strong { font-weight: 800; }
.empty { text-align: center; color: var(--muted); padding: 40px 12px; }
.pager { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.pager .grow { flex: 1; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.stat { padding: 16px 18px; }
.stat .k { font-size: 12.5px; color: var(--muted); font-weight: 700; }
.stat .v { font-size: 28px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat .bar { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

/* drawer */
.scrim { position: fixed; inset: 0; background: rgba(15, 23, 42, .32); backdrop-filter: blur(2px); z-index: 40; }
.drawer { position: fixed; top: 0; bottom: 0; inset-inline-end: 0; width: min(560px, 100%); background: #fff; z-index: 41; box-shadow: -20px 0 60px rgba(15, 23, 42, .25);
  display: flex; flex-direction: column; animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(-20px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-h { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-h h2 { font-size: 16px; font-weight: 800; }
.drawer-b { flex: 1; min-height: 0; overflow: auto; padding: 18px 20px; display: grid; gap: 16px; align-content: start; }
.drawer-f { display: flex; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.drawer-f .grow { flex: 1; }

/* toasts */
.toasts { position: fixed; bottom: 18px; inset-inline-start: 18px; z-index: 60; display: grid; gap: 8px; }
.toast { background: #0f172a; color: #fff; padding: 11px 16px; border-radius: 11px; font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); max-width: 420px; animation: slide .18s ease-out; }
.toast.bad { background: #991b1b; }
.toast.ok { background: #065f46; }

.progress { height: 8px; background: #e2e8f0; border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #22c55e); width: 0; transition: width .2s; }

@media (max-width: 900px) {
  .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .build { grid-template-columns: 1fr; }
  .result { position: static; }
  .filters { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  body { overflow: auto; }
  .shell { grid-template-columns: 1fr; height: auto; }
  .side { flex-direction: row; flex-wrap: wrap; }
  .products, .feat, .grid.three, .grid.two { grid-template-columns: 1fr; }
}

/* ===== v3 layout: everything fits the window, no page scroll ===== */
html, body { height: 100%; }
body { overflow: hidden; }
#app { height: 100%; }
.shell { height: 100%; }
.main { min-height: 0; height: 100%; }
.content { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.top { padding-bottom: 10px; }
.top p { margin-top: 2px; }

.build { flex: 1; min-height: 0; display: grid; grid-template-columns: 430px minmax(0, 1fr); gap: 14px; }
.col { min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.card-b.fill { flex: 1; min-height: 0; overflow: hidden; display: block; }
.card-b.prods { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 12px 16px; }
.card-b.tight { padding: 12px 16px; }
.grid.tight { gap: 10px 12px; }
.grid.two.tight { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.prod { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; }
.prod .dot { width: 32px; height: 32px; flex: none; }
.prod span { display: grid; gap: 1px; }
.prod b { font-size: 13.5px; }
.prod small { font-size: 11.5px; }
.form-foot { flex: none; padding: 12px 16px; }
.form-stack { display: grid; gap: 12px; align-content: start; }
.form-stack .field > span { font-size: 12px; }
.form-stack input[type=text], .form-stack input[type=number], .form-stack input[type=date], .form-stack select { height: 34px; }
.section-t { margin-top: 2px; font-size: 12px; font-weight: 800; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.section-t::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.feat { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 12px; }
.feat .check { font-size: 12.5px; }
.feat.span-2 { grid-column: span 2; }
.camcard { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 6px; background: #fbfcfe; }
.camcard > b { font-size: 12.5px; }
.camcard .field > span { font-size: 11.5px; }
.code { min-height: 56px; height: 56px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px; padding: 8px 10px; }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.empty-big { height: 100%; min-height: 200px; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 24px; }
.muted.small, .small { font-size: 12px; }

.reports { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.tabbody { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.fill-card { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.filters { grid-template-columns: 150px 150px minmax(180px, 1fr) 150px 150px auto; padding: 12px 14px; gap: 10px; }
.filters .btn { height: 38px; }
.table-wrap { overflow: hidden; }
.pager { flex: none; }
tbody tr { height: 42px; }
.stats { grid-auto-rows: min-content; }
.upd-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; }
.upd-form .span-all { grid-column: 1 / -1; }
.stack-fill { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.stack-fill > .card.fill-card { flex: 1; }
.stack-form { display: grid; gap: 12px; }

/* dialogs */
.dialog { position: fixed; z-index: 42; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(620px, 94vw); max-height: 88vh;
  background: #fff; border-radius: 18px; box-shadow: 0 30px 80px rgba(15, 23, 42, .35); display: flex; flex-direction: column; overflow: hidden; }
.small-dialog { width: min(440px, 94vw); }
.dialog-h { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dialog-h h2 { font-size: 16px; font-weight: 800; }
.dialog-b { padding: 16px 20px; display: grid; gap: 12px; min-height: 0; overflow: hidden; }
.dialog-f { display: flex; align-items: center; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.ok-mark { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); flex: none; }
.out { max-height: 46vh; overflow: auto; margin: 0; }
.drawer-b { min-height: 0; }
.drawer-b .kv { margin: 0; }

@media (max-width: 1200px) {
  .build { grid-template-columns: 370px minmax(0, 1fr); }
  .feat { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .build { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .feat { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: 1fr 1fr; }
}

/* ===== v4: the app always fills the whole window, and stacks on narrow screens ===== */
html, body { width: 100%; margin: 0; padding: 0; }
body { position: fixed; inset: 0; overflow: hidden; }
#app { position: fixed; inset: 0; width: 100%; height: 100%; }
.shell { width: 100%; height: 100%; max-width: none; margin: 0; }
.main { width: 100%; min-width: 0; }
.content { width: 100%; }
@media (max-width: 760px) {
  body { position: static; overflow: auto; height: auto; }
  #app { position: static; height: auto; }
  .shell { height: auto; grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; }
  .nav { grid-auto-flow: column; }
  .side-foot { margin-top: 0; }
  .content { overflow: visible; }
  .build { display: flex; flex-direction: column; }
  .col { overflow: visible; }
  .reports, .tabbody, .fill-card { min-height: auto; }
  .table-wrap { overflow: auto; }
}
.badge.custom { --c: #7c3aed; background: color-mix(in srgb, var(--c) 10%, #fff); color: var(--c); border-color: color-mix(in srgb, var(--c) 35%, #fff); }
