:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #526174;
  --line: #d8dee8;
  --surface: #ffffff;
  --page: #f6f8fb;
  --soft: #eef4ff;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #0f766e;
  --warn: #9a3412;
  --danger: #b42318;
  --ok: #167647;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}
a { color: var(--primary-dark); }
a:hover { color: var(--primary); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.25);
  outline-offset: 2px;
}
main { width: min(1240px, calc(100% - 32px)); margin: 24px auto 56px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand-block { min-width: 220px; }
.brand { display: inline-block; color: var(--ink); font-size: 20px; font-weight: 800; text-decoration: none; }
.caption, small, .meta { color: var(--muted); }
nav { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
nav a { border-radius: 6px; color: var(--ink); font-size: 14px; font-weight: 700; padding: 7px 9px; text-decoration: none; }
nav a:hover { background: var(--soft); color: var(--primary-dark); }
nav form { margin: 0; }
button, .button-link {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: white;
  border-radius: 6px;
  padding: 9px 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  text-decoration: none;
  font: inherit;
  font-weight: 750;
  transition: background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}
button:hover, .button-link:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: white; }
.button-link.secondary, button.secondary { background: white; color: var(--primary-dark); }
.button-link.secondary:hover, button.secondary:hover { background: var(--soft); color: var(--primary-dark); }
button:disabled, .disabled {
  color: #5f6f83;
  background: #eef2f7;
  border-color: #cbd5e1;
}
.context-bar {
  align-items: center;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  color: var(--warn);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
  padding: 10px 12px;
}
.page-heading {
  align-items: end;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin: 18px 0;
}
.eyebrow, .label { color: var(--accent); font-size: 13px; font-weight: 850; margin: 0 0 6px; text-transform: uppercase; }
.lede { color: var(--muted); max-width: 760px; margin: 0; }
h1, h2, h3 { letter-spacing: 0; margin: 0 0 12px; }
h1 { font-size: 34px; line-height: 1.15; }
h2 { font-size: 21px; }
h3 { font-size: 16px; }
.panel, .login-panel, .metric-grid article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.panel { margin-top: 16px; }
.metric-grid, .quota-grid, .detail-grid { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-grid article span, .quota-grid span { color: var(--muted); display: block; font-size: 13px; font-weight: 700; }
.metric-grid article strong { display: block; font-size: 26px; margin: 4px 0; }
.metric-grid article small { overflow-wrap: anywhere; }
.quota-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.quota-grid div { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
meter { display: block; width: 100%; height: 10px; margin: 8px 0; }
.split { display: grid; gap: 16px; grid-template-columns: 1.4fr 1fr; }
.detail-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.section-header { align-items: center; display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
table { border-collapse: collapse; width: 100%; }
th, td { border-bottom: 1px solid var(--line); padding: 11px 10px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 13px; font-weight: 800; }
td { overflow-wrap: anywhere; }
dl { display: grid; gap: 8px 16px; grid-template-columns: max-content 1fr; margin: 0; }
dt { color: var(--muted); font-weight: 800; }
dd { margin: 0; }
.badge, .status, .pill {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 9px;
  white-space: nowrap;
}
.badge { background: #f8fafc; color: #334155; }
.badge-warning { background: #fff7ed; border-color: #fed7aa; color: var(--warn); }
.badge-danger { background: #fff1f2; border-color: #fecdd3; color: var(--danger); }
.status { background: #eef2f7; color: #334155; }
.status-active { background: #ecfdf3; border-color: #bbf7d0; color: var(--ok); }
.status-shutoff, .status-error { background: #fff1f2; border-color: #fecdd3; color: var(--danger); }
.pill { background: #f8fafc; margin: 3px 6px 3px 0; }
.amount { font-size: 36px; font-weight: 850; margin: 8px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.form-grid { align-items: end; display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid label { margin: 0; }
.confirmation { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; grid-column: 1 / -1; padding: 12px; }
.confirmation span { color: var(--muted); display: block; margin-top: 4px; }
.compact-form { margin-top: 12px; }
.inline-form { display: inline-flex; margin: 0 4px 4px 0; }
.inline-form button { min-height: 32px; padding: 6px 10px; }
.disabled {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  display: inline-flex;
  font-weight: 750;
  padding: 7px 10px;
}
label { display: block; font-weight: 750; margin: 14px 0 6px; }
input, select, textarea {
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  margin-top: 6px;
  padding: 10px 12px;
  width: 100%;
}
.login-page { display: grid; min-height: 100vh; place-items: center; }
.login-shell { margin: 0; width: min(440px, calc(100% - 32px)); }
.login-panel h1 { font-size: 34px; }
.login-panel button { margin-top: 18px; width: 100%; }
.qr svg { border: 1px solid var(--line); height: auto; max-width: 280px; }
.footer { color: var(--muted); margin: 0 auto 32px; width: min(1240px, calc(100% - 32px)); }
@media (max-width: 980px) {
  .topbar, .page-heading { align-items: flex-start; flex-direction: column; }
  nav { justify-content: flex-start; }
  .metric-grid, .quota-grid, .detail-grid, .split, .form-grid, .form-grid.two { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  main, .footer { width: min(100% - 20px, 1240px); }
  .topbar { padding: 12px 14px; }
  nav { gap: 4px; }
  nav a { padding: 6px 7px; }
  h1 { font-size: 28px; }
  th, td { padding: 9px 6px; }
}
