@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800;900&display=swap');

:root {
  color-scheme: light;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --primary-ring: rgba(79, 70, 229, .16);
  --success: #059669;
  --success-bright: #10b981;
  --success-soft: #ecfdf5;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fef2f2;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --info: #0284c7;
  --info-soft: #f0f9ff;
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-muted: #f8fafc;
  --panel-raised: #ffffff;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --sidebar: #0f172a;
  --sidebar-muted: #94a3b8;
  --sidebar-hover: rgba(255,255,255,.07);
  --sidebar-active: rgba(99,102,241,.18);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .03);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, .08), 0 2px 6px rgba(15, 23, 42, .05);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, .16);
  --radius: .75rem;
  --radius-lg: 1rem;
  --sidebar-width: 17.5rem;
  --topbar-height: 4.5rem;
  --transition: 200ms cubic-bezier(.2,.8,.2,1);
  /* Compatibility aliases used by a few legacy inline presentation values. */
  --gold: var(--primary);
  --gold-hover: var(--primary-hover);
  --gold-light: var(--primary-soft);
  --gold-muted: #c7d2fe;
  --card: var(--panel);
  --border-light: var(--border);
  --text-primary: var(--text);
}

html.dark {
  color-scheme: dark;
  --primary: #818cf8;
  --primary-hover: #a5b4fc;
  --primary-soft: rgba(99,102,241,.14);
  --primary-ring: rgba(129,140,248,.2);
  --success: #34d399;
  --success-bright: #34d399;
  --success-soft: rgba(16,185,129,.12);
  --danger: #f87171;
  --danger-hover: #fca5a5;
  --danger-soft: rgba(239,68,68,.12);
  --warning: #fbbf24;
  --warning-soft: rgba(245,158,11,.12);
  --info: #38bdf8;
  --info-soft: rgba(14,165,233,.12);
  --bg: #0b1120;
  --panel: #111827;
  --panel-muted: #0f172a;
  --panel-raised: #172033;
  --text: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border: #263244;
  --border-strong: #3b475a;
  --sidebar: #070d19;
  --sidebar-muted: #94a3b8;
  --sidebar-hover: rgba(255,255,255,.06);
  --sidebar-active: rgba(129,140,248,.17);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.24);
  --shadow-md: 0 14px 30px rgba(0,0,0,.28);
  --shadow-lg: 0 28px 70px rgba(0,0,0,.42);
}

*, *::before, *::after { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  font-family: 'Vazirmatn', Tahoma, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: .925rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.nav-open { overflow: hidden; }

button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { transition: color var(--transition), background-color var(--transition), border-color var(--transition), box-shadow var(--transition), opacity var(--transition), transform var(--transition); }
a { color: inherit; }
img { max-width: 100%; }
hr { margin: 1.25rem 0; border: 0; border-top: 1px solid var(--border); }
code { direction: ltr; display: inline-block; border: 1px solid var(--border); border-radius: .45rem; padding: .08rem .4rem; background: var(--panel-muted); color: var(--text); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
::selection { background: rgba(79,70,229,.2); color: var(--text); }
::-webkit-scrollbar { width: .55rem; height: .55rem; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border: 2px solid transparent; border-radius: 999px; background-clip: padding-box; }

/* Application shell */
.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 80;
  display: flex;
  width: var(--sidebar-width);
  min-height: 100vh;
  flex-direction: column;
  overflow-y: auto;
  border-left: 1px solid rgba(255,255,255,.06);
  background: var(--sidebar);
  color: #fff;
}
.sidebar-brand { display: flex; min-height: 5.25rem; align-items: center; gap: .8rem; padding: 1rem 1.1rem; border-bottom: 1px solid rgba(255,255,255,.07); text-decoration: none; }
.sidebar-logo { width: 2.7rem; height: 2.7rem; flex: 0 0 auto; border-radius: .8rem; object-fit: cover; box-shadow: 0 8px 20px rgba(0,0,0,.26); }
.sidebar-brand-copy, .sidebar-account-copy, .user-chip-copy { display: grid; min-width: 0; line-height: 1.45; }
.sidebar-brand-copy strong { overflow: hidden; color: #fff; font-size: .94rem; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-brand-copy small { color: var(--sidebar-muted); font-size: .7rem; }
.sidebar-nav { display: grid; flex: 1; align-content: start; gap: 1.25rem; padding: 1.2rem .85rem; }
.nav-section { display: grid; gap: .25rem; }
.nav-section-label { padding: 0 .65rem .35rem; color: #64748b; font-size: .65rem; font-weight: 800; letter-spacing: .04em; }
.nav-link { display: flex; min-height: 2.65rem; align-items: center; gap: .75rem; padding: .6rem .7rem; border: 1px solid transparent; border-radius: .7rem; color: var(--sidebar-muted); text-decoration: none; font-size: .82rem; font-weight: 600; }
.nav-link svg { width: 1.08rem; height: 1.08rem; flex: 0 0 auto; stroke-width: 1.8; }
.nav-link:hover { background: var(--sidebar-hover); color: #fff; transform: translateX(-2px); }
.nav-link.active { border-color: rgba(129,140,248,.16); background: var(--sidebar-active); color: #c7d2fe; box-shadow: inset -3px 0 0 #818cf8; }
.sidebar-account { display: flex; align-items: center; gap: .65rem; padding: .85rem 1rem; border-top: 1px solid rgba(255,255,255,.07); background: rgba(0,0,0,.12); }
.sidebar-account-copy { flex: 1; }
.sidebar-account-copy strong { overflow: hidden; color: #f8fafc; font-size: .78rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-account-copy small { color: var(--sidebar-muted); font-size: .65rem; }
.app-workspace { display: flex; min-height: 100vh; margin-right: var(--sidebar-width); flex-direction: column; }

.topbar { position: sticky; top: 0; z-index: 60; display: flex; min-height: var(--topbar-height); align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem clamp(1rem, 2.5vw, 2rem); border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(16px); }
.topbar-start, .topbar-user { display: flex; align-items: center; gap: .65rem; }
.topbar-brand { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.topbar-logo { width: 2.2rem; height: 2.2rem; border-radius: .65rem; object-fit: cover; }
.topbar-title { color: var(--text); font-size: .86rem; font-weight: 800; white-space: nowrap; }
.topbar-nav { display: flex; flex: 1; align-items: center; justify-content: center; gap: .2rem; }
.topbar-nav a { display: inline-flex; align-items: center; gap: .4rem; min-height: 2.3rem; padding: .45rem .7rem; border-radius: .6rem; color: var(--text-muted); text-decoration: none; font-size: .72rem; font-weight: 700; }
.topbar-nav a:hover, .topbar-nav a.active { background: var(--primary-soft); color: var(--primary); }
.topbar-nav a svg { width: .95rem; height: .95rem; }
.topbar-page-title { display: grid; line-height: 1.4; }
.topbar-page-title span { color: var(--text-muted); font-size: .67rem; font-weight: 600; }
.topbar-page-title strong { color: var(--text); font-size: .98rem; font-weight: 800; }
.hamburger { display: none; }
.icon-button, .hamburger { width: 2.45rem; height: 2.45rem; align-items: center; justify-content: center; padding: 0; border: 1px solid var(--border); border-radius: .7rem; background: var(--panel); color: var(--text-secondary); cursor: pointer; box-shadow: var(--shadow-sm); }
.icon-button { display: inline-flex; }
.icon-button svg, .hamburger svg { width: 1.05rem; height: 1.05rem; stroke-width: 1.9; }
.icon-button:hover, .hamburger:hover { border-color: var(--border-strong); background: var(--panel-muted); color: var(--primary); transform: translateY(-1px); }
.danger-icon { border-color: transparent; background: transparent; color: #fca5a5; box-shadow: none; }
.danger-icon:hover { border-color: rgba(248,113,113,.2); background: rgba(248,113,113,.1); color: #fecaca; }
.theme-sun { display: none; }
html.dark .theme-sun { display: block; }
html.dark .theme-moon { display: none; }
.user-menu-wrap { position: relative; }
.user-chip { display: flex; align-items: center; gap: .65rem; min-height: 2.55rem; padding: .25rem .35rem .25rem .6rem; border: 1px solid var(--border); border-radius: .75rem; background: var(--panel); color: var(--text); cursor: pointer; box-shadow: var(--shadow-sm); }
.user-chip:hover { border-color: var(--border-strong); background: var(--panel-muted); }
.user-chip > svg { width: .9rem; height: .9rem; color: var(--text-muted); }
.user-avatar { display: inline-grid; width: 2rem; height: 2rem; flex: 0 0 auto; place-items: center; border-radius: .62rem; background: linear-gradient(145deg, var(--primary), #6366f1); color: #fff; font-size: .76rem; font-weight: 800; box-shadow: 0 5px 14px rgba(79,70,229,.22); }
.user-chip-copy { text-align: right; }
.user-chip-copy strong { max-width: 9rem; overflow: hidden; color: var(--text); font-size: .72rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.user-chip-copy small { color: var(--text-muted); font-size: .61rem; }
.user-dropdown-menu { position: absolute; top: calc(100% + .55rem); left: 0; z-index: 110; display: none; width: 15rem; overflow: hidden; border: 1px solid var(--border); border-radius: .85rem; background: var(--panel-raised); box-shadow: var(--shadow-lg); }
.user-dropdown-menu.show { display: block; animation: menuIn 160ms ease-out; }
@keyframes menuIn { from { opacity: 0; transform: translateY(-.3rem) scale(.98); } to { opacity: 1; transform: none; } }
.menu-info { padding: .85rem 1rem; border-bottom: 1px solid var(--border); }
.menu-info-name { color: var(--text); font-size: .83rem; font-weight: 800; }
.menu-info-role { color: var(--text-muted); font-size: .67rem; direction: ltr; text-align: right; }
.user-dropdown-menu a, .user-dropdown-menu button { display: flex; width: 100%; align-items: center; gap: .6rem; padding: .7rem 1rem; border: 0; background: transparent; color: var(--text-secondary); text-decoration: none; text-align: right; cursor: pointer; font-size: .76rem; font-weight: 600; }
.user-dropdown-menu a svg, .user-dropdown-menu button svg { width: .95rem; height: .95rem; }
.user-dropdown-menu a:hover, .user-dropdown-menu button:hover { background: var(--panel-muted); color: var(--text); }
.user-dropdown-menu .danger-item { color: var(--danger); }
.user-dropdown-menu .danger-item:hover { background: var(--danger-soft); color: var(--danger); }
.alert-bell { position: relative; text-decoration: none; }
.alert-bell.has-alerts { border-color: rgba(220,38,38,.2); background: var(--danger-soft); color: var(--danger); }
.alert-bell span { position: absolute; top: -.35rem; left: -.35rem; display: grid; min-width: 1.1rem; height: 1.1rem; place-items: center; padding: 0 .25rem; border: 2px solid var(--panel); border-radius: 999px; background: var(--danger); color: #fff; font-size: .56rem; font-weight: 800; line-height: 1; }

.mobile-nav { display: none; }

/* Main layout and page headers */
.main-content { width: 100%; max-width: 94rem; flex: 1 0 auto; margin: 0 auto; padding: clamp(1rem, 2.3vw, 2rem); animation: contentIn 220ms ease-out; }
@keyframes contentIn { from { opacity: 0; transform: translateY(.25rem); } to { opacity: 1; transform: none; } }
.main-content > * + * { margin-top: 1rem; }
.hero-card { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; min-height: 8.4rem; padding: clamp(1.15rem, 2.4vw, 1.8rem); border: 1px solid var(--border); border-radius: var(--radius-lg); background: linear-gradient(135deg, var(--panel) 0%, color-mix(in srgb, var(--primary-soft) 45%, var(--panel)) 100%); box-shadow: var(--shadow-sm); }
.hero-card > div:first-child { max-width: 48rem; }
.hero-card h1, .page-header h1 { margin: .2rem 0 .35rem; color: var(--text); font-size: clamp(1.35rem, 2vw, 1.8rem); font-weight: 900; letter-spacing: -.025em; line-height: 1.45; }
.hero-card p { margin: 0; color: var(--text-secondary); font-size: .83rem; line-height: 1.9; }
.eyebrow { display: inline-flex; align-items: center; gap: .4rem; color: var(--primary); font-size: .66rem; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.eyebrow::before { content: ''; width: .38rem; height: .38rem; border-radius: 999px; background: currentColor; box-shadow: 0 0 0 .25rem var(--primary-soft); }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.page-header h1 { margin: 0; }
.page-header-actions { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.page-header-actions .form-input { width: auto; min-width: 10.5rem; }
.back-link { display: inline-flex; align-items: center; gap: .4rem; color: var(--text-muted); text-decoration: none; font-size: .75rem; font-weight: 700; }
.back-link:hover { color: var(--primary); }
.back-link svg { width: 1rem; height: 1rem; transform: scaleX(-1); }
.section-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.section-title h2, .card-header h2 { margin: 0; color: var(--text); font-size: .98rem; font-weight: 800; }
.section-title p { margin: .15rem 0 0; color: var(--text-muted); font-size: .75rem; }
.pagination { margin-top: .75rem; }
.ledger-heading { margin: 1rem 0 .4rem; color: var(--text); font-size: .9rem; font-weight: 800; }

/* Cards and metrics */
.card { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--panel); box-shadow: var(--shadow-sm); }
.card:hover { border-color: color-mix(in srgb, var(--border-strong) 82%, var(--primary)); box-shadow: 0 4px 15px rgba(15,23,42,.045); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.15rem; border-bottom: 1px solid var(--border); background: var(--panel-muted); }
.card-body { padding: clamp(1rem, 2vw, 1.35rem); }
.management-section { margin-top: 1rem; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: .75rem; }
.stat-card { position: relative; overflow: hidden; min-height: 6.5rem; padding: 1rem 1.1rem; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--panel); box-shadow: var(--shadow-sm); }
.stat-card::after { content: ''; position: absolute; right: 0; bottom: 0; width: 3px; height: 100%; background: var(--primary); opacity: .75; }
.stat-card:nth-child(2n)::after { background: var(--success-bright); }
.stat-label { margin-bottom: .35rem; color: var(--text-muted); font-size: .7rem; font-weight: 700; }
.stat-value { color: var(--text); font-size: 1.45rem; font-weight: 900; line-height: 1.3; font-variant-numeric: tabular-nums; }
.stat-value.gold { color: var(--primary); }
.stat-card p { margin: .45rem 0 0; color: var(--text-muted); font-size: .71rem; line-height: 1.7; }
.compact-stats .stat-card { min-height: 5.7rem; }
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1rem; }
.admin-hub-grid { grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.hub-card { display: block; min-height: 9rem; text-decoration: none; }
.hub-card:hover { border-color: rgba(79,70,229,.35); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.hub-card .stat-value { font-size: 1.05rem; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem,1fr)); gap: .75rem; }
.detail-item { padding: .85rem; border: 1px solid var(--border); border-radius: .75rem; background: var(--panel-muted); }
.detail-label { color: var(--text-muted); font-size: .68rem; font-weight: 700; }
.detail-value { margin-top: .2rem; color: var(--text); font-size: 1rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Tables */
.table-wrapper { width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; -webkit-overflow-scrolling: touch; }
.table { width: 100%; min-width: 44rem; border-spacing: 0; border-collapse: separate; color: var(--text-secondary); font-size: .77rem; }
.professional-table { min-width: 58rem; }
.table th { position: relative; padding: .78rem .9rem; border-bottom: 1px solid var(--border-strong); background: var(--panel-muted); color: var(--text-muted); text-align: right; font-size: .67rem; font-weight: 800; letter-spacing: .025em; white-space: nowrap; }
.table th:not(:last-child)::after { content: ''; position: absolute; top: 28%; bottom: 28%; left: 0; width: 1px; background: var(--border); }
.table td { padding: .82rem .9rem; border-bottom: 1px solid var(--border); color: var(--text-secondary); vertical-align: middle; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table tbody tr:nth-child(even):not(.matched-row):not(.mismatch-row) td { background: color-mix(in srgb, var(--panel-muted) 58%, transparent); }
.table tbody tr:hover td { background: var(--primary-soft) !important; }
.table tbody tr:last-child td { border-bottom: 0; }
.table td:first-child, .table th:first-child { border-right: 3px solid transparent; }
.table tbody tr:hover td:first-child { border-right-color: var(--primary); }
.table td small { display: block; margin-top: .12rem; color: var(--text-muted); font-size: .63rem; }
.table .link, .link { color: var(--primary); text-decoration: none; font-weight: 800; }
.table .link:hover, .link:hover { color: var(--primary-hover); text-decoration: underline; text-underline-offset: .2rem; }
.matched-row td { background: var(--success-soft) !important; }
.matched-row td:first-child { border-right-color: var(--success-bright); }
.mismatch-row td { background: var(--danger-soft) !important; }
.mismatch-row td:first-child { border-right-color: var(--danger); }
.num, .num-cell { direction: ltr; text-align: center; font-variant-numeric: tabular-nums; }
.actions-cell { display: flex; align-items: center; gap: .4rem; }
.actions-cell form { display: inline-flex; margin: 0; }
.floating-table-header { position: fixed; z-index: 55; display: none; overflow: hidden; border-bottom: 1px solid var(--border-strong); background: var(--panel-muted); box-shadow: 0 .45rem 1rem rgba(15,23,42,.12); pointer-events: none; }
.floating-table-header.is-visible { display: block; }
.floating-table-header table { position: absolute; top: 0; left: 0; margin: 0; }
.floating-table-header th { box-sizing: border-box; background: var(--panel-muted); }
.assignment-tooltip { display: inline-grid; width: 1.75rem; height: 1.75rem; place-items: center; border: 1px solid var(--border); border-radius: .5rem; background: var(--panel-muted); color: var(--primary); cursor: help; outline: none; transition: border-color 200ms ease, background 200ms ease, color 200ms ease; }
.assignment-tooltip:hover, .assignment-tooltip:focus-visible { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-hover); }
.assignment-tooltip svg { width: .9rem; height: .9rem; }
.assignment-tooltip-content { display: none; }
.assignment-tooltip-popover { position: fixed; z-index: 180; display: grid; width: max-content; max-width: min(20rem,calc(100vw - 1rem)); gap: .2rem; padding: .65rem .75rem; border: 1px solid var(--border); border-radius: .65rem; background: var(--panel-raised); color: var(--text-secondary); box-shadow: var(--shadow-lg); direction: rtl; pointer-events: none; }
.assignment-tooltip-popover strong { color: var(--text); font-size: .68rem; }
.assignment-tooltip-popover span { max-width: 18rem; white-space: normal; font-size: .68rem; line-height: 1.7; }
.category-chip-list { display: flex; flex-wrap: wrap; gap: .55rem; }
.category-chip { display: inline-flex; align-items: center; gap: .45rem; padding: .45rem .65rem; border: 1px solid var(--border); border-radius: 999px; background: var(--panel-muted); color: var(--text-secondary); font-size: .72rem; font-weight: 800; }
.category-chip small { padding-inline-start: .45rem; border-inline-start: 1px solid var(--border); color: var(--text-muted); font-size: .62rem; }
.category-management-grid { display: grid; grid-template-columns: minmax(17rem,.75fr) minmax(0,1.4fr); gap: 1rem; align-items: start; }
.category-line-filter { width: min(15rem,100%); min-width: 11rem; }
.compact-log-table { min-width: 48rem; }
.log-summary { min-width: 15rem; white-space: normal !important; line-height: 1.65; }

/* Statistics dashboard */
.statistics-dashboard { gap: 1rem; }
.statistics-filters .form-row { grid-template-columns: repeat(6,minmax(9rem,1fr)); }
.analytics-kpis { grid-template-columns: repeat(4,minmax(0,1fr)); }
.analytics-kpis .stat-card { min-height: 7.6rem; }
.analytics-kpis .stat-card small { margin-top: auto; color: var(--text-muted); font-size: .64rem; line-height: 1.6; }
.analytics-alert-card { border-color: color-mix(in srgb,var(--danger) 45%,var(--border)); background: linear-gradient(135deg,var(--panel),var(--danger-soft)); }
.analytics-chart-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; }
.analytics-chart-card { min-width: 0; overflow: hidden; }
.chart-shell { position: relative; height: 22rem; padding: .75rem 1rem 1rem; direction: ltr; }
.chart-shell.compact-chart { height: 20rem; }
.analytics-table-grid { display: grid; grid-template-columns: minmax(0,1.25fr) minmax(0,.75fr); gap: 1rem; align-items: start; }
.analytics-table-grid .card { min-width: 0; }

/* Forms and controls */
.stacked-form { display: grid; gap: 1rem; }
.stacked-form .form-group { margin: 0; }
.form-group { min-width: 0; margin-bottom: 1rem; }
.form-label { display: block; margin-bottom: .4rem; color: var(--text-secondary); font-size: .73rem; font-weight: 800; }
.form-input, .form-select, .form-textarea { width: 100%; min-height: 2.65rem; padding: .62rem .78rem; border: 1px solid var(--border-strong); border-radius: .7rem; outline: 0; background: var(--panel); color: var(--text); direction: rtl; font-size: .78rem; box-shadow: 0 1px 1px rgba(15,23,42,.02); }
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); opacity: .72; }
.form-input:hover, .form-select:hover, .form-textarea:hover { border-color: color-mix(in srgb, var(--border-strong) 70%, var(--primary)); }
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.form-input:disabled, .form-select:disabled, .form-textarea:disabled, .form-input[readonly] { cursor: not-allowed; background: var(--panel-muted); color: var(--text-muted); opacity: .82; }
.form-textarea { min-height: 6rem; resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(11.5rem,1fr)); gap: 1rem; }
.inline-control-group { display: flex; align-items: center; gap: .4rem; }
.inline-control-group .form-input { flex: 1; }
.sale-lookup-message { display: block; min-height: 1.2rem; margin-top: .35rem; color: var(--text-muted); font-size: .68rem; }
.form-help, .form-hint, .muted-text { color: var(--text-muted); font-size: .7rem; line-height: 1.75; }
.form-hint { display: block; margin: -.1rem 0 .6rem; }
.check-row { display: flex; align-items: flex-start; gap: .55rem; min-height: 2.4rem; padding: .55rem .65rem; border: 1px solid var(--border); border-radius: .65rem; background: var(--panel-muted); color: var(--text-secondary); font-size: .75rem; font-weight: 600; cursor: pointer; }
.check-row:hover { border-color: var(--border-strong); background: var(--primary-soft); }
.check-row input { width: 1rem; height: 1rem; margin-top: .16rem; accent-color: var(--primary); }
.permission-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(11rem,1fr)); gap: .6rem; }
.permission-section + .permission-section { margin-top: 1.15rem; padding-top: 1.15rem; border-top: 1px solid var(--border); }
.permission-section h3 { margin: 0 0 .65rem; color: var(--text-secondary); font-size: .78rem; font-weight: 900; }
.assignment-grid { grid-template-columns: repeat(auto-fit,minmax(13rem,1fr)); }
.assignment-grid .check-row span { display: grid; gap: .1rem; }
.assignment-grid .check-row small { color: var(--text-muted); font-size: .64rem; font-weight: 600; }
.check-row.is-disabled { cursor: not-allowed; opacity: .55; }
.scope-switches { display: grid; grid-template-columns: repeat(auto-fit,minmax(13rem,1fr)); gap: .6rem; margin-bottom: 1rem; }
.access-matrix { border: 1px solid var(--border); border-radius: .8rem; }
.access-matrix .table { min-width: 42rem; }
.access-matrix td:not(:first-child), .access-matrix th:not(:first-child) { width: 8.5rem; text-align: center; }
.access-matrix input { width: 1rem; height: 1rem; accent-color: var(--primary); }
.dashboard-columns { grid-template-columns: repeat(auto-fit,minmax(9rem,1fr)); }
.sticky-form-actions { position: sticky; bottom: .8rem; z-index: 5; display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; width: fit-content; margin-right: auto; padding: .55rem; border: 1px solid var(--border); border-radius: .85rem; background: color-mix(in srgb,var(--panel) 92%,transparent); box-shadow: var(--shadow-md); backdrop-filter: blur(12px); }
.filter-form { display: block; }
.searchable { appearance: auto; }

.btn { display: inline-flex; min-height: 2.55rem; align-items: center; justify-content: center; gap: .45rem; padding: .58rem .95rem; border: 1px solid transparent; border-radius: .68rem; text-decoration: none; white-space: nowrap; cursor: pointer; font-size: .75rem; font-weight: 800; line-height: 1.4; }
.btn svg { width: .95rem; height: .95rem; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible, .icon-button:focus-visible, .hamburger:focus-visible, .user-chip:focus-visible, .password-toggle:focus-visible, .auth-text-button:focus-visible, .nav-link:focus-visible { outline: 3px solid var(--primary-ring); outline-offset: 2px; }
.btn-primary { border-color: var(--primary); background: var(--primary); color: #fff; box-shadow: 0 5px 14px rgba(79,70,229,.16); }
.btn-primary:hover { border-color: var(--primary-hover); background: var(--primary-hover); box-shadow: 0 8px 18px rgba(79,70,229,.23); }
html.dark .btn-primary { color: #0f172a; }
.btn-secondary { border-color: var(--border-strong); background: var(--panel); color: var(--text-secondary); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.btn-danger { border-color: var(--danger); background: var(--danger); color: #fff; }
.btn-danger:hover { border-color: var(--danger-hover); background: var(--danger-hover); }
.btn-outline { border-color: var(--primary); background: transparent; color: var(--primary); }
.btn-outline:hover { background: var(--primary-soft); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--panel-muted); color: var(--text); }
.btn-sm { min-height: 2rem; padding: .38rem .65rem; border-radius: .55rem; font-size: .68rem; }
.btn-icon { width: 2.3rem; padding: 0; }
.btn-block { width: 100%; }
.btn[disabled], button[disabled], .loading-disabled { cursor: not-allowed; opacity: .58; transform: none !important; }

/* Status, notifications and empty states */
.badge { display: inline-flex; min-height: 1.45rem; align-items: center; gap: .3rem; padding: .18rem .55rem; border: 1px solid transparent; border-radius: 999px; font-size: .63rem; font-weight: 800; white-space: nowrap; }
.badge-gold { border-color: rgba(79,70,229,.16); background: var(--primary-soft); color: var(--primary); }
.badge-success { border-color: rgba(16,185,129,.18); background: var(--success-soft); color: var(--success); }
.badge-danger { border-color: rgba(220,38,38,.18); background: var(--danger-soft); color: var(--danger); }
.badge-neutral { border-color: var(--border); background: var(--panel-muted); color: var(--text-muted); }
.alert { padding: .78rem .9rem; border: 1px solid var(--border); border-radius: .75rem; color: var(--text-secondary); font-size: .74rem; line-height: 1.8; }
.alert-info { border-color: color-mix(in srgb,var(--primary) 22%,var(--border)); background: var(--primary-soft); color: var(--primary); }
.alert-warning { border-color: rgba(217,119,6,.22); background: var(--warning-soft); color: var(--warning); }
.text-danger { color: var(--danger) !important; font-weight: 800; }
.text-success { color: var(--success) !important; font-weight: 800; }
.toast-container { position: fixed; top: 5rem; left: 1.25rem; z-index: 200; display: grid; gap: .55rem; width: min(23rem, calc(100vw - 2rem)); pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: .65rem; padding: .8rem .95rem; border: 1px solid var(--border); border-right-width: 3px; border-radius: .8rem; background: var(--panel-raised); color: var(--text-secondary); box-shadow: var(--shadow-lg); font-size: .76rem; font-weight: 600; animation: toastIn 220ms ease-out; }
.toast svg { width: 1.05rem; height: 1.05rem; flex: 0 0 auto; margin-top: .15rem; }
.toast.success { border-right-color: var(--success); }
.toast.success svg { color: var(--success); }
.toast.error { border-right-color: var(--danger); }
.toast.error svg { color: var(--danger); }
.toast.info { border-right-color: var(--info); }
.toast.info svg { color: var(--info); }
@keyframes toastIn { from { opacity: 0; transform: translateX(-.6rem); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(-.6rem); } }
.empty-state { padding: 3rem 1.25rem; color: var(--text-muted); text-align: center; }
.empty-state.compact { padding: 1.5rem; }
.empty-state h3 { margin: 0 0 .25rem; color: var(--text-secondary); font-size: .9rem; font-weight: 800; }
.empty-state p { margin: 0; font-size: .75rem; }
.notice-card { display: flex; align-items: flex-start; gap: .65rem; padding: .8rem .9rem; border: 1px solid var(--border); border-radius: .7rem; font-size: .74rem; }
.notice-card.warning { border-color: rgba(217,119,6,.22); background: var(--warning-soft); color: var(--warning); }

/* Dashboard-specific compact inputs */
.physical-form { display: grid; grid-template-columns: 5.2rem minmax(9rem,1fr) auto; align-items: center; gap: .38rem; min-width: 19rem; padding: .35rem; border: 1px solid var(--border); border-radius: .72rem; background: var(--panel-muted); }
.physical-form .compact-input { min-height: 2rem; padding: .36rem .5rem; font-size: .68rem; }
.physical-actions { display: flex; align-items: center; gap: .3rem; }
.physical-actions .btn { min-height: 2rem; }
.physical-form.is-locked { opacity: .76; }
.print-physical-note { display: none; }
.lent-alert { position: relative; display: inline-flex; width: 1.55rem; height: 1.55rem; align-items: center; justify-content: center; margin-inline-start: .4rem; border: 1px solid rgba(220,38,38,.18); border-radius: 999px; background: var(--danger-soft); color: var(--danger); text-decoration: none; font-size: .75rem; }
.lent-alert span { position: absolute; top: -.45rem; left: -.45rem; display: grid; min-width: 1rem; height: 1rem; place-items: center; padding: 0 .2rem; border-radius: 999px; background: var(--danger); color: #fff; font-size: .52rem; font-weight: 900; }
.item-name-actions { display: flex; align-items: center; gap: .35rem; }
.statement-link { display: inline-grid; width: 1.55rem; height: 1.55rem; flex: 0 0 auto; place-items: center; border: 1px solid var(--border); border-radius: .45rem; background: var(--panel-muted); color: var(--primary); transition: all 200ms ease; }
.statement-link:hover { border-color: var(--primary); background: var(--primary-soft); transform: translateY(-1px); }
.statement-link svg, .lent-alert svg { width: .85rem; height: .85rem; }
.stock-dashboard-table th.numeric-column, .stock-dashboard-table td.numeric-column { text-align: center; direction: ltr; font-variant-numeric: tabular-nums; }
.stock-dashboard-table th.item-column, .stock-dashboard-table td.item-column { min-width: 12rem; text-align: right; direction: rtl; }
.stock-dashboard-table td.numeric-column small { direction: rtl; }
.statement-table { min-width: 92rem; }
.opening-row td { background: var(--primary-soft) !important; font-weight: 700; }
.table-tools { display: flex; justify-content: flex-end; gap: .45rem; margin: .7rem .8rem 0; }
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .35rem; padding: 1rem; border-top: 1px solid var(--border); }
.page-link { display: inline-grid; min-width: 2.15rem; min-height: 2.15rem; place-items: center; padding: .35rem .6rem; border: 1px solid var(--border); border-radius: .55rem; background: var(--panel); color: var(--text-secondary); text-decoration: none; font-size: .7rem; font-weight: 800; transition: all 200ms ease; }
.page-link:hover, .page-link.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.page-link.is-disabled { pointer-events: none; opacity: .4; }
.page-ellipsis { color: var(--text-muted); }
.pagination-summary { margin-inline-start: .5rem; color: var(--text-muted); font-size: .68rem; }
.multi-ledger-row { display: grid; grid-template-columns: minmax(10rem,1fr) 8rem minmax(10rem,1fr) auto; align-items: end; gap: .65rem; margin-bottom: .7rem; padding: .7rem; border: 1px solid var(--border); border-radius: .75rem; background: var(--panel-muted); }
.document-line-row { display: grid; grid-template-columns: minmax(13rem,1fr) minmax(8rem,.35fr) auto; align-items: end; gap: .7rem; margin-bottom: .65rem; padding: .8rem; border: 1px solid var(--border); border-radius: .8rem; background: var(--panel-muted); }
.document-line-row .form-group, .document-line-row > div { margin: 0; }
.document-line-row > .icon-button { margin-bottom: .08rem; color: var(--danger); }
.document-type { display: inline-flex; align-items: center; gap: .4rem; color: var(--text); font-weight: 800; }
.document-type svg { width: .95rem; height: .95rem; color: var(--primary); }
.document-items-summary { min-width: 15rem; max-width: 24rem; white-space: normal !important; line-height: 1.75; }
.document-table { min-width: 78rem; }
.review-card { border-color: color-mix(in srgb, var(--primary) 32%, var(--border)); }
.timeline { position: relative; display: grid; gap: 1rem; padding-right: .35rem; }
.timeline::before { content: ''; position: absolute; top: .5rem; right: .72rem; bottom: .5rem; width: 1px; background: var(--border-strong); }
.timeline-item { position: relative; display: grid; grid-template-columns: 1.5rem 1fr; gap: .7rem; }
.timeline-dot { position: relative; z-index: 1; width: .75rem; height: .75rem; margin: .35rem .35rem 0 0; border: 2px solid var(--panel); border-radius: 999px; background: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.timeline-item strong { color: var(--text); font-size: .76rem; }
.timeline-item p { margin: .15rem 0; color: var(--text-secondary); font-size: .72rem; }
.timeline-item small { color: var(--text-muted); font-size: .65rem; }

/* Tabs and modals */
.tabs { display: flex; gap: .2rem; overflow-x: auto; margin-bottom: 1rem; padding: .25rem; border: 1px solid var(--border); border-radius: .7rem; background: var(--panel-muted); }
.tab-btn { display: inline-flex; min-height: 2.35rem; align-items: center; padding: .45rem .8rem; border: 0; border-radius: .52rem; background: transparent; color: var(--text-muted); text-decoration: none; cursor: pointer; font-size: .73rem; font-weight: 800; white-space: nowrap; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { background: var(--panel); color: var(--primary); box-shadow: var(--shadow-sm); }
.tab-content { display: none; }
.tab-content.active { display: block; }
.modal-overlay { position: fixed; inset: 0; z-index: 160; display: none; align-items: center; justify-content: center; padding: 1rem; background: rgba(2,6,23,.58); backdrop-filter: blur(5px); }
.modal-overlay.open { display: flex; }
.modal { width: min(100%, 31rem); max-height: 90vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 1rem; background: var(--panel-raised); box-shadow: var(--shadow-lg); animation: menuIn 180ms ease-out; }
.modal-header, .modal-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font-size: .95rem; font-weight: 800; }
.modal-body { padding: 1.1rem; }
.modal-footer { justify-content: flex-start; border-top: 1px solid var(--border); border-bottom: 0; }

/* Authentication and setup screens */
.auth-screen { display: grid; min-height: calc(100vh - 3.25rem); grid-template-columns: minmax(19rem, 36%) 1fr; direction: ltr; background: var(--bg); }
.auth-brand-side { position: relative; display: flex; overflow: hidden; flex-direction: column; justify-content: space-between; padding: clamp(2rem,5vw,4.5rem); background: linear-gradient(145deg, #111827 0%, #172033 55%, #312e81 135%); color: #fff; direction: rtl; }
.auth-brand-side::before, .auth-brand-side::after { content: ''; position: absolute; border: 1px solid rgba(255,255,255,.07); border-radius: 999px; }
.auth-brand-side::before { width: 25rem; height: 25rem; top: -13rem; left: -10rem; box-shadow: 0 0 0 4rem rgba(255,255,255,.018), 0 0 0 8rem rgba(255,255,255,.012); }
.auth-brand-side::after { width: 13rem; height: 13rem; right: -7rem; bottom: -6rem; background: rgba(79,70,229,.15); }
.auth-brand-mark { position: relative; z-index: 1; width: 4.3rem; height: 4.3rem; }
.auth-brand-mark img { width: 100%; height: 100%; display: block; border-radius: 1rem; object-fit: cover; box-shadow: 0 16px 38px rgba(0,0,0,.32); }
.auth-brand-side > div:last-child { position: relative; z-index: 1; }
.auth-brand-side p { margin: 0 0 .35rem; color: #a5b4fc; font-size: .74rem; font-weight: 800; }
.auth-brand-side h1 { max-width: 23rem; margin: 0 0 .8rem; color: #fff; font-size: clamp(1.75rem,3.6vw,3rem); font-weight: 900; line-height: 1.3; letter-spacing: -.03em; }
.auth-brand-side span { color: #cbd5e1; font-size: .82rem; }
.auth-form-side { display: grid; place-items: center; padding: clamp(1.5rem,6vw,5.5rem); background: var(--bg); direction: rtl; }
.auth-form-card { width: min(100%, 25rem); }
.setup-form-card { width: min(100%, 29rem); }
.auth-form-header { margin-bottom: 1.7rem; }
.auth-form-header h2 { margin: 0 0 .35rem; color: var(--text); font-size: 1.45rem; font-weight: 900; letter-spacing: -.02em; }
.auth-form-header p { margin: 0; color: var(--text-muted); font-size: .78rem; }
.login-form { display: grid; gap: 1rem; }
.login-form .form-group { margin: 0; }
.login-input { min-height: 3rem; background: var(--panel); direction: ltr; text-align: left; }
.login-security { padding: .75rem; border: 1px solid var(--border); border-radius: .8rem; background: var(--panel); }
.turnstile-box { display: flex; min-height: 4.1rem; align-items: center; justify-content: center; overflow: hidden; }
.auth-main-button { min-height: 3rem; }
.auth-text-button { border: 0; background: transparent; color: var(--text-muted); cursor: pointer; font-size: .73rem; font-weight: 700; }
.auth-text-button:hover { color: var(--primary); }
.auth-inline-notice { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin: -.5rem 0 1.25rem; padding: .7rem .8rem; border: 1px solid rgba(79,70,229,.18); border-right: 3px solid var(--primary); border-radius: .6rem; background: var(--primary-soft); color: var(--text-secondary); font-size: .7rem; }
.auth-inline-notice a { color: var(--primary); font-weight: 800; white-space: nowrap; }
.password-field { position: relative; }
.password-field .form-input { padding-left: 4.5rem; }
.password-toggle { position: absolute; top: 50%; left: .4rem; transform: translateY(-50%); padding: .35rem .6rem; border: 0; border-radius: .5rem; background: var(--primary-soft); color: var(--primary); cursor: pointer; font-size: .65rem; font-weight: 800; }
.otp-input { min-height: 3.9rem !important; padding-left: 0 !important; text-align: center !important; font-size: 1.6rem !important; font-weight: 900; letter-spacing: .55em; font-variant-numeric: tabular-nums; }
.login-shell, .auth-shell { display: grid; min-height: calc(100vh - 3.25rem); place-items: center; padding: 1.5rem; background: var(--bg); }
.login-page { display: grid; min-height: calc(100vh - 3.25rem); place-items: center; padding: 1.5rem; background: linear-gradient(145deg, var(--bg), var(--primary-soft)); }
.login-card { width: min(100%, 25rem); padding: 1.5rem; border: 1px solid var(--border); border-radius: 1rem; background: var(--panel); box-shadow: var(--shadow-md); }
.logo-icon { display: inline-grid; width: 3rem; height: 3rem; overflow: hidden; place-items: center; margin-bottom: .6rem; border-radius: .8rem; background: var(--primary); color: #fff; }
.logo-icon svg { width: 1.35rem; height: 1.35rem; }
.logo-icon img { width: 100%; height: 100%; object-fit: cover; }
.login-panel, .auth-panel { width: min(100%, 28rem); padding: 1.5rem; border: 1px solid var(--border); border-radius: 1rem; background: var(--panel); box-shadow: var(--shadow-md); }
.login-logo { margin-bottom: 1.25rem; text-align: center; }
.login-logo h1 { margin: .3rem 0; color: var(--text); font-size: 1.15rem; font-weight: 900; }
.login-logo p { margin: 0; color: var(--text-muted); font-size: .75rem; }
.login-kicker { display: inline-flex; padding: .2rem .55rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: .65rem; font-weight: 800; }
.login-brand-img { width: 4.8rem; height: 4.8rem; margin: 0 auto .7rem; border-radius: 1rem; object-fit: cover; }
.setup-success-icon { display: grid; width: 3.3rem; height: 3.3rem; place-items: center; margin: 0 auto .8rem; border-radius: 999px; background: var(--success-soft); color: var(--success); font-size: 1.5rem; font-weight: 900; }
.qr-card, .secret-card { display: grid; justify-items: center; gap: .55rem; margin-bottom: .8rem; padding: .8rem; border: 1px solid var(--border); border-radius: .8rem; background: var(--panel-muted); text-align: center; }
.qr-card img { border-radius: .55rem; }
.qr-card p, .secret-card span { margin: 0; color: var(--text-muted); font-size: .68rem; }
.secret-card code { max-width: 100%; overflow-wrap: anywhere; font-size: .85rem; }
.qr-panel { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem; border: 1px solid var(--border); border-radius: 1rem; background: var(--panel); }
.qr-panel img { width: 8rem; height: 8rem; border-radius: .7rem; }

/* Footer */
.site-footer { display: flex; min-height: 3.25rem; align-items: center; justify-content: center; gap: 1rem; padding: .7rem clamp(1rem,2.5vw,2rem); border-top: 1px solid var(--border); background: var(--panel); color: var(--text-muted); font-size: .65rem; }
.has-sidebar .site-footer { justify-content: space-between; }
.footer-brand { display: flex; align-items: center; gap: .4rem; font-weight: 700; }
.status-dot { width: .45rem; height: .45rem; border-radius: 999px; background: var(--success-bright); box-shadow: 0 0 0 .22rem var(--success-soft); }
.status-dot.online, .status-dot.offline { display: inline-block; margin-left: .45rem; }
.status-dot.offline { background: var(--text-muted); box-shadow: 0 0 0 .22rem color-mix(in srgb,var(--text-muted) 14%,transparent); }
.footer-powered { direction: rtl; }
.footer-powered a { color: var(--primary); text-decoration: none; font-weight: 700; }
.footer-powered a:hover { text-decoration: underline; }
.footer-copy { direction: ltr; }

/* Responsive */
@media (max-width: 1180px) {
  .statistics-filters .form-row { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .analytics-table-grid { grid-template-columns: 1fr; }
  .category-management-grid { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .app-workspace { margin-right: 0; }
  .hamburger { display: inline-flex; }
  .topbar-nav { display: none; }
  .mobile-nav { position: fixed; inset: 0; z-index: 150; display: none; }
  .mobile-nav.open { display: block; }
  .mobile-nav-backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(2,6,23,.62); backdrop-filter: blur(4px); cursor: pointer; }
  .mobile-nav-content { position: absolute; inset: 0 0 0 auto; width: min(21rem, 88vw); overflow-y: auto; border-left: 1px solid rgba(255,255,255,.06); background: var(--sidebar); color: #fff; box-shadow: var(--shadow-lg); animation: drawerIn 180ms ease-out; }
  @keyframes drawerIn { from { transform: translateX(100%); } to { transform: none; } }
  .mobile-nav-header { position: sticky; top: 0; z-index: 2; display: flex; min-height: 4.3rem; align-items: center; justify-content: space-between; padding: .8rem 1rem; border-bottom: 1px solid rgba(255,255,255,.07); background: color-mix(in srgb, var(--sidebar) 94%, transparent); color: #fff; font-size: .84rem; font-weight: 800; backdrop-filter: blur(12px); }
  .mobile-nav-header .icon-button { border-color: rgba(255,255,255,.1); background: rgba(255,255,255,.05); color: #fff; box-shadow: none; }
  .mobile-nav-content nav { display: grid; gap: 1.2rem; padding: 1rem .8rem; }
  .has-sidebar .site-footer { justify-content: space-between; }
}

@media (max-width: 820px) {
  .analytics-kpis { grid-template-columns: repeat(2,minmax(0,1fr)); }
  body { font-size: .88rem; }
  .main-content { padding: .9rem; }
  .hero-card { align-items: stretch; min-height: 0; flex-direction: column; gap: 1rem; }
  .page-header { align-items: stretch; flex-direction: column; }
  .page-header-actions { width: 100%; }
  .page-header-actions > * { flex: 1 1 auto; }
  .page-header-actions .form-input { width: 100%; }
  .admin-grid { grid-template-columns: 1fr; }
  .professional-table { min-width: 54rem; }
  .auth-screen { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-brand-side { min-height: 8rem; flex-direction: row; align-items: center; justify-content: flex-start; gap: 1rem; padding: 1.2rem; }
  .auth-brand-mark { width: 3.6rem; height: 3.6rem; flex: 0 0 auto; }
  .auth-brand-side h1 { margin-bottom: .1rem; font-size: 1.25rem; }
  .auth-brand-side span { font-size: .68rem; }
  .auth-form-side { align-items: start; padding: 2rem 1.15rem; }
  .multi-ledger-row { grid-template-columns: 1fr 7rem 1fr auto; }
}

@media (max-width: 600px) {
  .statistics-filters .form-row, .analytics-chart-grid { grid-template-columns: 1fr; }
  .chart-shell, .chart-shell.compact-chart { height: 18rem; padding: .5rem; }
  .category-line-filter { width: 100%; }
  .topbar { min-height: 4rem; padding: .55rem .7rem; }
  .topbar-page-title span { display: none; }
  .topbar-page-title strong { max-width: 8.5rem; overflow: hidden; font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
  .user-chip-copy, .user-chip > svg { display: none; }
  .user-chip { padding: .22rem; border: 0; background: transparent; box-shadow: none; }
  .stats-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .stat-card { min-height: 5.5rem; padding: .8rem; }
  .stat-value { font-size: 1.15rem; }
  .form-row, .permission-grid, .multi-ledger-row, .document-line-row { grid-template-columns: 1fr; }
  .scope-switches { grid-template-columns: 1fr; }
  .sticky-form-actions { position: static; width: 100%; }
  .sticky-form-actions .btn { flex: 1 1 12rem; }
  .multi-ledger-row .btn { width: 100%; }
  .physical-form { grid-template-columns: 4.5rem minmax(8rem,1fr); min-width: 16rem; }
  .physical-actions { grid-column: 1 / -1; }
  .physical-actions .btn { flex: 1; }
  .toast-container { top: 4.6rem; left: 1rem; }
  .site-footer, .has-sidebar .site-footer { flex-wrap: wrap; justify-content: center; gap: .35rem .8rem; text-align: center; }
  .footer-brand { width: 100%; justify-content: center; }
  .qr-panel { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr; }
  .theme-toggle { display: none; }
}

/* Print */
@media print {
  :root { --bg: #fff; --panel: #fff; --text: #111827; --text-secondary: #334155; --text-muted: #64748b; --border: #d1d5db; }
  body { background: #fff; color: #111827; font-size: 10px; }
  .sidebar, .topbar, .site-footer, .page-header-actions, .no-print, .back-link, .tabs, .btn, .toast-container, .mobile-nav { display: none !important; }
  .app-workspace { margin: 0; }
  .main-content { max-width: none; padding: 0; }
  .hero-card { min-height: 0; margin-bottom: .7rem; padding: .7rem; border: 0; box-shadow: none; }
  .hero-card p, .eyebrow, .stats-grid { display: none; }
  .card { border-color: #d1d5db; box-shadow: none; }
  .table { min-width: 100%; font-size: 9px; }
  .table th, .table td { padding: 5px 6px; }
  .table th { background: #f1f5f9 !important; color: #334155; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .matched-row td { background: #ecfdf5 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .mismatch-row td { background: #fef2f2 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-physical-note { display: inline; }
}
