:root {
  color-scheme: dark;
  --bg: #0e1013;
  --surface: #171a1f;
  --surface-2: #1d2127;
  --surface-3: #252b32;
  --line: #2d333b;
  --line-strong: #414954;
  --text: #f0f2f5;
  --muted: #99a2ad;
  --muted-strong: #c6ccd3;
  --sidebar: #111318;
  --sidebar-hover: #20242a;
  --red: #df3e47;
  --red-dark: #bd2932;
  --red-soft: #351a1e;
  --green: #72dba7;
  --green-soft: #173326;
  --amber: #f0c05e;
  --amber-soft: #352b17;
  --blue: #82b8ef;
  --blue-soft: #172a3e;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.48);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0;
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

button,
input,
select,
textarea { font: inherit; letter-spacing: 0; }

button,
a,
input,
select { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(130, 184, 239, 0.3);
  outline-offset: 2px;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.icon {
  display: block;
  flex: 0 0 auto;
  pointer-events: none;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 244px;
  z-index: 100;
  padding: 8px 12px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  transform: translateY(-150%);
}

.skip-link:focus { transform: translateY(0); }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: 236px;
  flex-direction: column;
  padding: 18px 14px;
  overflow-y: auto;
  background: var(--sidebar);
  border-right: 1px solid #252a31;
  color: var(--text);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 0 5px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  font-size: 17px;
  font-weight: 760;
  line-height: 1;
}

.brand:hover { text-decoration: none; }

.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 6px;
  background: var(--red);
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
}

.icon-button.sidebar-close { display: none; color: var(--text); }

.nav {
  display: grid;
  gap: 3px;
  margin-top: 27px;
}

.nav-link {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: 6px;
  color: #b5bdc6;
  font-weight: 620;
}

.nav-link .icon { color: #929aa4; }
.nav-link:hover { background: var(--sidebar-hover); color: var(--text); text-decoration: none; }
.nav-link:hover .icon { color: #d9dee4; }

.nav-link.active {
  position: relative;
  background: #282d34;
  color: var(--text);
}

.nav-link.active::before {
  position: absolute;
  inset: 8px auto 8px 0;
  width: 3px;
  border-radius: 2px;
  background: #e54149;
  content: "";
}

.nav-link.active .icon { color: var(--text); }

.sidebar-foot {
  display: grid;
  gap: 12px;
  margin-top: auto;
  padding-top: 22px;
}

.environment-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  color: #aeb6bf;
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #8a929d;
  box-shadow: 0 0 0 3px rgba(138, 146, 157, 0.14);
}

.status-dot.success { background: #47bd7e; box-shadow: 0 0 0 3px rgba(71, 189, 126, 0.14); }
.status-dot.warning { background: #e3a823; box-shadow: 0 0 0 3px rgba(227, 168, 35, 0.14); }
.status-dot.danger { background: #e24b54; box-shadow: 0 0 0 3px rgba(226, 75, 84, 0.14); }

.sidebar-backdrop { display: none; }
.mobile-bar { display: none; }

.main {
  width: calc(100% - 236px);
  max-width: 1680px;
  min-height: 100vh;
  margin-left: 236px;
  padding: 27px 32px 48px;
}

.page-header {
  display: flex;
  min-height: 56px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 19px;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.header-actions form { margin: 0; }

.page-header h1 {
  margin: 0;
  font-size: 25px;
  font-weight: 740;
  line-height: 1.2;
}

.subtitle { margin: 5px 0 0; color: var(--muted); }

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 650;
  line-height: 1.2;
  cursor: pointer;
}

.button:hover { border-color: #59636f; background: var(--surface-3); text-decoration: none; }
.button:active { transform: translateY(1px); }
.button:disabled { opacity: 0.48; cursor: not-allowed; transform: none; }
.button[aria-busy="true"] { cursor: wait; }
.button.primary { border-color: var(--red); background: var(--red); color: #fff; }
.button.primary:hover { border-color: #ef535b; background: #ef535b; }
.button.danger { border-color: var(--red); background: var(--red); color: #fff; }
.button.danger:hover { border-color: var(--red-dark); background: var(--red-dark); }
.button.ghost { border-color: #474f59; background: transparent; color: #d5dae0; }
.button.ghost:hover { border-color: #626c78; background: #22262d; }
.button.small { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.button.full { width: 100%; }

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.icon-button:hover { background: rgba(128, 136, 146, 0.12); }

.mode-badge,
.pill {
  display: inline-flex;
  width: max-content;
  max-width: 100%;
  align-items: center;
  border-radius: 4px;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 780;
  line-height: 1;
}

.mode-badge { padding: 5px 7px; }
.mode-badge.live { background: var(--green-soft); color: var(--green); }
.mode-badge.warn { background: var(--amber-soft); color: var(--amber); }

.flash-stack { display: grid; gap: 8px; margin-bottom: 16px; }

.flash {
  display: grid;
  grid-template-columns:auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 12px;
  border: 1px solid;
  border-radius: 6px;
  background: var(--surface);
}

.flash.success { border-color: #285a43; background: #142a20; color: #8ce2b7; }
.flash.error { border-color: #6f2c32; background: #2c171a; color: #ff9da3; }

.flash-close {
  display: grid;
  width: 30px;
  height: 30px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: currentColor;
  cursor: pointer;
}

.flash-close:hover { background: rgba(255, 255, 255, 0.08); }

.status-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 17px;
  overflow: hidden;
  border: 1px solid #343b44;
  border-radius: 7px;
  background: #181c21;
  color: var(--text);
}

.status-strip > div {
  display: grid;
  min-width: 0;
  gap: 5px;
  padding: 13px 15px;
  border-right: 1px solid #343b44;
}

.status-strip > div:last-child { border-right: 0; }
.status-strip span { color: #aeb5bd; font-size: 12px; }
.status-strip strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.status.ok { color: #7bd8aa; }
.status.bad { color: #ff9298; }
.status.warning { color: #f5c968; }
.muted-status { color: #c6cbd1; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(145px, 1fr));
  gap: 9px;
  margin-bottom: 21px;
}

.metric {
  display: grid;
  min-height: 102px;
  align-content: space-between;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.metric span,
.metric small { color: var(--muted); }
.metric strong { font-size: 21px; font-variant-numeric: tabular-nums; line-height: 1.2; }

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 17px;
}

.section-block,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.section-block { margin-bottom: 18px; padding: 16px; }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.section-heading h2 { margin: 0; font-size: 17px; line-height: 1.3; }
.section-heading a { font-size: 13px; font-weight: 650; }

.table-wrap { width: 100%; overflow: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}

td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { transition: background 120ms ease; }

.cell-note {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.pill { padding: 5px 7px; background: var(--surface-3); color: var(--muted-strong); font-size: 12px; }
.pill.success { background: var(--green-soft); color: var(--green); }
.pill.warning { background: var(--amber-soft); color: var(--amber); }
.pill.danger { background: var(--red-soft); color: #ff9299; }
.pill.neutral { background: var(--surface-3); color: var(--muted-strong); }

.actions { text-align: right; }
.truncate { display: block; max-width: 330px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-variant-numeric: tabular-nums; }
.empty { padding: 25px; color: var(--muted); text-align: center; }
.metric-unavailable { font-size: 16px !important; color: var(--muted-strong); }

.api-section { padding: 0; overflow: hidden; }
.api-section .table-wrap { overflow-x: auto; }
.api-table { min-width: 980px; }
.api-table th,
.api-table td { padding-block: 11px; }
.api-table tbody tr { transition: background 120ms ease; }
.api-table tbody tr:has([data-api-select]:checked) { background: #211a1e; }
.selection-column,
.selection-cell { width: 42px; padding-right: 2px !important; text-align: center; }
.selection-check { display: inline-grid; width: 30px; height: 30px; place-items: center; cursor: pointer; }
.selection-check input { width: 17px; height: 17px; margin: 0; accent-color: var(--red); cursor: pointer; }
.selection-toolbar {
  display: flex;
  min-height: 49px;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: #1d191d;
}
.selection-toolbar[hidden] { display: none; }
.selection-toolbar strong { margin-right: auto; font-size: 13px; }
.mobile-selection-all { display: none !important; min-height: 32px; }
.actions-heading { text-align: right; }
.api-actions {
  display: flex;
  width: 126px;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}
.api-actions form { margin: 0; }
.icon-action {
  display: inline-grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--muted-strong);
  cursor: pointer;
}
.icon-action:hover { border-color: #59636f; background: var(--surface-3); color: var(--text); }
.icon-action:active { transform: translateY(1px); }
.icon-action:disabled { opacity: 0.48; cursor: wait; }
.icon-action.destructive { border-color: #6a3036; color: #ff8e95; }
.icon-action.destructive:hover { border-color: var(--red); background: var(--red-soft); color: #ffb3b8; }
.quota-cell { min-width: 240px; }
.quota-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px; }
.quota-number { font-variant-numeric: tabular-nums; }
.quota-line span { color: var(--muted); font-size: 12px; }
.quota-cell progress {
  display: block;
  width: 100%;
  height: 5px;
  margin-top: 7px;
  overflow: hidden;
  border: 0;
  border-radius: 3px;
  background: var(--surface-3);
  color: var(--blue);
}
.quota-cell progress::-webkit-progress-bar { background: var(--surface-3); }
.quota-cell progress::-webkit-progress-value { background: var(--blue); }
.quota-cell progress::-moz-progress-bar { background: var(--blue); }
.sync-time { display: block; margin-top: 5px; color: #737d88; font-size: 11px; }
.danger-dialog { width: min(560px, calc(100vw - 30px)); }
.selected-api-list { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 0 14px; }
.selected-api-list span { padding: 4px 6px; border: 1px solid #5f3035; border-radius: 4px; background: #321a1e; color: #ffc1c5; font-size: 12px; }

.activity-list { display: grid; }

.activity {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 9px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.activity:last-child { border-bottom: 0; }
.activity-dot { width: 7px; height: 7px; margin-top: 6px; border-radius: 50%; background: #8b949f; }
.activity strong { overflow-wrap: anywhere; }
.activity small { display: block; margin-top: 3px; color: var(--muted); overflow-wrap: anywhere; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-grid.one { grid-template-columns: 1fr; }

.form-grid label,
.filter-row label {
  display: grid;
  min-width: 0;
  gap: 6px;
  color: var(--muted-strong);
  font-weight: 650;
}

.span-2 { grid-column: span 2; }

input,
select,
textarea {
  width: 100%;
  min-height: 39px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #12151a;
  color: var(--text);
}

input:hover,
select:hover,
textarea:hover { border-color: #59636f; }

input:focus,
select:focus,
textarea:focus { border-color: var(--blue); outline: 3px solid rgba(130, 184, 239, 0.18); }

input::placeholder,
textarea::placeholder { color: #747e89; opacity: 1; }

select option { background: #12151a; color: var(--text); }

input[type="checkbox"],
input[type="radio"] { accent-color: var(--red); }

.check,
.toggle {
  display: flex !important;
  min-height: 39px;
  align-items: center;
  justify-content: flex-start;
  gap: 9px !important;
  font-weight: 520 !important;
  cursor: pointer;
}

.check { grid-template-columns: auto 1fr !important; }
.check input,
.toggle input { width: 18px; min-height: 18px; margin: 0; accent-color: var(--red); }
.form-help { align-self: end; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.inline-actions form { margin: 0; }

.filter-row,
.search-bar {
  display: flex;
  align-items: end;
  gap: 9px;
  margin-bottom: 15px;
}

.search-field { position: relative; width: min(520px, 100%); }
.search-field .icon { position: absolute; top: 11px; left: 11px; color: #747d87; }
.search-field input { padding-left: 37px; }
.search-bar > input { max-width: 520px; }

dialog {
  width: min(720px, calc(100vw - 30px));
  max-height: calc(100vh - 30px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(0, 0, 0, 0.74); }
.dialog-body { padding: 24px; }
.dialog-body h2 { margin: 0 40px 18px 0; font-size: 20px; line-height: 1.25; overflow-wrap: anywhere; }

.dialog-close {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 0;
  text-align: right;
}

.dialog-close button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 0 8px 0 6px;
  background: var(--surface);
  color: var(--muted-strong);
  cursor: pointer;
}

.dialog-close button:hover { background: var(--surface-2); color: var(--text); }

.tabs .tab-list {
  display: flex;
  gap: 3px;
  margin-bottom: 18px;
  overflow: auto;
  border-bottom: 1px solid var(--line);
}

.tab-list button {
  min-height: 38px;
  padding: 8px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.tab-list button:hover { color: var(--text); }
.tab-list button.active { border-bottom-color: var(--red); color: var(--text); }

.danger-zone {
  padding: 15px;
  border: 1px solid #733038;
  border-radius: 6px;
  background: #281518;
}

.danger-zone p { margin-top: 0; color: #ffc1c5; line-height: 1.55; }

.master-detail {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(330px, 0.55fr);
  gap: 17px;
}

.detail-panel {
  position: sticky;
  top: 18px;
  align-self: start;
  padding: 16px;
}

.detail-panel h3 { margin: 22px 0 10px; font-size: 14px; }
.detail-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.detail-stats > div {
  display: grid;
  min-width: 0;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.detail-stats span { color: var(--muted); font-size: 12px; }
.detail-stats strong { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.mini-list > div { display: grid; gap: 3px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.mini-list > div:last-child { border-bottom: 0; }
.mini-list small { color: var(--muted); overflow-wrap: anywhere; }
.clickable { cursor: pointer; }
.clickable:hover { background: var(--surface-2); }

.tariff-list { display: grid; gap: 9px; }

.tariff-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 130px 140px 105px 104px auto;
  align-items: end;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.tariff-row > div { align-self: center; min-width: 0; }
.tariff-row small { display: block; margin-top: 4px; color: var(--muted); overflow-wrap: anywhere; }

.system-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.system-grid .section-block { display: flex; min-height: 210px; flex-direction: column; }
.system-grid .section-block > form,
.system-grid .section-block > .inline-actions { margin-top: auto; padding-top: 16px; }
.muted { color: var(--muted); line-height: 1.55; }

.callout {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid #315475;
  border-radius: 6px;
  background: var(--blue-soft);
  color: #b8d8fa;
}

.callout.warning { border-color: #6c5725; background: var(--amber-soft); color: #f5d78f; }
.callout .icon { margin-top: 1px; }
.callout p { margin: 0; }

.secret-box {
  display: grid;
  gap: 6px;
  margin: 15px 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.secret-box code { font-size: 16px; overflow-wrap: anywhere; }

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
  background: var(--bg);
}

.auth-shell { width: min(460px, 100%); }

.auth-panel {
  padding: 27px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-panel.wide { width: min(560px, calc(100vw - 30px)); margin-left: 50%; transform: translateX(-50%); }
.auth-panel h1 { margin: 24px 0 18px; font-size: 23px; line-height: 1.25; }
.auth-brand { font-size: 16px; }

.empty-state {
  padding: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  text-align: center;
}

.empty-state .icon { margin: 0 auto 14px; color: var(--muted); }
.empty-state strong { font-size: 19px; }
.empty-state p { margin-bottom: 20px; color: var(--muted); }

/* Reusable settings and integration rows for provider configuration pages. */
.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 17px; }
.settings-nav { display: grid; align-self: start; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); overflow: hidden; }
.settings-nav a { padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--muted-strong); font-weight: 650; }
.settings-nav a:last-child { border-bottom: 0; }
.settings-nav a.active { border-left: 3px solid var(--red); background: var(--surface-2); color: var(--text); }
.integration-list { display: grid; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); overflow: hidden; }
.integration-row { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(180px, 1.4fr) auto; align-items: center; gap: 14px; padding: 14px 15px; border-bottom: 1px solid var(--line); }
.integration-row:last-child { border-bottom: 0; }
.integration-row small { display: block; margin-top: 3px; color: var(--muted); overflow-wrap: anywhere; }
.integrations-warning { margin-bottom: 17px; }
.system-warning { margin-bottom: 17px; }
.settings-stack { display: grid; gap: 12px; }
.integration-group { margin-bottom: 0; }
.integration-heading { align-items: flex-start; }
.integration-heading .muted { margin: 4px 0 0; }
.integration-section-form { display: grid; }
.integration-fields { display: grid; }
.integration-field {
  display: grid;
  grid-template-columns: minmax(170px, 0.75fr) minmax(240px, 1.25fr);
  gap: 6px 18px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}
.integration-field > label:first-child,
.integration-field > .field-label { align-self: center; color: var(--muted-strong); font-weight: 650; }
.field-control { display: flex; min-width: 0; align-items: center; gap: 8px; }
.field-control > input,
.field-control > select,
.field-control > textarea { min-width: 0; }
.field-control textarea { width: 100%; resize: vertical; }
.compact-control { max-width: 220px; }
.field-help { grid-column: 2; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.warning-text { color: var(--amber); }
.key-state { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 5px; padding: 5px 7px; border-radius: 4px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.key-state.configured { background: var(--green-soft); color: var(--green); }
.key-state.missing { background: var(--surface-3); color: var(--muted-strong); }
.clear-secret { grid-column: 2; min-height: 28px; color: var(--red-dark) !important; font-size: 12px; }
.clear-secret input { accent-color: var(--red); }
.toggle-field { margin: 0; }
.section-submit {
  display: grid;
  grid-template-columns: minmax(140px, 190px) minmax(140px, 190px) auto;
  align-items: end;
  justify-content: end;
  gap: 10px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}
.section-submit label { display: grid; gap: 6px; color: var(--muted-strong); font-weight: 650; }
.restart-confirmation {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(480px, 1.4fr);
  align-items: end;
  gap: 20px;
  margin-top: 17px;
  padding: 17px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
}
.restart-confirmation h2 { margin: 0; font-size: 17px; }
.restart-confirmation p { margin: 4px 0 0; }
.confirmation-fields { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 10px; }
.confirmation-fields label { display: grid; gap: 6px; color: var(--muted-strong); font-weight: 650; }
.audit-filter { margin-bottom: 15px; }
.table-filter-empty { margin: 0; }
.setup-command { display: grid; gap: 4px; margin: 13px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); }
.setup-command span { color: var(--muted); font-size: 12px; font-weight: 700; }
.setup-command code { overflow-wrap: anywhere; font-size: 13px; }
.setup-command + .button { margin-top: 8px; }

@media (prefers-reduced-motion: no-preference) {
  dialog[open] { animation: dialog-in 140ms ease-out; }
  dialog[open]::backdrop { animation: backdrop-in 140ms ease-out; }
  @keyframes dialog-in { from { opacity: 0; transform: translateY(8px); } }
  @keyframes backdrop-in { from { opacity: 0; } }
}

@media (max-width: 1180px) {
  .status-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .status-strip > div:nth-child(3) { border-right: 0; }
  .status-strip > div:nth-child(-n + 3) { border-bottom: 1px solid #393e45; }
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .master-detail { grid-template-columns: 1fr; }
  .detail-panel { position: static; }
  .tariff-row { grid-template-columns: minmax(180px, 1fr) 130px 130px; }
  .tariff-row .toggle,
  .tariff-row button { align-self: end; }
}

@media (max-width: 820px) {
  body.menu-open { overflow: hidden; }
  .sidebar { width: min(286px, calc(100vw - 48px)); transform: translateX(-101%); transition: transform 180ms ease; }
  .sidebar.open { transform: translateX(0); }
  .icon-button.sidebar-close { display: inline-grid; }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 25;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(17, 20, 24, 0.48);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }
  body.menu-open .sidebar-backdrop { display: block; opacity: 1; pointer-events: auto; }
  .mobile-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    height: 56px;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
  }
  .brand.compact { color: var(--text); font-size: 15px; }
  .brand.compact .brand-mark { width: 28px; height: 28px; font-size: 15px; }
  .main { width: 100%; margin-left: 0; padding: 19px 14px 40px; }
  .skip-link { left: 12px; }
  .page-header { margin-top: 3px; }
  .status-strip { grid-template-columns: 1fr 1fr; }
  .status-strip > div,
  .status-strip > div:nth-child(3) { border-right: 1px solid #393e45; border-bottom: 1px solid #393e45; }
  .status-strip > div:nth-child(even) { border-right: 0; }
  .status-strip > div:last-child { border-bottom: 0; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .two-column,
  .system-grid,
  .settings-layout { grid-template-columns: 1fr; }
  .system-grid .section-block { min-height: 0; }
  .settings-nav { grid-auto-flow: column; overflow-x: auto; }
  .settings-nav a { border-right: 1px solid var(--line); border-bottom: 0; white-space: nowrap; }
  .settings-nav a.active { border-bottom: 2px solid var(--red); border-left: 0; }
  .integration-row { grid-template-columns: 1fr auto; }
  .integration-row > :nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .restart-confirmation { grid-template-columns: 1fr; }
  .confirmation-fields { grid-template-columns: 1fr 1fr auto; }
  .section-submit { grid-template-columns: 1fr 1fr auto; }
  .table-wrap { overflow: visible; }
  table,
  thead,
  tbody,
  tr,
  th,
  td { display: block; }
  thead { display: none; }
  tr { padding: 9px 0; border-bottom: 1px solid var(--line); }
  tr:last-child { border-bottom: 0; }
  td { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 10px; padding: 6px 4px; border: 0; overflow-wrap: anywhere; }
  td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 700; }
  td[colspan] { display: block; }
  td[colspan]::before { display: none; }
  .actions { text-align: left; }
  .actions:empty { display: none; }
  .actions .button,
  .actions form { width: 100%; }
  .api-table { min-width: 0; }
  .api-table tr[data-api-row] { position: relative; padding: 12px 8px; }
  .api-table td { padding: 6px 4px; }
  .api-table .selection-cell { display: flex; width: 100%; align-items: center; justify-content: space-between; padding: 0 4px 4px !important; text-align: left; }
  .api-table .selection-cell::before { content: "Выбрать"; display: block; }
  .api-table .selection-check { width: 32px; height: 28px; }
  .api-actions { display: flex; width: auto; align-items: center; justify-content: flex-start; gap: 7px; }
  .api-actions::before { margin-right: auto; }
  .api-actions form { width: auto; }
  .mobile-selection-all { display: flex !important; }
  .selection-toolbar { position: sticky; top: 56px; z-index: 10; flex-wrap: wrap; }
  .selection-toolbar strong { margin-right: 0; }
  .selection-toolbar .button { margin-left: auto; }
  .truncate { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
  .tariff-row { grid-template-columns: 1fr 1fr; }
  .tariff-row > div,
  .tariff-row > button { grid-column: span 2; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .filter-row,
  .search-bar { align-items: stretch; flex-direction: column; }
  .search-field,
  .search-bar > input { width: 100%; max-width: none; }
  .filter-row .button,
  .search-bar .button { width: 100%; }
}

@media (max-width: 520px) {
  .page-header { align-items: stretch; flex-direction: column; }
  .page-header > .button { width: 100%; }
  .header-actions { display: grid; grid-template-columns: 1fr; }
  .header-actions .button { width: 100%; }
  .status-strip { grid-template-columns: 1fr; }
  .status-strip > div,
  .status-strip > div:nth-child(3) { border-right: 0; border-bottom: 1px solid #393e45; }
  .status-strip > div:last-child { border-bottom: 0; }
  .metric-grid { grid-template-columns: 1fr; }
  .detail-stats { grid-template-columns: 1fr; }
  .tariff-row { grid-template-columns: 1fr; }
  .tariff-row > div,
  .tariff-row label,
  .tariff-row > button { grid-column: span 1; }
  .integration-row { grid-template-columns: 1fr; }
  .integration-row > :nth-child(2) { grid-column: auto; grid-row: auto; }
  .integration-field { grid-template-columns: 1fr; }
  .field-help,
  .clear-secret { grid-column: 1; }
  .field-control { align-items: stretch; flex-direction: column; }
  .key-state { width: max-content; }
  .confirmation-fields { grid-template-columns: 1fr; }
  .confirmation-fields .button { width: 100%; }
  .section-submit { grid-template-columns: 1fr; }
  .section-submit .button { width: 100%; }
  .dialog-body { padding: 20px 16px; }
  .auth-panel { padding: 22px 18px; }
  .empty-state { padding: 32px 18px; }
  .selection-toolbar { display: grid; grid-template-columns: 1fr auto; gap: 7px 10px; }
  .selection-toolbar .mobile-selection-all { grid-column: 1; }
  .selection-toolbar strong { grid-column: 2; text-align: right; }
  .selection-toolbar .button { grid-column: 1 / -1; width: 100%; margin-left: 0; }
}
