/* VoltLedger — one stylesheet, no inline styles (the page runs under a strict CSP). */
:root {
  --bg: #0b1020;
  --surface: #131a2e;
  --surface-2: #1b2440;
  --line: #2c3a5c;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #22c55e;
  --accent-ink: #04240f;
  --blue: #60a5fa;
  --amber: #fbbf24;
  --red: #f87171;
  --radius: 14px;
  --gap: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, system-ui, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.good { color: var(--accent); }
.warn { color: var(--amber); }
.bad { color: var(--red); }
.num { font-variant-numeric: tabular-nums; }
/* Phone numbers and other latin strings keep their own direction inside RTL text. */
.ltr { direction: ltr; unicode-bidi: isolate; }
.num.ltr { text-align: end; }
[dir="rtl"] .ltr:not(.num) { text-align: right; }

/* ---------------------------------------------------------------- sign in */
.signin {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.signin-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
}
.signin-card h1 { font-size: 22px; margin-bottom: 6px; }
.signin-card p { margin: 0 0 24px; color: var(--muted); font-size: 14px; }

/* ---------------------------------------------------------------- shell */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 20px 12px;
  background: #090d1a;
  border-inline-end: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 20px; font-size: 18px; font-weight: 700; }
/* The logo and the bolt occupy the same slot; app.js keeps exactly one visible. */
.logo { width: 34px; height: 34px; object-fit: contain; flex: none; }
.logo-lg { width: 76px; height: 76px; }
.bolt-lg { width: 56px; height: 56px; border-radius: 14px; font-size: 26px; }
.signin-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 20px; }
.signin-brand strong { font-size: 17px; text-align: center; }
.bolt {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 900;
}
.nav {
  border: 0;
  background: transparent;
  color: #cbd5e1;
  text-align: start;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 14px;
}
.nav:hover { background: var(--surface-2); color: #fff; }
.nav.active { background: var(--surface-2); color: #fff; box-shadow: inset 3px 0 var(--accent); }
[dir="rtl"] .nav.active { box-shadow: inset -3px 0 var(--accent); }
.side-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.side-foot strong { display: block; color: var(--text); font-size: 13px; }

.main { padding: 24px; width: 100%; max-width: 1500px; margin-inline: auto; }
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.top h1 { font-size: 24px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
/* Inputs default to full width; in the actions bar a search box shares the row. */
.actions .search { flex: 1 1 200px; width: auto; min-width: 160px; max-width: 340px; }

/* ---------------------------------------------------------------- controls */
.btn {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  padding: 0 14px;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, .nav:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}
.link { border: 0; background: transparent; color: var(--blue); padding: 2px 4px; text-decoration: underline; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input, select {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
}
.field { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 var(--gap); }
.form-actions { display: flex; gap: 8px; margin-top: 8px; }

/* ---------------------------------------------------------------- layout blocks */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: var(--gap); }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card + .card, .grid + .card, .card + .grid, .metrics + .card, .metrics + .grid { margin-top: var(--gap); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: var(--gap); }
.metric-label { color: var(--muted); font-size: 13px; }
.metric-value { font-weight: 700; font-size: 22px; margin-top: 8px; font-variant-numeric: tabular-nums; }
.metric-note { font-size: 12px; margin-top: 6px; color: var(--muted); }
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.section-head h2 { font-size: 16px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
  text-align: start;
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 11px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
/* The totals line is a summary, not another record: ruled off and not hoverable. */
tfoot td { border-top: 2px solid var(--line); border-bottom: 0; background: var(--surface-2); }
td.num, th.num { text-align: end; font-variant-numeric: tabular-nums; }
.empty { padding: 26px 8px; text-align: center; color: var(--muted); }

.tag { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; border: 1px solid; }
.tag.green { color: var(--accent); border-color: #14532d; background: #052e16; }
.tag.amber { color: var(--amber); border-color: #713f12; background: #2b1c04; }
.tag.red { color: var(--red); border-color: #7f1d1d; background: #300c0c; }
.tag.blue { color: var(--blue); border-color: #1e3a8a; background: #0b1b3f; }
.tag.grey { color: var(--muted); border-color: var(--line); background: var(--surface-2); }

.banner { border-radius: 10px; padding: 12px 14px; margin-bottom: var(--gap); border: 1px solid; font-size: 14px; }
.banner.warn { border-color: #713f12; background: #2b1c04; color: var(--amber); }
.banner.bad { border-color: #7f1d1d; background: #300c0c; color: var(--red); }
.banner.info { border-color: #1e3a8a; background: #0b1b3f; color: var(--blue); }

/* ---------------------------------------------------------------- modal + toast */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, .72);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 40;
}
.modal {
  width: min(660px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.modal-wide { width: min(900px, 100%); }
textarea {
  width: 100%;
  min-height: 120px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.6;
  direction: ltr;
  resize: vertical;
}
.preview {
  white-space: pre-wrap;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px 14px;
  margin: 0 0 14px;
  font-size: 14px;
}
code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--blue); }

.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-head h2 { font-size: 18px; }
.close { border: 0; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; padding: 0 6px; }

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 18px;
  z-index: 50;
  max-width: min(560px, 92vw);
}
.toast.bad { border-color: var(--red); color: #fecaca; }
.toast.good { border-color: var(--accent); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .brand { width: 100%; padding-bottom: 10px; }
  .side-foot { width: 100%; }
  .main { padding: 16px; }
}
