/* Smart Gas customer PWA — Haldorium design system */

:root {
  --teal: #0F6E56;     --teal-l: #E1F5EE;
  --red: #E24B4A;      --red-l: #FCEBEB;
  --amber: #BA7517;    --amber-l: #FAEEDA;
  --grey: #888780;     --grey-l: #ECEBE6;
  --text: #2D2D2A;     --muted: #888780;
  --bg: #F5F4F0;       --card: #FFFFFF;
  --line: #E6E4DD;     --gauge-track: #E1F5EE;
  --header-bg: #0F6E56; --header-fg: #FFFFFF;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --teal: #2BB58F;   --teal-l: #12302A;
    --red: #EF6463;    --red-l: #3A1D1D;
    --amber: #E09A3A;  --amber-l: #36291A;
    --grey: #8D8C86;   --grey-l: #262624;
    --text: #EDECE7;   --muted: #9A9993;
    --bg: #121211;     --card: #1C1C1A;
    --line: #2C2C29;   --gauge-track: #1F3A33;
    --header-bg: #121211; --header-fg: #EDECE7;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --teal: #2BB58F;   --teal-l: #12302A;
  --red: #EF6463;    --red-l: #3A1D1D;
  --amber: #E09A3A;  --amber-l: #36291A;
  --grey: #8D8C86;   --grey-l: #262624;
  --text: #EDECE7;   --muted: #9A9993;
  --bg: #121211;     --card: #1C1C1A;
  --line: #2C2C29;   --gauge-track: #1F3A33;
  --header-bg: #121211; --header-fg: #EDECE7;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px; line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input { font: inherit; color: inherit; }

.view { min-height: 100%; max-width: 480px; margin: 0 auto; }
.hint { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }
.hint.inline { display: inline; margin-left: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ── Login ── */
.login { padding: 72px 24px calc(32px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; min-height: 100vh; }
.brand-tile { width: 72px; height: 72px; border-radius: 20px; background: #0F6E56; display: grid; place-items: center; margin-bottom: 28px; }
.login-title { font-size: 36px; font-weight: 800; letter-spacing: -0.5px; }
.login-form { display: flex; flex-direction: column; gap: 8px; margin-top: 40px; flex: 1; }
.field-label { font-weight: 600; font-size: 18px; margin-top: 12px; }
.phone-field { display: flex; border: 2px solid var(--teal); border-radius: 14px; overflow: hidden; background: var(--card); }
.phone-prefix { background: var(--teal-l); color: var(--teal); font-weight: 700; font-size: 20px; padding: 14px 16px; }
.phone-field input, .pin-field { border: 0; outline: 0; background: transparent; font-size: 20px; padding: 14px 16px; width: 100%; letter-spacing: 1px; }
.pin-field { border: 2px solid var(--line); border-radius: 14px; background: var(--card); letter-spacing: 8px; }
.pin-field:focus { border-color: var(--teal); }
.form-error { color: var(--red); font-weight: 600; margin-top: 8px; }
.btn-primary { margin-top: auto; background: #0F6E56; color: #fff; border-radius: 14px; padding: 14px; font-size: 20px; font-weight: 700; }
.btn-primary .hint { color: #CFE9DF; }
.btn-primary:disabled { opacity: .6; }

/* ── Home ── */
.topbar { display: flex; align-items: center; gap: 4px; padding: calc(14px + env(safe-area-inset-top)) 12px 14px 20px;
  background: var(--header-bg); color: var(--header-fg); position: sticky; top: 0; z-index: 2; }
.topbar-title { font-size: 20px; font-weight: 700; flex: 1; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; }
.home { padding: 16px 18px calc(28px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }

.banner { display: flex; align-items: center; gap: 12px; background: var(--teal-l); border-radius: 14px; padding: 12px 14px; font-size: 14px; font-weight: 600; }
.banner > span { flex: 1; }
.btn-small { background: var(--teal); color: #fff; border-radius: 10px; padding: 8px 14px; font-weight: 700; }

.status-row { display: flex; justify-content: center; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 16px; white-space: nowrap; max-width: 100%; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill .hint { display: inline; margin-left: 4px; }
.pill.safe    { background: var(--teal-l);  color: var(--teal); }
.pill.low_gas, .pill.valve_open { background: var(--amber-l); color: var(--amber); }
.pill.danger  { background: var(--red); color: #fff; }
.pill.danger .hint { color: #FCEBEB; }
.pill.offline { background: var(--grey-l);  color: var(--grey); }

.gauge-wrap { position: relative; width: 190px; height: 190px; margin: 0 auto; }
.gauge { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge circle { fill: none; stroke-width: 10; }
.gauge-track { stroke: var(--gauge-track); }
.gauge-fill { stroke: var(--teal); stroke-linecap: round; stroke-dasharray: 326.73; stroke-dashoffset: 326.73; transition: stroke-dashoffset .6s ease; }
.gauge-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.gauge-value { font-size: 52px; font-weight: 800; letter-spacing: -1px; line-height: 1; }
.gauge-label { font-size: 14px; font-weight: 600; text-align: center; margin-top: 4px; }
.offline-mode .gauge-fill { stroke: var(--grey); }
.offline-mode .gauge-value { color: var(--grey); }

.last-seen { text-align: center; color: var(--muted); font-size: 15px; }
.last-seen.stale { color: var(--amber); font-weight: 600; }

.card { background: var(--card); border-radius: 16px; padding: 14px 16px; }
.card-title { font-size: 18px; font-weight: 700; display: flex; align-items: baseline; }
.usage-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.usage-grid b { display: block; font-size: 24px; font-weight: 800; }
.usage-grid span { display: block; font-size: 13px; font-weight: 600; }
.usage-grid .hint { font-weight: 400; }
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 56px; margin-top: 16px; }
.bar { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar i { display: block; width: 100%; border-radius: 4px; background: var(--teal); opacity: .55; min-height: 4px; }
.bar.today i { opacity: 1; }
.bar small { font-size: 10px; color: var(--muted); }

.sub-card.active   { background: var(--teal-l); }
.sub-card.expiring { background: var(--amber-l); }
.sub-card.expired  { background: var(--red-l); }
.sub-title { font-weight: 700; font-size: 16px; display: flex; gap: 8px; align-items: baseline; }
.sub-title::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; transform: translateY(-2px); }
.sub-card.active .sub-title { color: var(--teal); }
.sub-card.expiring .sub-title { color: var(--amber); }
.sub-card.expired .sub-title { color: var(--red); }
.sub-card .hint { margin-left: 16px; }
.sub-pay { margin: 8px 0 0 16px; font-weight: 600; }

.alert-list { list-style: none; margin-top: 6px; }
.alert-list li { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); font-weight: 600; }
.alert-list li:last-child { border-bottom: 0; }
.alert-list .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.alert-list .dot.red { background: var(--red); }
.alert-list .dot.amber { background: var(--amber); }
.alert-list .title { flex: 1; }
.alert-list time { color: var(--muted); font-weight: 400; font-size: 13px; white-space: nowrap; }
.alert-empty { color: var(--teal); font-weight: 600; padding: 12px 0; }

/* Theme sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet { background: var(--card); width: 100%; max-width: 480px; border-radius: 22px 22px 0 0; padding: 10px 18px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 6px; }
.radio { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; border: 2px solid transparent; background: var(--bg); font-weight: 600; }
.radio:has(input:checked) { border-color: var(--teal); background: var(--teal-l); color: var(--teal); }
.radio input { width: 20px; height: 20px; accent-color: var(--teal); }

/* ── Alarm (same in every theme) ── */
.alarm { background: #E24B4A; color: #fff; padding: calc(56px + env(safe-area-inset-top)) 28px calc(32px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; min-height: 100vh; max-width: none; }
.alarm .hint { color: #FCEBEB; }
.alarm-icon { width: 72px; height: 72px; border-radius: 50%; background: #fff; display: grid; place-items: center; }
.alarm-title { font-size: 44px; font-weight: 800; line-height: 1.05; margin-top: 28px; }
.alarm-sub { color: #FCEBEB; font-size: 14px; margin-top: 6px; }
.alarm-time { font-weight: 700; font-size: 18px; margin-top: 12px; }
.alarm-steps { list-style: none; counter-reset: s; margin-top: 28px; display: flex; flex-direction: column; gap: 20px; }
.alarm-steps li { counter-increment: s; display: grid; grid-template-columns: 40px 1fr; column-gap: 12px; }
.alarm-steps li::before { content: counter(s); grid-row: span 2; width: 36px; height: 36px; border-radius: 50%; background: #fff; color: #E24B4A; font-weight: 800; display: grid; place-items: center; }
.alarm-steps b { font-size: 22px; }
.alarm-steps span { font-size: 13px; color: #FCEBEB; }
.btn-alarm { margin-top: auto; background: #fff; color: #E24B4A; border-radius: 14px; padding: 16px; font-size: 24px; font-weight: 800; }
.btn-alarm .hint { color: #888780; }

.noscript { padding: 24px; text-align: center; }
