:root {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #15202b;
  background: #f4f7fa;
  --ink: #101828;
  --muted: #667085;
  --line: #dfe7ef;
  --line-soft: #eef2f6;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --nav: #0d1b2a;
  --primary: #175cd3;
  --primary-soft: #eef4ff;
  --success: #067647;
  --warning: #b54708;
  --danger: #b42318;
  --radius: 12px;
  --shadow: 0 4px 16px rgba(17, 34, 51, .05);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; background: #f4f7fa; color: #15202b; line-height: 1.45; }
a { color: #175cd3; }
h1, h2, h3 { color: var(--ink); line-height: 1.2; }
h1 { margin: 0 0 8px; font-size: clamp(1.65rem, 2.2vw, 2.15rem); }
h2 { margin: 0 0 10px; font-size: 1.2rem; }
h3 { margin: 0 0 8px; font-size: 1rem; }
p { overflow-wrap: anywhere; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 58px;
  background: var(--nav);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06);
}
.topbar-inner {
  max-width: 1680px;
  height: 100%;
  margin: 0 auto;
  padding: 0 22px;
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
}
.brand {
  color: #fff;
  text-decoration: none;
  font-weight: 800;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.main-nav {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
}
.main-nav > a,
.nav-dropdown > summary,
.link-button {
  color: #d7e3ef;
  text-decoration: none;
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 7px 9px;
  cursor: pointer;
  font: inherit;
  font-size: .9rem;
  font-weight: 550;
}
.main-nav > a:hover,
.nav-dropdown > summary:hover,
.link-button:hover {
  color: #fff;
  background: rgba(255, 255, 255, .08);
}
.nav-dropdown { position: relative; }
.nav-dropdown > summary { list-style: none; user-select: none; }
.nav-dropdown > summary::-webkit-details-marker { display: none; }
.nav-dropdown > summary::after { content: " ▾"; font-size: .72rem; opacity: .75; }
.nav-dropdown[open] > summary { color: #fff; background: rgba(255, 255, 255, .1); }
.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 50;
  width: 220px;
  padding: 7px;
  border: 1px solid #263a4d;
  border-radius: 12px;
  background: #122437;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .28);
}
.nav-dropdown-menu a {
  display: block;
  padding: 9px 10px;
  border-radius: 7px;
  color: #d7e3ef;
  text-decoration: none;
  font-size: .9rem;
}
.nav-dropdown-menu a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.logout-form { margin: 0 0 0 auto; }
.logout-form .link-button { white-space: nowrap; }

.page {
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
  padding: 24px 28px 48px;
}
.page-head,
.section-head {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
}
.page-head > div:first-child,
.section-head > div:first-child { min-width: 0; }
.page-head h1,
.section-head h2 { margin-top: 0; }
.page-subtitle { max-width: 900px; margin: 4px 0 0; color: var(--muted); }
.eyebrow,
.capability-eyebrow {
  margin: 0 0 5px;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #667085;
  font-weight: 800;
}

.card,
.chart-card,
.login-card,
.object-block,
.empty-state {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.compact-card { padding: 16px; min-width: 0; }
.chart-card { overflow: hidden; }
.object-block { margin-bottom: 20px; }
.login-card { max-width: 440px; margin: 8vh auto; }
.empty-state { text-align: center; padding: 30px; }
.empty-state h2, .empty-state h3 { margin-top: 0; }

.status-grid,
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 24px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.label,
small { display: block; color: #617181; }
.metric-value { font-size: 1.8rem; margin: 8px 0; display: block; }
.summary-value { display: block; margin: 6px 0 4px; font-size: 1.35rem; color: var(--ink); }
.muted { color: #617181; }
.stale { border-color: #e3a008; background: #fff9e8; }
.status.alarm { color: var(--danger); }
.status.degraded { color: var(--warning); }
.status.ok, .ok-text { color: var(--success); }

.event {
  background: #fff;
  border-left: 5px solid #d0d5dd;
  border-radius: 8px;
  padding: 12px 16px;
  margin: 10px 0;
  box-shadow: 0 2px 8px rgba(17, 34, 51, .04);
}
.event.high, .event.critical { border-left-color: #d92d20; }
.event.warning { border-left-color: #f79009; }
.event.recovered { border-left-color: #12b76a; }
.event span { display: block; color: #617181; font-size: .9rem; }
.note,
.alert { padding: 14px 16px; border-radius: 10px; background: #eaf2fb; margin: 18px 0; }
.alert.warning { background: #fff1e8; border: 1px solid #fed7aa; }
.alert p:last-child { margin-bottom: 0; }

.flash-stack { display: grid; gap: 8px; margin: 0 0 18px; }
.flash { padding: 11px 14px; border: 1px solid #cfe1f5; border-radius: 10px; background: #eef6ff; }
.flash.success { border-color: #abefc6; background: #ecfdf3; color: #05603a; }
.flash.warning { border-color: #fedf89; background: #fffaeb; color: #93370d; }
.flash.error { border-color: #fecdca; background: #fef3f2; color: #912018; }

.stack,
.filters { display: flex; flex-direction: column; gap: 14px; }
.stack label,
.filters label,
.filter-grid label { display: grid; gap: 6px; }
input,
select,
button,
textarea { font: inherit; }
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  width: 100%;
  min-width: 0;
  padding: 9px 11px;
  color: #15202b;
  background: #fff;
  border: 1px solid #b9c6d3;
  border-radius: 8px;
}
input[type="checkbox"],
input[type="radio"] { width: 17px; height: 17px; margin: 0; accent-color: var(--primary); }
button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 39px;
  padding: 9px 12px;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}
button:hover,
.button-link:hover { filter: brightness(.96); }
.button-link.secondary,
.secondary-button { background: #fff; color: var(--primary); border-color: #84adff; }
.danger-button { background: #fff; color: var(--danger); border-color: #fda29b; }
.link-button { min-height: auto; }
.filters { flex-direction: row; align-items: end; margin-bottom: 18px; }
.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}
.filter-grid button { min-height: 40px; }
.actions,
.pill-row,
.pagination { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.pill,
.status-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 5px 9px;
  background: #eef4fa;
  color: #344054;
  font-size: .8rem;
  font-weight: 750;
  white-space: nowrap;
}
.status-badge.fresh,
.status-badge.available_with_data,
.status-badge.online { background: #ecfdf3; color: #067647; }
.status-badge.stale,
.status-badge.available_empty,
.status-badge.unknown { background: #fff6ed; color: #b54708; }
.status-badge.no_data,
.status-badge.denied,
.status-badge.out_of_scope,
.status-badge.offline { background: #fef3f2; color: #b42318; }
.status-badge.needs_operator,
.status-badge.needs_omada,
.status-badge.not_implemented { background: #fffaeb; color: #b54708; }
.status-badge.forbidden_by_design { background: #f2f4f7; color: #344054; }

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  scrollbar-gutter: stable;
}
.table-wrap table { width: 100%; border-collapse: collapse; min-width: 720px; }
.wide-table { min-width: 1040px !important; }
.coverage-table { min-width: 1160px !important; }
th,
td {
  position: static;
  text-align: left;
  vertical-align: top;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-soft);
  overflow-wrap: anywhere;
}
th {
  background: #f8fafc;
  color: #344054;
  font-size: .82rem;
  font-weight: 750;
  white-space: normal;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcff; }
code,
pre { overflow-wrap: anywhere; white-space: pre-wrap; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .87em; }
canvas { width: 100%; height: auto; }

.details { display: grid; grid-template-columns: minmax(130px, .45fr) 1fr; gap: 8px 14px; }
.details dt { color: #617181; }
.details dd { margin: 0; overflow-wrap: anywhere; }
.section-gap { margin-top: 24px; }
.section-gap-small { margin-top: 14px; }
.pagination { justify-content: flex-end; margin-top: 14px; }
.pagination span { margin-right: auto; color: #617181; }

.capability-head { margin-bottom: 16px; }
.capability-head > div:first-child { max-width: 900px; }
.capability-snapshot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 15px 17px;
  margin: 0 0 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 3px 12px rgba(17, 34, 51, .04);
}
.capability-snapshot > div:first-child { display: grid; gap: 3px; min-width: 0; }
.capability-chips { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.capability-chip { display: inline-flex; gap: 4px; padding: 6px 9px; border-radius: 999px; background: #f2f4f7; color: #475467; font-size: .78rem; }
.capability-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.capability-legend > span { display: flex; gap: 8px; align-items: center; min-width: 0; color: #475467; font-size: .86rem; }
.capability-table-wrap { box-shadow: 0 4px 18px rgba(17, 34, 51, .04); }
.coverage-table.capability-table { min-width: 1160px !important; table-layout: fixed; }
.capability-table th { position: static; top: auto; }
.capability-table td { padding: 13px 11px; line-height: 1.35; }
.capability-table tbody tr:nth-child(even) { background: #fbfcfe; }
.capability-table tbody tr:hover { background: #f4f8fd; }
.capability-name { width: 14%; min-width: 150px; }
.capability-name strong { display: block; color: #101828; margin-bottom: 4px; }
.capability-name small,
.cell-explain,
.tech-code,
.capability-comment small { margin-top: 5px; font-size: .77rem; line-height: 1.35; }
.tech-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #98a2b3; }
.capability-count { font-weight: 750; white-space: normal; }
.capability-line { display: block; margin-bottom: 5px; color: #344054; }
.capability-line:last-child { margin-bottom: 0; }
.capability-comment { min-width: 220px; color: #344054; }
.capability-comment > strong { display: block; font-size: .87rem; font-weight: 650; }
.capability-comment small { color: #667085; }
.capability-footnote { display: grid; gap: 7px; border: 1px solid #cfe1f5; background: #eef6ff; }
.capability-footnote strong { font-size: .95rem; }

.settings-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, .75fr);
  gap: 20px;
  align-items: start;
}
.settings-panel { min-width: 0; }
.settings-form { display: grid; gap: 18px; }
.form-section { display: grid; gap: 10px; padding-top: 15px; border-top: 1px solid var(--line-soft); }
.field-row,
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
}
.field-row > span,
.switch-row > span { min-width: 0; }
.field-row select { width: min(330px, 45%); }
.switch-row input[type="checkbox"] { flex: 0 0 auto; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 14px; }
.check-grid label,
.mini-check { display: flex; align-items: center; gap: 8px; color: #344054; }
.time-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 180px)); gap: 12px; }
.time-grid label { display: grid; gap: 5px; }
.settings-details { margin: 0; grid-template-columns: minmax(120px, .55fr) 1fr; }
.recipient-add-form { display: grid; grid-template-columns: minmax(180px, .55fr) minmax(240px, 1fr) auto; gap: 12px; align-items: end; }
.recipient-add-form label,
.recipient-label { display: grid; gap: 5px; }
.recipient-list { display: grid; gap: 10px; }
.recipient-card {
  display: grid;
  grid-template-columns: minmax(130px, .5fr) minmax(180px, 1fr) auto auto auto minmax(230px, auto);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbfcfe;
}
.recipient-id { min-width: 0; }
.recipient-actions { display: flex; justify-content: flex-end; gap: 7px; flex-wrap: wrap; }
.telegram-log-table { min-width: 980px !important; }

@media (max-width: 1250px) {
  .topbar-inner { gap: 12px; padding-inline: 16px; }
  .main-nav > a, .nav-dropdown > summary, .link-button { padding-inline: 7px; font-size: .85rem; }
  .settings-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .recipient-card { grid-template-columns: minmax(130px, .5fr) minmax(190px, 1fr) repeat(3, auto); }
  .recipient-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

@media (max-width: 1000px) {
  .topbar { height: auto; min-height: 58px; position: sticky; }
  .topbar-inner { min-height: 58px; flex-wrap: wrap; padding-block: 8px; }
  .main-nav { order: 3; width: 100%; flex-basis: 100%; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
  .nav-dropdown-menu { position: fixed; top: auto; right: 16px; }
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .capability-legend { grid-template-columns: 1fr; }
  .capability-snapshot { align-items: flex-start; flex-direction: column; }
  .capability-chips { justify-content: flex-start; }
  .settings-grid { grid-template-columns: 1fr; }
  .recipient-add-form { grid-template-columns: 1fr 1fr; }
  .recipient-add-form button { grid-column: 1 / -1; justify-self: start; }
}

@media (max-width: 800px) {
  .page { padding: 16px 12px 36px; }
  .status-grid,
  .metric-grid,
  .two-col,
  .settings-summary { grid-template-columns: 1fr; }
  .filters,
  .page-head,
  .section-head,
  .field-row,
  .switch-row { flex-direction: column; align-items: stretch; }
  .filter-grid,
  .check-grid,
  .time-grid,
  .recipient-add-form { grid-template-columns: 1fr; }
  .field-row select { width: 100%; }
  .metric-value { font-size: 1.5rem; }
  .details,
  .settings-details { grid-template-columns: 1fr; }
  .page-head .actions { width: 100%; }
  .capability-legend > span { align-items: flex-start; flex-direction: column; }
  .capability-snapshot { padding: 14px; }
  .capability-comment { min-width: 200px; }
  .recipient-card { grid-template-columns: 1fr; align-items: stretch; }
  .recipient-actions { grid-column: auto; }
  .topbar { position: static; }
  .nav-dropdown-menu { position: absolute; left: 0; right: auto; }
}
