/* ==========================================================================
   PropertyVest Metering Solution — Design Tokens
   ========================================================================== */

:root {
  /* Color */
  --bg: #0B0F14;
  --bg-raised: #0E1420;
  --surface: #111926;
  --surface-2: #151F2E;
  --border-hair: #212D3D;
  --border-hair-soft: #1A2432;

  --text-primary: #F3F6FA;
  --text-secondary: #8B99AC;
  --text-tertiary: #5D6B7F;

  --accent-green: #14E600;
  --accent-green-dim: #0B7A55;
  --accent-blue: #4FD6FF;
  --accent-amber: #FFB454;
  --accent-red: #FF5C72;

  --focus-ring: #4FD6FF;

  /* Type */
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Consolas, "Liberation Mono", monospace;

  /* Layout */
  --app-max-width: 460px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --header-h: 60px;
  --tabbar-h: 72px;
}

/* ==========================================================================
   Reset
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  background:
    radial-gradient(ellipse 900px 460px at 50% -8%, rgba(20, 230, 0, 0.08), transparent 60%),
    var(--bg);
}

h1, h2, h3, p, ul, fieldset, legend, input, button, form { margin: 0; padding: 0; }
fieldset { border: none; }
ul { list-style: none; }
button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input { font-family: inherit; color: inherit; }
button:focus-visible,
input:focus-visible,
.source-badge:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ==========================================================================
   App Shell
   ========================================================================== */

#app {
  max-width: var(--app-max-width);
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  border-left: 1px solid var(--border-hair-soft);
  border-right: 1px solid var(--border-hair-soft);
}

.app-header {
  flex: 0 0 var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--border-hair);
  background: rgba(11, 15, 20, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border-hair);
  padding: 4px;
}
.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-size: 14.5px; font-weight: 650; letter-spacing: 0.01em; }
.brand-sub { font-size: 10.5px; color: var(--text-secondary); letter-spacing: 0.02em; }

.conn-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  padding: 5px 9px;
  border: 1px solid var(--border-hair);
  border-radius: 999px;
  background: var(--surface);
}
.conn-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 6px 1px rgba(20, 230, 0, 0.7);
}

.app-main {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 16px calc(24px + var(--tabbar-h));
  -webkit-overflow-scrolling: touch;
}

.tab-panel { display: flex; flex-direction: column; gap: 16px; }
.tab-panel[hidden] { display: none; }

.tab-bar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  flex: 0 0 var(--tabbar-h);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  border-top: 1px solid var(--border-hair);
  background: rgba(11, 15, 20, 0.9);
  backdrop-filter: blur(10px);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 10px 0 8px;
  color: var(--text-tertiary);
  font-size: 9.5px;
  letter-spacing: 0.01em;
  transition: color 0.15s ease;
}
.tab-btn svg { transition: transform 0.15s ease; }
.tab-btn.is-active { color: var(--accent-green-dim); }
.tab-btn.is-active svg { transform: translateY(-1px); }
.tab-btn:active svg { transform: scale(0.92); }

/* ==========================================================================
   Dashboard — Readout
   ========================================================================== */

.readout-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-hair);
  border-radius: var(--radius-md);
  background: linear-gradient(155deg, var(--surface) 0%, var(--surface-2) 100%);
  box-shadow: 0 1px 2px rgba(16, 22, 31, 0.03), 0 16px 32px -12px rgba(16, 22, 31, 0.10);
  padding: 22px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.readout-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.readout-value {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.readout-digits {
  font-family: var(--font-mono);
  font-size: 46px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-primary);
}

.readout-unit {
  font-family: var(--font-mono);
  font-size: 17px;
  color: var(--accent-blue);
  font-weight: 600;
}

.readout-sub {
  font-size: 12px;
  color: var(--text-tertiary);
}

.readout-glow {
  position: absolute;
  right: -60px;
  top: -60px;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(20, 230, 0, 0.14), transparent 70%);
  pointer-events: none;
}

/* Source badges */

.source-row { display: flex; gap: 8px; }

.source-badge {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 10px;
  border: 1px solid var(--border-hair);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 550;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.source-badge .source-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-tertiary);
}

.source-badge.is-active {
  color: var(--text-primary);
  border-color: var(--accent-green-dim);
  background: rgba(20, 230, 0, 0.08);
}
.source-badge.is-active .source-dot {
  background: var(--accent-green);
  box-shadow: 0 0 6px 1px rgba(20, 230, 0, 0.65);
}

/* Metrics strip */

.metrics-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--border-hair);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}

.metric-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 14px 6px;
  border-right: 1px solid var(--border-hair);
}
.metric-block:last-child { border-right: none; }

.metric-value {
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 600;
  color: var(--accent-blue);
}
.metric-unit {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  min-height: 13px;
}
.metric-label {
  font-size: 10.5px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Panel card (key/value) */

.panel-card {
  border: 1px solid var(--border-hair);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
}

.panel-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-hair-soft);
  font-size: 13px;
}
.panel-card-row:last-child { border-bottom: none; }

.panel-card-key { color: var(--text-secondary); }
.panel-card-val { font-family: var(--font-mono); color: var(--text-primary); font-size: 12.5px; }
.panel-card-val--active { color: var(--accent-green-dim); }

.app-footer-inline {
  text-align: center;
  font-size: 11px;
  color: var(--text-tertiary);
  padding-top: 6px;
}

/* ==========================================================================
   Shared panel headings
   ========================================================================== */

.panel-heading { font-size: 19px; font-weight: 650; }
.panel-subheading { font-size: 12.5px; color: var(--text-secondary); margin-top: -10px; }

/* ==========================================================================
   Token Vending
   ========================================================================== */

.vend-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  border: 1px solid var(--border-hair);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 18px 16px;
}

.field-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.voucher-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.voucher-chip {
  padding: 11px 4px;
  text-align: center;
  border: 1px solid var(--border-hair);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font-mono);
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.voucher-chip--custom { grid-column: span 3; font-family: var(--font-ui); }

.voucher-chip.is-selected {
  color: #06130B;
  background: var(--accent-green);
  border-color: var(--accent-green);
  font-weight: 650;
}

.custom-amount-input,
.text-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-hair);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text-primary);
  font-size: 14px;
  margin-top: 10px;
}
.text-input { margin-top: 0; font-family: var(--font-mono); }
.custom-amount-input::placeholder,
.text-input::placeholder { color: var(--text-tertiary); }

.btn-primary {
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  background: var(--accent-green);
  color: #06130B;
  font-size: 14px;
  font-weight: 650;
  text-align: center;
  transition: transform 0.1s ease, filter 0.15s ease;
}
.btn-primary:active { transform: scale(0.98); filter: brightness(0.94); }

.btn-secondary {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-hair);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 550;
  text-align: center;
  transition: transform 0.1s ease, border-color 0.15s ease;
}
.btn-secondary:active { transform: scale(0.98); }

.token-result {
  border: 1px solid var(--accent-green-dim);
  border-radius: var(--radius-md);
  background: linear-gradient(155deg, rgba(20, 230, 0, 0.09), var(--surface) 60%);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: token-in 0.35s ease;
}

@keyframes token-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.token-result-label {
  font-size: 11.5px;
  color: var(--accent-green-dim);
  font-weight: 650;
  letter-spacing: 0.02em;
}

.token-digits {
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  word-spacing: 4px;
  line-height: 1.6;
}

.token-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.token-disclaimer {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.45;
}

/* ==========================================================================
   Usage Analytics
   ========================================================================== */

.chart-card {
  position: relative;
  border: 1px solid var(--border-hair);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 20px 16px 12px;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  height: 140px;
}

.chart-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 8px;
}

.chart-bar {
  width: 100%;
  max-width: 26px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, var(--accent-blue), rgba(10, 111, 192, 0.35));
  transition: filter 0.15s ease;
}
.chart-bar-col.is-selected .chart-bar {
  background: linear-gradient(180deg, var(--accent-green), rgba(20, 230, 0, 0.4));
}

.chart-bar-label {
  font-size: 10.5px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.chart-tooltip {
  position: absolute;
  top: 8px;
  right: 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border-hair);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.usage-log {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-hair);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}

.usage-log-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-hair-soft);
}
.usage-log-row:last-child { border-bottom: none; }

.usage-log-date { font-size: 12.5px; color: var(--text-primary); }
.usage-log-source { font-size: 10.5px; color: var(--text-tertiary); margin-top: 2px; }
.usage-log-figures { text-align: right; }
.usage-log-kwh { font-family: var(--font-mono); font-size: 13px; color: var(--accent-blue); }
.usage-log-cost { font-size: 10.5px; color: var(--text-tertiary); margin-top: 2px; }

/* ==========================================================================
   Scanner
   ========================================================================== */

.scanner-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border-hair);
}

#scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scanner-frame {
  position: absolute;
  inset: 14% 10%;
  pointer-events: none;
}
.corner {
  position: absolute;
  width: 26px;
  height: 26px;
  border: 3px solid var(--accent-green);
  filter: drop-shadow(0 0 4px rgba(20, 230, 0, 0.6));
}
.corner-tl { top: 0; left: 0; border-right: none; border-bottom: none; border-radius: 4px 0 0 0; }
.corner-tr { top: 0; right: 0; border-left: none; border-bottom: none; border-radius: 0 4px 0 0; }
.corner-bl { bottom: 0; left: 0; border-right: none; border-top: none; border-radius: 0 0 0 4px; }
.corner-br { bottom: 0; right: 0; border-left: none; border-top: none; border-radius: 0 0 4px 0; }

.scanner-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: var(--surface);
  color: var(--text-tertiary);
}
.scanner-fallback svg { color: var(--text-tertiary); }
.scanner-fallback p { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

.scanner-controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.btn-capture {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border-hair);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  justify-self: center;
}
.capture-ring {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 14px 2px rgba(20, 230, 0, 0.45);
}
.btn-capture:active .capture-ring { transform: scale(0.9); }
.btn-capture:disabled { opacity: 0.4; }
.btn-capture:disabled .capture-ring { box-shadow: none; }

.scanner-count {
  font-size: 11.5px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  text-align: right;
}

.capture-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.capture-strip:empty::after {
  content: "Captured frames appear here.";
  font-size: 12px;
  color: var(--text-tertiary);
}

.capture-thumb {
  flex: 0 0 auto;
  width: 68px;
  height: 68px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-hair);
  overflow: hidden;
}
.capture-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ==========================================================================
   Small screens
   ========================================================================== */

@media (max-width: 360px) {
  .readout-digits { font-size: 38px; }
  .metric-value { font-size: 16px; }
}

/* ==========================================================================
   Prepay Wallet card
   ========================================================================== */

.wallet-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  border: 1px solid var(--border-hair);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 16px;
}

.wallet-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.wallet-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.wallet-balance {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 2px;
}

.wallet-currency { color: var(--accent-green-dim); font-size: 20px; margin-right: 1px; }
.wallet-balance-decimals { color: var(--text-tertiary); font-size: 16px; }

.wallet-sub {
  display: block;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.wallet-eye-btn {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border-hair);
  color: var(--text-secondary);
  background: var(--surface-2);
}
.wallet-eye-btn:active { transform: scale(0.94); }

.wallet-actions { display: flex; gap: 10px; }
.wallet-action-btn { flex: 1; }

.wallet-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px solid var(--border-hair-soft);
  animation: token-in 0.25s ease;
}

.wallet-form-actions { display: flex; gap: 10px; }
.wallet-form-actions .wallet-form-submit { flex: 1; }

.wallet-form-note {
  font-size: 11.5px;
  color: var(--accent-red);
}

.btn-ghost {
  padding: 12px 16px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 550;
  text-align: center;
}
.btn-ghost:active { opacity: 0.7; }

/* ==========================================================================
   Vend — wallet warning
   ========================================================================== */

.vend-wallet-warning {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--accent-red);
  border-radius: var(--radius-md);
  background: rgba(224, 50, 76, 0.05);
  padding: 14px 16px;
}
.vend-wallet-warning p {
  font-size: 12.5px;
  color: var(--text-primary);
  line-height: 1.5;
}

/* ==========================================================================
   Ledger
   ========================================================================== */

.ledger-log {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-hair);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}

.ledger-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-hair-soft);
}
.ledger-row:last-child { border-bottom: none; }

.ledger-icon {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ledger-icon--credit { background: rgba(20, 230, 0, 0.12); color: var(--accent-green-dim); }
.ledger-icon--debit { background: rgba(224, 50, 76, 0.10); color: var(--accent-red); }

.ledger-main { flex: 1 1 auto; min-width: 0; }
.ledger-desc {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ledger-meta { font-size: 10.5px; color: var(--text-tertiary); margin-top: 2px; }

.ledger-amount {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
}
.ledger-amount--credit { color: var(--accent-green-dim); }
.ledger-amount--debit { color: var(--accent-red); }

/* ==========================================================================
   Hub
   ========================================================================== */

.hub-section { display: flex; flex-direction: column; gap: 8px; }

.hub-section-title {
  font-size: 11.5px;
  font-weight: 650;
  color: var(--text-tertiary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding-left: 2px;
}

.hub-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-hair);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}

.hub-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border-hair-soft);
}
.hub-row:last-child { border-bottom: none; }
.hub-row:active { background: var(--bg-raised); }

.hub-icon {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 230, 0, 0.12);
  color: var(--accent-green-dim);
}

.hub-row-label {
  flex: 1 1 auto;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--text-primary);
}

.hub-row-meta {
  flex: 0 0 auto;
  font-size: 11.5px;
  color: var(--text-tertiary);
}

.hub-chevron { flex: 0 0 auto; color: var(--text-tertiary); transition: transform 0.2s ease; }
.hub-row.is-open .hub-chevron { transform: rotate(90deg); color: var(--accent-green-dim); }

.hub-detail {
  padding: 12px 14px 16px 58px;
  border-bottom: 1px solid var(--border-hair-soft);
  background: var(--surface-2);
}
.hub-detail:last-child { border-bottom: none; }
.hub-detail p { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }

.hub-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.hub-mini-list { display: flex; flex-direction: column; gap: 8px; }
.hub-mini-list li { display: flex; flex-direction: column; }
.hub-mini-title { font-size: 12px; color: var(--text-primary); }
.hub-mini-meta { font-size: 10.5px; color: var(--text-tertiary); margin-top: 1px; }

.hub-facility-card {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
}
.hub-facility-card + .hub-facility-card { border-top: 1px solid var(--border-hair-soft); }
.hub-facility-name { font-size: 12.5px; color: var(--text-primary); font-weight: 550; }
.hub-facility-meta { font-size: 10.5px; color: var(--text-tertiary); margin-top: 2px; font-family: var(--font-mono); }


/* ==========================================================================
   Auth shell
   ========================================================================== */

#auth-shell {
  max-width: var(--app-max-width);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-hair-soft);
  border-right: 1px solid var(--border-hair-soft);
}

.auth-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 28px 18px 10px;
}

.auth-main {
  flex: 1 1 auto;
  padding: 10px 20px 32px;
  display: flex;
  flex-direction: column;
}

.auth-demo-hint {
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-tertiary);
  background: var(--bg-raised);
  border: 1px solid var(--border-hair);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  margin-bottom: 16px;
}
.auth-demo-hint code {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-secondary);
}

.auth-view { display: flex; flex-direction: column; }
.auth-view[hidden] { display: none; }

.auth-heading { font-size: 24px; font-weight: 650; margin-bottom: 4px; }
.auth-subheading { font-size: 13px; color: var(--text-secondary); margin-bottom: 18px; }

.auth-error {
  font-size: 12.5px;
  color: var(--accent-red);
  background: rgba(224, 50, 76, 0.06);
  border: 1px solid rgba(224, 50, 76, 0.35);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  margin-bottom: 14px;
}
.auth-error--info {
  color: var(--accent-green-dim);
  background: rgba(20, 230, 0, 0.07);
  border-color: var(--accent-green-dim);
}

.auth-form { display: flex; flex-direction: column; gap: 4px; }
.auth-form .field-label { margin-top: 10px; }
.auth-form .field-label:first-child { margin-top: 0; }
.auth-form .btn-primary { margin-top: 18px; }

.field-label-optional { color: var(--text-tertiary); font-weight: 400; }

.auth-link-btn {
  align-self: flex-start;
  font-size: 12.5px;
  color: var(--accent-blue);
  font-weight: 550;
  padding: 6px 0;
}
.auth-link-btn:active { opacity: 0.7; }

.auth-switch {
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
}
.auth-switch .auth-link-btn { display: inline; padding: 0; font-size: 13px; }

/* ==========================================================================
   Header badges
   ========================================================================== */

.header-badges { display: flex; align-items: center; gap: 8px; }

.env-badge {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.03em;
  color: var(--accent-amber);
  background: rgba(201, 115, 0, 0.1);
  border: 1px solid rgba(201, 115, 0, 0.35);
  border-radius: 999px;
  padding: 4px 9px;
}

.estate-badge {
  font-size: 10.5px;
  font-weight: 650;
  color: var(--accent-blue);
  background: rgba(10, 111, 192, 0.08);
  border: 1px solid rgba(10, 111, 192, 0.3);
  border-radius: 999px;
  padding: 4px 10px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.estate-badge:active { opacity: 0.7; }

/* ==========================================================================
   Quick actions
   ========================================================================== */

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 6px;
  border: 1px solid var(--border-hair);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  line-height: 1.25;
  transition: transform 0.1s ease, border-color 0.15s ease;
}
.quick-action-btn:active { transform: scale(0.97); border-color: var(--accent-green-dim); }

.quick-action-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(20, 230, 0, 0.12);
  color: var(--accent-green-dim);
}

/* ==========================================================================
   Multi-step flows (Fund Wallet / Buy Electricity / Bill Centre / Link Meter)
   ========================================================================== */

[data-step][hidden] { display: none; }

.flow-summary-line { font-size: 14px; color: var(--text-primary); line-height: 1.5; margin-bottom: 8px; }
.flow-summary-line strong { font-family: var(--font-mono); color: var(--accent-green-dim); }
.flow-summary-note { font-size: 11.5px; color: var(--text-tertiary); line-height: 1.5; margin-bottom: 4px; }

.flow-success-line { font-size: 14px; color: var(--accent-green-dim); font-weight: 600; line-height: 1.5; margin-bottom: 10px; }
.flow-failure-line { font-size: 13.5px; color: var(--accent-red); line-height: 1.5; margin-bottom: 12px; }

.flow-pending {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 10px 0;
}

.flow-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border-hair);
  border-top-color: var(--accent-green-dim);
  animation: flow-spin 0.7s linear infinite;
  flex: 0 0 auto;
}
@keyframes flow-spin { to { transform: rotate(360deg); } }

.flow-receipt {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-hair);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
  margin-bottom: 10px;
}
.flow-receipt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border-hair-soft);
}
.flow-receipt-row:last-child { border-bottom: none; }
.flow-receipt-row span:first-child { color: var(--text-secondary); }
.flow-receipt-row span:last-child { font-family: var(--font-mono); color: var(--text-primary); font-weight: 600; }

/* ==========================================================================
   Sheet overlay (Bill Centre / Link Meter)
   ========================================================================== */

body.sheet-lock { overflow: hidden; }

.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(16, 22, 31, 0);
  transition: background 0.2s ease;
}
.sheet-overlay[hidden] { display: none; }
.sheet-overlay.is-open { background: rgba(16, 22, 31, 0.45); }

.sheet-panel {
  width: 100%;
  max-width: var(--app-max-width);
  max-height: 86dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 18px 18px 0 0;
  border: 1px solid var(--border-hair);
  border-bottom: none;
  box-shadow: 0 -12px 32px -12px rgba(16, 22, 31, 0.25);
  transform: translateY(100%);
  transition: transform 0.25s ease;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.sheet-overlay.is-open .sheet-panel { transform: translateY(0); }

.sheet-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border-hair-soft);
}
.sheet-title { font-size: 16px; font-weight: 650; }
.sheet-close-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-raised);
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sheet-close-btn:active { opacity: 0.7; }

.sheet-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 18px 24px;
  -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   Bill Centre
   ========================================================================== */

.bill-filter-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.bill-filter-btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-hair);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 550;
}
.bill-filter-btn.is-active {
  color: var(--text-primary);
  border-color: var(--accent-green-dim);
  background: rgba(20, 230, 0, 0.08);
}

.bill-add-btn {
  margin-left: auto;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--accent-green-dim);
  background: rgba(20, 230, 0, 0.08);
  color: var(--accent-green-dim);
  font-size: 12px;
  font-weight: 650;
}
.bill-add-btn:active { opacity: 0.75; }

.bill-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-hair);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}
.bill-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border-hair-soft);
}
.bill-row:last-child { border-bottom: none; }
.bill-row:active { background: var(--bg-raised); }
.bill-row-title { font-size: 13px; font-weight: 550; color: var(--text-primary); }
.bill-row-meta { font-size: 10.5px; color: var(--text-tertiary); margin-top: 2px; }
.bill-row-right { text-align: right; flex: 0 0 auto; }
.bill-row-amount { font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: var(--text-primary); }

.bill-status-badge {
  display: inline-block;
  margin-top: 3px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 650;
  text-transform: capitalize;
}
.bill-status-badge--outstanding { background: rgba(201, 115, 0, 0.12); color: var(--accent-amber); }
.bill-status-badge--overdue { background: rgba(224, 50, 76, 0.12); color: var(--accent-red); }
.bill-status-badge--paid { background: rgba(20, 230, 0, 0.12); color: var(--accent-green-dim); }

.bill-empty { padding: 20px 14px; text-align: center; font-size: 12.5px; color: var(--text-tertiary); }

.estate-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-hair);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
  margin-bottom: 14px;
}
.estate-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border-hair-soft);
}
.estate-row:last-child { border-bottom: none; }
.estate-row:active { background: var(--bg-raised); }
.estate-row-name { font-size: 13px; font-weight: 550; color: var(--text-primary); }
.estate-row-address { font-size: 10.5px; color: var(--text-tertiary); margin-top: 2px; }
.estate-row-badge {
  flex: 0 0 auto;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 650;
  background: rgba(20, 230, 0, 0.12);
  color: var(--accent-green-dim);
}

/* ==========================================================================
   Meter status (Hub -> My Meters) + Link Meter
   ========================================================================== */

.meter-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }

.meter-status-badge {
  flex: 0 0 auto;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 650;
  white-space: nowrap;
}
.meter-status-badge--active { background: rgba(20, 230, 0, 0.12); color: var(--accent-green-dim); }
.meter-status-badge--inactive { background: var(--bg-raised); color: var(--text-tertiary); }
.meter-status-badge--pending_verification { background: rgba(201, 115, 0, 0.12); color: var(--accent-amber); }
.meter-status-badge--fault { background: rgba(224, 50, 76, 0.12); color: var(--accent-red); }

.meter-unlink-btn { margin-top: 8px; align-self: flex-start; padding: 8px 12px; font-size: 11.5px; }

.hub-detail-note { font-size: 12px; color: var(--text-tertiary); }

/* ==========================================================================
   Ledger status badge (pending/failed entries)
   ========================================================================== */

.ledger-status {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 650;
  text-transform: capitalize;
  vertical-align: middle;
}
.ledger-status--pending { background: rgba(201, 115, 0, 0.12); color: var(--accent-amber); }
.ledger-status--failed { background: rgba(224, 50, 76, 0.12); color: var(--accent-red); }
.ledger-empty { padding: 18px 14px; text-align: center; font-size: 12.5px; color: var(--text-tertiary); }

/* ==========================================================================
   Dashboard: recent activity + empty meter state
   ========================================================================== */

.recent-tx-section { display: flex; flex-direction: column; gap: 8px; }
.recent-tx-header { display: flex; align-items: center; justify-content: space-between; }
.recent-tx-header .auth-link-btn { padding: 0; font-size: 11.5px; }
.recent-tx-empty { font-size: 12px; color: var(--text-tertiary); text-align: center; padding: 14px 0; }

.dashboard-meter-empty .panel-card-key { color: var(--text-secondary); }
.panel-card-action { width: 100%; }

/* ==========================================================================
   Scanner: manual meter-number confirmation
   ========================================================================== */

.scanner-confirm {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--border-hair);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  padding: 14px;
}

/* ==========================================================================
   Small screens — auth
   ========================================================================== */

@media (max-width: 360px) {
  .quick-action-btn { font-size: 10px; }
  .auth-heading { font-size: 21px; }
}

/* ==========================================================================
   hidden-attribute fix for the two shells

   #app and #auth-shell each set `display: flex` via an ID selector. Since
   normal author CSS always outranks the UA default `[hidden]{display:none}`
   regardless of specificity, that flex rule would otherwise defeat the
   `hidden` attribute entirely. These two rules make `hidden` win back by
   matching on the attribute at equal-or-higher specificity.
   ========================================================================== */

#app[hidden], #auth-shell[hidden] { display: none; }

/* Global safety net: the `hidden` attribute must always win, no matter
   what a class rule elsewhere sets `display` to. A static audit found six
   elements across wallet forms, the Buy Electricity token panel, and the
   scanner fallback/confirm panels that were ALWAYS visible despite being
   marked hidden, because a class-based `display` rule (same author
   origin, equal specificity) was declared after `[hidden]` in the
   cascade and simply overrode it. The per-element overrides above predate
   this and are now redundant but harmless. This one rule covers every
   current case and any future one — nothing should ever need its own
   `.class[hidden]` override again. */
[hidden] { display: none !important; }

/* ==========================================================================
   Loading-state polish
   ========================================================================== */

.ledger-empty--loading, .bill-empty--loading {
  animation: loading-pulse 1.4s ease-in-out infinite;
}
@keyframes loading-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

/* ==========================================================================
   Responsive: desktop layout

   Below ~880px this file is untouched — that's the exact mobile layout
   it's always been, phone or otherwise. Above that, the app stops being
   a phone-width column stretched into empty space on a wide screen and
   becomes an actual desktop layout:
     - the app frame widens and gets a subtle card treatment on the page
     - the tab bar moves from a bottom mobile tab bar to a top nav, via
       explicit flex `order` on the three #app children — no DOM/JS
       change, so mobile markup and behavior stay identical
     - content settles into a comfortable reading width instead of
       stretching edge to edge across the whole frame
     - sheet overlays (Bill Centre, Link a Meter, Manage Admins) stop
       sliding up as a mobile bottom sheet and become a centered dialog
   ========================================================================== */

@media (min-width: 880px) {
  #app {
    max-width: none;
    min-height: 100dvh;
    height: auto;
    border-left: none;
    border-right: none;
  }

  #auth-shell {
    max-width: 480px;
    box-shadow: 0 1px 40px -12px rgba(16, 22, 31, 0.12);
  }

  .app-header {
    order: 0;
    padding: 0 36px;
  }

  .tab-bar {
    order: 1;
    position: static;
    flex: 0 0 52px;
    display: flex;
    justify-content: flex-start;
    align-items: stretch;
    gap: 4px;
    padding: 0 30px;
    border-top: none;
    border-bottom: 1px solid var(--border-hair);
    background: var(--surface);
    backdrop-filter: none;
  }

  .app-main {
    order: 2;
    width: 100%;
    padding: 28px 36px 48px;
  }

  .tab-btn {
    flex-direction: row;
    gap: 7px;
    padding: 0 14px;
    font-size: 12.5px;
    font-weight: 550;
    border-radius: var(--radius-sm);
  }
  .tab-btn.is-active { background: rgba(20, 230, 0, 0.08); }
  .tab-btn.is-active svg { transform: none; }

  /* Sheet overlays: centered dialog, not a mobile bottom sheet. */
  .sheet-overlay { align-items: center; padding: 24px; }
  .sheet-panel {
    max-width: 480px;
    max-height: 84dvh;
    border-radius: 16px;
    border-bottom: 1px solid var(--border-hair);
    box-shadow: 0 24px 60px -20px rgba(16, 22, 31, 0.35);
    transform: translateY(12px);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
  }
  .sheet-overlay.is-open .sheet-panel { transform: translateY(0); opacity: 1; }
}
