:root {
  --primary: #2563eb;
  --ink: #0f2147;
  --gold: #bda04c;
  --muted: #64748b;
  --border: #e2e8f0;
  --surface: #ffffff;
  --page: #f5f7fb;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: #111827; font-family: Arial, Helvetica, sans-serif; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 272px 1fr; }
.sidebar { background: #071a3d; color: #fff; padding: 18px 14px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px 18px; border-bottom: 1px solid rgba(255,255,255,.12); color: #fff; }
.brand-logo { width: 84px; height: auto; display: block; background: #fff; border-radius: 6px; padding: 5px; }
.brand-title { display: block; font-size: 15px; font-weight: 700; line-height: 1.2; }
.brand-subtitle { display: block; color: rgba(255,255,255,.68); font-size: 12px; margin-top: 3px; }
.sidebar-nav { padding-top: 14px; }
.sidebar-nav p { margin: 18px 10px 6px; color: rgba(255,255,255,.45); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.sidebar-nav a { display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.76); text-decoration: none; border-radius: 7px; padding: 9px 10px; font-size: 14px; }
.sidebar-nav a:hover, .sidebar-nav a.active { background: rgba(37,99,235,.25); color: #fff; }
.main { min-width: 0; }
.topbar { height: 68px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 24px; position: sticky; top: 0; z-index: 10; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-actions .form-control { width: 220px; }
.logout-action { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 42px; min-height: 44px; line-height: 1; padding: 4px 7px; }
.logout-action span { display: block; font-size: 10px; line-height: 1; margin-top: 2px; }
.page { padding: 24px; }
.page-title { color: var(--ink); font-size: 24px; font-weight: 700; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi-card, .panel { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 1px 2px rgba(15,23,42,.03); }
.kpi-card { padding: 16px; }
.kpi-card span { display: block; color: var(--muted); font-size: 12px; }
.kpi-card strong { display: block; margin-top: 8px; color: var(--ink); font-size: 20px; }
.panel { padding: 18px; }
.inner-panel { box-shadow: none; }
.panel h2 { font-size: 16px; margin: 0 0 14px; color: var(--ink); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.badge-soft { background: #e8f0ff; color: #1d4ed8; text-transform: capitalize; }
.auth-body { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #eef3ff, #ffffff); padding: 24px; }
.auth-card { width: min(430px, 100%); background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 28px; box-shadow: 0 24px 60px rgba(15,23,42,.12); }
.auth-logo { display: block; width: 230px; max-width: 100%; margin: 0 auto 22px; }
.report-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.report-tile { border: 1px solid var(--border); border-radius: 8px; padding: 14px; display: grid; gap: 10px; }
.report-tile i { color: var(--primary); font-size: 22px; }
.table { margin-bottom: 0; }
.form-label { font-weight: 600; color: #334155; font-size: 13px; }
.document-header { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 16px; }
.eyebrow { margin: 0 0 4px; color: var(--primary); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.doc-number { background: #fff; border: 1px solid var(--border); border-radius: 8px; color: var(--ink); font-size: 18px; font-weight: 700; padding: 10px 14px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-title h2 { margin: 0; }
.document-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr); gap: 18px; align-items: start; }
.summary-lines { display: grid; gap: 10px; }
.summary-lines div { display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.summary-lines div:last-child { border-bottom: 0; padding-bottom: 0; }
.summary-lines span { color: var(--muted); }
.summary-lines strong { color: var(--ink); }
.summary-lines .grand { font-size: 18px; }
.summary-lines .grand strong { color: var(--primary); }
.profit-statement { display: grid; gap: 2px; }
.profit-statement div { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.profit-statement div:last-child { border-bottom: 0; }
.profit-statement span { color: #334155; }
.profit-statement strong { color: var(--ink); font-size: 15px; }
.profit-statement .statement-total { border-top: 1px solid #cbd5e1; font-weight: 700; }
.profit-statement .statement-total span, .profit-statement .statement-total strong { color: var(--ink); }
.profit-statement .statement-grand { margin-top: 4px; padding: 14px 0 0; border-top: 2px solid var(--ink); border-bottom: 0; }
.profit-statement .statement-grand span, .profit-statement .statement-grand strong { color: var(--ink); font-size: 18px; font-weight: 700; }
.icon-btn { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; }
.line-items th { font-size: 12px; color: var(--muted); text-transform: uppercase; }
.line-items .form-control, .line-items .form-select { min-width: 92px; }
.stock-tabs { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.stock-tabs a { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; color: #334155; text-decoration: none; background: #fff; }
.stock-tabs a.active { border-color: var(--primary); background: #eef4ff; color: var(--primary); }
.stock-tabs strong { font-size: 18px; color: var(--ink); }
.stock-table th { white-space: nowrap; font-size: 12px; color: var(--muted); }
.stock-table td { white-space: nowrap; }
.stock-low td { background: #fff1f2 !important; }
.stock-out td { background: #fee2e2 !important; }
.invoice-share { align-items: center; background: #f8fbff; border: 1px solid var(--border); border-radius: 8px; display: flex; gap: 16px; padding: 14px; }
.invoice-share .invoice-qr-code { align-items: center; background: #fff; border: 1px solid var(--border); border-radius: 6px; display: flex; flex: 0 0 112px; height: 112px; justify-content: center; overflow: hidden; padding: 6px; width: 112px; }
.invoice-share .invoice-qr-code img, .invoice-share .invoice-qr-code canvas { display: block; height: 100px !important; width: 100px !important; }
.invoice-share p { color: var(--muted); margin: 4px 0; }
.invoice-share a { display: block; font-size: 12px; overflow-wrap: anywhere; }
.public-invoice-body { background: #eef2f7; min-height: 100vh; }
.public-invoice-shell { margin: 0 auto; max-width: 980px; padding: 32px 18px; }
.public-invoice-page { background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 12px 36px rgba(15,23,42,.08); padding: 28px; }
.public-invoice-header { align-items: center; border-bottom: 1px solid var(--border); display: flex; gap: 14px; margin-bottom: 24px; padding-bottom: 18px; }
.public-invoice-header img { background: #fff; border: 1px solid var(--border); border-radius: 6px; display: block; height: auto; padding: 6px; width: 112px; }
.public-invoice-header strong, .public-invoice-header span { display: block; }
.public-invoice-header strong { color: var(--ink); font-size: 18px; }
.public-invoice-header span, .public-invoice-meta span { color: var(--muted); }
.public-invoice-title { align-items: center; display: flex; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.public-invoice-title h1 { color: var(--ink); font-size: 28px; margin: 0; }
.public-invoice-meta { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 22px; }
.public-invoice-meta span, .public-invoice-meta strong { display: block; }
.public-invoice-meta strong { color: var(--ink); margin-top: 4px; overflow-wrap: anywhere; }
.public-invoice-table th { color: var(--muted); font-size: 12px; text-transform: uppercase; white-space: nowrap; }
.public-invoice-totals { margin-left: auto; margin-top: 18px; max-width: 360px; }
.public-invoice-missing { padding: 28px 0 10px; text-align: center; }
.public-invoice-missing h1 { color: var(--ink); font-size: 28px; }
.public-invoice-missing p { color: var(--muted); margin-bottom: 0; }

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .report-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stock-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .sidebar.open { display: block; }
  .grid-2 { grid-template-columns: 1fr; }
  .document-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .page { padding: 16px; }
  .kpi-grid, .report-grid { grid-template-columns: 1fr; }
  .stock-tabs { grid-template-columns: 1fr; }
  .topbar-actions .form-control { display: none; }
  .invoice-share { align-items: flex-start; flex-direction: column; }
  .public-invoice-shell { padding: 14px; }
  .public-invoice-page { padding: 18px; }
  .public-invoice-title { align-items: flex-start; flex-direction: column; }
  .public-invoice-meta { grid-template-columns: 1fr 1fr; }
}
