/* =====================================================================
   PVC ERP — Hand-authored design system (no framework)
   Guided by UI/UX Pro Max: SaaS/B2B palette, Swiss/minimal style,
   8pt spacing rhythm, tabular figures, accessible contrast, dark mode.
   ===================================================================== */

:root {
  --brand-50:#eff6ff; --brand-100:#dbeafe; --brand-500:#3b82f6; --brand-600:#2563eb; --brand-700:#1d4ed8;
  --bg:#f1f5f9; --surface:#ffffff; --surface-2:#f8fafc; --surface-3:#f1f5f9;
  --text:#1e293b; --text-strong:#0f172a; --muted:#64748b; --faint:#94a3b8;
  --border:#e2e8f0; --border-soft:#eef2f7;
  --shadow-sm:0 1px 2px rgba(15,23,42,.05);
  --shadow:0 1px 3px rgba(15,23,42,.06),0 8px 24px rgba(15,23,42,.05);
  --shadow-lg:0 10px 40px rgba(15,23,42,.12);
  --ok:#059669; --ok-bg:#ecfdf5; --warn:#d97706; --warn-bg:#fffbeb;
  --danger:#e11d48; --danger-bg:#fff1f2; --info:#2563eb; --info-bg:#eff6ff;
  --side:#0f172a; --side-2:#1e293b; --side-text:#cbd5e1; --side-muted:#64748b;
  --radius:16px; --radius-sm:10px; --radius-lg:20px;
}
html.dark {
  --bg:#020617; --surface:#0f172a; --surface-2:#0b1220; --surface-3:#1e293b;
  --text:#e2e8f0; --text-strong:#f8fafc; --muted:#94a3b8; --faint:#64748b;
  --border:#1e293b; --border-soft:#1e293b;
  --shadow-sm:0 1px 2px rgba(0,0,0,.3);
  --shadow:0 1px 3px rgba(0,0,0,.4),0 8px 24px rgba(0,0,0,.35);
  --shadow-lg:0 10px 40px rgba(0,0,0,.5);
  --ok-bg:rgba(16,185,129,.12); --warn-bg:rgba(217,119,6,.14);
  --danger-bg:rgba(225,29,72,.14); --info-bg:rgba(37,99,235,.14);
  --side:#0b1220; --side-2:#0f172a;
}

* { box-sizing:border-box; }
html, body { height:100%; }
body {
  margin:0; font-family:Vazirmatn,Tahoma,sans-serif; background:var(--bg); color:var(--text);
  font-size:14px; line-height:1.6; -webkit-font-smoothing:antialiased;
}
a { color:inherit; text-decoration:none; }
h1,h2,h3,h4 { margin:0; color:var(--text-strong); font-weight:700; }
.tnum { font-variant-numeric:tabular-nums; }
.muted { color:var(--muted); }
.faint { color:var(--faint); }
.strong { color:var(--text-strong); font-weight:700; }
.text-end { text-align:end; }
.nowrap { white-space:nowrap; }
::-webkit-scrollbar { width:10px; height:10px; }
::-webkit-scrollbar-thumb { background:var(--border); border-radius:99px; }

/* ---------- layout ---------- */
.scrim { position:fixed; inset:0; z-index:30; background:rgba(15,23,42,.55); backdrop-filter:blur(2px); display:none; }
.scrim.show { display:block; }

.sidebar {
  position:fixed; inset-block:0; inset-inline-start:0; width:256px; z-index:40;
  background:var(--side); display:flex; flex-direction:column;
  transform:translateX(100%); transition:transform .22s ease, width .22s ease;
}
html[dir="ltr"] .sidebar { transform:translateX(-100%); }
.sidebar.open { transform:none; }
.sidebar .brand { display:flex; align-items:center; gap:12px; height:64px; padding:0 20px; color:#fff; }
.sidebar .brand .logo { display:grid; place-items:center; width:38px; height:38px; border-radius:11px; background:var(--brand-600); font-size:18px; flex:none; }
.sidebar .brand img.logo { background:#fff; object-fit:contain; padding:3px; }
.sidebar .brand .name { font-weight:800; font-size:16px; white-space:nowrap; overflow:hidden; }
.nav { flex:1; overflow-y:auto; padding:10px 12px; }
.nav-section { padding:14px 12px 4px; font-size:11px; font-weight:700; letter-spacing:.04em; text-transform:uppercase; color:var(--side-muted); white-space:nowrap; overflow:hidden; }
.nav-link { display:flex; align-items:center; gap:11px; padding:10px 12px; margin:2px 0; border-radius:11px; color:var(--side-text); font-weight:500; transition:background .15s,color .15s; }
.nav-link i { font-size:18px; width:20px; text-align:center; flex:none; }
.nav-link .lbl { white-space:nowrap; overflow:hidden; }
.nav-link:hover { background:rgba(255,255,255,.06); color:#fff; }
.nav-link.active { background:var(--brand-600); color:#fff; box-shadow:var(--shadow-sm); }
.nav-foot { padding:12px; border-top:1px solid rgba(255,255,255,.06); }
.nav-foot .user { display:flex; align-items:center; gap:11px; padding:6px; }
.nav-foot .ava { display:grid; place-items:center; width:36px; height:36px; border-radius:50%; background:rgba(37,99,235,.2); color:#93c5fd; font-weight:700; flex:none; }
.nav-foot .uname { color:#fff; font-size:13px; font-weight:600; white-space:nowrap; overflow:hidden; }
.nav-foot .urole { color:var(--side-muted); font-size:12px; }

.shell { min-height:100%; transition:margin .22s ease; }
.topbar {
  position:sticky; top:0; z-index:20; height:64px; display:flex; align-items:center; justify-content:space-between;
  gap:12px; padding:0 16px; background:color-mix(in srgb,var(--surface) 85%, transparent);
  backdrop-filter:blur(10px); border-bottom:1px solid var(--border);
}
.topbar .tt { display:flex; align-items:center; gap:8px; }
.topbar h1 { font-size:17px; }
.topbar .ta { display:flex; align-items:center; gap:6px; }
.divider-v { width:1px; height:24px; background:var(--border); }
.main { max-width:1200px; margin:0 auto; padding:22px 16px; }

@media (min-width:1024px) {
  .sidebar { transform:none; }
  .shell { margin-inline-start:256px; }
  html.side-collapsed .sidebar { width:76px; }
  html.side-collapsed .sidebar .name, html.side-collapsed .nav-section, html.side-collapsed .nav-link .lbl, html.side-collapsed .nav-foot .uname, html.side-collapsed .nav-foot .urole { display:none; }
  html.side-collapsed .nav-link { justify-content:center; }
  html.side-collapsed .shell { margin-inline-start:76px; }
}
@media (min-width:768px) { .main { padding:24px; } }

/* ---------- cards ---------- */
.card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow); overflow:hidden; }
.card-body { padding:20px; }
@media (min-width:640px){ .card-body { padding:24px; } }
.card-head { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:16px 20px; border-bottom:1px solid var(--border-soft); }
.card-head h2,.card-head h3 { font-size:15px; }
.card-accent { height:6px; }
.card.danger-zone { border-color:rgba(225,29,72,.3); }

/* ---------- grids ---------- */
.grid { display:grid; gap:16px; }
.kpi-grid { display:grid; gap:16px; grid-template-columns:1fr; }
@media (min-width:640px){ .kpi-grid { grid-template-columns:repeat(2,1fr); } }
@media (min-width:1100px){ .kpi-grid { grid-template-columns:repeat(4,1fr); } }
.form-grid { display:grid; gap:18px 20px; grid-template-columns:1fr; }
@media (min-width:640px){ .form-grid { grid-template-columns:1fr 1fr; } }
.form-grid .col-full { grid-column:1/-1; }
.cols-3 { display:grid; gap:18px 20px; grid-template-columns:1fr; }
@media (min-width:768px){ .cols-3 { grid-template-columns:repeat(3,1fr); } }
.split { display:grid; gap:16px; grid-template-columns:1fr; }
@media (min-width:1024px){ .split { grid-template-columns:1fr 2fr; } .split.r { grid-template-columns:2fr 3fr; } }
.dash-grid { display:grid; gap:16px; grid-template-columns:1fr; }
@media (min-width:1024px){ .dash-grid { grid-template-columns:2fr 1fr; } }
.stack > * + * { margin-top:16px; }

/* ---------- flex helpers ---------- */
.flex { display:flex; align-items:center; gap:8px; }
.flex.wrap { flex-wrap:wrap; }
.between { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.grow { flex:1; min-width:0; }
.ms-auto { margin-inline-start:auto; }

/* ---------- buttons ---------- */
.btn { display:inline-flex; align-items:center; justify-content:center; gap:8px; padding:10px 16px; border:1px solid transparent;
  border-radius:12px; font:inherit; font-size:14px; font-weight:600; line-height:1; cursor:pointer; white-space:nowrap;
  transition:background .18s,border-color .18s,color .18s,box-shadow .18s,transform .05s; }
.btn:active { transform:translateY(1px); }
.btn:focus-visible { outline:none; box-shadow:0 0 0 3px var(--surface),0 0 0 5px var(--brand-500); }
.btn:disabled { opacity:.5; pointer-events:none; }
.btn i { font-size:15px; }
.btn--primary { background:var(--brand-600); color:#fff; box-shadow:var(--shadow-sm); }
.btn--primary:hover { background:var(--brand-700); }
.btn--soft { background:var(--brand-50); color:var(--brand-700); }
html.dark .btn--soft { background:rgba(37,99,235,.15); color:#93c5fd; }
.btn--soft:hover { background:var(--brand-100); }
.btn--outline { background:var(--surface); border-color:var(--border); color:var(--text); }
.btn--outline:hover { background:var(--surface-3); }
.btn--ghost { background:transparent; color:var(--muted); }
.btn--ghost:hover { background:var(--surface-3); color:var(--text); }
.btn--success { background:var(--ok); color:#fff; }
.btn--success:hover { filter:brightness(.95); }
.btn--danger { background:var(--danger); color:#fff; }
.btn--danger:hover { filter:brightness(.95); }
.btn--danger-soft { background:var(--danger-bg); color:var(--danger); }
.btn--sm { padding:7px 12px; font-size:13px; border-radius:10px; }
.icon-btn { display:inline-grid; place-items:center; width:36px; height:36px; border:none; background:transparent; color:var(--muted);
  border-radius:10px; cursor:pointer; transition:background .15s,color .15s; }
.icon-btn:hover { background:var(--surface-3); color:var(--text); }
.icon-btn.danger:hover { background:var(--danger-bg); color:var(--danger); }
.icon-btn i { font-size:17px; }

/* ---------- forms ---------- */
.field { display:block; }
.label { display:block; margin-bottom:6px; font-size:13px; font-weight:600; color:var(--text); }
.req { color:var(--danger); }
.input, select.input, textarea.input { width:100%; padding:10px 14px; font:inherit; font-size:14px; color:var(--text);
  background:var(--surface); border:1px solid var(--border); border-radius:12px; box-shadow:var(--shadow-sm);
  transition:border-color .15s,box-shadow .15s; }
textarea.input { resize:vertical; min-height:64px; }
.input:focus { outline:none; border-color:var(--brand-500); box-shadow:0 0 0 4px rgba(37,99,235,.12); }
.input.is-error { border-color:var(--danger); }
.input--sm { width:100%; padding:7px 10px; font:inherit; font-size:13px; color:var(--text); background:var(--surface);
  border:1px solid var(--border); border-radius:9px; }
.input--sm:focus { outline:none; border-color:var(--brand-500); box-shadow:0 0 0 3px rgba(37,99,235,.1); }
.help { margin-top:5px; font-size:12px; color:var(--muted); }
.err { margin-top:5px; font-size:12px; color:var(--danger); }
.check { display:flex; align-items:center; gap:10px; cursor:pointer; font-size:14px; }
.check input { width:18px; height:18px; accent-color:var(--brand-600); }
.switch { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px 14px; border:1px solid var(--border); border-radius:12px; }
.switch input { width:20px; height:20px; accent-color:var(--brand-600); }
input[type=file].file { width:100%; font-size:13px; color:var(--muted); }
input[type=file].file::file-selector-button { margin-inline-end:12px; padding:8px 12px; border:none; border-radius:9px; background:var(--brand-50); color:var(--brand-700); font:inherit; font-weight:600; cursor:pointer; }
html.dark input[type=file].file::file-selector-button { background:rgba(37,99,235,.15); color:#93c5fd; }

/* ---------- badges ---------- */
.badge { display:inline-flex; align-items:center; gap:5px; padding:3px 10px; border-radius:99px; font-size:12px; font-weight:600; border:1px solid transparent; }
.badge i { font-size:10px; }
.badge--blue { background:var(--info-bg); color:var(--info); border-color:rgba(37,99,235,.2); }
.badge--green { background:var(--ok-bg); color:var(--ok); border-color:rgba(5,150,105,.2); }
.badge--amber { background:var(--warn-bg); color:var(--warn); border-color:rgba(217,119,6,.25); }
.badge--rose { background:var(--danger-bg); color:var(--danger); border-color:rgba(225,29,72,.2); }
.badge--slate { background:var(--surface-3); color:var(--muted); border-color:var(--border); }

/* ---------- tables ---------- */
.table-wrap { overflow-x:auto; }
.table { width:100%; border-collapse:collapse; font-size:14px; }
.table thead th { padding:12px 16px; text-align:start; font-size:11px; font-weight:700; letter-spacing:.03em; text-transform:uppercase;
  color:var(--muted); border-bottom:1px solid var(--border); background:var(--surface-2); white-space:nowrap; }
.table tbody td { padding:14px 16px; border-bottom:1px solid var(--border-soft); vertical-align:middle; }
.table tbody tr { transition:background .12s; }
.table tbody tr:hover { background:var(--surface-2); }
.table tbody tr:last-child td { border-bottom:none; }
.table tfoot td { padding:14px 16px; border-top:2px solid var(--border); background:var(--surface-2); font-size:14px; vertical-align:middle; }
.table a.link { color:var(--brand-600); font-weight:600; }
html.dark .table a.link { color:#93c5fd; }
.table a.link:hover { text-decoration:underline; }
.avatar { display:grid; place-items:center; width:36px; height:36px; border-radius:50%; background:var(--brand-50); color:var(--brand-700); font-weight:700; font-size:13px; flex:none; }
html.dark .avatar { background:rgba(37,99,235,.15); color:#93c5fd; }
.thumb { width:42px; height:42px; border-radius:10px; border:1px solid var(--border); object-fit:contain; background:var(--surface); flex:none; }
.thumb-ph { display:grid; place-items:center; width:42px; height:42px; border-radius:10px; background:var(--surface-3); color:var(--faint); flex:none; }
.row-actions { display:flex; align-items:center; justify-content:flex-end; gap:2px; }
.cell-main { display:flex; align-items:center; gap:12px; }

/* ---------- kpi ---------- */
.kpi { display:flex; align-items:center; gap:16px; }
.kpi .ic { display:grid; place-items:center; width:50px; height:50px; border-radius:14px; flex:none; font-size:23px; }
.kpi .lbl { font-size:13px; color:var(--muted); }
.kpi .val { font-size:21px; font-weight:800; color:var(--text-strong); margin-top:2px; }
.kpi.t-blue .ic { background:var(--info-bg); color:var(--info); }
.kpi.t-green .ic { background:var(--ok-bg); color:var(--ok); }
.kpi.t-rose .ic { background:var(--danger-bg); color:var(--danger); }
.kpi.t-amber .ic { background:var(--warn-bg); color:var(--warn); }
.card.kpi-card { transition:transform .18s,box-shadow .18s; }
.card.kpi-card:hover { transform:translateY(-3px); box-shadow:var(--shadow-lg); }

/* ---------- misc ui ---------- */
.alert { display:flex; align-items:flex-start; gap:10px; padding:14px 16px; border-radius:12px; font-size:14px; margin-bottom:20px; border:1px solid transparent; }
.alert i { margin-top:2px; }
.alert--ok { background:var(--ok-bg); color:var(--ok); border-color:rgba(5,150,105,.25); }
.alert--err { background:var(--danger-bg); color:var(--danger); border-color:rgba(225,29,72,.25); }
.alert ul { margin:4px 0 0; padding-inline-start:20px; }
.empty { display:flex; flex-direction:column; align-items:center; gap:8px; padding:48px 16px; color:var(--faint); }
.empty i { font-size:40px; }
.page-back { display:inline-flex; align-items:center; gap:6px; font-size:13px; color:var(--muted); margin-bottom:16px; }
.page-back:hover { color:var(--brand-600); }
.toolbar { display:flex; flex-direction:column; gap:12px; padding:16px; border-bottom:1px solid var(--border-soft); }
@media (min-width:768px){ .toolbar { flex-direction:row; align-items:center; justify-content:space-between; } }
.actions { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.search { position:relative; }
.search i { position:absolute; inset-block:0; inset-inline-end:12px; display:flex; align-items:center; color:var(--faint); pointer-events:none; }
.search .input { padding-inline-end:38px; }
.summary { background:var(--surface-2); border-radius:14px; padding:16px; }
.summary .ln { display:flex; justify-content:space-between; padding:6px 0; font-size:14px; }
.summary .ln .k { color:var(--muted); }
.summary .total { display:flex; justify-content:space-between; align-items:center; margin-top:6px; padding-top:12px; border-top:1px solid var(--border); }
.summary .total .v { font-size:19px; font-weight:800; color:var(--brand-600); }
html.dark .summary .total .v { color:#93c5fd; }

/* pill tabs (invoice type filter) */
.pill-tabs { display:flex; flex-wrap:wrap; gap:6px; }
.pill { padding:7px 14px; border-radius:10px; font-size:13px; font-weight:600; color:var(--muted); }
.pill:hover { background:var(--surface-3); }
.pill.active { background:var(--brand-600); color:#fff; }

/* dropdown */
.dropdown { position:relative; }
.dropdown > summary { list-style:none; cursor:pointer; }
.dropdown > summary::-webkit-details-marker { display:none; }
.dropdown .menu { position:absolute; inset-inline-end:0; margin-top:8px; min-width:208px; background:var(--surface);
  border:1px solid var(--border); border-radius:12px; box-shadow:var(--shadow-lg); padding:6px; z-index:30; }
.dropdown .menu a { display:block; padding:9px 12px; border-radius:8px; font-size:14px; color:var(--text); }
.dropdown .menu a:hover { background:var(--surface-3); }

/* details disclosure */
details.disc > summary { list-style:none; cursor:pointer; }
details.disc > summary::-webkit-details-marker { display:none; }

/* ---------- pagination (custom Laravel view) ---------- */
.pagination { display:flex; flex-wrap:wrap; align-items:center; gap:4px; }
.pagination .pg { display:inline-grid; place-items:center; min-width:36px; height:36px; padding:0 10px; border-radius:10px;
  border:1px solid var(--border); background:var(--surface); color:var(--text); font-size:13px; font-weight:600; }
.pagination .pg:hover { background:var(--surface-3); }
.pagination .pg.active { background:var(--brand-600); border-color:var(--brand-600); color:#fff; }
.pagination .pg.disabled { opacity:.45; pointer-events:none; }
.pagination .dots { padding:0 6px; color:var(--faint); }
.product-thumb {background-color: #fff !important;}