:root {
  --ink: #17221d;
  --muted: #67766e;
  --line: #dfe6e1;
  --panel: #ffffff;
  --bg: #f4f7f5;
  --sidebar: #10201a;
  --emerald: #0f9f6e;
  --emerald-dark: #0a7d56;
  --emerald-soft: #e5f6ef;
  --amber: #b7791f;
  --amber-soft: #fdf4e3;
  --red: #b53a3a;
  --red-soft: #fbeaea;
  --mono: "SFMono-Regular", "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--sidebar); color: #e9f3ed; padding: 20px 16px;
  display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: var(--emerald); color: #062016; font-weight: 800; letter-spacing: -0.5px;
}
.brand strong { display: block; font-size: 16px; letter-spacing: -0.2px; }
.brand small { color: #8fb3a3; font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  text-align: left; background: transparent; border: 0; color: #b7cdc2; padding: 9px 10px;
  border-radius: 8px; font-size: 13px;
}
.nav-item:hover, .nav-item.active { background: #1a3228; color: #fff; }
.recent { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.side-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.side-head h2 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: #8fb3a3; margin: 0; }
.link { background: none; border: 0; color: #9ad8bd; font-size: 11px; padding: 0; }
.recent-list { overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.recent-item {
  background: #152b22; border: 1px solid #234136; color: #dcebe3; border-radius: 8px;
  padding: 8px; text-align: left; font-size: 12px; display: grid; gap: 3px;
}
.recent-item:hover { border-color: var(--emerald); }
.recent-item b { font-family: var(--mono); font-size: 11px; }
.recent-item span { color: #8fb3a3; font-size: 11px; }
.side-foot { font-size: 11px; color: #8fb3a3; display: flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--emerald); }
.muted { color: var(--muted); margin: 0; }
.sidebar .muted { color: #8fb3a3; }

.main { padding: 26px 30px 96px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 22px; }
.eyebrow { margin: 0 0 4px; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--emerald-dark); font-weight: 700; }
h1 { margin: 0 0 6px; font-size: 25px; letter-spacing: -0.5px; }
.top-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; max-width: 560px; }
.sample-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); width: 100%; text-align: right; }

.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 12px;
  font-weight: 600; font-size: 12.5px; transition: 0.15s ease;
}
.btn:hover { border-color: #b9c8bf; transform: translateY(-1px); }
.btn.primary { background: var(--emerald); border-color: var(--emerald); color: #fff; }
.btn.primary:hover { background: var(--emerald-dark); }
.btn.ghost { background: #fff; }
.btn.full { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: grid; gap: 3px;
}
.kpi span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.kpi strong { font-size: 24px; letter-spacing: -0.7px; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: 11px; }
.kpi.accent { background: linear-gradient(160deg, #ecfbf4, #fff 65%); border-color: #b6e4d2; }
.kpi.accent strong { color: var(--emerald-dark); }

.workspace { display: grid; grid-template-columns: 350px minmax(0, 1fr); gap: 14px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.panel-head h2 { font-size: 14px; margin: 0; }
.panel-sub { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 0 8px; }
.panel-sub h3 { font-size: 12px; margin: 0; text-transform: uppercase; letter-spacing: 0.08em; }
.chip {
  font-family: var(--mono); font-size: 10px; background: #f1f5f2; border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 8px; color: var(--muted); text-transform: uppercase;
}
.dropzone {
  border: 1.5px dashed #c6d4cc; border-radius: 10px; padding: 12px; margin-bottom: 8px;
  display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center;
  cursor: pointer; transition: 0.15s; background: #fbfdfc;
}
.dropzone:hover, .dropzone.drag { border-color: var(--emerald); background: var(--emerald-soft); }
.dropzone.slim { padding: 9px 12px; }
.dropzone strong { font-size: 12.5px; }
.dropzone small { grid-column: 2; color: var(--muted); font-size: 11px; }
.drop-icon { grid-row: 1 / span 2; font-size: 17px; color: var(--emerald-dark); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
label { display: grid; gap: 4px; font-size: 11px; color: var(--muted); font-weight: 600; }
input, select, textarea {
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 8px; background: #fff;
  font-size: 12.5px; width: 100%; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #a8e5cc; border-color: var(--emerald); }
textarea { font-family: var(--mono); font-size: 11px; resize: vertical; }
.advanced { margin: 10px 0; }
.advanced summary { font-size: 11.5px; color: var(--emerald-dark); cursor: pointer; margin-bottom: 8px; }
.advanced label { margin-top: 6px; }
.status-line { font-size: 11.5px; color: var(--muted); margin: 10px 0 0; min-height: 18px; }

.tabs { display: flex; gap: 4px; background: #f1f5f2; padding: 3px; border-radius: 8px; }
.tab { border: 0; background: none; padding: 6px 10px; border-radius: 6px; font-size: 12px; color: var(--muted); }
.tab.active { background: #fff; color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.filters { display: grid; grid-template-columns: 170px 130px 1fr; gap: 8px; margin-bottom: 10px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 9px; max-height: 62vh; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th {
  text-align: left; padding: 8px 10px; background: #f7faf8; border-bottom: 1px solid var(--line);
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
  position: sticky; top: 0; z-index: 1;
}
.data-table td { padding: 9px 10px; border-bottom: 1px solid #eef2ef; vertical-align: top; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr:hover td { background: #fbfdfc; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ref { font-family: var(--mono); font-size: 11.5px; }
.math { color: #4a5a52; max-width: 380px; line-height: 1.45; }
.money-recover { color: var(--emerald-dark); font-weight: 700; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px !important; }
.rule-chip { font-family: var(--mono); font-size: 9.5px; background: #f1f5f2; padding: 3px 6px; border-radius: 5px; white-space: nowrap; }
.badge { font-size: 10px; font-weight: 700; text-transform: uppercase; padding: 3px 7px; border-radius: 999px; letter-spacing: 0.04em; }
.badge.high { background: var(--red-soft); color: var(--red); }
.badge.medium { background: var(--amber-soft); color: var(--amber); }
.badge.low { background: #eef2ef; color: #55665d; }
.badge.ok { background: var(--emerald-soft); color: var(--emerald-dark); }
.badge.leak { background: var(--amber-soft); color: var(--amber); }
.badge.overbill { background: var(--red-soft); color: var(--red); }
.recon-summary { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin: 0 0 10px; }
.recon-summary b { color: var(--ink); font-variant-numeric: tabular-nums; }
.warnings { margin-top: 12px; background: var(--amber-soft); border: 1px solid #ecd9a9; border-radius: 8px; padding: 10px 12px; font-size: 12px; color: #76551a; }
.warnings ul { margin: 4px 0 0; padding-left: 18px; }

.drawer {
  position: fixed; top: 0; right: 0; width: min(330px, 100vw); height: 100vh; background: #fff;
  border-left: 1px solid var(--line); box-shadow: -14px 0 40px rgba(16,32,26,0.12);
  padding: 20px; transform: translateX(105%); visibility: hidden; pointer-events: none;
  transition: transform 0.22s ease, visibility 0.22s ease; z-index: 40;
  display: flex; flex-direction: column; gap: 14px; overflow: auto;
}
.drawer.open { transform: translateX(0); visibility: visible; pointer-events: auto; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; }
.drawer-head h2 { margin: 0; font-size: 16px; }
.icon-btn { border: 0; background: #f1f5f2; width: 28px; height: 28px; border-radius: 50%; font-size: 17px; line-height: 1; }
.drawer-actions { display: grid; gap: 8px; }
.drawer-card { background: #f7faf8; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.drawer-card h3, .drawer-foot h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; margin: 0 0 8px; color: var(--muted); }
.snap-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 12px; border-bottom: 1px dashed #e2e9e4; }
.snap-row:last-child { border: 0; }
.snap-row b { font-variant-numeric: tabular-nums; }
.snap-row.total b { color: var(--emerald-dark); font-size: 14px; }
.drawer-foot { font-size: 11.5px; color: var(--muted); }
.drawer-foot p { line-height: 1.55; margin: 0; }

.modal { border: 0; border-radius: 14px; padding: 0; width: min(620px, 92vw); box-shadow: 0 30px 80px rgba(0,0,0,0.22); }
.modal::backdrop { background: rgba(16,32,26,0.42); }
.modal form { padding: 18px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.modal-head h2 { margin: 0; font-size: 17px; }
.map-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; max-height: 45vh; overflow: auto; }
.unmapped { font-size: 11.5px; color: var(--amber); margin-top: 10px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--sidebar);
  color: #fff; padding: 10px 16px; border-radius: 9px; font-size: 12.5px; z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.hidden { display: none !important; }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .main { padding: 18px 16px 120px; }
  .sidebar { position: static; height: auto; }
  .recent { display: none; }
  .topbar { flex-direction: column; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters input { grid-column: 1 / -1; }
}


/* edge edition */
/* Edge-edition additions on top of app/static/styles.css. */

.trust-banner {
  margin: 0 0 16px;
  padding: 10px 14px;
  border: 1px solid #b6e4d2;
  border-radius: 10px;
  background: linear-gradient(120deg, #ecfbf4, #f7fdfa);
  color: #0a6644;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.trust-banner::before { content: "🔒 "; }
.edge-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em;
  color: #0a6644; background: var(--emerald-soft);
  border: 1px solid #b6e4d2; border-radius: 999px; padding: 3px 9px;
  font-weight: 700;
}
.sample-row { display: flex; flex-wrap: wrap; gap: 8px; }
.sample-row .btn { border-style: dashed; }
.field-hint { font-size: 10.5px; color: var(--muted); margin: 0; line-height: 1.4; }
.pilot-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 22px; background: #10201a; color: #e9f3ed;
  border-top: 1px solid #234136; box-shadow: 0 -8px 24px rgba(16,32,26,0.18);
}
.pilot-bar strong { display: block; font-size: 12.5px; }
.pilot-bar span { color: #9ad8bd; font-size: 11.5px; }
.pilot-bar .spacer { flex: 1; }
.pilot-bar .btn.primary { background: var(--emerald); border-color: var(--emerald); color: #fff; }
.pilot-bar .btn.ghost { background: transparent; color: #b7cdc2; border-color: #2f5343; }
html, body { overflow-x: hidden; }
body { padding-bottom: 84px; }
.toast {
  top: 18px; right: 20px; left: auto; bottom: auto; transform: none;
}
.pilot-modal { width: min(520px, 92vw); }
.pilot-modal .form-grid { grid-template-columns: 1fr 1fr; }
.pilot-modal label.full { grid-column: 1 / -1; }
.pilot-status { margin: 10px 0 0; font-size: 12px; color: var(--emerald-dark); min-height: 18px; }
.pilot-status.error { color: var(--red); }
.small-note { font-size: 10.5px; color: var(--muted); margin-top: 8px; }
.local-foot { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: #8fb3a3; }
.recent-item .edge { color: #9ad8bd; }
@media (max-width: 820px) {
  .pilot-bar { padding: 10px 14px; }
  body { padding-bottom: 124px; }
}
