:root {
  --navy-950: #0b1624;
  --navy-900: #112033;
  --navy-800: #172b43;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --cyan-500: #06b6d4;
  --emerald-600: #059669;
  --emerald-500: #10b981;
  --amber-500: #f59e0b;
  --red-500: #ef4444;
  --purple-500: #8b5cf6;
  --slate-900: #172033;
  --slate-700: #3a475c;
  --slate-600: #5d6a7d;
  --slate-500: #7c8899;
  --slate-400: #a7b0bd;
  --slate-300: #ced5df;
  --slate-200: #e5e9ef;
  --slate-100: #f1f4f8;
  --slate-50: #f7f9fc;
  --white: #ffffff;
  --sidebar-width: 248px;
  --filing-height: 34px;
  --shadow-sm: 0 1px 2px rgba(10, 22, 38, .05), 0 1px 5px rgba(10, 22, 38, .04);
  --shadow-md: 0 14px 32px rgba(11, 24, 41, .10);
  --radius: 12px;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--slate-50); }

body {
  margin: 0;
  padding-bottom: var(--filing-height);
  color: var(--slate-900);
  background: var(--slate-50);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg { display: block; }

.app-shell { min-height: calc(100vh - var(--filing-height)); }

.sidebar {
  position: fixed;
  inset: 0 auto var(--filing-height) 0;
  z-index: 40;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  color: #dbe6f4;
  background:
    radial-gradient(circle at 12% 3%, rgba(59, 130, 246, .18), transparent 29%),
    linear-gradient(180deg, var(--navy-900), var(--navy-950));
  box-shadow: 8px 0 24px rgba(6, 16, 30, .08);
  transition: transform .24s ease;
}

.brand {
  height: 76px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 11px;
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(135deg, #3b82f6, #0ea5e9);
  box-shadow: 0 8px 22px rgba(37, 99, 235, .28);
}
.brand-logo { width: 38px; height: 38px; flex: 0 0 auto; object-fit: contain; filter: drop-shadow(0 7px 16px rgba(207,157,62,.22)); }

.brand b { display: block; color: #fff; font-size: 15px; letter-spacing: .02em; white-space: nowrap; }
.brand small { display: block; margin-top: 1px; color: #8fa3bc; font-size: 12px; }

#sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 12px 24px; scrollbar-width: thin; }
.nav-group + .nav-group { margin-top: 15px; }
.nav-group-title { padding: 0 12px 7px; color: #6f829b; font-size: 12px; font-weight: 700; letter-spacing: .08em; }

.nav-item {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  color: #aebed0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  transition: color .16s, background .16s, transform .16s;
}

.nav-item:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.nav-item:active { transform: translateY(1px); }
.nav-item.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(37, 99, 235, .95), rgba(14, 165, 233, .72));
  box-shadow: 0 8px 18px rgba(37, 99, 235, .18);
}
.nav-icon { width: 19px; height: 19px; flex: 0 0 auto; }
.nav-label { flex: 1; font-size: 14px; font-weight: 600; }
.nav-badge { min-width: 20px; padding: 1px 6px; border-radius: 999px; color: #fff; background: var(--red-500); font-size: 11px; text-align: center; }

.sidebar-foot {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 22px;
  color: #8194ab;
  border-top: 1px solid rgba(255,255,255,.07);
  font-size: 12px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--emerald-500); box-shadow: 0 0 0 4px rgba(16,185,129,.12); }

.main-area { min-height: calc(100vh - var(--filing-height)); margin-left: var(--sidebar-width); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 13px 28px;
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--slate-200);
  backdrop-filter: blur(14px);
}
.page-heading { min-width: 0; }
.page-heading h1 { margin: 0; font-size: 20px; line-height: 1.3; letter-spacing: -.01em; }
.page-heading p { margin: 3px 0 0; color: var(--slate-500); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.date-chip, .icon-button, .profile-button, .mobile-menu {
  min-height: 38px;
  border: 1px solid var(--slate-200);
  border-radius: 9px;
  color: var(--slate-700);
  background: #fff;
}
.date-chip { padding: 0 13px; font-size: 13px; font-weight: 600; }
.organization-chip { max-width: 260px; overflow: hidden; color: #7a5418; border-color: #ead7ae; background: #fffaf0; text-overflow: ellipsis; white-space: nowrap; }
.icon-button { position: relative; width: 38px; padding: 0; display: grid; place-items: center; }
.notify-dot { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--red-500); border: 2px solid white; }
.profile-button { display: flex; align-items: center; gap: 8px; padding: 4px 9px 4px 5px; font-size: 13px; }
.avatar { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; color: #fff; background: linear-gradient(135deg, #1d4ed8, #0891b2); font-weight: 700; }
.mobile-menu { display: none; width: 38px; padding: 0; font-size: 20px; }

.content { max-width: 1680px; margin: 0 auto; padding: 24px 28px 48px; }
.loading-card { padding: 52px; border: 1px solid var(--slate-200); border-radius: var(--radius); color: var(--slate-500); background: #fff; text-align: center; }
.demo-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 16px;
  padding: 10px 13px;
  color: #67420a;
  border: 1px solid #f8d990;
  border-radius: 9px;
  background: #fff9e9;
  font-size: 13px;
}
.demo-banner b { font-weight: 700; }
.demo-banner > span { width: 18px; height: 18px; flex: 0 0 auto; }
.demo-banner svg, .alert-symbol svg { width: 17px; height: 17px; }

.hero-strip {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 138px;
  padding: 24px 28px;
  color: #fff;
  border-radius: 15px;
  background:
    radial-gradient(circle at 88% 10%, rgba(6, 182, 212, .42), transparent 36%),
    linear-gradient(120deg, #10223a 5%, #183e68 62%, #145671 100%);
  box-shadow: var(--shadow-md);
}
.hero-strip::after { content: ""; position: absolute; right: -70px; bottom: -115px; width: 260px; height: 260px; border: 1px solid rgba(255,255,255,.13); border-radius: 50%; box-shadow: 0 0 0 34px rgba(255,255,255,.03), 0 0 0 68px rgba(255,255,255,.025); }
.hero-copy { position: relative; z-index: 1; }
.hero-eyebrow { color: #99cced; font-size: 13px; font-weight: 700; }
.hero-copy h2 { margin: 6px 0 5px; font-size: clamp(21px, 2.2vw, 30px); font-weight: 750; letter-spacing: -.03em; }
.hero-copy p { margin: 0; color: #b9ccdf; font-size: 14px; }
.hero-actions { position: relative; z-index: 1; display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.hero-button { min-height: 41px; padding: 0 15px; border: 1px solid rgba(255,255,255,.18); border-radius: 9px; color: #fff; background: rgba(255,255,255,.10); font-weight: 650; }
.hero-button.primary { color: #113050; background: #fff; border-color: #fff; }

.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(150px, 1fr)); gap: 14px; margin-top: 17px; }
.metric-card {
  position: relative;
  min-width: 0;
  padding: 17px 17px 15px;
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.metric-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.metric-label { color: var(--slate-600); font-size: 13px; font-weight: 600; }
.metric-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; }
.metric-icon svg { width: 17px; height: 17px; }
.metric-card.income .metric-icon { color: var(--emerald-600); background: #e9fbf4; }
.metric-card.expense .metric-icon { color: var(--red-500); background: #fff0f1; }
.metric-card.asset .metric-icon { color: var(--blue-600); background: #eef4ff; }
.metric-card.receivable .metric-icon { color: var(--amber-500); background: #fff8e7; }
.metric-card.payable .metric-icon { color: var(--purple-500); background: #f5f0ff; }
.metric-card.stock .metric-icon { color: var(--cyan-500); background: #e9fbff; }
.metric-value { margin-top: 9px; font-size: 23px; font-weight: 760; letter-spacing: -.025em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.metric-meta { margin-top: 5px; color: var(--slate-500); font-size: 12px; }
.trend-up { color: var(--emerald-600); }
.trend-down { color: var(--red-500); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, .9fr); gap: 17px; margin-top: 17px; }
.panel { border: 1px solid var(--slate-200); border-radius: 12px; background: #fff; box-shadow: var(--shadow-sm); }
.panel + .panel { margin-top: 17px; }
.panel-header { min-height: 57px; display: flex; align-items: center; gap: 12px; padding: 12px 17px; border-bottom: 1px solid var(--slate-200); }
.panel-title { margin: 0; font-size: 15px; font-weight: 720; }
.panel-subtitle { margin: 2px 0 0; color: var(--slate-500); font-size: 12px; }
.panel-header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.panel-body { padding: 17px; }

.chart-wrap { min-height: 250px; display: flex; flex-direction: column; }
.chart-legend { display: flex; justify-content: flex-end; gap: 17px; color: var(--slate-600); font-size: 12px; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 9px; height: 9px; border-radius: 3px; }
.legend-swatch.income { background: var(--blue-500); }
.legend-swatch.expense { background: #c7d2e5; }
.bar-chart { flex: 1; display: flex; align-items: stretch; gap: 11px; padding: 22px 3px 2px; border-bottom: 1px solid var(--slate-200); background: repeating-linear-gradient(to bottom, transparent 0, transparent 48px, #edf0f5 49px); }
.bar-month { min-width: 0; flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 7px; }
.bar-pair { height: 175px; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.bar { width: min(13px, 40%); min-height: 2px; border-radius: 4px 4px 1px 1px; transition: height .3s ease; }
.bar.income { background: linear-gradient(180deg, #60a5fa, #2563eb); }
.bar.expense { background: #c7d2e5; }
.bar-label { color: var(--slate-500); font-size: 11px; }

.quick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.quick-action { min-height: 82px; display: flex; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--slate-200); border-radius: 10px; color: var(--slate-700); background: #fff; text-align: left; transition: border-color .16s, box-shadow .16s, transform .16s; }
.quick-action:hover { border-color: #a9c5fa; box-shadow: 0 7px 18px rgba(37,99,235,.09); transform: translateY(-1px); }
.quick-action-icon { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 10px; color: var(--blue-600); background: #eef4ff; }
.quick-action-icon svg { width: 20px; height: 20px; }
.quick-action b { display: block; font-size: 13px; }
.quick-action small { display: block; margin-top: 3px; color: var(--slate-500); font-size: 11px; }

.alert-list { display: grid; gap: 10px; }
.alert-item { display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: 9px; background: var(--slate-50); }
.alert-symbol { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 8px; color: var(--amber-500); background: #fff5d8; }
.alert-copy { min-width: 0; flex: 1; }
.alert-copy b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alert-copy small { color: var(--slate-500); font-size: 11px; }
.alert-number { color: var(--red-500); font-size: 12px; font-weight: 700; }

.page-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar-spacer { flex: 1; }
.button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 13px; border: 1px solid var(--slate-300); border-radius: 8px; color: var(--slate-700); background: #fff; font-size: 13px; font-weight: 650; transition: all .15s; }
.button:hover { border-color: var(--blue-500); color: var(--blue-600); }
.button.primary { color: #fff; border-color: var(--blue-600); background: var(--blue-600); box-shadow: 0 5px 12px rgba(37,99,235,.18); }
.button.primary:hover { color: #fff; background: #1d4ed8; }
.button.success { color: #fff; border-color: var(--emerald-600); background: var(--emerald-600); }
.button.danger { color: var(--red-500); border-color: #fecaca; background: #fff5f5; }
.button.ghost { border-color: transparent; background: transparent; }
.button.small { min-height: 30px; padding: 0 9px; font-size: 12px; }
.button svg { width: 16px; height: 16px; }
.button:disabled { cursor: not-allowed; opacity: .55; }

.search-box { position: relative; min-width: 240px; }
.search-box svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; color: var(--slate-400); transform: translateY(-50%); }
.search-box input { width: 100%; height: 38px; padding: 0 12px 0 35px; border: 1px solid var(--slate-300); border-radius: 8px; outline: none; background: #fff; }
.search-box input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(59,130,246,.11); }
.filter-select { height: 38px; padding: 0 32px 0 11px; border: 1px solid var(--slate-300); border-radius: 8px; color: var(--slate-700); background: #fff; }

.filter-tabs { display: inline-flex; gap: 3px; padding: 3px; border-radius: 9px; background: var(--slate-100); }
.filter-tab { min-height: 31px; padding: 0 11px; border: 0; border-radius: 7px; color: var(--slate-600); background: transparent; font-size: 12px; font-weight: 650; }
.filter-tab.active { color: var(--blue-600); background: #fff; box-shadow: var(--shadow-sm); }

.table-card { overflow: hidden; border: 1px solid var(--slate-200); border-radius: 12px; background: #fff; box-shadow: var(--shadow-sm); }
.table-scroll { overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 900px; }
.data-table th { height: 43px; padding: 0 13px; color: var(--slate-600); background: #f8fafc; border-bottom: 1px solid var(--slate-200); font-size: 12px; font-weight: 700; text-align: left; white-space: nowrap; }
.data-table td { height: 48px; padding: 7px 13px; border-bottom: 1px solid #edf0f4; color: var(--slate-700); font-size: 13px; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: #fbfcfe; }
.data-table .number { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .muted { color: var(--slate-500); }
.data-table .strong { color: var(--slate-900); font-weight: 650; }
.data-table .link { color: var(--blue-600); font-weight: 650; }
.table-footer { min-height: 48px; display: flex; align-items: center; gap: 12px; padding: 8px 13px; border-top: 1px solid var(--slate-200); color: var(--slate-500); font-size: 12px; }
.table-footer .button { margin-left: auto; }

.badge { display: inline-flex; align-items: center; justify-content: center; min-height: 24px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge.income, .badge.success, .badge.paid, .badge.posted { color: #047857; background: #e8fbf4; }
.badge.expense, .badge.danger, .badge.low, .badge.void { color: #dc2626; background: #fff0f1; }
.badge.transfer, .badge.info { color: #2563eb; background: #edf4ff; }
.badge.warning, .badge.partial { color: #a16207; background: #fff7dd; }
.badge.neutral, .badge.unpaid, .badge.draft { color: #667085; background: #f0f2f5; }
.amount-income { color: var(--emerald-600); font-weight: 700; }
.amount-expense { color: var(--red-500); font-weight: 700; }

.summary-row { display: grid; grid-template-columns: repeat(4, minmax(170px, 1fr)); gap: 13px; margin-bottom: 16px; }
.summary-box { padding: 16px; border: 1px solid var(--slate-200); border-radius: 11px; background: #fff; box-shadow: var(--shadow-sm); }
.summary-box span { color: var(--slate-500); font-size: 12px; }
.summary-box b { display: block; margin-top: 6px; font-size: 21px; font-variant-numeric: tabular-nums; }

.account-grid { display: grid; grid-template-columns: repeat(4, minmax(210px, 1fr)); gap: 14px; }
.account-card { position: relative; overflow: hidden; padding: 18px; min-height: 130px; border-radius: 13px; color: #fff; background: linear-gradient(135deg, #1d4ed8, #0f77a8); box-shadow: var(--shadow-md); }
.account-card:nth-child(2n) { background: linear-gradient(135deg, #0f766e, #0d9488); }
.account-card:nth-child(3n) { background: linear-gradient(135deg, #4338ca, #7c3aed); }
.account-card:nth-child(4n) { background: linear-gradient(135deg, #374151, #111827); }
.account-card::after { content: ""; position: absolute; width: 125px; height: 125px; right: -40px; bottom: -55px; border-radius: 50%; border: 18px solid rgba(255,255,255,.08); }
.account-card small { color: rgba(255,255,255,.72); }
.account-card h3 { margin: 16px 0 2px; font-size: 25px; font-variant-numeric: tabular-nums; }
.account-card p { margin: 0; color: rgba(255,255,255,.72); font-size: 12px; }

.inventory-name { display: flex; align-items: center; gap: 10px; }
.product-avatar { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; color: var(--blue-600); background: #eef4ff; font-weight: 800; }
.inventory-name b { display: block; }
.inventory-name small { display: block; color: var(--slate-500); font-size: 11px; }
.stock-progress { width: 100%; min-width: 100px; }
.stock-track { height: 6px; overflow: hidden; border-radius: 999px; background: var(--slate-100); }
.stock-fill { height: 100%; border-radius: inherit; background: var(--emerald-500); }
.stock-fill.low { background: var(--red-500); }
.stock-progress small { display: block; margin-top: 4px; color: var(--slate-500); font-size: 11px; }

.empty-state { padding: 48px 20px; color: var(--slate-500); text-align: center; }
.empty-icon { width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto 12px; border-radius: 15px; color: var(--slate-400); background: var(--slate-100); }
.empty-icon svg { width: 25px; height: 25px; }
.empty-state h3 { margin: 0 0 5px; color: var(--slate-700); font-size: 15px; }
.empty-state p { margin: 0; font-size: 13px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 22px; background: rgba(8,18,32,.52); backdrop-filter: blur(3px); }
.modal { width: min(720px, 100%); max-height: min(88vh, 900px); display: flex; flex-direction: column; overflow: hidden; border-radius: 14px; background: #fff; box-shadow: 0 28px 80px rgba(2,12,27,.28); animation: modal-in .18s ease-out; }
.modal.wide { width: min(980px, 100%); }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-header { min-height: 62px; display: flex; align-items: center; gap: 12px; padding: 13px 19px; border-bottom: 1px solid var(--slate-200); }
.modal-header h2 { margin: 0; font-size: 17px; }
.modal-header p { margin: 2px 0 0; color: var(--slate-500); font-size: 12px; }
.modal-close { margin-left: auto; width: 34px; height: 34px; border: 0; border-radius: 8px; color: var(--slate-500); background: var(--slate-100); font-size: 20px; }
.modal-body { overflow-y: auto; padding: 19px; }
.modal-footer { min-height: 62px; display: flex; align-items: center; justify-content: flex-end; gap: 9px; padding: 12px 19px; border-top: 1px solid var(--slate-200); background: #fbfcfd; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field.full { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: 6px; color: var(--slate-700); font-size: 12px; font-weight: 700; }
.required::after { content: " *"; color: var(--red-500); }
.field input, .field select, .field textarea { width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--slate-300); border-radius: 8px; color: var(--slate-900); background: #fff; outline: none; }
.field textarea { min-height: 76px; resize: vertical; }
.field-help { margin-top: 5px; color: var(--slate-500); font-size: 11px; }
.form-section-title { grid-column: 1 / -1; margin: 3px 0 -4px; padding-bottom: 7px; border-bottom: 1px solid var(--slate-200); font-size: 13px; font-weight: 750; }
.transfer-fee-panel.full { grid-column: 1 / -1; padding: 13px 14px; border: 1px solid #dbe5f2; border-radius: 10px; background: #f8fbff; }
.transfer-fee-toggle { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.transfer-fee-toggle input { width: 17px; min-height: 17px; margin: 2px 0 0; accent-color: var(--blue-600); }
.transfer-fee-toggle span { display: grid; gap: 3px; }
.transfer-fee-toggle b { color: var(--slate-800); font-size: 13px; }
.transfer-fee-toggle small { color: var(--slate-500); font-size: 11px; line-height: 1.5; }
.transfer-fee-details { margin-top: 13px; padding-top: 13px; border-top: 1px dashed #cbd9ea; }
.transfer-fee-summary { color: #b45309; font-size: 11px; font-weight: 650; line-height: 1.55; }

.line-items { margin-top: 16px; border: 1px solid var(--slate-200); border-radius: 10px; overflow: hidden; }
.line-items-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: var(--slate-50); border-bottom: 1px solid var(--slate-200); }
.line-items-header b { font-size: 13px; }
.line-row { display: grid; grid-template-columns: minmax(180px, 2fr) 110px 120px 120px 32px; align-items: end; gap: 9px; padding: 11px; border-bottom: 1px solid var(--slate-200); }
.line-row:last-child { border-bottom: 0; }
.line-row .field label { font-size: 11px; }
.remove-line { width: 32px; height: 40px; border: 0; border-radius: 7px; color: var(--red-500); background: #fff1f2; }
.line-total { padding: 11px 12px; color: var(--slate-700); background: #fbfcfd; text-align: right; font-size: 13px; }
.line-total b { margin-left: 9px; font-size: 18px; }

.report-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.horizontal-bars { display: grid; gap: 13px; }
.hbar-row { display: grid; grid-template-columns: 96px 1fr 88px; align-items: center; gap: 10px; }
.hbar-label { color: var(--slate-600); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 9px; overflow: hidden; border-radius: 99px; background: var(--slate-100); }
.hbar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #3b82f6, #06b6d4); }
.hbar-value { color: var(--slate-700); text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; }

.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(230px, 1fr)); gap: 15px; }
.settings-card { padding: 17px; border: 1px solid var(--slate-200); border-radius: 11px; background: #fff; box-shadow: var(--shadow-sm); }
.settings-card-head { display: flex; align-items: center; gap: 11px; }
.settings-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; color: var(--blue-600); background: #eef4ff; }
.settings-icon svg { width: 20px; height: 20px; }
.settings-card h3 { margin: 0; font-size: 14px; }
.settings-card p { margin: 3px 0 0; color: var(--slate-500); font-size: 11px; }
.settings-card-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--slate-200); }
.settings-card-actions span { color: var(--slate-500); font-size: 12px; }

.login-page { min-height: calc(100vh - var(--filing-height)); display: grid; grid-template-columns: minmax(430px, 1.25fr) minmax(420px, .75fr); background: #fff; }

.site-filing {
  position: fixed;
  inset: auto 0 0;
  z-index: 80;
  min-height: var(--filing-height);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 14px;
  color: #748094;
  background: rgba(255, 255, 255, .96);
  border-top: 1px solid var(--slate-200);
  box-shadow: 0 -4px 16px rgba(11, 24, 41, .035);
  backdrop-filter: blur(10px);
  font-size: 12px;
  line-height: 1.4;
}

.site-filing a { padding: 3px 8px; text-decoration: none; }
.site-filing a:hover { color: var(--blue-600); text-decoration: underline; }
.login-visual { position: relative; overflow: hidden; display: flex; align-items: center; padding: 8vw; color: #fff; background: radial-gradient(circle at 85% 14%, rgba(220,174,79,.23), transparent 32%), linear-gradient(135deg, #0d0c0a, #292116); }
.login-visual::after { content: ""; position: absolute; width: 520px; height: 520px; right: -250px; bottom: -220px; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; box-shadow: 0 0 0 65px rgba(255,255,255,.03), 0 0 0 130px rgba(255,255,255,.02); }
.login-copy { position: relative; z-index: 1; max-width: 580px; }
.login-copy .brand-mark { width: 48px; height: 48px; margin-bottom: 30px; font-size: 24px; }
.login-logo { width: 58px; height: 58px; margin-bottom: 28px; object-fit: contain; filter: drop-shadow(0 9px 24px rgba(202,147,46,.26)); }
.login-copy h1 { margin: 0 0 14px; font-size: clamp(31px, 4vw, 52px); letter-spacing: -.04em; line-height: 1.12; }
.login-copy p { max-width: 520px; margin: 0; color: #bdb4a7; font-size: 16px; line-height: 1.8; }
.login-features { display: grid; grid-template-columns: repeat(2, 1fr); gap: 11px; margin-top: 38px; }
.login-feature { display: flex; align-items: center; gap: 9px; color: #ddd3c3; font-size: 13px; }
.login-feature span { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 7px; color: #edc875; background: rgba(226,184,93,.10); }
.login-panel { display: grid; place-items: center; padding: 50px; }
.login-box { width: min(430px, 100%); }
.login-brand-small { width: 42px; height: 42px; margin-bottom: 18px; object-fit: contain; }
.login-box h2 { margin: 0; font-size: 25px; }
.login-box > p { margin: 8px 0 28px; color: var(--slate-500); }
.login-box .field { margin-bottom: 16px; }
.login-submit { width: 100%; min-height: 44px; margin-top: 4px; }
.login-box .login-submit { color: #241808; border-color: #bd8931; background: linear-gradient(135deg, #efd08b, #ca963b); box-shadow: 0 10px 24px rgba(165,111,24,.16); }
.login-mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 22px 0 21px; padding: 4px; border-radius: 12px; background: var(--slate-100); }
.login-mode-tabs button { min-width: 0; padding: 10px 8px; border: 0; border-radius: 9px; color: var(--slate-500); background: transparent; text-align: center; }
.login-mode-tabs button.active { color: #7a5116; background: #fff; box-shadow: 0 3px 12px rgba(11, 24, 41, .08); }
.login-mode-tabs b, .login-mode-tabs small { display: block; }
.login-mode-tabs b { font-size: 14px; }
.login-mode-tabs small { margin-top: 2px; font-size: 10px; font-weight: 500; }
.login-mode-body { min-height: 338px; }
.login-account-links { display: flex; align-items: center; justify-content: space-between; margin: -5px 0 14px; font-size: 13px; }
.login-account-links a { color: #96661e; font-weight: 750; }
.login-account-links button { padding: 0; border: 0; color: #96661e; background: transparent; font-size: 13px; font-weight: 750; }
.login-account-links span { max-width: 245px; color: var(--slate-500); text-align: right; font-size: 11px; line-height: 1.45; }
.login-note { margin-top: 18px; color: var(--slate-500); font-size: 12px; text-align: center; }
.login-error { display: none; margin-bottom: 15px; padding: 10px 12px; border-radius: 8px; color: #b42318; background: #fff0f0; font-size: 13px; }
.login-error.show { display: block; }
.embedded-qr-login { display: grid; justify-items: center; text-align: center; }
.embedded-qr { width: 224px; height: 224px; display: grid; place-items: center; overflow: hidden; margin: 0 auto 13px; padding: 10px; border: 1px solid #e5dac7; border-radius: 18px; background: #fff; box-shadow: inset 0 0 0 6px #fffbf4; }
.embedded-qr.loading { color: var(--slate-500); font-size: 13px; }
.embedded-qr img { width: 100%; height: 100%; object-fit: contain; }
.embedded-qr-login h3 { margin: 0 0 6px; color: var(--slate-900); font-size: 17px; }
.embedded-qr-login p { max-width: 360px; min-height: 40px; margin: 0; color: var(--slate-500); font-size: 12px; line-height: 1.65; }
.embedded-qr-refresh { min-width: 150px; margin-top: 10px; color: var(--slate-700); border: 1px solid var(--slate-300); background: #fff; }
.embedded-qr-login.error { min-height: 270px; align-content: center; padding: 28px; border: 1px dashed #e3c5c5; border-radius: 14px; background: #fff8f8; }
.fatal-box { padding: 28px; border: 1px solid var(--slate-200); border-radius: 16px; background: #fff; box-shadow: var(--shadow-md); }
.fatal-box > p { padding: 12px; border-radius: 9px; color: #9f2d25; background: #fff3f2; overflow-wrap: anywhere; }
.fatal-actions { display: grid; gap: 10px; }
.fatal-actions .button { width: 100%; min-height: 44px; }
.fatal-box > small { display: block; margin-top: 15px; color: var(--slate-500); line-height: 1.6; }
.organization-onboarding .login-box { width: min(440px, 100%); }
.onboarding-divider { position: relative; margin: 23px 0; border-top: 1px solid var(--slate-200); text-align: center; }
.onboarding-divider span { position: relative; top: -10px; padding: 0 12px; color: var(--slate-400); background: #fff; font-size: 12px; }
.onboarding-logout { display: block; margin: 22px auto 0; }

.qr-auth-box { display: grid; justify-items: center; gap: 11px; padding: 4px 0 10px; text-align: center; }
.qr-auth-box img { width: min(300px, 76vw); aspect-ratio: 1; border: 1px solid var(--slate-200); border-radius: 12px; background: #fff; }
.qr-auth-box b { color: #8a5b18; font-size: 15px; }
.qr-auth-box p { max-width: 390px; margin: 0; color: var(--slate-500); font-size: 12px; }

.company-choice-list { display: grid; gap: 10px; }
.company-choice { width: 100%; display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--slate-200); border-radius: 11px; color: var(--slate-700); background: #fff; text-align: left; }
.company-choice:hover, .company-choice.active { border-color: #d6b268; background: #fffbf3; }
.company-choice span:nth-child(2) { min-width: 0; }
.company-choice b, .company-choice small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.company-choice small { margin-top: 3px; color: var(--slate-500); font-size: 11px; }
.company-choice em { color: #96661e; font-size: 12px; font-style: normal; font-weight: 750; }
.tenant-logo { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 11px; color: #f4d68f; background: linear-gradient(145deg, #1c1710, #4a3720); font-weight: 800; }
.invite-code-box { display: grid; justify-items: center; gap: 7px; padding: 24px; border: 1px dashed #d4ad62; border-radius: 12px; background: #fffaf0; text-align: center; }
.invite-code-box small, .invite-code-box span { color: var(--slate-500); font-size: 12px; }
.invite-code-box b { color: #7a4e0d; font-size: 34px; letter-spacing: .16em; font-variant-numeric: tabular-nums; }

#toast-root { position: fixed; z-index: 200; right: 22px; bottom: 22px; display: grid; gap: 9px; }
.toast { min-width: 270px; max-width: 420px; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--slate-200); border-radius: 10px; color: var(--slate-700); background: #fff; box-shadow: var(--shadow-md); animation: toast-in .2s ease-out; }
.toast.success { border-left: 4px solid var(--emerald-500); }
.toast.error { border-left: 4px solid var(--red-500); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.mobile-overlay { display: none; position: fixed; inset: 0; z-index: 35; background: rgba(4,13,26,.52); }

@media (max-width: 1380px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .account-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1020px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .mobile-overlay.show { display: block; }
  .main-area { margin-left: 0; }
  .mobile-menu { display: grid; place-items: center; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: repeat(2, 1fr); }
  .login-page { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-panel { min-height: calc(100vh - var(--filing-height)); }
}

@media (max-width: 720px) {
  body { font-size: 14px; }
  .topbar { min-height: 64px; padding: 10px 14px; }
  .page-heading h1 { font-size: 17px; }
  .page-heading p, .date-chip, .profile-button > span:not(.avatar) { display: none; }
  .content { padding: 16px 14px 36px; }
  .hero-strip { align-items: flex-start; flex-direction: column; padding: 20px; }
  .hero-actions { width: 100%; justify-content: flex-start; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .metric-card { padding: 14px; }
  .metric-value { font-size: 19px; }
  .summary-row { grid-template-columns: repeat(2, 1fr); }
  .account-grid, .report-grid, .settings-grid { grid-template-columns: 1fr; }
  .search-box { min-width: 0; width: 100%; }
  .page-toolbar { align-items: stretch; }
  .page-toolbar .filter-tabs { overflow-x: auto; }
  .toolbar-spacer { display: none; }
  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .line-row { grid-template-columns: 1fr 1fr; }
  .line-row .field:first-child { grid-column: 1 / -1; }
  .line-row .remove-line { grid-column: 2; justify-self: end; }
  .quick-grid { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal, .modal.wide { width: 100%; max-height: 94vh; border-radius: 16px 16px 0 0; }
}

@media (max-width: 450px) {
  .metric-grid, .summary-row { grid-template-columns: 1fr; }
  .hero-actions .hero-button { flex: 1; }
  .login-panel { padding: 28px 20px; }
  .login-mode-tabs small { display: none; }
  .login-mode-body { min-height: 320px; }
  .embedded-qr { width: 208px; height: 208px; }
}

@media print {
  .sidebar, .topbar, .page-toolbar, .demo-banner, .button, .site-filing { display: none !important; }
  .main-area { margin: 0; }
  .content { max-width: none; padding: 0; }
  .panel, .table-card { border-color: #bbb; box-shadow: none; }
}
