:root {
  --navy: #0a3d62;
  --navy-2: #072a40;
  --teal: #0e7c7b;
  --aqua: #17c3b2;
  --gold: #f0b429;
  --ink: #102a43;
  --muted: #627d98;
  --line: #d9e2ec;
  --paper: #f4f7f8;
  --white: #ffffff;
  --danger: #c0392b;
  --warn: #b7791f;
  --ok: #0f766e;
  --shadow: 0 18px 50px rgba(7, 42, 64, .28);
  --radius: 18px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
}

a { color: inherit; }
button, input, select, textarea { font-family: inherit; }
img { max-width: 100%; }

.demo-banner {
  background: var(--gold);
  color: var(--navy-2);
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .03em;
  padding: 9px 16px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.guest-body .demo-banner {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
}
.install-steps {
  margin: 18px 0 0;
  padding-left: 18px;
  color: rgba(255,255,255,.88);
  font-size: 14px;
}
.install-steps li { margin: 0 0 10px; }
.install-steps code { color: var(--gold); }

.muted { color: var(--muted); }
.gold { color: var(--gold); }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, Consolas, monospace; }

/* Guest / login */
.guest-body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(23, 195, 178, .35), transparent 50%),
    linear-gradient(165deg, #072a40 0%, #0a3d62 42%, #0e7c7b 100%);
  color: #fff;
  display: grid;
  place-items: center;
  padding: 24px;
}
.guest-body:has(.demo-banner) {
  padding-top: 52px;
}
.login-wrap {
  width: min(1080px, 100%);
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 28px;
  align-items: stretch;
}
.login-brand, .login-card {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 28px;
  padding: 36px;
  backdrop-filter: blur(10px);
}
.seal {
  display: block;
  object-fit: contain;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
}
.seal-sm { width: 40px; height: 40px; }
.seal-md { width: 72px; height: 72px; }
.seal-lg { width: 96px; height: 96px; }
.seal-xl { width: 140px; height: 140px; }
.login-brand .seal { margin-bottom: 4px; }
.login-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.login-card-head h2 { margin: 0; }
.home-crest, .bill-crest, .admin-title, .topbar-brand {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.topbar-brand { margin: 0; min-width: 0; }
.topbar-brand strong, .topbar-brand small { display: block; }
.bill-crest { background: #fff; border-radius: 16px; padding: 12px; margin-bottom: 12px; box-shadow: 0 8px 24px rgba(16,42,67,.06); }
.overlay .seal { margin: 0 auto 16px; }
.receipt-seal { text-align: center; margin: 0 0 8px; }
.receipt-seal .seal { margin: 0 auto; box-shadow: none; }
.qr-card .seal { margin: 0 auto 8px; }
.login-brand h1 { margin: 18px 0 6px; font-size: 32px; line-height: 1.15; }
.login-brand p { margin: 0 0 18px; color: rgba(255,255,255,.82); }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 28px; }
.kpi { background: rgba(0,0,0,.18); border-radius: 16px; padding: 14px 16px; }
.kpi b { display: block; font-size: 28px; }
.login-card { background: #fff; color: var(--ink); }
.login-card h2 { margin: 0 0 6px; }
.field { margin: 14px 0; }
.field label { display: block; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid rgba(14, 124, 123, .35);
  border-color: var(--teal);
}
.demo-grid { display: grid; gap: 8px; margin-top: 16px; }
.demo-chip {
  display: flex; justify-content: space-between; gap: 8px;
  background: var(--paper); border-radius: 12px; padding: 10px 12px; font-size: 13px;
}
.alert {
  padding: 12px 14px; border-radius: 12px; margin: 12px 0; font-size: 14px;
}
.alert-error { background: #fdecea; color: var(--danger); }
.alert-warn { background: #fff6e5; color: var(--warn); }
.alert-ok { background: #e6fffa; color: var(--ok); }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  vertical-align: middle;
}
.badge-demo { background: #fff6e5; color: var(--warn); }
.badge-office { background: #e6fffa; color: var(--ok); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 14px; padding: 14px 18px; font-weight: 700; cursor: pointer;
  text-decoration: none; font-size: 15px;
}
.btn-block { width: 100%; }
.btn-primary { background: linear-gradient(180deg, #14948f, #0e7c7b); color: #fff; box-shadow: 0 8px 20px rgba(14,124,123,.28); }
.btn-gold { background: var(--gold); color: var(--navy-2); }
.btn-dark { background: var(--navy); color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn-danger { background: #c0392b; color: #fff; }
.btn-lg { min-height: 56px; font-size: 17px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* Field presentation shell */
.field-body {
  min-height: 100vh;
  background: linear-gradient(165deg, #072a40, #0e7c7b 80%);
}
.field-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 430px;
  gap: 24px;
  padding: 24px;
  max-width: 1280px;
  margin: 0 auto;
}
.presenter {
  color: #fff;
  padding: 18px 8px 24px;
}
.presenter h1 { font-size: 42px; line-height: 1.05; margin: 12px 0 8px; }
.presenter .eyebrow { letter-spacing: .16em; text-transform: uppercase; font-size: 12px; color: var(--gold); font-weight: 700; }
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 28px 0; }
.stat { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.14); border-radius: 18px; padding: 16px; }
.stat b { font-size: 30px; display: block; }
.hint-box { background: rgba(0,0,0,.2); border-radius: 18px; padding: 16px 18px; }
.hint-box code { color: var(--gold); font-size: 16px; }

.phone {
  background: #111;
  border-radius: 36px;
  padding: 12px;
  box-shadow: var(--shadow);
  min-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}
.phone-notch { width: 120px; height: 8px; background: #2a2a2a; border-radius: 99px; margin: 4px auto 10px; }
.phone-screen {
  background: var(--paper);
  color: var(--ink);
  border-radius: 26px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.topbar {
  background: var(--navy);
  color: #fff;
  padding: 14px 16px 12px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.topbar small { color: rgba(255,255,255,.7); }
.screen-body { padding: 16px; overflow: auto; flex: 1; }
.nav-dock {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  padding: 8px; background: #fff; border-top: 1px solid var(--line);
}
.nav-dock a { text-align: center; text-decoration: none; font-size: 11px; font-weight: 700; color: var(--muted); padding: 8px 4px; border-radius: 12px; }
.nav-dock a.active, .nav-dock a:hover { color: var(--teal); background: #e6fffa; }

.hero-actions { display: grid; gap: 12px; margin: 8px 0 18px; }
.hero-actions[hidden] { display: none !important; }
.card {
  background: #fff; border-radius: var(--radius); padding: 16px; box-shadow: 0 8px 24px rgba(16,42,67,.06);
}
.card h3 { margin: 0 0 8px; }
.list { display: grid; gap: 8px; }
.list a, .list .row {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center;
  padding: 10px 12px; border-radius: 14px; background: #fff; text-decoration: none;
  border: 1px solid var(--line);
}
.time { font-size: 12px; color: var(--muted); font-weight: 700; }
.badge {
  display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 8px;
  font-size: 11px; font-weight: 800; letter-spacing: .03em;
}
.badge-ok { background: #c6f6d5; color: #22543d; }
.badge-warn { background: #feebc8; color: #7b341e; }
.badge-info { background: #bee3f8; color: #2a4365; }
.badge-bad { background: #fed7d7; color: #822727; }

.customer-name { font-size: 26px; margin: 0 0 4px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 10px; font-size: 14px; margin: 12px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 700; }

.reading-input {
  font-size: 42px; text-align: center; font-weight: 800; letter-spacing: .04em;
  border: 2px solid var(--teal) !important; border-radius: 18px !important; padding: 16px !important;
  background: #f0fffd !important;
}
.consumption-pill {
  margin-top: 10px; background: var(--navy); color: #fff; border-radius: 14px; padding: 12px;
  display: flex; justify-content: space-between; align-items: center;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 12px;
  font-size: 12px; font-weight: 700; cursor: pointer;
}
.chip input { display: none; }
.chip:has(input:checked) { background: var(--navy); color: #fff; border-color: var(--navy); }

.photo-box {
  border: 2px dashed var(--line); border-radius: 16px; padding: 16px; text-align: center; background: #fff;
}
.photo-box img { max-height: 180px; border-radius: 12px; margin-top: 8px; }

.total-hero { text-align: center; padding: 8px 0 16px; }
.total-hero span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .08em; }
.total-hero strong { font-size: 40px; }

.receipt {
  width: 58mm; margin: 0 auto; background: #fff; color: #111;
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 12px; line-height: 1.35; padding: 10px 8px;
}
.receipt.paper-80 { width: 80mm; }
.receipt pre { margin: 0; white-space: pre-wrap; }

/* Admin */
.admin-body { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: var(--navy-2); color: #fff; padding: 20px 14px; }
.sidebar .brand { display: flex; gap: 10px; align-items: center; margin-bottom: 24px; }
.sidebar img, .sidebar .seal { width: 42px; height: 42px; }
.sidebar nav a {
  display: block; color: rgba(255,255,255,.8); text-decoration: none; padding: 10px 12px; border-radius: 10px; margin-bottom: 4px; font-size: 14px;
}
.sidebar nav a:hover, .sidebar nav a.active { background: rgba(255,255,255,.1); color: #fff; }
.admin-main { padding: 24px 28px; }
.admin-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 20px; }
.admin-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.admin-card { background: #fff; border-radius: 16px; padding: 16px; border: 1px solid var(--line); }
.admin-card b { font-size: 28px; display: block; }
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 16px; overflow: hidden; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; }
th { background: #e8eef3; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input, .toolbar select { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); }

.overlay {
  position: fixed; inset: 0; background: rgba(7,42,64,.72); color: #fff;
  display: none; place-items: center; z-index: 50; text-align: center; padding: 24px;
}
.overlay.show { display: grid; }
.spinner {
  width: 48px; height: 48px; border: 4px solid rgba(255,255,255,.3); border-top-color: var(--gold);
  border-radius: 50%; margin: 0 auto 16px; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.qr-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px; text-align: center; }
.qr-card svg { width: 140px; height: 140px; }

@media (max-width: 960px) {
  .login-wrap, .field-shell, .admin-body { grid-template-columns: 1fr; }
  .presenter, .phone-notch { display: none; }
  .phone { padding: 0; border-radius: 0; min-height: 100vh; box-shadow: none; background: transparent; }
  .phone-screen { border-radius: 0; min-height: 100vh; }
  .admin-cards { grid-template-columns: 1fr 1fr; }
  .guest-body { padding: 12px; }
}

@media print {
  body * { visibility: hidden; }
    .receipt, .receipt * { visibility: visible; }
    .receipt { position: absolute; left: 0; top: 0; box-shadow: none; }
    .qr-card, .qr-card * { visibility: visible; }
  .no-print { display: none !important; }
}
