:root {
  color-scheme: light;
  --bg: #faf8f4;
  --paper: #ffffff;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e5e0;
  --accent: #a67c4a;
  --accent-soft: #f3ebe0;
  --green: #2d4a3a;
  --green-soft: #e8f0ea;
  --danger: #b91c1c;
  --shadow: 0 1px 2px rgba(28, 25, 23, 0.04), 0 4px 12px rgba(28, 25, 23, 0.04);
  --shadow-lg: 0 8px 30px rgba(28, 25, 23, 0.08);
  --radius: 16px;
  --radius-lg: 20px;
  --nav: rgba(255, 255, 255, 0.9);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0a09;
  --paper: #1c1917;
  --ink: #fafaf9;
  --muted: #a8a29e;
  --line: #292524;
  --accent: #d4a574;
  --accent-soft: #292018;
  --green: #86b08a;
  --green-soft: #1a2a1e;
  --danger: #f87171;
  --shadow: none;
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.4);
  --nav: rgba(28, 25, 23, 0.92);
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button {
  cursor: pointer;
  touch-action: manipulation;
  border: 0;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s ease;
}
button:disabled { opacity: 0.4; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:not(:disabled):active { transform: scale(0.97); }

h1, h2, h3, p { margin: 0; }
h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
h3 { font-size: 15px; font-weight: 700; }
strong { font-weight: 700; font-variant-numeric: tabular-nums; }
.icon { width: 20px; height: 20px; flex-shrink: 0; }

.shell {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(16px + max(env(safe-area-inset-top), var(--tg-content-safe-area-inset-top, 0px))) 18px 130px;
}

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.brand { min-width: 0; }
.original-logo {
  display: block;
  width: 140px;
  height: auto;
  max-height: 44px;
  object-fit: contain;
}
.header-actions { display: flex; gap: 8px; align-items: center; }
.station-id {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--muted);
}
.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
}
.icon-button .icon { width: 16px; height: 16px; }
.icon-button:disabled .icon { animation: spin 0.8s linear infinite; }

.connection {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 22px;
}
.connection::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}
.connection.offline { color: var(--danger); }
.connection.offline::before {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.2);
}

.greeting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.greeting p {
  font-size: 15px;
  font-weight: 600;
}
.pill {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent);
  border: none;
}

/* ——— HERO: completely different ——— */
.hero {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  min-height: auto;
  color: var(--ink);
}

.hero::before,
.hero::after { display: none; }

.hero-top {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 20px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 8px;
  border-radius: 20px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 600;
  border: none;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
}
.status-dot.bad { background: var(--danger); }

.hero-copy {
  width: 100%;
  max-width: none;
  position: static;
}

.hero h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.6px;
  margin: 0 0 4px;
  max-width: none;
  color: var(--ink);
}

.hero p {
  font-size: 13px;
  color: var(--muted);
  max-width: none;
}

.hero-price {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hero-price > span {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.hero-price strong {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--ink);
}

/* Hide the flower illustration in this version */
.flower-art {
  display: none;
}

/* Actions */
.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 16px;
}

.primary, .secondary {
  border-radius: 12px;
  min-height: 48px;
  padding: 12px;
  font-size: 13px;
  font-weight: 650;
}

.primary {
  background: var(--green);
  color: #fff;
  box-shadow: 0 2px 8px rgba(45, 74, 58, 0.25);
}
:root[data-theme="dark"] .primary {
  color: #0c0a09;
}

.open-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.open-action .icon { width: 16px; height: 16px; }
.open-action .action-arrow { display: none; }

.secondary {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
}

/* Sections */
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 40px 0 18px;
}
.section-heading h2 { font-size: 16px; }
.text-button {
  background: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.text-button .icon { width: 14px; height: 14px; }

/* Metrics — horizontal strip style */
.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.metric {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.metric-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--green-soft);
  color: var(--green);
}
.metric-icon .icon { width: 14px; height: 14px; }
.metric-icon.rose {
  background: #fef2f2;
  color: #b91c1c;
}
:root[data-theme="dark"] .metric-icon.rose {
  background: #2a1515;
  color: #f87171;
}

.metric-caption {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--muted);
}

.metric > span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.metric strong {
  display: block;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.8px;
  margin-top: 2px;
}

/* Cards */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 16px;
  box-shadow: var(--shadow);
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.info-row:last-child { border: 0; }
.info-row > span { color: var(--muted); font-weight: 500; }
.info-label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.info-label .icon { width: 15px; height: 15px; opacity: 0.6; }
.info-row strong {
  font-size: 13px;
  font-weight: 650;
  text-align: right;
  max-width: 50%;
}

.footnote {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin: 16px 0;
}
.card > .footnote {
  padding-left: 22px;
  margin: 8px 0 12px;
}

.contacts { display: flex; gap: 6px; justify-content: flex-end; }
.contact {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--danger);
  background: #fef2f2;
  border: 1px solid #fecaca;
}
.contact.closed {
  color: var(--green);
  background: var(--green-soft);
  border-color: transparent;
}
:root[data-theme="dark"] .contact {
  background: #2a1515;
  border-color: #4a2020;
}
:root[data-theme="dark"] .contact.closed {
  background: var(--green-soft);
  border-color: transparent;
}

.event-list { padding: 4px 16px; }
.event {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.event:last-child { border: 0; }
.event::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.event > div { flex: 1; min-width: 0; }
.event-title { font-size: 13px; font-weight: 650; }
.event-detail { font-size: 12px; color: var(--muted); margin-top: 2px; }
.event-value {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.small { font-size: 12px; }
.muted { color: var(--muted); }

footer {
  text-align: center;
  margin: 20px 0 4px;
  font-size: 11px;
  color: var(--muted);
}

/* Nav */
.nav {
  position: fixed;
  bottom: calc(10px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 480px;
  z-index: 5;
  display: flex;
  gap: 4px;
  padding: 5px;
  border-radius: 16px;
  background: var(--nav);
  border: 1px solid var(--line);
  box-shadow: 0 8px 30px rgba(28, 25, 23, 0.1);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.nav button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  min-height: 56px;
}
.nav .icon { width: 20px; height: 20px; }
.nav button.active {
  color: var(--green);
  background: var(--green-soft);
  font-weight: 700;
}

/* Reports */
.page-title {
  font-size: 24px;
  font-weight: 750;
  letter-spacing: -0.6px;
}
.segments {
  display: flex;
  background: var(--line);
  border-radius: 12px;
  padding: 3px;
  margin: 18px 0;
}
.segments button {
  flex: 1;
  border-radius: 10px;
  background: none;
  padding: 10px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.segments .selected {
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-weight: 700;
}
.chart-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 16px 8px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.report-total > span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}
.report-total strong {
  display: block;
  font-size: 36px;
  font-weight: 750;
  letter-spacing: -1.4px;
  margin: 6px 0 4px;
}
.report-total small {
  font-size: 12px;
  color: var(--muted);
}
.chart {
  height: 130px;
  display: flex;
  align-items: flex-end;
  gap: 5px;
  margin: 18px 0 14px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  background: repeating-linear-gradient(to top, transparent 0, transparent 32px, var(--line) 33px, transparent 34px);
}
.bar-column {
  height: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
  min-width: 0;
}
.bar {
  background: #c4b5a0;
  border-radius: 4px 4px 1px 1px;
  min-height: 3px;
  max-width: 40px;
  margin: 0 auto;
  width: 100%;
}
.bar-column:last-child .bar { background: var(--accent); }
:root[data-theme="dark"] .bar { background: #5a4e40; }
:root[data-theme="dark"] .bar-column:last-child .bar { background: var(--accent); }
.bar-column small {
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  color: var(--muted);
  white-space: nowrap;
}
.chart.empty {
  height: 100px;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px dashed var(--line);
  border-radius: 12px;
  margin-top: 14px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* Settings */
.form-card { padding: 18px; }
.form-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
  margin-bottom: 20px;
}
.form-heading p { font-size: 12px; color: var(--muted); margin-top: 2px; }
.form-heading .metric-icon { width: 34px; height: 34px; }
.form-card label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 20px;
  font-weight: 500;
}
.form-card label:last-child { margin-bottom: 0; }
.field-action {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.field-action input,
.field-action select {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  padding: 11px 12px;
  color: var(--ink);
  font-size: 16px;
  min-height: 44px;
  font-weight: 500;
}
.field-action input:focus,
.field-action select:focus {
  border-color: var(--accent);
  outline: none;
  background: var(--paper);
}
.field-action button {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
  min-width: 72px;
  flex-shrink: 0;
}
.form-card > .footnote { padding: 0; margin: 0 0 14px; }
.form-card #settings-zone { margin: 8px 0 0; }
.access-note {
  margin-top: 16px;
  display: flex;
  gap: 12px;
  padding: 18px;
}
.access-note h3 { font-size: 14px; }
.access-note p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.5;
}
.security-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  background: var(--green-soft);
  color: var(--green);
  border-radius: 8px;
  display: grid;
  place-items: center;
}
.security-icon .icon { width: 16px; height: 16px; }

/* Gate */
.gate { padding: 48px 16px; text-align: center; }
.gate-icon {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  background: var(--green-soft);
  color: var(--green);
  border-radius: 20px;
  margin: auto;
}
.gate-icon .icon { width: 36px; height: 36px; }
.gate h2 {
  font-size: 24px;
  font-weight: 750;
  margin: 20px 0 12px;
  letter-spacing: -0.5px;
}
.gate p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 24px;
}
.gate button { min-width: 180px; }

/* Dialog */
dialog {
  width: calc(100% - 32px);
  max-width: 360px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
dialog::backdrop {
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(6px);
}
.dialog-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--green-soft);
  color: var(--green);
  border-radius: 12px;
  margin-bottom: 14px;
}
dialog h2 {
  font-size: 20px;
  font-weight: 750;
  margin: 6px 0 10px;
}
dialog p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 20px;
}
.dialog-actions { display: flex; gap: 8px; }
.dialog-actions button { flex: 1; }
.dialog-actions .primary,
.dialog-actions .secondary {
  font-size: 14px;
  min-height: 44px;
}

#toast {
  position: fixed;
  bottom: calc(90px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 400px;
  background: var(--ink);
  color: var(--paper);
  padding: 14px 16px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  z-index: 20;
  font-size: 14px;
  font-weight: 500;
  animation: toast-in 0.25s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

[hidden] { display: none !important; }
.tab { animation: enter 0.2s ease-out; }
@keyframes enter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 359px) {
  .shell { padding-left: 12px; padding-right: 12px; }
  .hero h2 { font-size: 20px; }
  .hero-price strong { font-size: 24px; }
  .original-logo { width: 120px; }
  .metric strong { font-size: 20px; }
}

header .connection{margin-bottom:0}header{margin-bottom:20px}

/* Spacing and consistent user-management fields */
#user-management{margin-top:24px}
#user-management h3{margin-bottom:16px}
#user-management input,#user-management select{display:block;width:100%;min-width:0;margin-top:8px;box-sizing:border-box;border:1px solid var(--line);border-radius:12px;background:var(--bg);color:var(--ink);font:inherit;font-size:16px;padding:12px;min-height:46px}
#user-management label{margin-bottom:18px}
#user-management .primary{margin-top:4px}
