
/* ============================================================================
   LinkHub Admin Console — Unified Enterprise Design System
   Single source of truth for layout, typography, tables, forms, tabs & modals
   ============================================================================ */
:root {
  --font-sans: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", "SFMono-Regular", Consolas, Menlo, ui-monospace, monospace;

  --bg: #f3f5f9;
  --bg-subtle: #f8fafc;
  --surface: #ffffff;
  --sidebar: #ffffff;

  --text: #0f172a;
  --text-secondary: #334155;
  --muted: #64748b;
  --muted-light: #94a3b8;

  --border: #e2e8f0;
  --border-subtle: #eef2f6;
  --border-strong: #cbd5e1;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-tint: #f0f7ff;
  --primary-border: #bfdbfe;

  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;

  --ok-bg: #ecfdf5;
  --ok-text: #047857;
  --ok-border: #a7f3d0;

  --warn-bg: #fffbeb;
  --warn-text: #b45309;
  --warn-border: #fde68a;

  --off-bg: #f1f5f9;
  --off-text: #475569;
  --off-border: #e2e8f0;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.24);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea {
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}

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

/* ---------- Shell & Sidebar ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 228px;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 15px 8px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.brand-title {
  font-weight: 700;
  color: var(--text);
  font-size: 15px;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-group {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted-light);
  letter-spacing: 0.04em;
  padding: 13px 10px 4px 10px;
}

.nav a {
  color: #475569;
  text-decoration: none;
  height: 35px;
  padding: 0 10px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.14s ease, color 0.14s ease;
  display: flex;
  align-items: center;
  gap: 9px;
}

.nav a svg {
  width: 16px;
  height: 16px;
  color: var(--muted-light);
  flex-shrink: 0;
  transition: color 0.14s ease;
}

.nav a:hover {
  background: var(--bg-subtle);
  color: var(--text);
  text-decoration: none;
}

.nav a:hover svg { color: var(--text-secondary); }

.nav a.active {
  background: var(--primary-soft);
  color: var(--primary-hover);
  font-weight: 600;
}

.nav a.active svg { color: var(--primary); }

.sidebar-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 12px 8px 2px 8px;
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-ver {
  font-size: 11.5px;
  color: var(--muted-light);
  font-weight: 500;
}

/* ---------- Main Area & Topbar ---------- */
.main-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 54px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.topbar-crumb {
  font-size: 13px;
  color: var(--muted-light);
  font-weight: 500;
}

.topbar-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-status {
  height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 11px;
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ok-text);
  line-height: 1;
}

.dot-live {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  flex-shrink: 0;
}

.user-chip {
  height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 11px 0 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1;
}

.user-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  display: grid;
  place-items: center;
}

.topbar-right .btn-logout {
  height: 30px;
  padding: 0 11px;
  font-size: 12px;
  border-radius: var(--radius);
}

.content {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 22px 28px 40px 28px;
}

/* ---------- KPI Stat Cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 15px 17px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-xs);
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  margin-top: 4px;
}

.stat-value .muted {
  font-size: 12.5px;
  font-weight: 500;
}

.stat-sub {
  font-size: 11.5px;
  color: var(--muted-light);
  margin-top: 3px;
  line-height: 1.35;
}

.stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.stat-icon.blue { background: #eff6ff; color: #2563eb; }
.stat-icon.green { background: #ecfdf5; color: #059669; }
.stat-icon.indigo { background: #eef2ff; color: #4f46e5; }
.stat-icon.amber { background: #fffbeb; color: #d97706; }

/* ---------- Cards, Headers & Toolbars ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.card-warn {
  border-color: #fcd34d;
  background: #fffdf5;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.card-header > div:first-child:not(.seg-tabs):not(.toolbar) {
  min-width: 0;
  flex: 1 1 auto;
}

.card-header > .toolbar,
.card-header > .inline-form,
.card-header > .btn {
  flex: 0 0 auto;
}

@media (max-width: 980px) {
  .card-header {
    flex-wrap: wrap;
    align-items: flex-start;
  }
}

.card h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.card-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--off-bg);
  border: 1px solid var(--border);
  padding: 1px 8px;
  border-radius: 999px;
}

.card-desc {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.45;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.search-input {
  width: 228px !important;
  height: 34px !important;
  padding: 0 11px !important;
  font-size: 12.5px !important;
  background: var(--bg-subtle) !important;
  border-color: var(--border) !important;
}
.search-input:focus {
  background: #fff !important;
  border-color: var(--primary) !important;
}

/* ---------- Segmented Tabs & Hint Bars ---------- */
.seg-tabs {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 9px;
}

.seg-tab {
  height: 30px;
  padding: 0 13px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #475569;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.seg-tab:hover { color: var(--text); }

.seg-tab.active {
  background: #ffffff;
  color: var(--primary-hover);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.seg-count {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #475569;
  line-height: 1.3;
}

.seg-tab.active .seg-count {
  background: #dbeafe;
  color: var(--primary-hover);
}

.hint-bar, .policy-hint-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  margin-bottom: 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12.5px;
  color: #475569;
  line-height: 1.5;
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
}

th, td {
  text-align: left;
  padding: 11px 13px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

th {
  height: 38px;
  padding: 0 13px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

tbody tr { transition: background 0.1s ease; }
tbody tr:hover td { background: #f8fafc; }

th.col-actions, td.col-actions {
  text-align: right;
  white-space: nowrap;
  width: 1%;
}

.col-actions .actions {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.actions-stack {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.actions-row {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.nowrap, .col-nowrap { white-space: nowrap; }

.empty-cell {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Cell Typography & Credential Rows ---------- */
.cell-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.cell-sub {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  margin-top: 3px;
}

.kv-line {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.muted { font-size: 12px; color: var(--muted); }

code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: #f1f5f9;
  color: #1e293b;
  padding: 1.5px 6px;
  border-radius: 5px;
  border: 1px solid #e2e8f0;
  line-height: 1.3;
}

.fp-code {
  max-width: 156px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: bottom;
}

.cred-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cred-row {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  font-size: 12px;
  color: #475569;
}

.cred-label {
  color: var(--muted);
  font-size: 11.5px;
  min-width: 36px;
}

.pw-code {
  min-width: 76px;
  text-align: center;
  letter-spacing: 0.03em;
  background: #f8fafc;
}

/* ---------- Tags & Status Badges ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 21px;
  padding: 0 7px;
  border-radius: 5px;
  background: var(--primary-soft);
  color: var(--primary-hover);
  border: 1px solid #dbeafe;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.tag-green { background: var(--ok-bg); color: var(--ok-text); border-color: var(--ok-border); }
.tag-amber { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-border); }
.tag-slate { background: var(--off-bg); color: var(--off-text); border-color: var(--off-border); }
.tag-purple { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.tag-red { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }

.tag-list, .tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 23px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-ok { background: var(--ok-bg); color: var(--ok-text); border: 1px solid var(--ok-border); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); border: 1px solid var(--warn-border); }
.badge-off { background: var(--off-bg); color: var(--off-text); border: 1px solid var(--off-border); }

/* ---------- Buttons ---------- */
.btn {
  height: 34px;
  padding: 0 13px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: #fff;
  color: #1e293b;
  cursor: pointer;
  font-weight: 500;
  font-size: 12.5px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
  white-space: nowrap;
  text-decoration: none;
  vertical-align: middle;
}

.btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  text-decoration: none;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}

.btn-soft {
  background: var(--primary-soft);
  color: var(--primary-hover);
  border-color: var(--primary-border);
  font-weight: 500;
}
.btn-soft:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

.btn-danger, .btn-danger-soft {
  background: #fff;
  color: var(--danger);
  border-color: var(--danger-border);
}
.btn-danger:hover, .btn-danger-soft:hover {
  background: var(--danger-soft);
  border-color: #f87171;
}

.btn-ghost {
  background: transparent;
  color: #475569;
  border-color: var(--border);
}
.btn-ghost:hover {
  background: #f1f5f9;
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-sm {
  height: 28px;
  padding: 0 9px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-xs {
  height: 21px;
  padding: 0 6px;
  font-size: 11px;
  border-radius: 5px;
  gap: 3px;
}

/* ---------- Forms & Inputs ---------- */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
select,
textarea {
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 13px;
  background: #fff;
  color: var(--text);
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
  width: 100%;
  line-height: 1.4;
}

select { padding-right: 28px; }
textarea { height: auto; padding: 9px 11px; line-height: 1.5; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0;
}

.inline-form input[type="text"],
.inline-form input[type="password"],
.inline-form input[type="number"],
.inline-form select,
form.inline input[type="text"],
form.inline input[type="password"],
form.inline select {
  width: auto;
  height: 34px;
}

form.inline {
  margin: 0;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.input-row > input { flex: 1; min-width: 0; }
.input-row > .btn { flex-shrink: 0; height: 36px; }

.input-sm {
  width: 118px !important;
  height: 30px !important;
  padding: 0 8px !important;
  font-size: 12px !important;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  align-items: end;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.form-grid-name-ttl {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(180px, 1fr);
  gap: 14px;
  align-items: start;
}

@media (max-width: 760px) {
  .form-grid-2, .form-grid-3, .form-grid-name-ttl { grid-template-columns: 1fr; }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  min-height: 18px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field-hint {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.45;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-footer {
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-start;
  gap: 10px;
}

.section-divider {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  margin: 4px 0 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-divider .muted {
  font-size: 11.5px;
  font-weight: 400;
}

.actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 5px;
  align-items: center;
}

/* ---------- Checkboxes, Radio Mode Cards & Switch Grids ---------- */
.checkbox {
  min-height: 36px;
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  transition: all 0.14s ease;
  width: auto;
}

.checkbox:hover {
  border-color: #93c5fd;
  background: var(--primary-tint);
}

.checkbox input[type="checkbox"],
.checkbox input[type="radio"] {
  width: 15px !important;
  height: 15px !important;
  accent-color: var(--primary);
  margin: 0;
  flex-shrink: 0;
}

/* 4-tier Remote Access Mode Cards (2x2 clean selectable cards, auto height) */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 640px) {
  .mode-grid { grid-template-columns: 1fr; }
}

.mode-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #ffffff;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.mode-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

.mode-card input[type="radio"] {
  width: 15px;
  height: 15px;
  margin: 2px 0 0 0;
  accent-color: var(--primary);
  flex-shrink: 0;
  cursor: pointer;
}

.mode-card-body {
  min-width: 0;
  flex: 1;
}

.mode-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mode-card-desc {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.45;
}

.mode-card:has(input:checked) {
  border-color: #3b82f6;
  background: var(--primary-tint);
  box-shadow: 0 0 0 1px #3b82f6 inset;
}

.mode-card:has(input:checked) .mode-card-title { color: var(--primary-hover); }
.mode-card:has(input:checked) .mode-card-desc { color: #334155; }

/* Protocol multi-select pills */
.proto-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.proto-pill {
  height: 34px;
  min-width: 74px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: all 0.14s ease;
}
.proto-pill input {
  width: 14px;
  height: 14px;
  accent-color: var(--primary);
  margin: 0;
  cursor: pointer;
  flex-shrink: 0;
}
.proto-pill:has(input:checked) {
  background: var(--primary-soft);
  border-color: #60a5fa;
  color: var(--primary-hover);
}

/* Feature switches grid (2-col and 3-col) */
.flag-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 10px;
}

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

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

.flag-item {
  min-height: 38px;
  height: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #ffffff;
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
}

.flag-item span:first-of-type {
  line-height: 1.35;
  min-width: 0;
}

.flag-item:hover {
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

.flag-item input {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  margin: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.flag-item:has(input:checked) {
  background: var(--primary-tint);
  border-color: #93c5fd;
  color: #1e3a8a;
  font-weight: 600;
}

.tip {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  cursor: help;
  flex-shrink: 0;
  margin-left: auto;
}
.tip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

/* ---------- Tunnel Rate Panel, Member Lists & Command Banner ---------- */
.rate-panel {
  background: linear-gradient(180deg, #f8faff 0%, #f0f5ff 100%);
  border: 1px solid #dbeafe;
  border-radius: var(--radius-md);
  padding: 12px 16px;
}

.rate-legend {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 600;
}

.node-details {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
}

.node-details > summary {
  cursor: pointer;
  padding: 9px 14px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  list-style: none;
}

.node-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px 16px;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
}

.deploy-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 12.5px;
}

.member-summary-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: var(--radius-md);
}

.member-list {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cmd-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: #0f172a;
  border: 1px solid #1e293b;
  color: #e2e8f0;
  padding: 11px 14px;
  border-radius: var(--radius-md);
}

.cmd-code {
  flex: 1;
  min-width: 260px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.06);
  padding: 7px 11px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow-x: auto;
  white-space: nowrap;
}

/* ---------- Modal Dialogs ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
}

.modal-backdrop.open { display: flex; }

.modal-dialog {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  animation: modalIn 0.15s ease-out;
}

.modal-dialog.modal-md { max-width: 680px; }
.modal-dialog.modal-sm { max-width: 500px; }

.modal-dialog > form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  margin: 0;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(6px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 22px;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
}

.modal-header h3 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  display: grid;
  place-items: center;
  line-height: 1;
}
.modal-close:hover { background: #f1f5f9; color: var(--text); }

.modal-body {
  padding: 18px 22px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 13px 22px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}

/* ---------- Alerts, Code Boxes & Login ---------- */
.alert {
  padding: 11px 15px;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  color: #1e40af;
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.alert-error {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  color: #991b1b;
}

.code-box {
  margin-bottom: 14px;
  padding: 12px 15px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background-color: #f8fafc;
  background-image:
    radial-gradient(at 20% 15%, rgba(37, 99, 235, 0.08) 0px, transparent 50%),
    radial-gradient(at 80% 85%, rgba(14, 165, 233, 0.08) 0px, transparent 50%),
    linear-gradient(to right, rgba(226, 232, 240, 0.45) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(226, 232, 240, 0.45) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 32px 32px, 32px 32px;
  padding: 20px;
}

.login-box {
  width: 100%;
  max-width: 400px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 30px 28px 30px;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.08);
}

.login-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.login-head .brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 11px;
}

.login-head h1 {
  margin: 0;
  font-size: 17.5px;
  font-weight: 700;
  color: var(--text);
}

.login-head p {
  margin: 2px 0 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.login-submit {
  height: 38px;
  font-size: 13.5px;
  margin-top: 4px;
  width: 100%;
}
