:root {
  --bg: #f5f5f2;
  --card: #fff;
  --ink: #20211f;
  --muted: #767872;
  --line: #e7e7e1;
  --green: #198754;
  --green-bg: #e9f7ef;
  --red: #cf3636;
  --red-bg: #fff0ef;
  --orange: #f05a28;
  --shadow: 0 18px 50px rgba(31, 33, 29, .09);
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1440px; margin: auto; padding: 14px 28px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; color: #fff; background: var(--orange); }
.test-badge { padding: 7px 11px; border-radius: 999px; color: #8a421e; background: #fff0e8; font-weight: 700; font-size: 13px; }
.page { max-width: 1440px; margin: auto; padding: 24px 28px 72px; }
.city-picker { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.city-picker label { font-weight: 750; }
select, input { border: 1px solid #d8d9d3; border-radius: 12px; background: #fff; color: var(--ink); padding: 11px 13px; }
.city-picker select { min-width: 230px; }
.sync { color: var(--muted); margin-left: auto; font-size: 13px; }
.hero { display: flex; justify-content: space-between; gap: 28px; align-items: end; padding: 38px 42px; border-radius: 28px; background: #22231f; color: #fff; box-shadow: var(--shadow); }
.eyebrow { margin: 0 0 7px; color: var(--orange); text-transform: uppercase; font-size: 12px; font-weight: 850; letter-spacing: .12em; }
h1, h2 { margin: 0; letter-spacing: -.035em; }
h1 { font-size: clamp(42px, 6vw, 74px); line-height: .95; }
h2 { font-size: 27px; }
.address { margin: 15px 0 0; color: #c8c9c4; font-size: 17px; }
.hero-status { white-space: nowrap; padding: 10px 14px; border-radius: 999px; background: #3b3c37; color: #e4e5df; font-weight: 750; }
.hero-status.good { background: #153e2b; color: #a8efc7; }
.hero-status.bad { background: #4d2220; color: #ffc2bd; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 18px 0 34px; }
.stat { padding: 22px 24px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); }
.stat span { display: block; color: var(--muted); margin-bottom: 6px; }
.stat strong { font-size: 25px; }
.good-text { color: var(--green); }
.bad-text { color: var(--red); }
.section { margin-top: 30px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.secondary, .primary, .configure { border: 0; border-radius: 12px; padding: 11px 15px; font-weight: 780; }
.secondary { background: #e9e9e4; color: #343531; }
.primary { background: var(--orange); color: #fff; }
.primary:disabled { background: #d4d4cf; color: #898a84; cursor: not-allowed; }
.configure { background: #f0f0eb; color: #363732; }
.table-wrap { overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: var(--card); }
.zone-row { display: grid; grid-template-columns: minmax(220px, 1.5fr) minmax(125px, .65fr) minmax(170px, .85fr) minmax(220px, 1.2fr) auto; align-items: center; gap: 18px; padding: 17px 20px; border-top: 1px solid var(--line); }
.zone-row:first-child { border-top: 0; }
.zone-header { color: var(--muted); font-size: 12px; font-weight: 780; text-transform: uppercase; letter-spacing: .06em; background: #fafaf7; }
.zone-row.inactive { background: var(--red-bg); }
.zone-name { display: flex; align-items: center; gap: 12px; font-weight: 780; }
.zone-color { flex: 0 0 auto; width: 18px; height: 18px; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px #d9d9d3; }
.state { font-weight: 800; }
.timing strong { display: block; font-size: 18px; }
.timing small, .conditions { color: var(--muted); }
.timing small.delay { color: var(--red); font-weight: 750; }
.order-list { overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: var(--card); }
.order-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 18px; padding: 18px 20px; border-top: 1px solid var(--line); }
.order-row:first-child { border-top: 0; }
.order-title { font-weight: 780; }
.order-note { color: var(--muted); font-size: 13px; margin-top: 3px; }
.chat-note { color: var(--muted); font-weight: 650; }
.journal { overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: var(--card); }
.journal-row { display: grid; grid-template-columns: 160px minmax(220px, 1fr) 130px; gap: 18px; padding: 16px 20px; border-top: 1px solid var(--line); }
.journal-row:first-child { border-top: 0; }
.journal-row time, .journal-row small { color: var(--muted); }
.empty { margin: 0; padding: 24px; color: var(--muted); }
.modal-layer { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 18px; }
.modal-layer[hidden] { display: none; }
.modal-shade { position: absolute; inset: 0; background: rgba(21, 22, 19, .66); }
.modal { position: relative; z-index: 1; width: min(560px, 100%); max-height: calc(100vh - 36px); overflow: auto; border-radius: 24px; background: #fff; padding: 28px; box-shadow: 0 30px 90px rgba(0,0,0,.25); }
.modal-close { position: absolute; right: 18px; top: 15px; border: 0; background: transparent; font-size: 30px; color: var(--muted); }
.field, .switch-line { margin-top: 20px; }
.field label, .pin-box label { display: block; font-weight: 750; margin-bottom: 8px; }
.field select { width: 100%; }
.switch-line { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 16px; border-radius: 14px; background: #f5f5f1; }
.switch { position: relative; width: 50px; height: 28px; }
.switch input { position: absolute; opacity: 0; }
.switch span { display: block; width: 50px; height: 28px; border-radius: 999px; background: #c9cac5; transition: .2s; }
.switch span::after { content: ""; position: absolute; top: 4px; left: 4px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(22px); }
.pin-box { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.pin-row { display: flex; align-items: center; gap: 12px; }
.pin-row input { width: 150px; font-size: 20px; letter-spacing: .18em; }
#pinState { font-weight: 800; }
.modal-message { min-height: 22px; color: var(--red); font-weight: 650; }
.modal-message.success { color: var(--green); }
.modal-actions { display: flex; justify-content: end; gap: 10px; margin-top: 12px; }
@media (max-width: 900px) {
  .zone-header { display: none; }
  .zone-row { grid-template-columns: 1fr 1fr; }
  .zone-row > :first-child { grid-column: 1 / -1; }
  .zone-row .conditions { grid-column: 1 / -1; }
  .zone-row .configure { justify-self: start; }
}
@media (max-width: 640px) {
  .topbar-inner, .page { padding-left: 16px; padding-right: 16px; }
  .test-badge { font-size: 11px; }
  .city-picker { align-items: stretch; flex-wrap: wrap; }
  .city-picker label { width: 100%; }
  .city-picker select { flex: 1; min-width: 0; }
  .sync { width: 100%; margin-left: 0; }
  .hero { align-items: flex-start; flex-direction: column; padding: 30px 24px; border-radius: 22px; }
  .stats { grid-template-columns: 1fr; }
  .stat { padding: 17px 19px; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .zone-row { grid-template-columns: 1fr; gap: 10px; padding: 18px 16px; }
  .zone-row > :first-child, .zone-row .conditions { grid-column: auto; }
  .order-row { grid-template-columns: 1fr auto; padding: 17px 16px; }
  .order-row .configure, .order-row .chat-note { grid-column: 1 / -1; justify-self: start; }
  .journal-row { grid-template-columns: 1fr; gap: 4px; }
  .modal { padding: 24px 20px; }
}
