:root {
  color-scheme: dark;
  --bg: #0b0f13;
  --surface: #12181e;
  --surface-2: #171f27;
  --line: #27313a;
  --text: #f3f7f8;
  --muted: #8fa0aa;
  --accent: #b9f34a;
  --accent-dark: #8fca24;
  --danger: #ff6b6b;
  --success: #62d69a;
  --shadow: 0 24px 80px rgba(0, 0, 0, .28);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: radial-gradient(circle at 75% -15%, rgba(185,243,74,.10), transparent 34%), var(--bg); }
a { color: inherit; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.app-shell { display: grid; grid-template-columns: 252px 1fr; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 252px; display: flex; flex-direction: column; padding: 28px 20px; border-right: 1px solid var(--line); background: rgba(11,15,19,.92); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--accent); color: #11180b; font-weight: 900; box-shadow: 0 0 32px rgba(185,243,74,.18); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: .01em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.sidebar nav { display: grid; gap: 6px; margin-top: 48px; }
.nav-link { padding: 12px 14px; border-radius: 10px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 650; }
.nav-link:hover { color: var(--text); background: var(--surface); }
.nav-link.active { color: #10170a; background: var(--accent); }
.sidebar-foot { display: grid; gap: 12px; margin-top: auto; padding: 16px 12px 0; border-top: 1px solid var(--line); }
.sidebar-foot a, .link-button { padding: 0; border: 0; background: transparent; color: var(--muted); text-decoration: none; font-size: 13px; text-align: left; }
.sidebar-foot a:hover, .link-button:hover { color: var(--text); }

.main { grid-column: 2; width: min(1400px, 100%); padding: 54px 56px 80px; }
.page-head { display: flex; justify-content: space-between; gap: 32px; align-items: flex-end; margin-bottom: 30px; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(34px, 5vw, 58px); line-height: .98; letter-spacing: -.045em; }
h2 { margin-bottom: 4px; font-size: 18px; letter-spacing: -.02em; }
.muted, .panel-head p { color: var(--muted); }
.page-head .muted { margin: 0; }
.health { display: inline-flex; align-items: center; gap: 9px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 100px; color: var(--muted); font-size: 12px; font-weight: 700; }
.health i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 14px currentColor; }
.health.ok { color: var(--success); }
.health.bad { color: var(--danger); }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.metric, .panel { border: 1px solid var(--line); background: linear-gradient(145deg, rgba(23,31,39,.90), rgba(16,22,28,.96)); box-shadow: var(--shadow); }
.metric { min-height: 165px; padding: 24px; border-radius: 16px; }
.metric span, .metric small { display: block; color: var(--muted); }
.metric span { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.metric strong { display: block; margin: 20px 0 8px; font-size: 46px; line-height: 1; letter-spacing: -.05em; }
.metric strong.metric-time { font-size: 20px; margin-top: 30px; letter-spacing: -.02em; }
.metric small { font-size: 12px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.panel { margin-bottom: 14px; padding: 24px; border-radius: 16px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.panel-head p { margin: 0; font-size: 12px; }
.service-row { display: flex; justify-content: space-between; align-items: center; padding: 13px 0; border-top: 1px solid var(--line); font-size: 13px; }
.status { display: inline-flex; align-items: center; width: max-content; padding: 5px 8px; border-radius: 7px; font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.status.ok { background: rgba(98,214,154,.12); color: var(--success); }
.status.bad { background: rgba(255,107,107,.12); color: var(--danger); }
.status.muted-status { background: rgba(143,160,170,.10); color: var(--muted); }
.route-code { display: block; padding: 15px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #090d10; color: var(--accent); font-size: 12px; }
.callout { margin-top: 18px; padding-left: 14px; border-left: 2px solid var(--accent); color: var(--muted); font-size: 12px; line-height: 1.6; }

.alert { margin: 0 0 18px; padding: 13px 15px; border: 1px solid rgba(255,107,107,.24); border-radius: 10px; background: rgba(255,107,107,.08); color: #ffc1c1; font-size: 13px; }
.alert.success { border-color: rgba(98,214,154,.24); background: rgba(98,214,154,.08); color: var(--success); }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.wide { grid-column: 1 / -1; }
label { display: grid; gap: 8px; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 9px; outline: none; background: #0d1217; color: var(--text); }
input, select { min-height: 44px; padding: 0 12px; }
textarea { min-height: 390px; padding: 14px; resize: vertical; font: 13px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace; }
input:focus, textarea:focus, select:focus { border-color: var(--accent-dark); box-shadow: 0 0 0 3px rgba(185,243,74,.08); }
.button, .mini { display: inline-flex; justify-content: center; align-items: center; border-radius: 9px; text-decoration: none; font-weight: 800; }
.button { min-height: 44px; padding: 0 18px; border: 1px solid transparent; font-size: 13px; }
.button.primary { background: var(--accent); color: #10170a; }
.button.primary:hover { background: #ccff68; }
.button.secondary { border-color: var(--line); background: var(--surface-2); color: var(--text); }
.mini { min-height: 28px; padding: 0 9px; border: 1px solid var(--line); background: #0d1217; color: var(--muted); font-size: 10px; }
.mini:hover { color: var(--text); border-color: #46535e; }
.mini.danger { color: var(--danger); }

.table-panel { padding: 0; overflow: hidden; }
.table-panel > .panel-head { padding: 24px 24px 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 11px 16px; background: rgba(9,13,16,.65); color: var(--muted); text-align: left; font-size: 9px; letter-spacing: .11em; text-transform: uppercase; }
td { padding: 16px; border-top: 1px solid var(--line); vertical-align: top; }
td strong, td small { display: block; }
td small { margin-top: 5px; color: var(--muted); font-size: 10px; }
td code { color: var(--muted); white-space: normal; word-break: break-word; }
.row-actions { display: flex; flex-wrap: wrap; gap: 5px; min-width: 190px; }
.row-actions form { margin: 0; }
.empty { padding: 36px; color: var(--muted); text-align: center; }
.inline-form { display: grid; grid-template-columns: minmax(180px, 1fr) 150px auto; gap: 10px; }
.share-box { display: grid; grid-template-columns: 1fr minmax(260px, 1fr); align-items: center; gap: 24px; margin-bottom: 14px; padding: 20px 24px; border: 1px solid rgba(185,243,74,.3); border-radius: 14px; background: rgba(185,243,74,.07); }
.share-box p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.share-box input { color: var(--accent); font-family: ui-monospace, monospace; }
.counter { display: grid; place-items: center; min-width: 32px; height: 32px; border-radius: 9px; background: rgba(185,243,74,.1); color: var(--accent); font-size: 12px; font-weight: 800; }
.route-edit .panel { margin: 0; }
.save-bar { position: sticky; bottom: 18px; display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 14px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: rgba(18,24,30,.94); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.save-bar strong, .save-bar small { display: block; }
.save-bar small { margin-top: 3px; color: var(--muted); }
.narrow { max-width: 620px; }
.stack { display: grid; gap: 16px; }

.login-shell { display: grid; place-items: center; padding: 24px; }
.login-shell .main { grid-column: auto; width: 100%; padding: 0; }
.login-card { width: min(460px, 100%); margin: auto; padding: 34px; border: 1px solid var(--line); border-radius: 20px; background: linear-gradient(145deg, rgba(23,31,39,.96), rgba(13,18,23,.98)); box-shadow: var(--shadow); }
.login-brand { margin-bottom: 48px; }
.login-card h1 { margin-bottom: 14px; font-size: 38px; line-height: 1.04; }
.login-card .muted { margin-bottom: 28px; line-height: 1.6; }
.fine { margin: 22px 0 0; color: var(--muted); font-size: 10px; text-align: center; }

@media (max-width: 1000px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; width: auto; height: auto; flex-direction: row; align-items: center; padding: 16px 20px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .sidebar nav { display: flex; margin: 0 0 0 30px; }
  .sidebar-foot { display: none; }
  .main { grid-column: 1; padding: 36px 24px 70px; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric { min-height: 130px; }
  .metric strong { margin: 14px 0 6px; }
}

@media (max-width: 720px) {
  .brand small { display: none; }
  .sidebar { padding: 12px; }
  .sidebar nav { margin-left: 12px; }
  .nav-link { padding: 10px; white-space: nowrap; }
  .page-head { display: grid; align-items: start; }
  .two-col, .form-grid { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .inline-form, .share-box { grid-template-columns: 1fr; }
  .save-bar { align-items: stretch; flex-direction: column; }
  .main { padding-inline: 14px; }
  .panel { padding: 18px; }
}
