:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17342d;
  background: #f3f7f5;
  --green: #0c6c52;
  --green-dark: #064939;
  --mint: #dff3eb;
  --line: #d8e4df;
  --paper: #fff;
  --muted: #6a7e77;
  --orange: #d87518;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 0; background: #f3f7f5; }
button, input { font: inherit; }
button { cursor: pointer; }

.topbar {
  height: 82px;
  padding: 0 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  background: linear-gradient(120deg, var(--green-dark), var(--green));
  box-shadow: 0 3px 16px rgba(8, 60, 46, .18);
}
.topbar h1 { margin: 2px 0 0; font-size: 24px; letter-spacing: -.5px; }
.topbar h1 span { padding: 3px 7px; font-size: 12px; border-radius: 6px; color: var(--green-dark); background: #bfead9; vertical-align: middle; }
.eyebrow { margin: 0; font-size: 11px; font-weight: 800; letter-spacing: 1.5px; color: #7b9189; }
.topbar .eyebrow { color: #bfe7d8; }
.demo-badge { padding: 9px 13px; border: 1px solid rgba(255,255,255,.35); border-radius: 8px; font-size: 12px; font-weight: 800; }

.layout { display: grid; grid-template-columns: 210px 1fr; min-height: calc(100vh - 82px); }
.sidebar { padding: 24px 16px; background: #fff; border-right: 1px solid var(--line); }
.nav-item { width: 100%; padding: 12px 14px; margin-bottom: 7px; border: 0; border-radius: 9px; text-align: left; font-weight: 700; color: #567068; background: transparent; }
.nav-item.active { color: var(--green-dark); background: var(--mint); }
.nav-item[hidden] { display: none; }
.nav-item:disabled { opacity: .45; cursor: not-allowed; }

main { min-width: 0; padding: 28px 30px 50px; }
.intro { display: flex; align-items: end; justify-content: space-between; margin-bottom: 23px; }
.intro h2 { margin: 5px 0 6px; font-size: 27px; letter-spacing: -.6px; }
.intro p:not(.eyebrow) { margin: 0; color: var(--muted); }
.source-state { padding: 10px 13px; border: 1px solid #e2c59f; border-radius: 9px; color: #81501b; background: #fff8ee; font-size: 13px; font-weight: 700; }
.source-state i { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: #e49535; }
.source-state.connected { color: #17634e; border-color: #a9d9c7; background: #ecf9f4; }
.source-state.connected i { background: #24a277; }
.source-state.error { color: #942f2f; border-color: #e7b7b7; background: #fff2f2; }
.source-state.error i { background: #cf4545; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.metrics article { padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.metrics span { display: block; margin-bottom: 8px; font-size: 12px; color: var(--muted); font-weight: 700; }
.metrics strong { font-size: 26px; }
.metrics .accent { color: #fff; border-color: var(--green); background: var(--green); }
.metrics .accent span { color: #c6eadc; }

.card { border: 1px solid var(--line); border-radius: 13px; background: var(--paper); box-shadow: 0 8px 30px rgba(25, 67, 55, .06); overflow: hidden; }
.card-head { padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.card-head h3 { margin: 0 0 4px; }
.card-head p { margin: 0; font-size: 12px; color: var(--muted); }
.table-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.search { font-size: 12px; font-weight: 700; color: var(--muted); }
.search input, .search select { max-width: 100%; margin-left: 7px; padding: 9px 11px; border: 1px solid #cddbd6; border-radius: 8px; outline: none; background: #fff; }
.search input { width: 230px; }
.search input:focus, .search select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(12,108,82,.12); }

table { width: 100%; border-collapse: collapse; }
.table-wrap { max-height: calc(100vh - 390px); overflow: auto; }
.table-wrap table { min-width: 760px; }
thead { position: sticky; top: 0; z-index: 2; }
th { padding: 11px 13px; text-align: left; font-size: 11px; letter-spacing: .3px; color: #688078; background: #f7faf8; }
td { padding: 13px; border-top: 1px solid #edf2ef; font-size: 13px; white-space: nowrap; }
tbody tr:hover, tbody tr:focus { outline: none; background: #f5fbf8; }
tbody tr.selected { background: #e8f6f0; }
td small { display: block; margin-top: 4px; color: var(--muted); }
.product { display: inline-block; padding: 5px 8px; border-radius: 6px; font-weight: 800; }
.product.diesel { color: #9b6800; background: #fff6d9; }
.product.petrol { color: #087568; background: #e4f6f1; }
.product.lpg { color: #176aa8; background: #e9f4ff; }
.customer-metrics { grid-template-columns: repeat(3, minmax(170px, 1fr)); }
.customer-layout { display: grid; grid-template-columns: minmax(370px, .9fr) minmax(500px, 1.1fr); gap: 18px; align-items: start; }
.customer-table table { min-width: 520px; }
.customer-detail .card-head { align-items: end; }
.customer-detail .card-head > strong { color: var(--green-dark); font-size: 23px; white-space: nowrap; }
.status { display: inline-block; padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.status.neutral { color: #526963; background: #edf2f0; }
.status.suggested { color: #17634e; background: #daf1e8; }
.status.warning { color: #96540c; background: #fff0d8; }
.more { width: 34px; height: 30px; border: 1px solid #cedbd6; border-radius: 7px; color: var(--green); background: #fff; font-weight: 900; }
.load-error { text-align: center; color: #9c2f2f; }
.empty-state { padding: 34px; text-align: center; color: var(--muted); }

.rule-note { display: flex; gap: 16px; margin-top: 15px; padding: 15px 18px; border-left: 4px solid var(--orange); border-radius: 7px; color: #704419; background: #fff8ee; font-size: 13px; }
.rule-note span { color: #735d46; }
.danger-note { border-left-color: #bb3535; color: #7d2626; background: #fff3f3; }
.wide-metric strong { font-size: 21px; }
.reconciliation-card { display: grid; grid-template-columns: repeat(6, minmax(130px, 1fr)); gap: 1px; margin: 0 0 18px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--line); }
.reconciliation-card[hidden] { display: none; }
.reconciliation-card div { padding: 14px; background: #fff; }
.reconciliation-card span { display: block; min-height: 30px; margin-bottom: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
.reconciliation-card strong { font-size: 17px; }
.reconciliation-card .mismatch { color: #922d2d; background: #fff5f5; }
.difference-cell { color: #a23636; font-weight: 800; }

.context-menu { position: fixed; z-index: 20; width: 280px; padding: 7px; border: 1px solid #cbdad4; border-radius: 10px; background: #fff; box-shadow: 0 14px 40px rgba(9, 49, 39, .2); }
.context-menu button { width: 100%; padding: 10px 11px; border: 0; border-radius: 7px; text-align: left; color: #24473e; background: #fff; }
.context-menu button:hover { background: var(--mint); }

dialog { width: 510px; padding: 0; border: 0; border-radius: 14px; color: #193d33; box-shadow: 0 24px 80px rgba(0,0,0,.27); }
dialog::backdrop { background: rgba(5, 32, 25, .48); }
dialog form { position: relative; padding: 28px; }
dialog h3 { margin: 6px 0 8px; font-size: 24px; }
dialog p:not(.eyebrow) { color: var(--muted); line-height: 1.55; }
.dialog-close { position: absolute; right: 15px; top: 13px; border: 0; background: none; font-size: 25px; color: #6b807a; }
.price-example { display: grid; grid-template-columns: 1fr auto; gap: 9px 20px; margin: 18px 0; padding: 16px; border-radius: 9px; background: #f2f7f5; }
.price-example:empty { display: none; }
.price-example span { color: var(--muted); }
.primary { width: 100%; padding: 11px; border: 0; border-radius: 8px; color: #fff; background: var(--green); font-weight: 800; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 170px 1fr; }
  main { padding-left: 20px; padding-right: 20px; }
  .customer-layout { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .topbar { height: auto; min-height: 78px; padding: 14px 18px; gap: 12px; }
  .topbar h1 { font-size: 19px; }
  .demo-badge { max-width: 145px; text-align: center; font-size: 10px; }
  .layout { display: block; }
  .sidebar { display: flex; gap: 8px; overflow-x: auto; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav-item { width: auto; min-width: max-content; margin: 0; padding: 10px 12px; }
  main { padding: 20px 14px 36px; }
  .intro { display: block; }
  .intro h2 { font-size: 23px; }
  .source-state { display: inline-block; margin-top: 14px; }
  .metrics, .customer-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics article { padding: 13px; }
  .metrics strong { font-size: 20px; }
  .card-head { display: block; }
  .table-controls { margin-top: 12px; }
  .search { display: inline-flex; align-items: center; margin-top: 10px; }
  .search input { width: min(220px, 53vw); }
  .customer-detail .card-head { display: flex; gap: 12px; }
  .customer-detail .card-head > strong { font-size: 18px; }
}
