:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --rail: #0c1220;
  --rail-ink: #cbd2e0;
  --accent: #155eef;
  --accent-soft: #eff4ff;
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --ok-dot: #17b26a;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --warn-dot: #f79009;
  --bad: #b42318;
  --bad-soft: #fef3f2;
  --bad-dot: #f04438;
  --idle-dot: #98a2b3;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  color: var(--ink);
  background: var(--bg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1rem; }
h4 { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 0.86em; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.82rem; margin-top: 8px; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink-2);
  font-weight: 500;
  box-shadow: var(--shadow);
  white-space: nowrap;
}
.btn:hover { background: #f9fafb; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #004eeb; }
.btn.danger { color: var(--bad); border-color: #fda29b; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { height: 30px; padding: 0 10px; font-size: 0.82rem; }
.btn.link { border: 0; background: none; box-shadow: none; color: var(--accent); height: auto; padding: 0; }
.btn.wide { width: 100%; }
.icon-btn { border: 0; background: none; width: 32px; height: 32px; border-radius: 8px; color: var(--muted); font-size: 1rem; }
.icon-btn:hover { background: #f2f4f7; }

/* Fields */
.field { display: grid; gap: 6px; font-size: 0.82rem; font-weight: 500; color: var(--ink-2); }
input, select {
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 400;
  box-shadow: var(--shadow);
}
input:focus, select:focus { outline: 2px solid #b2ccff; outline-offset: 0; border-color: #84adff; }
input::placeholder { color: #98a2b3; }
.form-error { min-height: 1.2em; color: var(--bad); font-size: 0.85rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.span-2 { grid-column: 1 / -1; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--rail); }
.login-card {
  width: min(400px, 100%);
  background: var(--card);
  border-radius: 16px;
  padding: 32px;
  display: grid;
  gap: 14px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}
.logo {
  width: 44px; height: 44px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 700; letter-spacing: 0.02em;
}
.logo.small { width: 34px; height: 34px; border-radius: 8px; font-size: 0.85rem; }

/* Shell */
.shell { min-height: 100vh; display: grid; grid-template-columns: 236px minmax(0, 1fr); }
.rail {
  background: var(--rail);
  color: var(--rail-ink);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 6px; }
.brand strong { display: block; color: #fff; font-size: 0.98rem; }
.brand span { display: block; font-size: 0.78rem; color: #8590a6; }
.rail nav { display: grid; gap: 2px; }
.rail nav button {
  display: flex; justify-content: space-between; align-items: center;
  text-align: left; border: 0; background: transparent; color: var(--rail-ink);
  padding: 9px 10px; border-radius: 8px; font-weight: 500;
}
.rail nav button:hover { background: #171f30; color: #fff; }
.rail nav button[aria-current="page"] { background: #1d2740; color: #fff; }
.count { font-size: 0.74rem; color: #8590a6; font-variant-numeric: tabular-nums; }
.count.alert { color: #fff; background: var(--bad-dot); border-radius: 999px; padding: 0 7px; }
.rail-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; padding: 0 6px; }
.rail-link { border: 0; background: none; color: #8590a6; padding: 4px 0; }
.rail-link:hover { color: #fff; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; color: #8590a6; }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok-dot); }
.live.off::before { background: var(--bad-dot); }

main { padding: 28px 36px 56px; max-width: 1360px; width: 100%; }
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
.top .muted { margin-top: 2px; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.notice {
  background: var(--warn-soft); color: var(--warn); border: 1px solid #fedf89;
  border-radius: 10px; padding: 10px 14px; margin-bottom: 18px;
}
.view { display: grid; gap: 18px; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-head .muted { font-size: 0.82rem; }
.card-tools { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-tools input { width: min(360px, 100%); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.empty { padding: 18px 0 6px; color: var(--muted); text-align: center; }
.empty strong { display: block; color: var(--ink-2); font-weight: 600; margin-bottom: 2px; }

/* Health banner and KPIs */
.health {
  display: flex; align-items: center; gap: 14px;
  border-radius: var(--radius); padding: 14px 18px; border: 1px solid;
}
.health .mark { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; }
.health strong { display: block; font-size: 0.98rem; }
.health.ok { background: var(--ok-soft); border-color: #abefc6; color: var(--ok); }
.health.ok .mark { background: var(--ok-dot); }
.health.warn { background: var(--warn-soft); border-color: #fedf89; color: var(--warn); }
.health.warn .mark { background: var(--warn-dot); }
.health.bad { background: var(--bad-soft); border-color: #fecdca; color: var(--bad); }
.health.bad .mark { background: var(--bad-dot); }
.health span { color: var(--ink-2); font-size: 0.86rem; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi small { display: block; color: var(--muted); font-weight: 500; }
.kpi b { display: block; font-size: 1.7rem; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi b em { font-style: normal; font-size: 1rem; color: var(--muted); font-weight: 500; }
.kpi p { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }

/* Status */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 500; padding: 2px 9px 2px 7px; border-radius: 999px; background: #f2f4f7; color: var(--ink-2); white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--idle-dot); }
.status.ok { background: var(--ok-soft); color: var(--ok); }
.status.ok::before { background: var(--ok-dot); }
.status.warn { background: var(--warn-soft); color: var(--warn); }
.status.warn::before { background: var(--warn-dot); }
.status.bad { background: var(--bad-soft); color: var(--bad); }
.status.bad::before { background: var(--bad-dot); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--idle-dot); flex: none; }
.dot.ok { background: var(--ok-dot); }
.dot.warn { background: var(--warn-dot); }
.dot.bad { background: var(--bad-dot); }
.tag { display: inline-block; font-size: 0.74rem; font-weight: 500; padding: 1px 7px; border-radius: 6px; background: #f2f4f7; color: var(--ink-2); }
.tag.blue { background: var(--accent-soft); color: #004eeb; }

/* Rows */
.rows { display: grid; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); min-width: 0; }
.row:first-child { border-top: 0; }
.row.clickable { cursor: pointer; margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: 8px; }
.row.clickable:hover { background: #f9fafb; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; }
.row .sub { color: var(--muted); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route { font-family: var(--mono); font-size: 0.78rem; color: var(--ink-2); }
.route i { font-style: normal; color: var(--muted); padding: 0 4px; }
.time { color: var(--muted); font-size: 0.8rem; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Sites */
.site + .site { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.site-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.site-head strong { font-size: 0.95rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; font-family: var(--mono); font-size: 0.78rem; background: #fcfcfd; cursor: pointer; }
.chip:hover { border-color: var(--line-strong); }
.site .warn-line { margin-top: 10px; font-size: 0.82rem; color: var(--warn); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #f9fafb; font-size: 0.74rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #f9fafb; }
td .title { font-weight: 600; }
td .sub { color: var(--muted); font-size: 0.8rem; }
td.right, th.right { text-align: right; }
.inner table th { background: transparent; padding: 8px 10px; }
.inner table td { padding: 9px 10px; }
.inner { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }

/* Host board */
.site-card .card-head { margin-bottom: 14px; }
.host-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.host {
  border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: #fff;
  display: grid; gap: 10px; cursor: pointer; text-align: left; width: 100%;
}
.host:hover { border-color: #84adff; box-shadow: 0 0 0 3px #eff4ff; }
.host-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.host-top .mono { font-weight: 600; font-size: 0.86rem; }
.host-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 0.8rem; }
.host-foot { display: flex; gap: 6px; flex-wrap: wrap; }

/* Hotels */
.hotel-card .card-head h3 { font-size: 1.05rem; }
.pos-block { border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.pos-block + .pos-block { margin-top: 12px; }
.pos-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.pos-head .left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pos-head .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.program-list { display: grid; }
.program-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.program-row:first-child { border-top: 0; }
.program-row .num { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink-2); background: #f2f4f7; border-radius: 6px; text-align: center; padding: 2px 0; }

.check { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; font-size: 0.86rem; color: var(--ink-2); }
.check input { width: 16px; height: 16px; box-shadow: none; padding: 0; }
input:disabled { background: #f2f4f7; color: var(--muted); }
.estimate { display: grid; gap: 2px; background: var(--accent-soft); color: #00359e; border-radius: 10px; padding: 12px 14px; font-size: 0.84rem; }
.estimate:empty { display: none; }
.estimate strong { font-size: 0.95rem; }

.away {
  margin: 16px 22px 0; padding: 14px; border-radius: 10px;
  background: var(--warn-soft); border: 1px solid #fedf89; color: var(--warn);
  display: grid; gap: 10px; justify-items: start;
}
.away strong { display: block; }
.away span { color: var(--ink-2); font-size: 0.84rem; }
select option:disabled { color: #98a2b3; }

/* Addresses */
.url-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.url-row:first-child { border-top: 0; }
.url-text { min-width: 0; }
.url-text .url { font-size: 0.8rem; color: var(--ink-2); overflow-wrap: anywhere; margin-top: 1px; }
.url-text .sub { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
.url-actions { display: flex; gap: 6px; align-items: center; flex: none; }
.addr-channel + .addr-channel { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-strong); }
.addr-channel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.card-tools h3 { margin-bottom: 2px; }
.card-tools .hint { margin-top: 0; }
#addr-lab pre.code { margin: 6px 0 4px; }

.install { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
.install li { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 12px; }
.install .mark { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 0.74rem; font-weight: 700; background: var(--accent-soft); color: var(--accent); }
.install strong { display: block; }
.install p { font-size: 0.84rem; margin-top: 2px; }
.install .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.install .status + .actions { margin-top: 10px; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 0.88rem; }
.checklist li { display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: 10px; align-items: baseline; }
.checklist .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); transform: translateY(-1px); }
.checklist li.ok .dot { background: var(--ok-dot); }
.checklist li.warn .dot { background: var(--warn-dot); }
.checklist li.fail .dot { background: var(--bad-dot); }
.checklist li.fail { color: var(--bad); }
.udp-test { display: flex; gap: 8px; margin: 8px 0 10px; }
.udp-test input { flex: 1; min-width: 0; }
.udp-result { display: grid; gap: 3px; padding: 10px 12px; border-radius: 8px; font-size: 0.86rem; border: 1px solid var(--line); }
.udp-result.ok { background: var(--ok-soft); border-color: #abefc6; }
.udp-result.bad { background: var(--bad-soft); border-color: #fecdca; }
details > summary { cursor: pointer; color: var(--accent); font-size: 0.88rem; margin-bottom: 10px; }
.cmd { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; }
.cmd pre.code { flex: 1; min-width: 0; padding: 9px 12px; white-space: pre-wrap; word-break: break-all; }

/* Drawer */
.backdrop { position: fixed; inset: 0; background: rgba(12, 18, 32, 0.32); z-index: 20; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%);
  background: var(--card); z-index: 21; overflow-y: auto;
  box-shadow: -12px 0 32px rgba(16, 24, 40, 0.14);
  display: flex; flex-direction: column;
}
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 22px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 1; }
.drawer-head h3 { font-size: 1.15rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kicker { font-size: 0.78rem; color: var(--muted); margin-bottom: 2px; }
.drawer-actions { display: flex; gap: 8px; padding: 16px 22px 0; }
.drawer-section { padding: 18px 22px; border-bottom: 1px solid var(--line); }
.drawer-section:last-child { border-bottom: 0; }
.drawer-section h4 { margin-bottom: 12px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.section-head h4 { margin: 0; }
.tabs { display: flex; gap: 4px; padding: 12px 22px 0; border-bottom: 1px solid var(--line); position: sticky; top: 77px; background: var(--card); z-index: 1; }
.tabs button { border: 0; background: none; padding: 8px 10px 10px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.facts { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 9px 14px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; }
.steps li { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 10px; padding-bottom: 16px; position: relative; }
.steps li:last-child { padding-bottom: 0; }
.steps li::after { content: ""; position: absolute; left: 11px; top: 24px; bottom: 2px; width: 2px; background: var(--line); }
.steps li:last-child::after { display: none; }
.steps .mark { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 0.72rem; font-weight: 700; color: #fff; background: var(--idle-dot); }
.steps li.done .mark { background: var(--ok-dot); }
.steps li.wait .mark { background: var(--warn-dot); }
.steps li.bad .mark { background: var(--bad-dot); }
.steps strong { display: block; font-weight: 600; }
.steps span { color: var(--muted); font-size: 0.84rem; }

pre.code {
  margin: 0; padding: 14px; border-radius: 10px; background: #0c1220; color: #d0d5dd;
  font-family: var(--mono); font-size: 0.78rem; line-height: 1.6; overflow: auto; max-height: 360px;
}
pre.code.tall { max-height: 60vh; }
pre.token-value { font-size: 0.95rem; color: #fff; white-space: pre-wrap; word-break: break-all; }

/* Dialogs */
.dialog { border: 0; padding: 0; border-radius: 16px; width: min(520px, calc(100% - 32px)); box-shadow: 0 24px 48px rgba(16, 24, 40, 0.24); color: var(--ink); }
.dialog.wide { width: min(780px, calc(100% - 32px)); }
.dialog::backdrop { background: rgba(12, 18, 32, 0.45); }
.dialog-body { padding: 24px; display: grid; gap: 14px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; align-content: start; }
  main { min-width: 0; }
  .kpi b { font-size: 1.4rem; }
  .live { font-size: 0; gap: 0; }
  .rail { min-width: 0; position: sticky; height: auto; padding: 12px 14px; gap: 10px; z-index: 10; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .brand span { display: none; }
  .rail-foot { margin: 0 0 0 auto; gap: 12px; }
  .rail nav { order: 3; width: 100%; display: flex; overflow-x: auto; gap: 4px; }
  .rail nav button { flex: none; gap: 6px; }
  main { padding: 18px 14px 40px; }
  .top { flex-direction: column; align-items: stretch; }
  .form-grid, .facts { grid-template-columns: 1fr; }
  .facts dt { margin-top: 6px; }
  th, td { padding: 10px 12px; }
  .hide-sm { display: none; }
  .tabs { top: 73px; overflow-x: auto; }
}
