:root {
  color-scheme: light dark;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --surface-raised: #ffffff;
  --text: #101828;
  --text-soft: #475467;
  --text-faint: #667085;
  --border: #dce3ec;
  --border-strong: #cbd5e1;
  --primary: #0866e5;
  --primary-hover: #0759c9;
  --primary-soft: #eaf3ff;
  --success: #17a05d;
  --success-soft: #eaf8f0;
  --danger: #e5484d;
  --danger-soft: #fff0f0;
  --warning: #d97706;
  --warning-soft: #fff7e6;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 3px 10px rgba(16, 24, 40, 0.03);
  --shadow-md: 0 16px 40px rgba(16, 24, 40, 0.12);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --sidebar: 244px;
  --bottom-nav-height: 72px;
  --content-max: 1120px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-synthesis: none;
}

[data-theme="dark"] {
  --bg: #0b1018;
  --surface: #121923;
  --surface-subtle: #171f2b;
  --surface-raised: #18212e;
  --text: #f5f7fa;
  --text-soft: #c6cfda;
  --text-faint: #8f9cac;
  --border: #283445;
  --border-strong: #39475b;
  --primary: #57a3ff;
  --primary-hover: #79b5ff;
  --primary-soft: #142d4c;
  --success: #45c783;
  --success-soft: #123325;
  --danger: #ff7277;
  --danger-soft: #3c1a1d;
  --warning: #f0a33a;
  --warning-soft: #3a2a12;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 20px 48px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
[role="button"] {
  touch-action: manipulation;
}

button {
  color: inherit;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon.fill {
  fill: currentColor;
  stroke: none;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
}

.app-main {
  width: 100%;
  min-height: 100vh;
  padding: max(22px, env(safe-area-inset-top)) 18px calc(var(--bottom-nav-height) + max(22px, env(safe-area-inset-bottom)));
  outline: none;
}

.page {
  width: min(100%, var(--content-max));
  margin: 0 auto;
  animation: page-in 180ms ease-out;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.page-header.with-back {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  min-height: 44px;
}

.page-header.with-back .header-copy {
  text-align: center;
}

.header-copy h1,
.brand-heading {
  margin: 0;
  color: var(--text);
  font-size: clamp(25px, 7vw, 34px);
  line-height: 1.12;
  letter-spacing: -0.025em;
  font-weight: 730;
}

.page-header.with-back h1 {
  font-size: 20px;
  letter-spacing: -0.015em;
}

.header-copy p {
  margin: 5px 0 0;
  color: var(--text-soft);
  font-size: 15px;
  line-height: 1.4;
}

.eyebrow-free-label {
  display: block;
  margin-top: 4px;
  color: var(--text-soft);
  font-size: 16px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
}

.icon-button:hover {
  background: var(--surface-subtle);
  color: var(--primary);
}

.icon-button.danger-icon { color: var(--danger); }
.icon-button.danger-icon:hover { background: var(--danger-soft); color: var(--danger); }

.section {
  margin-top: 26px;
}

.section:first-of-type {
  margin-top: 0;
}

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

.section-heading h2,
.section-heading h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.section-heading span,
.section-description {
  color: var(--text-faint);
  font-size: 13px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.status-card {
  min-height: 118px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.status-card .card-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 600;
}

.status-card .card-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 20px;
  color: var(--text);
  font-size: 26px;
  line-height: 1;
  font-weight: 740;
  letter-spacing: -0.035em;
}

.status-card .card-value.status-text {
  color: var(--success);
  font-size: 21px;
}

.status-card .card-value.usage {
  color: var(--primary);
  font-size: 21px;
  white-space: nowrap;
}

.status-card .card-value small {
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 540;
  letter-spacing: 0;
}

.status-card .card-value.compact-value {
  overflow: hidden;
  max-width: 100%;
  font-size: 16px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-meta {
  display: block;
  overflow: hidden;
  margin-top: 9px;
  color: var(--text-faint);
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.usage-track {
  overflow: hidden;
  height: 5px;
  margin-top: 13px;
  border-radius: 999px;
  background: var(--primary-soft);
}

.usage-track span {
  display: block;
  height: 100%;
  min-width: 3px;
  border-radius: inherit;
  background: var(--primary);
}

.text-button {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  gap: 2px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 13px;
  font-weight: 660;
  cursor: pointer;
}

.text-button .icon { width: 16px; height: 16px; }

.node-overview-panel {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.node-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px;
  border-bottom: 1px solid var(--border);
}

.node-identity strong,
.node-identity small { display: block; }
.node-identity strong { font-size: 15px; }
.node-identity small { overflow: hidden; margin-top: 4px; color: var(--text-faint); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.node-health {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.node-health > span { min-width: 0; padding: 13px 14px; border-right: 1px solid var(--border); }
.node-health > span:last-child { border-right: 0; }
.node-health small, .node-health strong { display: block; }
.node-health small { color: var(--text-faint); font-size: 10px; }
.node-health strong { overflow: hidden; margin-top: 5px; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.node-health i { width: 7px; height: 7px; margin-right: 7px; box-shadow: none; }

.dashboard-columns { display: grid; gap: 26px; }

.activity-list {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.activity-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 68px;
  gap: 10px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
}
.activity-row:last-child { border-bottom: 0; }
.activity-marker { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 10px; background: var(--surface-subtle); color: var(--text-faint); }
.activity-marker.success { background: var(--success-soft); color: var(--success); }
.activity-marker .icon { width: 16px; height: 16px; }
.activity-copy { min-width: 0; }
.activity-copy strong, .activity-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-copy strong { font-size: 13px; }
.activity-copy small { margin-top: 4px; color: var(--text-faint); font-size: 11px; }
.activity-row time { color: var(--text-faint); font-size: 10px; white-space: nowrap; }

.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 12%, transparent);
}

.status-dot.danger { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 12%, transparent); }
.status-dot.neutral { background: var(--text-faint); box-shadow: none; }

.list-panel {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 68px;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
}

button.list-row {
  width: 100%;
  cursor: pointer;
}

.list-row:last-child {
  border-bottom: 0;
}

button.list-row:hover {
  background: var(--surface-subtle);
}

.row-main {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.row-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 3px;
}

.row-title {
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-subtitle {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-faint);
  font-size: 13px;
  line-height: 1.3;
}

.row-trailing {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: 10px;
  color: var(--text-faint);
  font-size: 13px;
}

.row-trailing .icon {
  width: 18px;
  height: 18px;
}

.row-trailing > span b,
.row-trailing > span small { display: block; text-align: right; }
.row-trailing > span b { color: var(--text-soft); font-size: 12px; }
.row-trailing > span small { margin-top: 3px; color: var(--text-faint); font-size: 10px; font-weight: 500; }

.status-text-inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--success);
  font-weight: 600;
}

.status-text-inline.disabled {
  color: var(--danger);
}

.avatar,
.feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 14px;
  font-weight: 750;
}

.avatar.disabled {
  background: var(--danger-soft);
  color: var(--danger);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--primary);
  color: white;
  font-size: 15px;
  font-weight: 680;
  line-height: 1;
  cursor: pointer;
  transition: background-color 150ms ease, transform 100ms ease, border-color 150ms ease;
}

.button:hover { background: var(--primary-hover); }
.button:active { transform: scale(0.985); }
.button.secondary { border-color: var(--border-strong); background: var(--surface); color: var(--text); }
.button.secondary:hover { border-color: var(--primary); color: var(--primary); }
.button.ghost { border-color: var(--primary); background: transparent; color: var(--primary); }
.button.ghost:hover { background: var(--primary-soft); }
.button.danger { border-color: var(--danger); background: transparent; color: var(--danger); }
.button.danger:hover { background: var(--danger-soft); }
.button.full { width: 100%; }
.button.small { min-height: 40px; padding: 0 13px; font-size: 14px; }
.button:disabled { opacity: .48; cursor: not-allowed; transform: none; }

.stack-actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.sticky-mobile-action {
  margin-top: 18px;
}

.detail-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
  padding: 0 16px;
  border: 1px solid color-mix(in srgb, var(--success) 25%, var(--border));
  border-radius: var(--radius-md);
  background: var(--success-soft);
  color: var(--success);
  font-size: 15px;
  font-weight: 680;
}

.detail-status.disabled {
  border-color: color-mix(in srgb, var(--danger) 25%, var(--border));
  background: var(--danger-soft);
  color: var(--danger);
}

.credential-row,
.subscription-row {
  min-height: 62px;
}

.credential-state {
  color: var(--success);
  font-weight: 600;
}

.copy-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 4px 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--primary);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.copy-button:hover { background: var(--primary-soft); }

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 3px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-subtle);
}

.segment {
  min-height: 40px;
  padding: 7px 5px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 620;
  cursor: pointer;
}

.segment.selected {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 5px rgba(8, 102, 229, 0.2);
}

.form-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.form-stack {
  display: grid;
  gap: 14px;
}

.form-group {
  display: grid;
  gap: 8px;
}

.form-label {
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
}

.form-hint {
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.45;
}

.input,
.select {
  width: 100%;
  min-height: 48px;
  padding: 0 13px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.input::placeholder { color: var(--text-faint); }
.input:focus,
.select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }

.radio-list {
  display: grid;
  gap: 4px;
}

.radio-row {
  display: flex;
  align-items: center;
  min-height: 46px;
  gap: 10px;
  cursor: pointer;
}

.radio-row input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--primary);
}

.radio-row span {
  font-size: 15px;
  font-weight: 570;
}

.form-page {
  max-width: 680px;
}

.form-page .form-card + .form-card {
  margin-top: 12px;
}

.template-list {
  display: grid;
  gap: 10px;
}

.template-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  min-height: 86px;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.template-card:hover { border-color: var(--primary); }

.template-card .feature-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
}

.template-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 16px;
}

.template-card small { color: var(--text-faint); font-size: 13px; }

.rule-list {
  display: grid;
  gap: 8px;
}

.rule-item {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 76px;
  padding: 10px 8px 10px 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.rule-item.dragging {
  z-index: 3;
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  opacity: .88;
  transform: scale(1.015);
}

.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 48px;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  cursor: grab;
  touch-action: none;
}

.drag-handle:active { cursor: grabbing; }

.rule-copy {
  min-width: 0;
}

.rule-title {
  overflow: hidden;
  font-size: 14px;
  font-weight: 660;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rule-meta {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 7px;
  margin-top: 5px;
  color: var(--text-faint);
  font-size: 11px;
}

.rule-type {
  flex: 0 0 auto;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 680;
}

.rule-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rule-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.rule-actions .icon-button {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  color: var(--primary);
}

.rule-actions .icon-button.danger-icon { color: var(--danger); }

.rule-origin {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 680;
}

.rule-origin.template { background: var(--surface-subtle); color: var(--text-faint); border: 1px solid var(--border); }
.rule-origin.override { background: var(--warning-soft); color: var(--warning); border: 1px solid color-mix(in srgb, var(--warning) 26%, var(--border)); }

.origin-explainer {
  display: grid;
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-subtle);
}

.origin-explainer div {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text-soft);
  font-size: 13px;
}

.masked-value {
  display: block;
  overflow: hidden;
  max-width: 100%;
  color: var(--text-faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.credential-panel .row-main { min-width: 0; }
.credential-panel .row-copy { max-width: min(58vw, 420px); }

.client-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.client-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 108px;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.client-option > span { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 9px; background: var(--surface-subtle); color: var(--text-faint); }
.client-option .icon { width: 16px; height: 16px; }
.client-option strong { font-size: 12px; line-height: 1.25; }
.client-option small { color: var(--text-faint); font-size: 10px; }
.client-option.selected { border-color: var(--primary); background: var(--primary-soft); }
.client-option.selected > span { background: var(--primary); color: white; }
.client-option.selected small { color: var(--primary); }

.empty-row {
  padding: 22px 16px;
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
}

.rule-resolution-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-subtle);
  text-align: center;
}
.rule-resolution-summary > span { color: var(--text-faint); font-size: 9px; line-height: 1.25; }
.rule-resolution-summary > span strong { display: block; color: var(--text); font-size: 15px; }
.rule-resolution-summary .icon { width: 14px; height: 14px; }

.checkbox-grid { display: grid; gap: 6px; }
.check-row { display: flex; align-items: center; min-height: 44px; gap: 10px; cursor: pointer; }
.check-row input { width: 20px; height: 20px; margin: 0; accent-color: var(--primary); }
.check-row span { font-size: 14px; font-weight: 570; }

.rule-model-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.rule-model-panel > div { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 4px 10px; }
.rule-model-panel strong { font-size: 13px; }
.rule-model-panel small { grid-column: 2; color: var(--text-faint); font-size: 11px; }
.model-arrow { display: none; color: var(--text-faint); }

.template-impact {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 20px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
}
.template-impact div { padding: 11px; border-radius: 10px; background: var(--surface); }
.template-impact small, .template-impact strong { display: block; }
.template-impact small { color: var(--text-faint); font-size: 10px; }
.template-impact strong { margin-top: 4px; font-size: 22px; }
.template-impact p { grid-column: 1 / -1; margin: 4px 2px 0; color: var(--text-soft); font-size: 12px; line-height: 1.55; }

.inline-form {
  display: grid;
  gap: 12px;
}

.inline-form .form-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.inline-form .input,
.inline-form .select { min-height: 44px; font-size: 14px; }

.settings-layout {
  display: grid;
  gap: 24px;
}

.settings-group h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.settings-row {
  min-height: 64px;
}

.security-summary,
.provider-callout {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
  padding: 15px;
  border: 1px solid color-mix(in srgb, var(--success) 25%, var(--border));
  border-radius: var(--radius-md);
  background: var(--success-soft);
}
.security-summary > span { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; flex: 0 0 auto; border-radius: 11px; background: var(--surface); color: var(--success); }
.security-summary .icon { width: 19px; height: 19px; }
.security-summary strong, .security-summary small { display: block; }
.security-summary strong { color: var(--success); font-size: 13px; }
.security-summary small { margin-top: 4px; color: var(--text-soft); font-size: 11px; line-height: 1.45; }

.section-action {
  margin-top: 12px;
}

.migration-page {
  max-width: 760px;
}

.migration-hero {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.provider-callout {
  margin: 14px 0 0;
  border-color: color-mix(in srgb, var(--primary) 25%, var(--border));
  background: var(--primary-soft);
}
.provider-callout .feature-icon { background: var(--surface); }
.provider-callout strong { display: block; color: var(--primary); font-size: 13px; }
.provider-callout p { margin: 5px 0 0; color: var(--text-soft); font-size: 11px; line-height: 1.55; }

.migration-hero-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.migration-hero-top strong,
.migration-hero-top small {
  display: block;
}

.migration-hero-top strong { font-size: 16px; }
.migration-hero-top small { margin-top: 3px; color: var(--text-faint); font-size: 12px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  gap: 7px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 680;
  white-space: nowrap;
}

.status-pill.success { background: var(--success-soft); color: var(--success); }
.status-pill.neutral { border: 1px solid var(--border); }
.status-pill .status-dot { width: 7px; height: 7px; box-shadow: none; }

.endpoint-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.endpoint-grid div {
  min-width: 0;
  padding: 14px 16px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.endpoint-grid div:nth-child(2n) { border-right: 0; }
.endpoint-grid div:nth-last-child(-n+2) { border-bottom: 0; }
.endpoint-grid span { display: block; color: var(--text-faint); font-size: 11px; }
.endpoint-grid strong { display: block; overflow: hidden; margin-top: 5px; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }

.address-mode-grid {
  display: grid;
  gap: 10px;
}

.address-mode {
  position: relative;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 82px;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.address-mode.selected { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 12%, transparent); }
.address-mode strong, .address-mode small { display: block; grid-column: 2; }
.address-mode strong { align-self: end; font-size: 15px; }
.address-mode small { align-self: start; margin-top: -7px; color: var(--text-faint); font-size: 12px; line-height: 1.4; }
.address-mode em { grid-column: 3; grid-row: 1 / 3; padding: 4px 7px; border-radius: 7px; background: var(--primary-soft); color: var(--primary); font-size: 10px; font-style: normal; font-weight: 700; }

.mode-check {
  display: inline-flex;
  grid-column: 1;
  grid-row: 1 / 3;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: white;
  font-size: 13px;
  font-weight: 800;
}

.address-mode.selected .mode-check { border-color: var(--primary); background: var(--primary); }

.mock-banner.compact {
  margin: 10px 0 0;
}

.migration-steps {
  overflow: hidden;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  list-style: none;
}

.migration-step {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 72px;
  gap: 10px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
}

.migration-step:last-child { border-bottom: 0; }
.step-marker { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface-subtle); color: var(--text-faint); font-size: 12px; font-weight: 720; }
.migration-step.active .step-marker { background: var(--primary-soft); color: var(--primary); animation: step-pulse 1s ease-in-out infinite alternate; }
.migration-step.done .step-marker { background: var(--success-soft); color: var(--success); }
.step-copy strong, .step-copy small { display: block; }
.step-copy strong { font-size: 13px; }
.step-copy small { margin-top: 4px; color: var(--text-faint); font-size: 11px; line-height: 1.4; }
.step-status { color: var(--text-faint); font-size: 11px; }
.migration-step.active .step-status { color: var(--primary); font-weight: 680; }
.migration-step.done .step-status { color: var(--success); font-weight: 680; }
@keyframes step-pulse { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 22%, transparent); } to { box-shadow: 0 0 0 5px transparent; } }

.unchanged-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.unchanged-grid span {
  display: flex;
  align-items: center;
  min-height: 48px;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 620;
}

.unchanged-grid .icon { width: 17px; height: 17px; color: var(--success); }

.ip-history {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.ip-history-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 66px;
  gap: 9px;
  padding: 10px 13px 10px 8px;
  border-bottom: 1px solid var(--border);
}
.ip-history-row:last-child { border-bottom: 0; }
.history-line { position: relative; align-self: stretch; }
.history-line::before { position: absolute; top: -10px; bottom: -10px; left: 9px; width: 1px; background: var(--border); content: ""; }
.ip-history-row:first-child .history-line::before { top: 50%; }
.ip-history-row:last-child .history-line::before { bottom: 50%; }
.history-line i { position: absolute; top: 50%; left: 5px; width: 9px; height: 9px; border: 2px solid var(--surface); border-radius: 50%; background: var(--text-faint); transform: translateY(-50%); box-shadow: 0 0 0 1px var(--border); }
.ip-history-row.active .history-line i { background: var(--success); box-shadow: 0 0 0 2px var(--success-soft); }
.history-copy strong, .history-copy small { display: block; }
.history-copy strong { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.history-copy small { margin-top: 4px; color: var(--text-faint); font-size: 10px; }
.history-meta { text-align: right; }
.history-meta time, .history-meta em { display: block; }
.history-meta time { color: var(--text-faint); font-size: 9px; white-space: nowrap; }
.history-meta em { margin-top: 5px; color: var(--success); font-size: 10px; font-style: normal; font-weight: 700; }

.typed-confirm-field { margin-top: 16px; }

.secret-boundary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.secret-boundary span { padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-subtle); text-align: center; }
.secret-boundary strong, .secret-boundary small { display: block; }
.secret-boundary strong { color: var(--text); font-size: 12px; }
.secret-boundary small { margin-top: 4px; color: var(--text-faint); font-size: 10px; line-height: 1.35; }
.secret-boundary b { color: var(--primary); }

.format-icon {
  color: var(--primary);
}

.theme-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-subtle);
}

.theme-option {
  min-height: 40px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 620;
  cursor: pointer;
}

.theme-option.selected { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

.sidebar {
  display: none;
}

.bottom-nav {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  min-height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
  padding: 7px 8px max(7px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: 0 -8px 22px rgba(16, 24, 40, 0.04);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  gap: 4px;
  padding: 4px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.nav-item .icon { width: 22px; height: 22px; }
.nav-item.active { color: var(--primary); }

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(3, 10, 20, 0.48);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade-in 150ms ease-out;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: min(100%, 480px);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-md);
  animation: modal-up 180ms ease-out;
}

@keyframes modal-up { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  padding: 20px 20px 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 19px;
  letter-spacing: -0.015em;
}

.modal-body {
  padding: 10px 20px 20px;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.55;
}

.modal-body p { margin: 0; }
.modal-body .inline-form { margin-top: 16px; }

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 20px 20px;
}

.modal-actions .button { min-width: 0; }

.toast-region {
  position: fixed;
  z-index: 140;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  left: 16px;
  display: grid;
  justify-items: center;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  min-height: 44px;
  max-width: 520px;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 610;
  animation: toast-in 180ms ease-out;
}

@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

.empty-state {
  display: grid;
  justify-items: center;
  padding: 36px 20px;
  color: var(--text-faint);
  text-align: center;
}

.empty-state .feature-icon { margin-bottom: 12px; }
.empty-state strong { color: var(--text); font-size: 15px; }
.empty-state p { max-width: 280px; margin: 6px 0 0; font-size: 13px; line-height: 1.5; }

.mock-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -4px 0 18px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-subtle);
  color: var(--text-faint);
  font-size: 12px;
}

.desktop-only { display: none; }

@media (min-width: 720px) {
  .app-main { padding-right: 28px; padding-left: 28px; }
  .status-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .status-card { min-height: 132px; }
  .content-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 24px; align-items: start; }
  .template-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .address-mode-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rule-model-panel { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; }
  .model-arrow { display: inline-flex; }
  .settings-group.full-width { grid-column: 1 / -1; }
  .modal-backdrop { align-items: center; }
  .desktop-only { display: initial; }
}

@media (min-width: 960px) {
  .app-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
  .sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px 16px;
    border-right: 1px solid var(--border);
    background: var(--surface);
  }
  .brand-block { display: flex; align-items: center; gap: 12px; padding: 4px 8px 26px; }
  .brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 12px; background: var(--primary); color: white; font-size: 14px; font-weight: 800; letter-spacing: -.02em; }
  .brand-block strong { display: block; font-size: 17px; letter-spacing: -.01em; }
  .brand-block span { display: block; margin-top: 2px; color: var(--text-faint); font-size: 12px; }
  .side-nav { display: grid; gap: 5px; }
  .side-nav .nav-item { flex-direction: row; justify-content: flex-start; min-height: 46px; gap: 12px; padding: 0 12px; font-size: 14px; }
  .side-nav .nav-item.active { background: var(--primary-soft); }
  .side-nav .nav-item .icon { width: 20px; height: 20px; }
  .prototype-note { display: flex; align-items: flex-start; gap: 10px; margin-top: auto; padding: 13px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-subtle); color: var(--text-faint); font-size: 12px; line-height: 1.45; }
  .prototype-note .status-dot { margin-top: 4px; }
  .bottom-nav { display: none; }
  .app-main { min-width: 0; padding: 44px 42px 60px; }
  .page-header { min-height: 66px; }
  .page-header.with-back { grid-template-columns: 44px 1fr 44px; }
  .page-header.with-back .header-copy { text-align: left; }
  .page-header.with-back h1 { font-size: 27px; }
  .page-header.with-back .header-copy p { display: block; }
  .page-header.with-back .header-spacer { display: none; }
  .sticky-mobile-action { position: static; }
  .dashboard-columns { grid-template-columns: minmax(0, 1.05fr) minmax(320px, .95fr); gap: 24px; }
}

@media (min-width: 1240px) {
  .status-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .status-card { min-height: 128px; }
}

@media (max-width: 380px) {
  .app-main { padding-right: 14px; padding-left: 14px; }
  .status-card { min-height: 110px; padding: 13px; }
  .status-card .card-value.usage { font-size: 18px; }
  .segmented { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rule-item { grid-template-columns: 30px minmax(0, 1fr) auto; }
  .rule-actions .icon-button { width: 36px; }
  .client-grid { grid-template-columns: 1fr; }
  .client-option { min-height: 74px; display: grid; grid-template-columns: 34px minmax(0, 1fr); align-items: center; }
  .client-option small { grid-column: 2; margin-top: -10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

@supports not (color: color-mix(in srgb, white, black)) {
  .bottom-nav { background: var(--surface); }
}
