:root {
  color-scheme: light;
  --bg: #f7faf9;
  --panel: #fff;
  --text: #172126;
  --muted: #64727a;
  --line: #dce5e8;
  --primary: #0f766e;
  --primary-strong: #115e59;
  --accent: #b45309;
  --danger: #b91c1c;
  --shadow: 0 18px 45px rgba(15, 23, 42, .08);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101615;
  --panel: #18211f;
  --text: #eef6f4;
  --muted: #9fb0ad;
  --line: #2c3a37;
  --primary: #14b8a6;
  --primary-strong: #0f766e;
  --accent: #f59e0b;
  --danger: #f87171;
  --shadow: 0 18px 45px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, "Segoe UI", system-ui, sans-serif; }
body::before { content: ""; position: fixed; inset: 0; z-index: -1; opacity: .6; background: linear-gradient(135deg, rgba(15,118,110,.08), transparent 32%), linear-gradient(315deg, rgba(180,83,9,.08), transparent 28%); }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--panel); border-right: 1px solid var(--line); padding: 18px; display: flex; flex-direction: column; gap: 18px; z-index: 10; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand.large { margin-bottom: 24px; }
.brand-mark { width: 48px; height: 48px; border-radius: 8px; display: grid; place-items: center; color: white; background: var(--primary-strong); flex: 0 0 auto; font-size: 24px; }
.brand strong { display: block; font-size: 15px; line-height: 1.25; }
.brand span { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.sidebar nav { display: grid; gap: 6px; }
.sidebar nav a, .logout { min-height: 48px; border-radius: 8px; padding: 0 12px; color: var(--muted); display: flex; align-items: center; gap: 11px; transition: transform .18s ease, background .18s ease, color .18s ease; }
.sidebar nav a span, .mobile-nav span { min-width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); font-size: 12px; font-weight: 800; }
.sidebar nav a.active, .sidebar nav a:hover { background: color-mix(in srgb, var(--primary) 13%, transparent); color: var(--primary); }
.sidebar nav a:hover { transform: translateX(2px); }
.logout { margin-top: auto; color: var(--danger); }

.main { min-width: 0; padding: 22px 24px 92px; }
.topbar { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.topbar h1 { margin: 0; font-size: 25px; letter-spacing: 0; }
.eyebrow { margin: 0 0 3px; color: var(--muted); font-size: 13px; }
.top-actions, .toolbar, .row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); display: grid; place-items: center; }
.mobile-only { display: none; }
.status, .queue-pill { min-height: 38px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 999px; padding: 0 12px; display: inline-flex; gap: 7px; align-items: center; font-size: 13px; white-space: nowrap; }
.status.online { color: var(--primary); }
.status.offline { color: var(--danger); }
.queue-pill.has-items { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }

.dashboard-hero { min-height: 190px; border-radius: 12px; margin-bottom: 16px; padding: clamp(18px, 4vw, 30px); color: white; background: linear-gradient(120deg, rgba(17,94,89,.95), rgba(15,118,110,.82)), url("../public/icons/icon.svg") right 24px center / 150px no-repeat; display: flex; justify-content: space-between; align-items: end; gap: 20px; box-shadow: var(--shadow); overflow: hidden; }
.dashboard-hero h2 { margin: 0 0 8px; font-size: clamp(24px, 4vw, 38px); letter-spacing: 0; }
.dashboard-hero p { margin: 0; max-width: 680px; color: rgba(255,255,255,.82); }
.eyebrow.light { color: rgba(255,255,255,.72); }
.hero-badge { min-width: 180px; border: 1px solid rgba(255,255,255,.25); border-radius: 10px; padding: 14px; background: rgba(255,255,255,.12); backdrop-filter: blur(10px); }
.hero-badge span { display: block; font-size: 12px; color: rgba(255,255,255,.72); margin-bottom: 4px; }
.hero-badge strong { display: block; }

.notice-banner { margin-bottom: 16px; border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--line)); border-radius: 12px; padding: 13px 15px; background: color-mix(in srgb, var(--accent) 12%, var(--panel)); color: var(--text); display: flex; justify-content: space-between; gap: 12px; align-items: center; animation: rise .28s ease both; }
.notice-banner strong, .notice-banner span { display: block; }
.notice-banner span { color: var(--muted); font-size: 13px; margin-top: 2px; }
.notice-banner a { min-height: 38px; border-radius: 999px; padding: 0 14px; display: inline-flex; align-items: center; background: var(--accent); color: white; font-weight: 800; white-space: nowrap; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 16px; }
.premium-metrics { display: grid; grid-template-columns: repeat(4, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.premium-card { position: relative; min-height: 174px; border: 1px solid var(--line); border-radius: 16px; padding: 18px; overflow: hidden; color: white; box-shadow: var(--shadow); display: grid; align-content: space-between; animation: rise .34s ease both; }
.premium-card::after { content: ""; position: absolute; right: -34px; bottom: -34px; width: 128px; height: 128px; border-radius: 999px; background: rgba(255,255,255,.13); }
.premium-card span { font-size: 13px; color: rgba(255,255,255,.82); }
.premium-card strong { font-size: clamp(25px, 4vw, 34px); line-height: 1.05; overflow-wrap: anywhere; position: relative; z-index: 1; }
.premium-card small { color: rgba(255,255,255,.78); position: relative; z-index: 1; }
.premium-card.petrol { background: linear-gradient(135deg, #0f766e, #0891b2); }
.premium-card.diesel { background: linear-gradient(135deg, #166534, #65a30d); }
.premium-card.petrol-sold { background: linear-gradient(135deg, #1d4ed8, #7c3aed); }
.premium-card.diesel-sold { background: linear-gradient(135deg, #b45309, #dc2626); }
.summary-card { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(145deg, var(--panel), color-mix(in srgb, var(--primary) 5%, var(--panel))); padding: 16px; min-height: 132px; box-shadow: var(--shadow); display: grid; align-content: space-between; animation: rise .32s ease both; }
.summary-card::after { content: ""; position: absolute; right: -30px; top: -30px; width: 92px; height: 92px; border-radius: 999px; background: color-mix(in srgb, var(--primary) 12%, transparent); }
.summary-card:hover { transform: translateY(-2px); transition: transform .18s ease; }
.summary-card span { color: var(--muted); font-size: 13px; }
.summary-card strong { position: relative; z-index: 1; font-size: clamp(18px, 2.4vw, 23px); overflow-wrap: anywhere; color: var(--primary); }
.summary-card.amber strong { color: var(--accent); }
.summary-card.red strong { color: var(--danger); }
.summary-card.violet strong { color: #7c3aed; }
.summary-card.green strong { color: #15803d; }
.summary-card.blue strong { color: #2563eb; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); gap: 16px; align-items: start; }
.content-grid.wide-left { grid-template-columns: minmax(360px, .75fr) minmax(0, 1.25fr); }
.panel { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 16px; box-shadow: var(--shadow); min-width: 0; animation: rise .34s ease both; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 17px; letter-spacing: 0; }
.panel-head span { color: var(--primary); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; min-height: 42px; padding: 9px 11px; background: var(--bg); color: var(--text); outline-color: var(--primary); }
textarea { min-height: 86px; resize: vertical; }
.span-2 { grid-column: span 2; }
.check { display: flex; grid-column: span 2; flex-direction: row; align-items: center; gap: 9px; }
.check input { width: 18px; min-height: 18px; }
.primary, .button, .big-action { border: 0; border-radius: 8px; min-height: 42px; padding: 0 14px; background: var(--primary-strong); color: white; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.button { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.form-total { align-self: center; color: var(--muted); }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; min-width: 620px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; vertical-align: top; }
th { color: var(--muted); background: color-mix(in srgb, var(--primary) 7%, transparent); font-weight: 700; }
tr:last-child td { border-bottom: 0; }
.inline-form { display: inline; }
.link-danger { background: transparent; border: 1px solid var(--line); border-radius: 8px; color: var(--danger); min-height: 34px; padding: 0 10px; }
.pagination { margin-top: 12px; display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.pagination a, .pagination select { min-height: 38px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); padding: 0 10px; display: inline-flex; align-items: center; }
.pagination a.disabled { opacity: .45; pointer-events: none; }

.chart-head { align-items: flex-start; }
.chart-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.segmented { display: inline-flex; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); gap: 4px; }
.segmented button { border: 0; border-radius: 999px; min-height: 32px; padding: 0 12px; background: transparent; color: var(--muted); }
.segmented button.active { background: var(--primary-strong); color: white; }
.sales-canvas { width: 100%; height: 320px; display: block; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.bar-chart { height: 280px; display: flex; align-items: end; gap: 10px; padding: 18px 6px 0; }
.bar-chart.enhanced { display: none; }
.bar-chart.enhanced.active { display: none; }
.bar-item { flex: 1; height: 100%; display: grid; grid-template-rows: 1fr auto; align-items: end; gap: 8px; min-width: 34px; }
.bar-item div { position: relative; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, var(--primary), var(--accent)); min-height: 18px; animation: growBar .6s ease both; }
.bar-item div span { position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%); padding: 3px 6px; border-radius: 6px; background: var(--text); color: var(--panel); font-size: 10px; opacity: 0; pointer-events: none; white-space: nowrap; }
.bar-item:hover div span { opacity: 1; }
.bar-item small, .bar-item > span { text-align: center; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.empty-chart { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; }
.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.quick-grid a { min-height: 58px; border: 1px solid var(--line); border-radius: 10px; display: grid; place-items: center; background: var(--bg); color: var(--primary); font-weight: 700; }
.offline-queue-card { margin-bottom: 14px; border-radius: 10px; padding: 14px; background: color-mix(in srgb, var(--accent) 10%, var(--bg)); border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--line)); display: flex; align-items: center; gap: 12px; color: var(--muted); }
.offline-queue-card strong { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; background: var(--accent); color: white; font-size: 20px; }
.alert, .toast { border-radius: 8px; padding: 12px; margin-bottom: 12px; font-size: 14px; border: 1px solid var(--line); }
.danger, .alert.danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.success, .alert.success { color: #15803d; background: color-mix(in srgb, #15803d 10%, transparent); }
.toast { background: var(--panel); box-shadow: var(--shadow); }

.toolbar { margin-bottom: 14px; }
.toolbar select { width: 220px; }
.search-input { width: min(360px, 100%); }
.report-header { border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 12px; display: grid; gap: 4px; }
.report-header span { color: var(--muted); font-size: 13px; }
.action-grid { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 12px; }
.big-action { min-height: 96px; background: var(--bg); color: var(--text); border: 1px solid var(--line); flex-direction: column; }
.developer-card { margin-top: 16px; display: grid; gap: 6px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 14px; }
.developer-card strong { color: var(--text); }
.permission-box { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--bg); display: grid; gap: 6px; }
.permission-box strong { color: var(--text); }
.site-footer { margin-top: 18px; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--panel); color: var(--muted); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12px; }
.site-footer div { display: grid; gap: 3px; }
.site-footer strong { color: var(--text); font-size: 13px; }
.mobile-nav { display: none; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes growBar { from { transform: scaleY(.15); transform-origin: bottom; } to { transform: scaleY(1); transform-origin: bottom; } }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--bg); }
.login-panel { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 24px; }
.login-panel form { display: grid; gap: 14px; }
.scrim { display: none; }

@media (max-width: 1180px) {
  .premium-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-grid { grid-template-columns: repeat(3, minmax(160px, 1fr)); }
  .content-grid, .content-grid.wide-left { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; transform: translateX(-105%); transition: transform .2s ease; width: min(310px, 88vw); }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 14px 12px 86px; }
  .mobile-only { display: grid; }
  .topbar { align-items: flex-start; }
  .top-actions .status { max-width: 100px; overflow: hidden; }
  .queue-pill { display: none; }
  .topbar h1 { font-size: 21px; }
  .dashboard-hero { min-height: 230px; align-items: start; flex-direction: column; background-size: 112px; background-position: right 14px bottom 14px; }
  .hero-badge { width: 100%; }
  .notice-banner { align-items: stretch; flex-direction: column; }
  .notice-banner a { justify-content: center; width: 100%; }
  .premium-metrics { grid-template-columns: 1fr; }
  .premium-card { min-height: 150px; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .summary-card { min-height: 118px; padding: 13px; }
  .summary-card strong { font-size: 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2, .check { grid-column: auto; }
  .action-grid { grid-template-columns: 1fr; }
  .toolbar select, .toolbar input, .toolbar .button { width: 100%; }
  .table-wrap { border: 1px solid var(--line); overflow: hidden; }
  table, thead, tbody, tr, th, td { display: block; min-width: 0; width: 100%; }
  thead { display: none; }
  tr { border-bottom: 1px solid var(--line); background: transparent; margin: 0; padding: 8px 0; }
  tr:last-child { border-bottom: 0; }
  td { border: 0; padding: 7px 10px; display: grid; grid-template-columns: minmax(104px, 38%) minmax(0, 1fr); gap: 8px; align-items: start; word-break: break-word; overflow-wrap: anywhere; }
  td::before { content: attr(data-label); color: var(--muted); font-weight: 700; }
  .inline-form, .link-danger { width: 100%; }
  .link-danger { min-height: 40px; }
  .pagination { justify-content: stretch; }
  .pagination a, .pagination form, .pagination select { width: 100%; justify-content: center; }
  .mobile-nav { position: fixed; left: 0; right: 0; bottom: 0; height: 68px; background: var(--panel); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); z-index: 20; box-shadow: 0 -12px 30px rgba(15,23,42,.08); }
  .mobile-nav a { display: grid; place-items: center; align-content: center; gap: 2px; font-size: 11px; color: var(--muted); }
  .mobile-nav a.active { color: var(--primary); }
  .mobile-nav span { min-width: 26px; height: 26px; }
  .bar-chart { overflow-x: auto; padding-top: 34px; }
  .bar-item { min-width: 52px; }
}

@media (max-width: 420px) {
  .premium-metrics,
  .summary-grid { grid-template-columns: 1fr; }
  .topbar { gap: 8px; }
  .icon-button { width: auto; min-width: 42px; padding: 0 9px; }
  .site-footer { display: grid; }
}

@media print {
  .sidebar, .topbar, .toolbar, .toast, .mobile-nav { display: none !important; }
  .app-shell, .main { display: block; padding: 0; }
  .panel { box-shadow: none; border: 0; }
  body { background: #fff; color: #000; }
}
