/* ====== Sadat Commission — Modern Design System ====== */
:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --text: #1a2238;
  --muted: #6b7593;
  --border: #e6e9f2;
  --primary: #2b59ff;
  --primary-2: #5b7bff;
  --accent: #00b894;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #06b6d4;
  --shadow: 0 8px 24px rgba(20,30,80,.08);
  --radius: 14px;
  --radius-sm: 10px;
}
[data-theme="dark"] {
  --bg: #0b1020;
  --surface: #131a30;
  --surface-2: #182142;
  --text: #e8ecff;
  --muted: #8c95b8;
  --border: #25305a;
  --primary: #5b7bff;
  --primary-2: #8aa3ff;
  --shadow: 0 10px 30px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Vazirmatn', 'Tahoma', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background .25s, color .25s;
}
[dir="ltr"] body { font-family: 'Inter', system-ui, "Segoe UI", Roboto, sans-serif; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-2); }

/* ===== Layout ===== */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.hm-sync-status { position:sticky;top:56px;z-index:40;width:fit-content;max-width:calc(100% - 24px);margin:8px auto 0;padding:8px 14px;border:1px solid #f0b84c55;border-radius:999px;background:var(--surface);color:var(--text);box-shadow:var(--shadow);font-size:12px;font-weight:700;text-align:center; }
.container { max-width: 1280px; margin: 0 auto; padding: 24px; width: 100%; }

/* ===== Topbar ===== */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(10px);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; gap: 8px; flex-wrap: nowrap;
}
@media (max-width: 900px) { .topbar-inner { flex-wrap: wrap; } }
.brand {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
  font-weight: 800; font-size: 14px; color: var(--text);
}
.brand > span:last-child { white-space: nowrap; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid; place-items: center; color: #fff; font-weight: 900; font-size: 13px;
}
.tabs {
  display: flex; gap: 2px; flex: 1; min-width: 0;
  flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin;
}
.tabs::-webkit-scrollbar { height: 4px; }
.tab {
  padding: 6px 8px; border-radius: 8px; color: var(--muted);
  font-weight: 600; font-size: 12px; transition: .15s;
  display: inline-flex; align-items: center; gap: 4px;
  white-space: nowrap; flex-shrink: 0; line-height: 1;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; box-shadow: 0 4px 12px rgba(43,89,255,.25);
}
.top-actions { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.icon-btn {
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center; cursor: pointer;
  transition: .15s; font-size: 13px;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
/* On narrower fullscreen widths, drop the tab text and keep just icons so all tabs fit in one row */
@media (max-width: 1400px) {
  .tab > span:last-child { display: none; }
  .tab { padding: 6px 9px; font-size: 14px; }
}

/* ===== Hero ===== */
.hero { text-align: center; padding: 28px 0 8px; }
.hero h1 {
  font-size: clamp(24px, 3vw, 36px);
  margin: 0 0 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  font-weight: 800;
}
.hero .sub { color: var(--muted); font-size: 14px; }

/* ===== Cards Grid ===== */
.grid { display: grid; gap: 18px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-3,.grid-4 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 560px) { .grid-3,.grid-4,.grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.card:hover { transform: translateY(-2px); border-color: color-mix(in oklab, var(--primary) 30%, var(--border)); }

.menu-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 32px 16px; gap: 14px; min-height: 170px;
  cursor: pointer;
}
.menu-card .ic {
  width: 64px; height: 64px; border-radius: 16px;
  display: grid; place-items: center; font-size: 28px; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 6px 18px rgba(43,89,255,.3);
}
.menu-card .ic.green { background: linear-gradient(135deg,#16a34a,#22c55e); box-shadow: 0 6px 18px rgba(34,197,94,.3); }
.menu-card .ic.amber { background: linear-gradient(135deg,#d97706,#fbbf24); box-shadow: 0 6px 18px rgba(245,158,11,.3); }
.menu-card .ic.cyan  { background: linear-gradient(135deg,#0891b2,#22d3ee); box-shadow: 0 6px 18px rgba(6,182,212,.3); }
.menu-card .ic.pink  { background: linear-gradient(135deg,#be185d,#ec4899); box-shadow: 0 6px 18px rgba(236,72,153,.3); }
.menu-card .ic.purple { background: linear-gradient(135deg,#7c3aed,#a78bfa); box-shadow: 0 6px 18px rgba(167,139,250,.3); }
.menu-card .ttl { font-weight: 700; font-size: 17px; color: var(--text); }

/* ===== Stat cards ===== */
.stat { padding: 20px; }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat .value { font-size: 26px; font-weight: 800; margin-top: 6px; }
.stat .desc { color: var(--muted); font-size: 12px; margin-top: 6px; }
.stat.success .value { color: #22c55e; }
.stat.danger .value { color: var(--danger); }
.stat.info .value { color: var(--info); }
.stat.warn .value { color: var(--warning); }
.stat.primary .value { color: var(--primary); }

/* ===== Forms ===== */
.form-card { padding: 28px; }
.form-title { text-align: center; font-size: 22px; font-weight: 800; color: var(--primary); margin: 0 0 20px; }
.form-grid { display: grid; gap: 18px; grid-template-columns: 1fr 1fr; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.field label { display: block; color: var(--primary); font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.input, .select, textarea {
  width: 100%; padding: 11px 14px; border-radius: 10px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); outline: none;
  font: inherit; transition: .15s;
}
.input:focus, .select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary) 20%, transparent);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 10px 18px; border-radius: 10px; border: none;
  font: inherit; font-weight: 700; font-size: 14px;
  transition: .15s; color: #fff;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); }
.btn-success { background: linear-gradient(135deg,#16a34a,#22c55e); }
.btn-info { background: linear-gradient(135deg,#0891b2,#22d3ee); }
.btn-danger { background: linear-gradient(135deg,#dc2626,#ef4444); }
.btn-warn { background: linear-gradient(135deg,#d97706,#f59e0b); }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-dark { background: linear-gradient(135deg,#1f2937,#374151); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 18px; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl thead th {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; font-weight: 700; padding: 12px 10px; text-align: center;
  font-size: 13px; white-space: nowrap;
}
table.tbl tbody td { padding: 11px 10px; text-align: center; border-bottom: 1px solid var(--border); }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tfoot td { background: var(--surface-2); font-weight: 700; padding: 11px 10px; text-align: center; }
.row-warn td { color: var(--danger); border-color: rgba(239,68,68,.3) !important; }

/* ===== Section heading ===== */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 28px 0 14px; gap: 12px; flex-wrap: wrap;
}
.section-head h2 {
  margin: 0; color: var(--primary); font-size: 22px; font-weight: 800;
  display: flex; align-items: center; gap: 8px;
}

/* ===== Search panel ===== */
.search-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 18px;
  text-align: center;
}
.search-panel .ttl { font-size: 18px; font-weight: 800; color: var(--primary); margin-bottom: 12px; }
.search-row { display: flex; gap: 8px; max-width: 640px; margin: 0 auto; }
.search-row .input { flex: 1; }

/* ===== Bill ===== */
.bill-head { text-align: center; padding: 14px 0 18px; border-bottom: 1px dashed var(--border); margin-bottom: 18px; }
.bill-head h1 { margin: 0 0 6px; color: var(--primary); }
.bill-head .meta { color: var(--muted); font-size: 13px; }

/* ===== Alerts ===== */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; border: 1px solid; font-weight: 600; }
.alert-success { background: rgba(34,197,94,.12); color: #16a34a; border-color: rgba(34,197,94,.3); }
.alert-error { background: rgba(239,68,68,.12); color: var(--danger); border-color: rgba(239,68,68,.3); }
.alert-warn { background: rgba(245,158,11,.12); color: var(--warning); border-color: rgba(245,158,11,.3); }

/* ===== Footer ===== */
.footer { text-align: center; padding: 24px; color: var(--muted); font-size: 13px; margin-top: auto; }

/* ===== 80mm thermal receipt ===== */
.receipt-80mm {
  /* برای پرینترهایی مثل Goojprt که عرض مفیدشان خیلی کمتر از 80mm است، کمی باریک‌تر تا مطمئن داخل کاغذ جا شود */
  width: 60mm; max-width: 60mm; margin: 4mm auto; padding: 3mm 2mm;
  background: #fff; color: #000;
  font-family: 'Vazirmatn','Tahoma',monospace; font-size: 11px; line-height: 1.4;
  border: 1px solid #000;
}
.receipt-80mm .r-head { text-align: center; }
.receipt-80mm .r-shop { font-size: 16px; font-weight: 800; color: #000; }
.receipt-80mm .r-title { font-size: 14px; font-weight: 700; margin: 4px 0; color: #000; }
.receipt-80mm .r-meta { font-size: 11px; color: #000; }
.receipt-80mm .r-divider { border-top: 1px solid #000; margin: 6px 0; }
.receipt-80mm .r-tbl { width: 100%; border-collapse: collapse; font-size: 10px; }
.receipt-80mm .r-tbl th, .receipt-80mm .r-tbl td { padding: 1px 1px; text-align: center; border-bottom: 1px solid #000; color: #000; }
.receipt-80mm .r-tbl th:first-child, .receipt-80mm .r-tbl td:first-child { text-align: start; }
.receipt-80mm .r-total { display: flex; justify-content: space-between; align-items: flex-start; gap: 4px; font-size: 11px; padding: 2px 0; flex-wrap: wrap; color: #000; }
.receipt-80mm .r-total span { flex: 1 1 auto; min-width: 0; word-break: break-word; color: #000; }
.receipt-80mm .r-total b { flex: 0 0 auto; white-space: nowrap; color: #000; }
.receipt-80mm .r-grand { font-size: 12px; font-weight: 800; border-top: 2px solid #000; padding-top: 4px; background: #fff; color: #000; }
.receipt-80mm .r-words { font-size: 10px; line-height: 1.45; padding: 2px 0 4px; text-align: center; word-break: break-word; color: #000; }
.receipt-80mm .r-words-grand { font-weight: 700; border-bottom: 1px solid #000; margin-bottom: 4px; color: #000; }
.receipt-80mm .r-foot { text-align: center; margin-top: 2px; font-size: 11px; color: #000; }

/* ===== Print (base) — A4 by default; thermal 80mm only via body.print-thermal ===== */
@media print {
  .topbar, .actions, .footer, .no-print, .alert { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  .container { padding: 0 !important; max-width: 100% !important; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* Chart bars (simple CSS chart) */
.bars { display: flex; align-items: flex-end; gap: 18px; height: 280px; padding: 10px; border-bottom: 1px solid var(--border); }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 50px; }
.bar { width: 100%; max-width: 80px; background: linear-gradient(180deg, var(--primary), var(--primary-2)); border-radius: 8px 8px 0 0; transition: height .5s; }
.bar-label { font-size: 12px; color: var(--muted); }

/* ===== Local Persian fonts (offline) — Vazirmatn + B Titr alias ===== */
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn-Medium.woff2')  format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn-Bold.woff2')    format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn-Black.woff2')   format('woff2'); font-weight: 900; font-display: swap; }
/* B Titr substitute (offline, similar bold display Persian face) */
@font-face { font-family: 'B Titr'; src: url('../fonts/Vazirmatn-Black.woff2') format('woff2'); font-weight: 900; font-display: swap; }

/* Headings & titles use B Titr */
h1, h2, h3, .brand, .form-title, .section-head h2, .hero h1, .r-shop, .r-title,
.r-shop-title, .report-title, .modal-head, .stat-num, .bill-head h1 {
  font-family: 'B Titr','Vazirmatn','Tahoma',sans-serif;
  font-weight: 900;
  letter-spacing: 0;
}

/* ===== Operations cluster ===== */
.ops {
  display: flex; gap: 5px; flex-wrap: nowrap; align-items: center;
  justify-content: center; width: max-content; max-width: 100%; margin: 0 auto;
}
.tbl .col-ops { white-space: nowrap; min-width: 220px; vertical-align: middle; }
.op-btn {
  display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
  padding: 5px 9px; border-radius: 8px; font-size: 12px; font-weight: 700;
  color: #fff; background: var(--primary); border: 0; cursor: pointer;
  transition: .15s; white-space: nowrap; text-decoration: none;
}
.op-btn:hover { transform: translateY(-1px); filter: brightness(1.08); color:#fff; }
.op-btn.op-bill   { background: #14b8a6; }
.op-btn.op-detail { background: #3b82f6; }
.op-btn.op-edit   { background: #f59e0b; }
.op-btn.op-del    { background: #ef4444; }
.op-btn.op-seer   { background: #8b5cf6; }
.op-btn span { font-size: 11px; }

/* small button */
.btn.btn-sm { padding: 5px 9px; font-size: 12px; }

/* Weight cell with calc button */
.w-cell { display: flex; gap: 4px; align-items: center; }
.w-cell .input { flex: 1; min-width: 70px; }
.cell-seer { font-weight: 700; color: var(--accent); text-align: center; }

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; z-index: 1000;
}
.modal-backdrop.open { display: flex; animation: fadeIn .15s ease; }
.modal {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.4);
  width: min(560px, 92vw); max-height: 88vh; overflow: auto;
  animation: slideUp .2s ease;
}
.modal-head {
  display:flex; justify-content:space-between; align-items:center;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  font-size: 16px; font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff;
  border-radius: 16px 16px 0 0;
}
.modal-x {
  background: rgba(255,255,255,.18); color: #fff; border: 0; width: 28px; height: 28px;
  border-radius: 50%; cursor: pointer; font-size: 18px; line-height: 1;
}
.modal-body { padding: 16px 18px; }
.modal-foot {
  padding: 12px 18px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
}
.muted-line { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.seer-tbl th, .seer-tbl td { text-align: center; }
.seer-totals {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px;
  font-size: 14px;
}
.seer-totals b { color: var(--accent); font-size: 18px; }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
@keyframes slideUp { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:translateY(0)} }

/* ===== Detail / report (A4) page ===== */
.report-page {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 28px; margin: 18px 0; box-shadow: var(--shadow);
}
.report-head { text-align:center; margin-bottom: 14px; }
.r-shop-title { font-size: 22px; color: var(--primary); margin-bottom: 4px; }
.r-shop-meta { color: var(--muted); font-size: 13px; }
.report-title { text-align: center; margin: 18px 0; color: var(--accent); font-size: 22px; }
.report-sub { margin: 22px 0 10px; font-size: 16px; color: var(--primary); }
.report-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.report-tbl th, .report-tbl td { border: 1px solid var(--border); padding: 8px 6px; text-align: center; }
.report-tbl thead th { background: var(--surface-2); font-weight: 800; }
.report-tbl .cust { color: #2563eb; font-weight: 700; }
.report-tbl .recv { color: #2563eb; }
  .report-tbl tfoot .grand td,
  .report-tbl tfoot .grand th { background: var(--surface-2); font-weight: 800; }
.report-tbl.tbl-small th, .report-tbl.tbl-small td { padding: 6px 4px; font-size: 12px; }
.report-money { margin: 14px 0; font-size: 15px; padding: 10px 14px; background: var(--surface-2); border-radius: 10px; }
.report-summary {
  display: grid; gap: 8px; margin-top: 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; font-size: 14px;
}
.report-summary .net { font-size: 17px; padding: 8px 0; border-top: 1px dashed var(--border); margin-top: 6px; }
.report-summary .net.pos { color: #16a34a; }
.report-summary .net.neg { color: #dc2626; }
.muted-box { background: var(--surface-2); border: 1px dashed var(--border); padding: 14px; border-radius: 10px; color: var(--muted); text-align:center; }


/* ===== Weight / seer details page ===== */
.weight-details-card {
  width: min(680px, 100%);
  margin: 28px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 18px;
}
.weight-details-actions { display: flex; justify-content: flex-start; margin-bottom: 8px; }
.weight-details-head { text-align: right; margin-bottom: 14px; }
.weight-details-head h1 { margin: 0 0 6px; font-size: 20px; color: var(--text); }
.weight-details-head div { font-size: 13px; color: var(--text); line-height: 1.7; }
.weight-details-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.weight-details-table th,
.weight-details-table td { border: 1px solid var(--border); padding: 8px 10px; text-align: center; }
.weight-details-table thead th { background: var(--surface-2); color: var(--text); font-weight: 900; }
.weight-details-table tfoot td { background: color-mix(in oklab, var(--accent) 16%, var(--surface)); font-weight: 900; }
.weight-empty { color: var(--muted); padding: 20px !important; }
@media print {
  .weight-details-card { box-shadow: none; border: 0; width: 100%; margin: 0 auto; padding: 0; }
  .receipt-80mm .weight-details-table th,
  .receipt-80mm .weight-details-table td { border-color: #000 !important; color: #000 !important; }
  .receipt-80mm .weight-details-table thead th,
  .receipt-80mm .weight-details-table tfoot td {
    background: #fff !important;
    color: #000 !important;
    border: 1px solid #000 !important;
  }
}

/* ===== 80mm thermal receipt — سیاه روی سفید (هر سه بل) ===== */
.receipt-80mm,
#thermalReceiptPrint,
#printArea.receipt-80mm {
  color: #000 !important;
  background: #fff !important;
}
.receipt-80mm .r-shop { font-family: 'B Titr','Vazirmatn',Tahoma,sans-serif; font-size: 17px; color: #000 !important; }
.receipt-80mm .r-title { color: #000 !important; }
.receipt-80mm .r-meta-row { display: flex; justify-content: space-between; font-size: 11px; padding: 1px 0; color: #000 !important; }
.receipt-80mm .r-meta-row span,
.receipt-80mm .r-meta-row b { color: #000 !important; }
.receipt-80mm .r-meta { color: #000 !important; }
.receipt-80mm .r-tbl thead th {
  background: #fff !important;
  color: #000 !important;
  font-weight: 700;
  padding: 3px 1px;
  font-size: 9px;
  line-height: 1.3;
  white-space: normal;
  border: 1px solid #000 !important;
  border-bottom: 2px solid #000 !important;
}
.receipt-80mm .r-tbl tbody td { color: #000 !important; background: #fff !important; }
.receipt-80mm .r-tbl tfoot th,
.receipt-80mm .r-tbl tfoot td {
  font-weight: 800;
  border-top: 2px solid #000 !important;
  color: #000 !important;
  background: #fff !important;
}
.receipt-80mm .weight-details-table thead th,
.receipt-80mm .weight-details-table tfoot td {
  background: #fff !important;
  color: #000 !important;
  border: 1px solid #000 !important;
}
.edit-sale-tbl th { background: var(--surface-2); color: var(--primary); font-weight: 700; text-align: start; white-space: nowrap; width: 1%; }
.edit-sale-tbl td { vertical-align: middle; }
@media print {
  .edit-sale-tbl th { background: #e5e7eb !important; color: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.receipt-80mm .r-total b { font-size: 13px; color: #000 !important; }
.receipt-80mm .r-grand {
  background: #fff !important;
  color: #000 !important;
  font-size: 12px;
  font-weight: 800;
  border-top: 2px solid #000 !important;
  padding: 4px 0 !important;
}
.receipt-80mm .r-grand span,
.receipt-80mm .r-grand b { color: #000 !important; }
.receipt-80mm .r-words,
.receipt-80mm .r-words-grand { color: #000 !important; background: transparent !important; }
.receipt-80mm .r-foot,
.receipt-80mm .r-foot.small { font-size: 10px; color: #000 !important; }

/* تم تاریک — رسید حرارتی همیشه سفید/سیاه */
[data-theme="dark"] .receipt-80mm,
[data-theme="dark"] #thermalReceiptPrint {
  background: #fff !important;
  color: #000 !important;
}
[data-theme="dark"] .receipt-80mm .r-tbl thead th,
[data-theme="dark"] .receipt-80mm .r-tbl tbody td,
[data-theme="dark"] .receipt-80mm .r-tbl tfoot th,
[data-theme="dark"] .receipt-80mm .r-tbl tfoot td,
[data-theme="dark"] .receipt-80mm .r-grand,
[data-theme="dark"] .receipt-80mm .r-total,
[data-theme="dark"] .receipt-80mm .r-meta,
[data-theme="dark"] .receipt-80mm .r-meta-row,
[data-theme="dark"] .receipt-80mm .r-words,
[data-theme="dark"] .receipt-80mm .r-foot,
[data-theme="dark"] .receipt-80mm .r-shop,
[data-theme="dark"] .receipt-80mm .r-title {
  background: #fff !important;
  color: #000 !important;
}
[data-theme="dark"] .receipt-80mm .r-grand span,
[data-theme="dark"] .receipt-80mm .r-grand b,
[data-theme="dark"] .receipt-80mm .r-total span,
[data-theme="dark"] .receipt-80mm .r-total b,
[data-theme="dark"] .receipt-80mm .r-meta-row span,
[data-theme="dark"] .receipt-80mm .r-meta-row b {
  color: #000 !important;
}

/* ===== Print: 80mm thermal ONLY when body.print-thermal is set ===== */
@media print {
  body.print-thermal { background:#fff; color:#000; }
  body.print-thermal .topbar, body.print-thermal .actions, body.print-thermal .footer,
  body.print-thermal .no-print, body.print-thermal .alert, body.print-thermal .search-panel,
  body.print-thermal .section-head { display:none !important; }
}
@media print {
  body.print-thermal { width: 80mm !important; }
}
body.print-thermal { /* placeholder */ }

/* ===== Kilo (scale) button — distinct from warning ===== */
.btn-warning { background: linear-gradient(135deg,#d97706,#f59e0b); }
.btn-kilo {
  background: linear-gradient(135deg,#0ea5e9,#22d3ee);
  color: #fff;
  box-shadow: 0 4px 12px rgba(14,165,233,.35);
}
.btn-kilo:hover { filter: brightness(1.08); }

/* Per-row kilo button inside weight cell */
.w-cell .btn-kilo-cell {
  background: linear-gradient(135deg,#0ea5e9,#22d3ee);
  color: #fff; border: 0; border-radius: 8px;
  width: 32px; height: 32px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(14,165,233,.3);
  transition: .15s;
}
.w-cell .btn-kilo-cell:hover { transform: translateY(-1px); filter: brightness(1.1); }


/* Dashboard dropdown */
.tab-dropdown{position:relative;display:inline-block}
.tab-dropdown .tab-menu{display:none;position:absolute;top:100%;inset-inline-start:0;background:var(--surface,#222);border:1px solid var(--border,#444);border-radius:8px;min-width:200px;z-index:1000;box-shadow:0 6px 18px rgba(0,0,0,.2);padding:6px;margin-top:4px}
.tab-dropdown:hover .tab-menu,.tab-dropdown:focus-within .tab-menu{display:block}
.tab-dropdown .tab-menu a{display:block;padding:8px 12px;color:inherit;text-decoration:none;border-radius:6px;white-space:nowrap}
.tab-dropdown .tab-menu a:hover{background:var(--primary,#3b82f6);color:#fff}


/* === Enhanced Print Layout (for reports, lists, dashboards) === */
@media print {
  /* Page setup */
  @page { size: A4; margin: 12mm 10mm; }
  /* hide UI chrome */
  .topbar, .footer, .no-print, .alert, .search-panel, .modal-backdrop { display: none !important; }
  body { background: #fff !important; color: #000 !important; font-family: 'Vazirmatn', sans-serif; }
  .container { padding: 0 !important; max-width: 100% !important; }
  /* Tables */
  .tbl, .report-tbl { width: 100%; border-collapse: collapse; font-size: 11pt; page-break-inside: auto; }
  .tbl th, .tbl td, .report-tbl th, .report-tbl td { border: 1px solid #444; padding: 4px 6px; }
  .tbl thead, .report-tbl thead { background: #e5e7eb !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tbl tr, .report-tbl tr { page-break-inside: avoid; }
  /* Action columns (جزئیات سیر، قسط، ویرایش) — reliable hide in table layout */
  .report-tbl th.no-print,
  .report-tbl td.no-print {
    display: none !important;
    width: 0 !important;
    max-width: 0 !important;
    padding: 0 !important;
    border: none !important;
    overflow: hidden !important;
  }
  .report-tbl tfoot .grand th,
  .report-tbl tfoot .grand td { background: #e5e7eb !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* Cards in print */
  .card { box-shadow: none !important; border: 1px solid #999 !important; padding: 8px !important; margin: 4px 0 !important; background: #fff !important; color: #000 !important; }
  .card .label { color: #444 !important; font-size: 10pt; }
  .card .value { color: #000 !important; font-weight: 700; font-size: 14pt; }
  .grid { display: grid !important; }
  .grid-3 { grid-template-columns: repeat(3, 1fr) !important; gap: 6px !important; }
  .grid-2 { grid-template-columns: repeat(2, 1fr) !important; gap: 6px !important; }
  /* Report title prominence */
  .report-head, .report-title, .report-sub { color: #000 !important; }
  .report-title { font-size: 16pt; text-align: center; margin: 6px 0 10px; }
  .report-sub  { font-size: 12pt; margin: 12px 0 4px; border-bottom: 1px solid #000; padding-bottom: 2px; }
  /* Net money emphasis */
  .net { background: #f3f4f6 !important; border: 2px solid #000 !important; padding: 8px !important; font-size: 13pt !important; }
  a { color: #000 !important; text-decoration: none; }
}

/* === Thermal 80mm @page (when receipt) === */
@media print {
  body.print-thermal { font-size: 11px; }
  body.print-thermal .receipt-80mm {
    width: 60mm !important;
    max-width: 60mm !important;
    border: 0 !important;
    margin: 0 auto !important;
    padding: 0mm 0mm !important;
    color: #000 !important;
  }
  body.print-thermal .receipt-80mm,
  body.print-thermal #thermalReceiptPrint,
  body.print-thermal #printArea {
    background: #fff !important;
    color: #000 !important;
  }
  body.print-thermal .receipt-80mm .r-divider {
    border-top: 1px solid #000 !important;
  }
  body.print-thermal .receipt-80mm .r-tbl th,
  body.print-thermal .receipt-80mm .r-tbl td,
  body.print-thermal .receipt-80mm .r-tbl tfoot th,
  body.print-thermal .receipt-80mm .r-tbl tfoot td {
    border-color: #000 !important;
    border-bottom: 1px solid #000 !important;
    background: #fff !important;
    color: #000 !important;
    -webkit-print-color-adjust: economy;
    print-color-adjust: economy;
  }
  body.print-thermal .receipt-80mm .r-tbl thead th {
    background: #fff !important;
    color: #000 !important;
    font-weight: 700 !important;
    border: 1px solid #000 !important;
    border-bottom: 2px solid #000 !important;
  }
  body.print-thermal .receipt-80mm .weight-details-table thead th,
  body.print-thermal .receipt-80mm .weight-details-table tfoot td {
    background: #fff !important;
    color: #000 !important;
    border: 1px solid #000 !important;
  }
  body.print-thermal .receipt-80mm .r-meta,
  body.print-thermal .receipt-80mm .r-meta-row,
  body.print-thermal .receipt-80mm .r-meta-row span,
  body.print-thermal .receipt-80mm .r-meta-row b,
  body.print-thermal .receipt-80mm .r-total,
  body.print-thermal .receipt-80mm .r-total span,
  body.print-thermal .receipt-80mm .r-total b,
  body.print-thermal .receipt-80mm .r-grand,
  body.print-thermal .receipt-80mm .r-grand span,
  body.print-thermal .receipt-80mm .r-grand b,
  body.print-thermal .receipt-80mm .r-words,
  body.print-thermal .receipt-80mm .r-words-grand,
  body.print-thermal .receipt-80mm .r-foot,
  body.print-thermal .receipt-80mm .r-foot.small,
  body.print-thermal .receipt-80mm .r-shop,
  body.print-thermal .receipt-80mm .r-title {
    color: #000 !important;
    background: #fff !important;
  }
}
@page thermal { size: 60mm auto; margin: 0mm; }

/* Force any non-thermal page to A4 with safe widths to avoid clipping */
@media print {
  html, body { width: auto !important; max-width: none !important; }
  body:not(.print-thermal) { width: auto !important; }
  body:not(.print-thermal) .table-wrap { overflow: visible !important; }
  body:not(.print-thermal) table { width: 100% !important; table-layout: auto; word-break: break-word; }
  .report-page { box-shadow: none !important; border: 0 !important; padding: 0 !important; margin: 0 !important; }
}

/* Default A4 for everything (overridden inline in thermal pages) */
@media print {
  @page { size: A4; margin: 10mm; }
}

/* ===== Center-screen Toast Notifications ===== */
.toast-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; pointer-events: none;
  background: rgba(10,16,32,0.35); backdrop-filter: blur(2px);
  animation: toastFade .25s ease-out;
}
.toast-overlay.fade-out { opacity: 0; transition: opacity .5s ease-out; }
.toast {
  pointer-events: auto;
  min-width: 320px; max-width: 80vw;
  padding: 22px 30px; border-radius: 16px;
  font-size: 18px; font-weight: 700; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center; gap: 12px;
  position: relative; cursor: pointer;
  animation: toastPop .35s cubic-bezier(.2,1.4,.4,1);
}
.toast-success { background: linear-gradient(135deg,#10b981,#059669); color:#fff; }
.toast-error   { background: linear-gradient(135deg,#ef4444,#dc2626); color:#fff; }
.toast-close { margin-inline-start: 8px; font-size: 22px; opacity: .8; }
@keyframes toastPop { 0%{transform:scale(.6);opacity:0} 100%{transform:scale(1);opacity:1} }
@keyframes toastFade { from{opacity:0} to{opacity:1} }
@media print { .toast-overlay { display:none !important; } }

/* ===== FAB & Modal ===== */
.fab {
  position: fixed; bottom: 28px; left: 28px; z-index: 80;
  width: 56px; height: 56px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; font-size: 24px; font-weight: 800; cursor: pointer;
  box-shadow: 0 8px 28px rgba(43,89,255,.45);
  transition: transform .15s;
}
[dir="ltr"] .fab { left: auto; right: 28px; }
.fab:hover { transform: scale(1.08); }
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(10,16,32,.5); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; width: min(420px, 96vw);
  box-shadow: var(--shadow);
}
.modal-card h3 { margin: 0 0 16px; color: var(--primary); }

/* ===== Dashboard formula & cards ===== */
.formula-hint {
  color: var(--muted); font-size: 13px; line-height: 1.6;
  padding: 10px 14px; background: var(--surface-2);
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  margin: 0 0 16px;
}
.cash-money-card {
  background: linear-gradient(135deg, #10b981, #059669) !important;
  color: #fff !important;
}
.cash-money-card .label { color: #e6fffa !important; }
.cash-money-card .value { font-size: 28px; font-weight: 800; }
.goods-notes-footer { margin-top: 28px; padding-top: 18px; border-top: 2px dashed var(--border); }
.notes-box {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px 18px; line-height: 1.8;
  white-space: pre-wrap;
}
.field-hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.print-only { display: none; }
@media print {
  body.print-daily-exp * { visibility: hidden; }
  body.print-daily-exp #dailyExpPrint,
  body.print-daily-exp #dailyExpPrint * { visibility: visible; }
  body.print-daily-exp #dailyExpPrint { position: absolute; left: 0; top: 0; width: 100%; }
  .print-only { display: block !important; visibility: visible !important; }
}
.menu-card .ic.teal { background: linear-gradient(135deg,#0d9488,#14b8a6); }
.menu-card .ic.warn { background: linear-gradient(135deg,#f59e0b,#d97706); }

.btn-got {
  background: linear-gradient(135deg, #22c55e, #16a34a) !important;
  color: #fff !important; font-weight: 700; border: none;
  padding: 12px 24px; font-size: 15px;
}
.btn-paid {
  background: linear-gradient(135deg, #ef4444, #dc2626) !important;
  color: #fff !important; font-weight: 700; border: none;
  padding: 12px 24px; font-size: 15px;
}
.pay-recv-actions {
  display: flex; gap: 14px; flex-wrap: wrap; justify-content: center;
  margin: 8px 0 16px;
}

/* ===== Cash Calculator Modal ===== */
.cash-calc-modal { width: min(480px, 96vw); }
.cash-calc-top {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px;
}
.cash-calc-total-box {
  background: var(--surface-2); border: 2px solid var(--primary);
  border-radius: var(--radius-sm); padding: 14px; text-align: center;
}
.cash-calc-total-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.cash-calc-total-value { font-size: 28px; font-weight: 800; color: var(--primary); }
.cash-calc-match label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.cash-calc-diff { font-size: 13px; font-weight: 700; margin-top: 6px; min-height: 18px; }
.cash-calc-diff.ok { color: #16a34a; }
.cash-calc-diff.over { color: #2563eb; }
.cash-calc-diff.under { color: #dc2626; }
.cash-calc-rows { display: flex; flex-direction: column; gap: 8px; max-height: 52vh; overflow-y: auto; }
.cash-calc-row {
  display: grid; grid-template-columns: 56px 20px 36px 1fr 36px 20px 72px;
  align-items: center; gap: 6px; padding: 8px 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.cash-calc-denom { font-weight: 800; text-align: center; color: var(--primary); }
.cash-calc-x, .cash-calc-eq { text-align: center; color: var(--muted); font-weight: 700; }
.cash-calc-count { text-align: center; padding: 8px 6px; min-width: 0; }
.cash-calc-sub { font-weight: 700; text-align: center; }
.cash-calc-btn { min-width: 36px; padding: 6px 0; font-size: 18px; line-height: 1; }
.input-with-calc { display: flex; gap: 8px; align-items: stretch; }
.input-with-calc .input { flex: 1; min-width: 0; }
.input-with-calc .btn { white-space: nowrap; align-self: stretch; }

/* ===== Print for Payments/Receipts sections ===== */
#payRecvPrint { display: none; }
@media print {
  body.print-payrecv * { visibility: hidden; }
  body.print-payrecv #payRecvPrint,
  body.print-payrecv #payRecvPrint * { visibility: visible; }
  body.print-payrecv #payRecvPrint { display: block !important; position: absolute; left: 0; top: 0; width: 100%; }
}

/* ===== Wholesale ledger refresh ===== */
:root {
  --bg: #f2f5ef;
  --surface: #fffefa;
  --surface-2: #f6f8f2;
  --text: #1c2b23;
  --muted: #718078;
  --border: #e1e9df;
  --primary: #176a50;
  --primary-2: #4c9b68;
  --accent: #d6a74f;
  --danger: #d95353;
  --warning: #c88718;
  --info: #398e9b;
  --shadow: 0 12px 34px rgba(36, 66, 46, .075);
  --radius: 18px;
  --radius-sm: 12px;
}
[data-theme="dark"] {
  --bg: #111a16;
  --surface: #1a2720;
  --surface-2: #223229;
  --text: #edf4ed;
  --muted: #a0b2a6;
  --border: #35483b;
  --primary: #91cfa0;
  --primary-2: #c4db8c;
  --accent: #e1b865;
  --danger: #ff7777;
  --warning: #e8b14f;
  --info: #6cc2cc;
  --shadow: 0 14px 38px rgba(0, 0, 0, .25);
}
body {
  background:
    radial-gradient(ellipse at 12% 0%, color-mix(in srgb, var(--primary) 7%, transparent), transparent 38rem),
    var(--bg);
  line-height: 1.65;
}
.container { max-width: 1380px; padding: clamp(16px, 2.6vw, 32px); }
.topbar {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom-color: color-mix(in srgb, var(--border) 85%, transparent);
  box-shadow: 0 8px 28px rgba(23, 47, 33, .045);
  backdrop-filter: blur(18px);
}
.topbar-inner {
  position: relative;
  max-width: 1440px;
  min-height: 62px;
  padding: 9px clamp(14px, 2.4vw, 30px);
  display: grid;
  grid-template-columns: minmax(max-content, auto) minmax(0, 1fr) auto;
  gap: clamp(12px, 2vw, 26px);
}
.brand { gap: 10px; font-size: 14px; }
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 13px;
  background: linear-gradient(145deg, #175b47, #317d56 62%, #d5a84e);
  box-shadow: 0 7px 18px rgba(27, 105, 76, .2);
  font-size: 19px;
}
.main-navigation { display: flex; align-items: center; gap: 8px; min-width: 0; }
.nav-home, .nav-menu-toggle {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  transition: background .16s, border-color .16s, transform .16s, box-shadow .16s;
  cursor: pointer;
  list-style: none;
}
.nav-home:hover, .nav-menu-toggle:hover {
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
  transform: translateY(-1px);
}
.nav-home.active {
  background: color-mix(in srgb, var(--primary) 11%, var(--surface));
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 28%, var(--border));
}
.nav-home-icon { font-size: 16px; }
.nav-menu { position: relative; }
.nav-menu summary::-webkit-details-marker { display: none; }
.nav-menu-toggle > i:first-child { color: var(--primary); font-size: 14px; }
.nav-chevron { color: var(--muted); font-size: 10px; transition: transform .16s; }
.nav-menu[open] .nav-chevron { transform: rotate(180deg); }
.nav-menu.has-active > summary { border-color: color-mix(in srgb, var(--primary) 33%, var(--border)); }
.nav-menu.has-active > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
.nav-popover {
  position: fixed;
  z-index: 80;
  top: 72px;
  inset-inline: max(16px, calc((100vw - 780px) / 2));
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(12, 28, 18, .2);
  animation: nav-pop .14s ease-out;
}
@keyframes nav-pop { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }
.nav-group { min-width: 0; padding: 2px; }
.nav-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 10px;
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  border-bottom: 1px solid var(--border);
}
.nav-group-title span { font-size: 15px; }
.nav-group-links { display: grid; gap: 4px; }
.nav-link {
  min-height: 40px;
  padding: 7px 9px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  transition: background .14s, color .14s, transform .14s;
}
.nav-link:hover { background: var(--surface-2); color: var(--primary); transform: translateX(-2px); }
[dir="ltr"] .nav-link:hover { transform: translateX(2px); }
.nav-link.active {
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
  color: var(--primary);
}
.nav-link-icon { width: 24px; height: 24px; flex: 0 0 24px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-2); font-size: 13px; }
.nav-link-check { margin-inline-start: auto; color: var(--primary); font-size: 11px; }
.top-actions { gap: 6px; }
.top-actions .icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--surface-2);
  border-color: var(--border);
  font-size: 13px;
}
.top-actions .icon-btn-logout { color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, var(--surface)); }
.top-actions .license-chip { width: auto; min-width: 36px; padding: 0 10px; color: var(--primary); font-size: 11px; font-weight: 900; }
.top-actions .trial-chip { color: #69490b; background: #f6e8c5; border-color: #ebd39b; }
.top-actions .license-chip-expired { color: var(--danger); }
.hero { padding: 32px 0 10px; }
.hero h1 { background-image: linear-gradient(120deg, var(--primary), var(--primary-2) 65%, var(--accent)); }
.hero .sub { line-height: 1.9; }
.card {
  border-color: color-mix(in srgb, var(--border) 85%, transparent);
  box-shadow: var(--shadow);
}
.card:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--primary) 24%, var(--border)); }
.form-card { padding: clamp(18px, 2.5vw, 28px); }
.form-title { color: var(--primary); }
.input, .select, textarea { border-radius: 11px; }
.input:focus, .select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent); }
.btn { border-radius: 11px; box-shadow: 0 4px 12px rgba(16, 54, 34, .09); }
.btn-primary { background: linear-gradient(130deg, #176a50, #388c60); }
[data-theme="dark"] .btn-primary { color: #102219; background: linear-gradient(130deg, #a6d9a4, #d1df91); }
.btn-success { background: linear-gradient(130deg, #19724d, #45a96c); }
.section-head h2 { color: var(--text); font-size: 20px; }
table.tbl thead th { background: linear-gradient(120deg, #155b46, #287a55); border-bottom: 2px solid var(--accent); }
[data-theme="dark"] table.tbl thead th { background: linear-gradient(120deg, #1d513e, #28704d); }
.table-wrap { box-shadow: 0 8px 24px rgba(30, 61, 41, .035); }
.alert { border-radius: 12px; }
.footer { padding: 22px; }
@media (max-width: 900px) {
  .topbar-inner { grid-template-columns: minmax(0, 1fr) auto; gap: 9px 14px; }
  .main-navigation { grid-column: 1 / -1; grid-row: 2; }
  .nav-popover {
    top: 116px;
    inset-inline: 14px;
    max-height: calc(100dvh - 132px);
    overflow-y: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 640px) {
  .topbar-inner { padding: 9px 12px; }
  .brand { min-width: 0; font-size: 12px; }
  .brand > span:last-child { overflow: hidden; text-overflow: ellipsis; }
  .brand-mark { width: 35px; height: 35px; flex: 0 0 35px; }
  .top-actions { gap: 4px; }
  .top-actions .icon-btn { width: 32px; height: 32px; border-radius: 10px; }
  .top-actions .license-chip { min-width: 32px; padding: 0 8px; }
  .main-navigation { width: 100%; }
  .nav-home, .nav-menu { flex: 0 0 auto; }
  .nav-menu-toggle, .nav-home { min-height: 38px; padding: 0 12px; font-size: 12px; }
  .nav-popover {
    top: 108px;
    inset-inline: 12px;
    max-height: calc(100dvh - 124px);
    overflow-y: auto;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 14px;
  }
  .nav-group-title { padding-bottom: 8px; }
  .nav-group-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-link { min-height: 42px; }
  .hero { padding-top: 24px; }
  .hero h1 { font-size: clamp(22px, 7vw, 30px); }
}
@media (max-width: 390px) {
  .topbar-inner { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .top-actions .icon-btn { width: 30px; height: 30px; }
  .nav-popover { top: 104px; }
  .nav-group-links { grid-template-columns: 1fr; }
  .nav-link { min-height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ===== Installment page: comfortable compact-window layout ===== */
.installment-head { align-items: center; }
.installment-toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.installment-card { padding: 18px; }
.installment-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.installment-summary > div { min-width: 0; overflow-wrap: anywhere; }
.installment-form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2fr);
  gap: 14px;
}
.installment-actions { margin-top: 12px; }
.installment-edit-card { margin-top: 14px; border: 2px solid var(--info); }
.installment-table-wrap { max-width: 100%; }

@media (max-width: 700px) {
  .installment-head { align-items: stretch; flex-direction: column; gap: 10px; margin: 18px 0 12px; }
  .installment-toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .installment-toolbar > .btn { min-width: 0; justify-content: center; padding: 9px 8px; font-size: 12px; }
  .installment-card { padding: clamp(14px, 3vw, 18px); }
  .installment-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
  .installment-summary > div { font-size: 13px; line-height: 1.8; }
  .installment-form-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .installment-actions { display: flex; flex-direction: column; }
  .installment-actions > .btn { width: 100%; justify-content: center; }
  .installment-card h3 { font-size: 16px; line-height: 1.7; }
  .installment-table { min-width: 620px; }
}
@media (max-width: 420px) {
  .installment-summary { grid-template-columns: minmax(0, 1fr); }
  .installment-toolbar { grid-template-columns: minmax(0, 1fr); }
}

/* ===== Saraf ledger: compact accounts and focused actions ===== */
.saraf-page-actions { margin: 8px 0 16px; }
.saraf-section-head { margin-top: 18px; }
.saraf-count { display: inline-flex; align-items: center; margin-inline-start: 6px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 11px; vertical-align: middle; }
.saraf-account-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 285px), 1fr)); gap: 12px; }
.saraf-account-card { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 14px; }
.saraf-account-main { display: flex; min-width: 0; flex-direction: column; gap: 4px; color: var(--text); }
.saraf-account-main:hover { color: var(--primary); }
.saraf-account-name { overflow: hidden; color: var(--text); font-size: 13px; font-weight: 900; text-overflow: ellipsis; white-space: nowrap; }
.saraf-account-balance { color: var(--primary); font-size: 21px; font-weight: 900; line-height: 1.25; white-space: nowrap; }
.saraf-account-balance small { font-size: 10px; font-weight: 800; }
.saraf-account-card.is-negative .saraf-account-balance { color: var(--danger); }
.saraf-account-desc { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.saraf-account-tools { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.saraf-account-tools form { margin: 0; }
.saraf-account-tools .btn { justify-content: center; min-width: 88px; padding: 7px 9px; font-size: 11px; }
.saraf-management-grid { align-items: start; margin-top: 18px; }
.saraf-form-panel { min-width: 0; padding: 18px; }
.saraf-form-panel > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0; list-style: none; cursor: pointer; text-align: start; }
.saraf-form-panel > summary::-webkit-details-marker { display: none; }
.saraf-form-panel > summary::after { content: "+"; display: grid; width: 28px; height: 28px; flex: 0 0 28px; place-items: center; border-radius: 9px; background: var(--surface-2); color: var(--primary); }
.saraf-form-panel[open] > summary { margin-bottom: 18px; }
.saraf-form-panel[open] > summary::after { content: "−"; }
.saraf-form-actions { grid-column: 1 / -1; }
.saraf-report-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.saraf-report-table { min-width: 980px; }
.saraf-report-wrap { max-width: 100%; }
@media (max-width: 700px) {
  .saraf-page-actions { margin: 4px 0 12px; }
  .saraf-section-head { align-items: center; gap: 8px; }
  .saraf-section-head h2 { font-size: 17px; }
  .saraf-count { font-size: 10px; }
  .saraf-account-grid { grid-template-columns: minmax(0, 1fr); gap: 9px; }
  .saraf-account-card { padding: 12px; }
  .saraf-management-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: 14px; }
  .saraf-form-panel { padding: 14px; }
  .saraf-report-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .saraf-report-actions .btn { justify-content: center; min-width: 0; padding: 9px 8px; font-size: 12px; }
  .saraf-report-table { min-width: 980px; }
}
