:root {
  color-scheme: light;
  --font-primary: "SF Pro Display", "SF Pro Text", "New York", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --bg: radial-gradient(circle at 10% 20%, rgba(120, 170, 255, 0.3), transparent 35%),
        radial-gradient(circle at 85% 15%, rgba(255, 198, 206, 0.22), transparent 32%),
        radial-gradient(circle at 20% 80%, rgba(120, 230, 210, 0.18), transparent 40%),
        linear-gradient(160deg, #0c1222 0%, #0a0f1a 48%, #0e162b 100%);
  --fg: #f4f7fb;
  --fg-muted: rgba(229, 237, 255, 0.7);
  --card: rgba(255, 255, 255, 0.08);
  --card-strong: rgba(255, 255, 255, 0.12);
  --card-border: rgba(255, 255, 255, 0.14);
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
  --accent: #7fc4ff;
  --accent-strong: #0a84ff;
  --accent-warm: #ffb9a6;
  --success: #30d158;
  --warning: #ffd60a;
  --danger: #ff453a;
  --glass: blur(16px);
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --border-soft: 1px solid rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }

.hidden { display: none !important; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-primary);
  background: var(--bg);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

.bg-ornament {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  filter: blur(90px);
  z-index: 0;
}

.bg-1 { background: radial-gradient(circle at 12% 70%, rgba(120, 218, 255, 0.6), transparent 45%); }
.bg-2 { background: radial-gradient(circle at 80% 20%, rgba(255, 174, 210, 0.55), transparent 38%); }

.topbar {
  width: min(1200px, 100%);
  padding: 1.6rem clamp(1.2rem, 4vw, 2rem) 0.6rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "brand tabs actions";
  align-items: center;
  gap: 1rem;
  position: relative;
  z-index: 2;
  min-width: 0;
}
.topbar .brand { grid-area: brand; }
.topbar .tab-nav-cell {
  grid-area: tabs;
  min-width: 0;
  display: flex;
  justify-content: center;
}
.topbar .top-actions { grid-area: actions; }

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(150deg, #7fd0ff, #76ffca);
  box-shadow: 0 0 0 8px rgba(127, 208, 255, 0.2);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 0.85rem;
  color: var(--fg-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font-size: 0.92rem;
  color: var(--fg-muted);
  backdrop-filter: var(--glass);
}

.btn {
  border: none;
  cursor: pointer;
  font-family: var(--font-primary);
  border-radius: 14px;
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  transition: transform 180ms ease, box-shadow 200ms ease, background 200ms ease;
  border: var(--border-soft);
  color: var(--fg);
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: var(--glass);
}

.btn.primary {
  background: linear-gradient(150deg, #9acbff, #5fa8ff 40%, #0a84ff 100%);
  color: #0b1222;
  font-weight: 600;
  box-shadow: 0 18px 38px rgba(10, 132, 255, 0.26);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.05);
}

.btn.tiny {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  border-radius: 10px;
}

.btn.danger {
  color: #ffb8b3;
  border-color: rgba(255, 69, 58, 0.35);
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.layout {
  width: min(1200px, 100%);
  padding: 0.6rem clamp(1.2rem, 4vw, 2rem) 3.4rem;
  display: grid;
  gap: 1.2rem;
  position: relative;
  z-index: 1;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  border-radius: var(--radius-lg);
  padding: clamp(1.4rem, 2.6vw, 2rem);
  backdrop-filter: var(--glass);
}

.section-header {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.2rem;
}

.section-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.section-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.section-title {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.section-subtitle {
  color: var(--fg-muted);
  font-size: 0.95rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.software-update-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.software-update-card {
  padding: 1rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.software-update-card h4 {
  margin: 0;
  font-size: 1rem;
}

.software-update-list {
  display: grid;
  gap: 0.45rem;
  color: var(--fg-muted);
  overflow-wrap: anywhere;
}

.software-update-list code {
  color: var(--fg);
  font-size: 0.85em;
}

.software-update-custom-version:not([hidden]) {
  margin-top: 0.35rem;
}

.software-update-agent-picker {
  display: grid;
  gap: 0.45rem;
  max-height: 12rem;
  overflow: auto;
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(0, 0, 0, 0.16);
}

.software-update-agent-option {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.25rem;
  cursor: pointer;
}

.software-update-agent-option input {
  accent-color: var(--accent-strong);
}

.stack {
  display: grid;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.8rem;
}

.label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
}

.input, .select, .textarea {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(12, 18, 34, 0.65);
  color: var(--fg);
  padding: 0.65rem 0.8rem;
  font-family: var(--font-primary);
  font-size: 0.95rem;
}

.textarea { min-height: 90px; resize: vertical; }

.muted { color: var(--fg-muted); }

.list {
  display: grid;
  gap: 0.8rem;
}

.node-card-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.8rem;
}

.list-item {
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.project-item {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.07);
  transition: border 200ms ease, transform 200ms ease;
  cursor: pointer;
}

.project-item.selected {
  border-color: rgba(127, 196, 255, 0.9);
  box-shadow: 0 10px 24px rgba(127, 196, 255, 0.2);
  transform: translateY(-1px);
}

.project-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.9rem;
}

.inline-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.inline-actions .input {
  flex: 1;
}

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.project-summary {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.agent-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.agent-actions {
  display: inline-flex;
  gap: 0.4rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.12rem 0.42rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.01em;
  color: var(--fg-muted);
}

.badge.accent { color: #0c203b; background: rgba(127, 196, 255, 0.8); border-color: transparent; }
.badge.success { color: rgba(122, 247, 176, 0.96); background: rgba(48, 209, 88, 0.16); border-color: rgba(48, 209, 88, 0.28); }
.badge.warning { color: #3f2f00; background: rgba(255, 214, 10, 0.85); border-color: transparent; }

.agent-modal-title-line {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.software-status-badge {
  text-transform: none;
  white-space: nowrap;
}

.agent-software-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.35rem;
  margin-bottom: 0.15rem;
}

.agent-software-actions .btn {
  flex: 0 0 auto;
}

.agent-software-actions .btn:disabled,
.agent-software-actions .btn[disabled] {
  cursor: not-allowed;
  opacity: 0.46;
  transform: none;
  box-shadow: none;
}

.agent-software-message {
  display: inline-flex;
  align-items: center;
  min-height: 1.65rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 214, 10, 0.2);
  background: rgba(255, 214, 10, 0.08);
  color: rgba(255, 232, 150, 0.96);
  font-size: 0.76rem;
  line-height: 1.35;
}
.badge.danger { color: rgba(255, 173, 168, 0.96); background: rgba(255, 69, 58, 0.14); border-color: rgba(255, 69, 58, 0.24); }

.frpc-status-badge {
  margin-left: 0.4rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
}

.status-dot.connected {
  background: rgba(48, 209, 88, 0.95);
  box-shadow: 0 0 0 2px rgba(48, 209, 88, 0.18);
}

.status-dot.failed {
  background: rgba(255, 69, 58, 0.95);
  box-shadow: 0 0 0 2px rgba(255, 69, 58, 0.16);
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.9rem;
}

.rule-card {
  position: relative;
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.rule-count {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}

.rule-name {
  font-weight: 600;
  font-size: 1rem;
}

.rule-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}
.rule-actions .rule-target-row { display: flex; align-items: center; gap: 0.4rem; }
.rule-actions .rule-target-label { font-size: 0.75rem; color: var(--fg-muted); min-width: 1.8em; }
.rule-actions .rule-failover-stat { font-size: 0.78rem; color: var(--fg-muted); margin-left: auto; }
.rule-actions .rule-failover-stat.has-backup-active { color: #ffb84d; }
.rule-actions .rule-failover-stat.critical { color: #ff5050; font-weight: 600; }
.failover-alert-banner { padding: 0.85rem 1rem; border-radius: 12px; border: 1px solid rgba(255,162,77,0.4); background: rgba(255,162,77,0.08); color: var(--fg); display: flex; flex-direction: column; gap: 0.5rem; }
.failover-alert-banner[hidden] { display: none; }
.failover-alert-banner .failover-alert-title { font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }
.failover-alert-banner .failover-alert-title.critical { color: #ff5050; }
.failover-alert-banner .failover-alert-row { font-size: 0.92rem; padding: 4px 8px; border-radius: 8px; background: rgba(255,255,255,0.04); }
.failover-alert-banner .failover-alert-row.critical { background: rgba(255,80,80,0.12); border: 1px solid rgba(255,80,80,0.35); }
.failover-alert-banner .failover-alert-row .muted { font-size: 0.82rem; }
.agent-failover-chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 0.78rem; background: rgba(255,162,77,0.18); color: #ffb84d; border: 1px solid rgba(255,162,77,0.3); }
.agent-failover-chip.critical { background: rgba(255,80,80,0.18); color: #ff5050; border-color: rgba(255,80,80,0.4); }
.failover-history-body { display: flex; flex-direction: column; gap: 0.5rem; max-height: 60vh; overflow-y: auto; }
.failover-history-row { padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,0.04); }
.failover-history-head { font-size: 0.92rem; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.failover-history-group { font-size: 0.86rem; color: var(--fg-muted); margin-left: 8px; }
.failover-history-down { color: #ff6b6b; font-weight: 600; }
.failover-history-up { color: #4caf78; font-weight: 600; }
.failover-history-pager { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: 0.75rem; }
.failover-tree { margin-top: 6px; font-size: 0.9rem; line-height: 1.55; display: flex; flex-direction: column; gap: 2px; }
.failover-tree-line { display: flex; align-items: center; gap: 6px; }
.failover-tree-line.primary { font-weight: 600; }
.failover-tree-line .tree-prefix { color: var(--fg-muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre; }
.failover-tree-line .tree-label { word-break: break-all; }
.failover-tree-line.rule { color: var(--fg-muted); font-size: 0.86rem; }
.failover-alert-banner .failover-alert-row { cursor: pointer; user-select: none; }
.failover-alert-banner .failover-alert-row .failover-tree { display: block; }
.failover-alert-banner .failover-alert-row.collapsed .failover-tree { display: none; }
.failover-alert-banner .failover-alert-row .row-toggle { display: inline-block; width: 1em; color: var(--fg-muted); transition: transform 0.15s; }
.failover-alert-banner .failover-alert-row.collapsed .row-toggle { transform: rotate(-90deg); }
.tab-nav {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  overflow: visible;
  width: max-content;
  max-width: 100%;
  position: relative;
}
.tab-nav .tab-btn[hidden] { display: none !important; }
.tab-nav .tab-more-btn { font-weight: 700; letter-spacing: 0.1em; padding: 0.45rem 0.85rem; }
.tab-more-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(28, 28, 32, 0.72);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  z-index: 50;
}
.tab-more-menu[hidden] { display: none !important; }
.tab-more-menu .tab-more-item {
  background: transparent;
  border: none;
  color: var(--fg);
  font-size: 0.92rem;
  text-align: left;
  padding: 0.5rem 0.85rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.tab-more-menu .tab-more-item:hover { background: rgba(255, 255, 255, 0.08); }
.tab-more-menu .tab-more-item.active {
  background: rgba(255, 255, 255, 0.14);
  font-weight: 600;
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab-nav .tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg-muted);
  font-size: 0.92rem;
  padding: 0.45rem 1rem;
  cursor: pointer;
  border-radius: 999px;
  white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  letter-spacing: 0.01em;
}
.tab-nav .tab-btn:hover {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.05);
}
.tab-nav .tab-btn.active {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  font-weight: 600;
}
.btn.glass {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--fg);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}
.btn.glass:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
}
.btn.glass:active { transform: translateY(1px); }
.tab-section[hidden] { display: none !important; }
.rules-action-group { display: inline-flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.ruleset-action-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; margin-top: 0.5rem; }
.ruleset-action-grid .btn { width: 100%; }
@media (max-width: 640px) {
  .ruleset-action-grid { grid-template-columns: repeat(2, 1fr); }
}
.outbound-health-cell { font-size: 0.85rem; }
.outbound-health-cell.warn { color: #ffb84d; }
.outbound-health-cell.ok { color: var(--fg-muted); }

.node-card-list .rule-actions {
  flex-wrap: nowrap;
  gap: 0.35rem;
}

.node-card-list .btn {
  min-height: 32px;
  padding: 0.38rem 0.62rem;
  font-size: 0.82rem;
}

.project-item .rule-actions {
  gap: 0.65rem;
  margin-top: 0.35rem;
}

@media (min-width: 900px) {
  .project-item .list-row {
    flex-wrap: nowrap;
    align-items: flex-start;
  }

  .project-item .list-row > div:first-child {
    min-width: 0;
  }

  .project-item .list-row > div:last-child {
    margin-left: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.4rem;
  }

  .project-item .rule-actions {
    justify-content: flex-end;
  }
}
.group-target { min-width: 160px; width: 100%; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 18, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 10;
}

/* Sub-modal: opened from inside another modal (e.g. DDNS accounts modal
   opened from the per-agent DDNS modal). Needs to stack above its parent. */
#ddnsAccountsModal { z-index: 20; }

.modal.hidden { display: none; }

.modal-card {
  width: min(780px, 100%);
  background: rgba(18, 24, 40, 0.9);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 1.4rem;
  box-shadow: var(--shadow);
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
}

.modal-body {
  display: grid;
  gap: 0.8rem;
  overflow: auto;
}

.latency-result-card {
  padding: 0.85rem 0.95rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  display: grid;
  gap: 0.65rem;
}

.latency-result-card.selection-error {
  border-color: rgba(255, 162, 162, 0.45);
  background: rgba(156, 34, 34, 0.18);
}

.latency-result-card.execution-error {
  border-color: rgba(255, 205, 125, 0.45);
  background: rgba(120, 80, 12, 0.18);
}

.latency-result-card.is-running {
  border-color: rgba(123, 163, 255, 0.45);
}

.latency-result-title {
  font-weight: 600;
}

.latency-stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.7rem;
}

.latency-stage {
  padding: 0.75rem 0.8rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 0.35rem;
}

.latency-stage-label {
  font-size: 0.82rem;
  color: var(--fg-muted);
}

.latency-stage-value {
  font-weight: 600;
}

.latency-stage-note,
.latency-result-meta {
  font-size: 0.84rem;
  color: var(--fg-muted);
}

.modal-card.wide {
  width: min(960px, 92vw);
}

#agentTerminalModal .modal-card {
  width: min(1120px, 95vw);
  height: min(80vh, 720px);
  max-height: 90vh;
}
#agentTerminalModal .modal-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.agent-terminal-status {
  flex: 0 0 auto;
  font-size: 0.85rem;
  padding-bottom: 0.4rem;
}
.agent-terminal-host {
  flex: 1 1 auto;
  min-height: 0;
  background: #0b1020;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  overflow: hidden;
}
.agent-terminal-host .xterm,
.agent-terminal-host .xterm-viewport,
.agent-terminal-host .xterm-screen {
  height: 100% !important;
  width: 100% !important;
}
.agent-terminal-host .xterm-viewport { overflow-y: auto; }

.latency-compare-agent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.latency-compare-agent-list label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.88rem;
  cursor: pointer;
}

.latency-compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin-top: 0.8rem;
}

.latency-compare-table th,
.latency-compare-table td {
  padding: 0.5rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.latency-compare-table th {
  color: var(--fg-muted);
  font-weight: 500;
}

.latency-status.selection-error { color: #ffb86c; }
.latency-status.execution-error { color: #ff6b6b; }
.latency-status.stage-error { color: #ffd166; }

.rule-list {
  max-height: 40vh;
  overflow: auto;
  display: grid;
  gap: 0.5rem;
}

.rule-item {
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.8rem;
  font-size: 0.9rem;
}

.rule-main {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.rule-text {
  word-break: break-all;
  color: var(--fg-muted);
}

.rule-item .btn {
  flex: 0 0 auto;
  width: auto;
}

.footer {
  padding: 1.6rem 1rem 2.4rem;
  color: rgba(235, 241, 255, 0.55);
  text-align: center;
  font-size: 0.9rem;
}

@media (max-width: 820px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand actions"
      "tabs tabs";
    gap: 0.75rem 0.75rem;
  }
  .topbar .tab-nav-cell { justify-content: center; }
  .topbar .top-actions { flex-wrap: nowrap; }
  .topbar .btn { width: auto; }
}


@media (max-width: 640px) {
  .card { border-radius: 18px; }
  .btn { width: 100%; justify-content: center; }
  .agent-software-actions { align-items: stretch; }
  .agent-software-actions .btn { flex: 1 1 calc(50% - 0.35rem); width: auto; min-height: 38px; }
  .agent-software-message { width: 100%; justify-content: center; text-align: center; }
  .list-row { flex-direction: column; align-items: flex-start; }
  .inline-actions { flex-direction: column; align-items: stretch; }
  .section-toolbar { align-items: stretch; }
  .section-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 0.5rem;
  }
  .section-actions .btn {
    width: 100%;
    min-height: 44px;
    touch-action: manipulation;
  }
}
.agent-cards {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.8rem;
}

.agent-card {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 0.8rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.probe-section-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 1rem;
}

.probe-toolbar { justify-content: flex-end; }

.probe-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.probe-overview-card,
.probe-node-card {
  border: 1px solid var(--card-border);
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.045));
  backdrop-filter: blur(18px) saturate(180%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 18px 45px rgba(0, 0, 0, 0.22);
}

.probe-overview-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 112px;
  padding: 1rem;
  border-radius: var(--radius-md);
}

.probe-overview-card.is-success {
  background: linear-gradient(155deg, rgba(48, 209, 88, 0.14), rgba(255, 255, 255, 0.045));
}

.probe-overview-card__label,
.probe-metric__label,
.probe-metric__hint,
.probe-overview-card__hint,
.probe-node-meta,
.probe-node-times {
  color: var(--fg-muted);
}

.probe-overview-card__label,
.probe-metric__label {
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.probe-overview-card__value {
  font-size: clamp(1.28rem, 3vw, 1.9rem);
  font-weight: 650;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.probe-overview-card__hint,
.probe-metric__hint { font-size: 0.76rem; }

.probe-node-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(520px, 100%), 1fr));
  gap: 0.8rem;
}

.probe-node-card {
  display: grid;
  gap: 0.58rem;
  padding: 0.78rem;
  border-radius: var(--radius-md);
}

.probe-node-card.is-offline,
.probe-node-card.is-stale { opacity: 0.82; }

.probe-node-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: flex-start;
}

.probe-node-title {
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.probe-node-meta { margin-top: 0.12rem; font-size: 0.78rem; }

.probe-status-badge { flex: 0 0 auto; }

.probe-node-times {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.74rem;
  line-height: 1.25;
}

.probe-metric-grid,
.probe-traffic-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.46rem;
}

.probe-metric {
  min-width: 0;
  padding: 0.52rem 0.58rem;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.052);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.probe-metric__value {
  margin-top: 0.12rem;
  font-size: 0.98rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
  line-height: 1.12;
}

.probe-meter {
  height: 4px;
  margin-top: 0.36rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
}

.probe-meter__fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8fd7ff, #76ffca);
  box-shadow: 0 0 18px rgba(127, 196, 255, 0.35);
}

.probe-service-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.probe-service-chip {
  padding: 0.22rem 0.48rem;
  font-size: 0.72rem;
}

.probe-empty {
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.045);
  color: var(--fg-muted);
}

.probe-empty--compact { font-size: 0.88rem; }

@media (max-width: 860px) {
  .probe-metric-grid,
  .probe-traffic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .probe-section-header { grid-template-columns: 1fr; }
  .probe-node-grid { grid-template-columns: 1fr; }
  .probe-node-head { flex-direction: column; gap: 0.5rem; }
}

.agent-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.agent-card-main {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1 1 360px;
  min-width: 0;
}

.agent-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  font-weight: 600;
}

.agent-title-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.agent-card-state-badge {
  flex: 0 0 auto;
}

.agent-card-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.agent-settings {
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(760px, 100%);
}

.agent-settings-title {
  margin-bottom: 0.5rem;
}

.agent-settings-actions {
  margin: 0.25rem 0 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.agent-settings-actions.agent-proxy-mobile-actions {
  gap: 0.75rem;
}

.agent-proxy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(88px, 96px) minmax(0, 1fr) minmax(0, 1fr) 36px;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}

.agent-proxy-row .proxy-inbound,
.agent-proxy-row .proxy-ruleset,
.agent-proxy-row .proxy-outbound {
  min-width: 0;
}

.agent-proxy-row .proxy-port {
  width: 100%;
  min-width: 0;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding-inline: 0.45rem;
}

.agent-proxy-row [data-action="remove-proxy-row"] {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 12px;
  justify-self: end;
  border-color: rgba(248, 113, 113, 0.22);
  background: rgba(248, 113, 113, 0.08);
  color: #fca5a5;
}

.agent-proxy-row [data-action="remove-proxy-row"]:hover {
  background: rgba(248, 113, 113, 0.14);
  border-color: rgba(248, 113, 113, 0.34);
}

.agent-port-forward-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

@media (max-width: 720px) {
  .agent-proxy-row {
    grid-template-columns: minmax(0, 1fr) minmax(88px, 96px) minmax(0, 1fr);
  }

  .agent-proxy-row .proxy-outbound {
    grid-column: 1 / 3;
  }

  .agent-proxy-row [data-action="remove-proxy-row"] {
    grid-column: 3;
    grid-row: 2;
    justify-self: end;
  }
}

.agent-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.agent-summary-block {
  padding: 0.8rem 0.9rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.agent-summary-title {
  letter-spacing: 0.04em;
}

.agent-summary-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.agent-summary-line {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.agent-summary-text {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.agent-summary-state-badge {
  flex: 0 0 auto;
  white-space: nowrap;
  position: relative;
}

.agent-summary-state-badge[data-agent-summary-detail] {
  cursor: help;
}

.agent-summary-state-badge[data-agent-summary-detail]::after {
  content: attr(data-agent-summary-detail);
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.45rem);
  min-width: max-content;
  max-width: min(280px, 75vw);
  padding: 0.4rem 0.55rem;
  border-radius: 10px;
  background: rgba(12, 18, 34, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--fg);
  font-size: 0.78rem;
  line-height: 1.4;
  white-space: normal;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.agent-summary-state-badge[data-agent-summary-detail]:hover::after,
.agent-summary-state-badge[data-agent-summary-detail]:focus::after,
.agent-summary-state-badge[data-agent-summary-detail]:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.agent-summary-empty,
.agent-summary-overflow {
  font-size: 0.88rem;
}

.agent-summary-line.summary-collapsed-hide { display: none; }
.agent-card.proxy-summary-expanded .agent-summary-line.summary-collapsed-hide { display: flex; }

.port-forward-mobile-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  width: 100%;
}

.port-forward-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1 1 120px;
  min-width: 0;
}

.port-forward-field-label {
  font-size: 0.8rem;
  color: var(--fg-muted);
}

.port-forward-field-protocol {
  flex: 0 1 88px;
}

.port-forward-field-listen-port,
.port-forward-field-dns-retry-cooldown,
.port-forward-field-target-port {
  flex: 1 1 110px;
}

.port-forward-field-target-address {
  flex: 1.8 1 220px;
}

.port-forward-field-enabled {
  flex: 0 1 88px;
}

.port-forward-row-action {
  display: flex;
  align-items: flex-end;
}

.port-forward-row-action-remove {
  flex: 0 0 auto;
}

.agent-port-forward-enabled,
.agent-frp-enabled {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
}

.agent-port-forward-row .select,
.agent-port-forward-row .input,
.agent-frp-row .select,
.agent-frp-row .input {
  width: 100%;
}

.agent-frp-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.agent-frp-row .select {
  flex: 0 0 auto;
  min-width: 70px;
  max-width: 90px;
}

.agent-frp-row .input {
  flex: 0 0 auto;
  min-width: 70px;
  max-width: 100px;
}

.agent-frp-row .frp-token {
  flex: 1;
  min-width: 100px;
  max-width: 180px;
}

.agent-frp-row .frp-target-agent {
  flex: 1;
  min-width: 100px;
  max-width: 160px;
}

.agent-frp-row .frp-server-addr {
  flex: 1;
  min-width: 100px;
  max-width: 180px;
}

.agent-frp-row .frp-bind-port {
  width: 90px;
  max-width: 90px;
}

.agent-frp-row .frp-server-port {
  width: 80px;
  max-width: 80px;
}

.agent-port-forward-row-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.agent-port-forward-summary-text {
  flex: 1 1 220px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-port-forward-summary-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.port-forward-status.running {
  color: var(--success);
}

.port-forward-status.error {
  color: #ffb8b3;
}

.port-forward-status.stopped {
  color: var(--fg-muted);
}

.agent-setting-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.agent-setting-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.8rem;
}

.agent-setting-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.88rem;
  color: var(--fg-muted);
  cursor: pointer;
}

.agent-setting-label input[type="checkbox"] {
  accent-color: var(--accent-strong);
}


.master-detail {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(360px, 2.2fr);
  gap: 1rem;
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: rgba(9, 14, 28, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.master-list {
  display: grid;
  gap: 0.8rem;
  align-content: start;
  padding-right: 0.6rem;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.master-list .section-header {
  margin-bottom: 0;
  padding-bottom: 0.15rem;
}

.project-overview-header {
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.8rem;
}

.project-overview-header .section-heading {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.project-overview-header .section-actions {
  margin-left: auto;
}

.detail-panel {
  border-radius: var(--radius-md);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 1.2rem;
  min-height: 260px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
}

.project-item.compact {
  padding: 0.9rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: transform 180ms ease, box-shadow 200ms ease, border-color 200ms ease;
}

.project-item.compact.selected {
  border-color: rgba(127, 196, 255, 0.8);
  box-shadow: 0 0 0 1px rgba(127, 196, 255, 0.5);
}

.project-item.compact .rule-actions {
  justify-content: flex-start;
  gap: 0.5rem;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.detail-title {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.detail-meta {
  color: var(--fg-muted);
  font-size: 0.9rem;
}

.detail-actions {
  display: inline-flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  .agent-port-forward-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }

  .port-forward-mobile-row {
    width: 100%;
    flex-wrap: nowrap;
  }

  .port-forward-mobile-row-primary .port-forward-field-protocol {
    flex: 0 0 96px;
  }

  .port-forward-mobile-row-primary .port-forward-field-listen-port,
  .port-forward-mobile-row-primary .port-forward-field-dns-retry-cooldown {
    flex: 1 1 0;
  }

  .port-forward-mobile-row-secondary .port-forward-field-target-address {
    flex: 1.75 1 0;
  }

  .port-forward-mobile-row-secondary .port-forward-field-target-port {
    flex: 0.9 1 0;
  }

  .port-forward-mobile-row-secondary .port-forward-field-enabled {
    flex: 0 0 72px;
  }

  .port-forward-mobile-row-secondary .port-forward-row-action-remove {
    flex: 0 0 auto;
  }
}

@media (max-width: 480px) {
  .port-forward-mobile-row {
    flex-wrap: wrap;
  }

  .port-forward-mobile-row-secondary .port-forward-field-target-address {
    flex: 1 0 100%;
  }

  .port-forward-mobile-row-secondary .port-forward-field-target-port {
    flex: 1 1 120px;
  }

  .port-forward-mobile-row-secondary .port-forward-field-enabled {
    flex: 0 0 88px;
  }
}

@media (max-width: 640px) {
  .agent-proxy-mobile-actions,
  .agent-port-forward-mobile-actions,
  .agent-frp-mobile-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .agent-port-forward-row .btn {
    width: auto;
  }

  .port-forward-row-action {
    align-self: flex-end;
  }
}

@media (max-width: 980px) {
  .master-detail {
    grid-template-columns: 1fr;
  }

  .master-list {
    padding-right: 0;
    padding-bottom: 0.2rem;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .detail-panel {
    min-height: 0;
  }
}

@media (max-width: 640px) {
  .master-detail {
    gap: 0.85rem;
    padding: 0.85rem;
    border-radius: 20px;
  }

  .master-list .section-header {
    padding-bottom: 0.1rem;
  }

  .project-item.compact {
    padding: 1rem 0.95rem;
  }

  .project-item.compact .stack {
    gap: 0.6rem;
  }

  .project-item.compact .rule-actions,
  .detail-actions,
  .agent-card-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    gap: 0.5rem;
  }

  .project-item.compact .btn,
  .detail-actions .btn,
  .agent-card-actions .btn {
    width: 100%;
    min-height: 44px;
    padding-inline: 0.55rem;
    touch-action: manipulation;
    white-space: nowrap;
  }

  .node-card-list .rule-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 0.5rem;
  }

  .node-card-list .rule-actions .btn {
    width: 100%;
    white-space: nowrap;
  }

  .detail-panel {
    padding: 1rem;
    border-radius: 18px;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.2);
  }

  .project-overview-header {
    flex-direction: row;
    align-items: center;
  }

  .project-overview-header .section-actions {
    display: inline-flex;
    margin-left: auto;
    width: auto;
  }

  .project-overview-header .section-actions .btn {
    width: auto;
    white-space: nowrap;
  }

  .detail-header {
    gap: 0.7rem;
    margin-bottom: 0.85rem;
  }

  .detail-title {
    line-height: 1.3;
  }

  .detail-meta {
    line-height: 1.5;
  }

  .agent-card {
    gap: 0.75rem;
    padding: 0.9rem;
  }

  .agent-card-main {
    min-width: 0;
  }
}

/* ── Users section ─────────────────────────────────────────────────── */
.users-list { display: flex; flex-direction: column; gap: 8px; }
.user-row { display: grid; grid-template-columns: 1.2fr 0.8fr 0.8fr 0.8fr 0.6fr auto; gap: 12px; align-items: center; padding: 8px 14px; border: 1px solid var(--card-border); border-radius: 10px; background: var(--card); }
/* 用户与订阅 desktop: name+pill packed left, [spacer], usage capped at the
   widest realistic value (32ch fits '9999.00 / 9999.00 GiB (100%)' + a bit
   of slack), days/tg/actions follow snug to usage. The 1fr spacer column
   absorbs all leftover so usage is never stretched and the right cluster
   stays together. */
#usersList .user-row {
  grid-template-columns: max-content auto 1fr fit-content(32ch) auto auto auto;
  column-gap: 8px;
}
#usersList .user-row > .user-name { grid-column: 1; }
#usersList .user-row > .pill { grid-column: 2; }
#usersList .user-row > span:nth-child(3) { grid-column: 4; }
#usersList .user-row > span:nth-child(4) { grid-column: 5; }
#usersList .user-row > span:nth-child(5) { grid-column: 6; }
#usersList .user-row > .actions { grid-column: 7; }
/* On wider desktops add 22px padding-left to days/tg/actions; combined with
   the 8px column-gap that totals ~30px breathing room between the right
   cluster items. Cramped widths (≤900px) keep the tight 8px gap. */
@media (min-width: 900px) {
  #usersList .user-row > span:nth-child(4),
  #usersList .user-row > span:nth-child(5),
  #usersList .user-row > .actions {
    padding-left: 22px;
  }
}
.user-row .user-name { font-weight: 600; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-row > span:not(.actions):not(.pill) { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-row .pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; justify-self: start; width: max-content; }
.user-row .node-ruleset-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.user-ruleset-options { display: flex; flex-direction: column; gap: 10px; padding: 8px 10px; border: 1px solid var(--card-border); border-radius: 8px; background: rgba(255,255,255,0.03); }
.user-ruleset-option { display: flex; align-items: center; gap: 8px; }
.user-ruleset-option-group { display: flex; flex-direction: column; gap: 4px; }
.user-ruleset-option-title { font-size: 12px; color: var(--fg-muted); }
/* auto-fill grid: wide screens get multiple columns, narrow stays one. Same min-width
   on both proxy and ruleset lists keeps the column boundaries aligned vertically. */
.user-ruleset-option-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 4px 12px; padding-left: 12px; }
.user-ruleset-option-list label { display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; }
.user-ruleset-option-list label > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-ruleset-option-list .empty { color: var(--fg-muted); font-size: 12px; grid-column: 1 / -1; }
.user-row .pill.active { background: #143; color: #4f6; }
.user-row .pill.suspended { background: #443; color: #fc6; }
.user-row .pill.exhausted, .user-row .pill.expired { background: #422; color: #f88; }
.user-row .actions { display: flex; gap: 6px; flex-wrap: nowrap; align-items: center; }
.users-empty { padding: 12px 0; color: var(--fg-muted); }
.inbound-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.inbound-checks label { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--card-border); border-radius: 999px; max-width: 100%; word-break: break-all; }
/* fieldset defaults to min-inline-size: min-content, which overflows narrow modals when chips are long. */
#userDialog fieldset.field { min-inline-size: 0; padding: 0; border: 0; margin: 0; }
/* Form inside modal-card needs to participate in the 80vh flex column so the body can scroll on short screens. */
#userDialog .modal-card > form { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; gap: 0.8rem; }
#userDialog .modal-body { min-height: 0; flex: 1 1 auto; }
#userDialog .modal-footer { flex: 0 0 auto; }
.modal .grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
/* Settings section read-only summary list */
#settings .settings-view { display: grid; gap: 0.5rem; }
#settings .settings-view .row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--card-border); }
#settings .settings-view .row:last-child { border-bottom: 0; }
#settings .settings-view .key { color: var(--fg-muted); }
#settings .settings-view .val { word-break: break-all; text-align: right; }
#settings .settings-edit[hidden] { display: none; }
.modal .grid-2 .full { grid-column: 1 / -1; }
.modal-errors { color: #f66; min-height: 1.5em; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 10px 14px 4px; }
.overflow-menu { position: relative; display: inline-block; }
.overflow-popup { position: absolute; right: 0; top: 100%; z-index: 1000; display: flex; flex-direction: column; gap: 4px; padding: 6px; background: var(--card); backdrop-filter: var(--glass); border: 1px solid var(--card-border); border-radius: var(--radius-md); box-shadow: var(--shadow); min-width: 140px; }
.overflow-popup.hidden { display: none; }
.overflow-popup .btn { justify-content: flex-start; }

/* Narrow viewports: stack each user-row's cells vertically, lay actions
   buttons side-by-side at equal width. Without this the 6-column grid
   collapses each cell to ~50px and the global .btn { width: 100% }
   forces every action button onto its own line. */
@media (max-width: 640px) {
  .user-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px 14px;
  }
  .user-row .pill { justify-self: start; }
  .user-row .actions { width: 100%; }
  .user-row .actions > .btn { width: auto; flex: 1 1 0; min-width: 0; }
  .user-row .actions > .overflow-menu { flex: 0 0 auto; }
  .user-row .actions > .overflow-menu .btn { width: auto; }

  /* 用户与订阅 packs into 3 rows: identity / metrics / actions */
  #usersList .user-row {
    grid-template-columns: auto auto 1fr;
    grid-template-areas:
      "name pill tg"
      "usage usage remaining"
      "actions actions actions";
    gap: 6px 10px;
  }
  #usersList .user-row .user-name { grid-area: name; }
  #usersList .user-row > .pill { grid-area: pill; }
  #usersList .user-row > span:nth-child(3) { grid-area: usage; }
  #usersList .user-row > span:nth-child(4) { grid-area: remaining; justify-self: end; }
  #usersList .user-row > span:nth-child(5) { grid-area: tg; justify-self: end; }
  #usersList .user-row .actions { grid-area: actions; }

  /* 节点管理: name / agent+port+pill / ruleset / actions */
  #userNodesList .user-row {
    grid-template-columns: 1fr auto auto;
    grid-template-areas:
      "name name name"
      "agent port pill"
      "ruleset ruleset ruleset"
      "actions actions actions";
    gap: 6px 8px;
  }
  #userNodesList .user-row .user-name { grid-area: name; }
  #userNodesList .user-row > span:nth-child(2) { grid-area: agent; }
  #userNodesList .user-row > .pill { grid-area: pill; justify-self: end; }
  #userNodesList .user-row > span:nth-child(4) { grid-area: port; }
  #userNodesList .user-row .node-ruleset-label { grid-area: ruleset; }
  #userNodesList .user-row .actions { grid-area: actions; }
}
@media (max-width: 480px) {
  .modal-card { padding: 1rem; max-height: 90vh; }
}

/* ============================================================
   Firewall modal — Apple-style frosted cards
   ============================================================ */

.fw-modal {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 2px 10px;
}

.fw-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 18px 20px;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.fw-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.fw-card__title {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg);
  margin: 0;
}

.fw-card__hint {
  font-size: 0.78rem;
  color: var(--fg-muted);
  margin: 4px 0 0;
  font-weight: 400;
  letter-spacing: -0.005em;
}

/* --- Hero card with the master toggle --- */

.fw-card--hero {
  padding: 22px 22px;
  position: relative;
  /* overflow:hidden used to live here to clip the ::before radial gradient
     to the border-radius. That also clipped any content overflowing on
     narrow mobile widths — long IP / domain values disappeared. The
     gradient is now layered directly into background: so border-radius
     clips it for free without needing overflow:hidden. */
  background:
    radial-gradient(120% 100% at 100% 0%, rgba(255, 255, 255, 0.08), transparent 55%),
    rgba(255, 255, 255, 0.05);
  transition: background 0.4s ease;
}

.fw-card--hero.is-on {
  background:
    radial-gradient(120% 100% at 100% 0%, rgba(48, 209, 88, 0.18), transparent 55%),
    rgba(255, 255, 255, 0.05);
}

.fw-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.fw-hero__title {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--fg);
}

.fw-hero__sub {
  font-size: 0.8rem;
  color: var(--fg-muted);
  margin-top: 4px;
  letter-spacing: -0.005em;
}

/* --- iOS-style switch --- */

.fw-switch {
  position: relative;
  display: inline-block;
  width: 51px;
  height: 31px;
  flex-shrink: 0;
  cursor: pointer;
}

.fw-switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.fw-switch__track {
  position: absolute;
  inset: 0;
  background: rgba(120, 120, 128, 0.32);
  border-radius: 999px;
  transition: background 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.fw-switch__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18), 0 1px 2px rgba(0, 0, 0, 0.12);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.fw-switch input:checked ~ .fw-switch__track {
  background: var(--success);
}

.fw-switch input:checked ~ .fw-switch__track .fw-switch__thumb {
  transform: translateX(20px);
}

/* --- Status block --- */

.fw-status {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px 18px;
}

.fw-status--muted {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--fg-muted);
}

.fw-statline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  min-width: 0;
}

.fw-statline__label {
  color: var(--fg-muted);
  font-size: 0.78rem;
  flex-shrink: 0;
}

.fw-statline__value {
  color: var(--fg);
  font-weight: 500;
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fw-statline__value--mono {
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.78rem;
  font-weight: 500;
  color: rgba(229, 237, 255, 0.85);
}

.fw-led {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(229, 237, 255, 0.35);
  box-shadow: 0 0 0 0 currentColor;
}

.fw-led--on {
  background: var(--success);
  box-shadow: 0 0 8px rgba(48, 209, 88, 0.55);
}

.fw-led--off {
  background: rgba(229, 237, 255, 0.3);
}

.fw-led--warn {
  background: var(--warning);
  box-shadow: 0 0 6px rgba(255, 214, 10, 0.45);
}

.fw-led--muted { background: rgba(229, 237, 255, 0.25); }

.fw-error {
  margin-top: 6px;
  padding: 10px 12px;
  background: rgba(255, 69, 58, 0.1);
  border: 1px solid rgba(255, 69, 58, 0.22);
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
}

.fw-error__label {
  color: rgba(255, 173, 168, 0.95);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.fw-error code {
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.78rem;
  color: rgba(255, 220, 218, 0.95);
  background: transparent;
  word-break: break-word;
}

/* --- Empty / callout states --- */

.fw-empty {
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  font-size: 0.85rem;
  color: var(--fg-muted);
  text-align: center;
  border: 1px dashed rgba(255, 255, 255, 0.07);
}

.fw-empty strong {
  color: var(--fg);
  font-weight: 600;
}

.fw-callout {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(127, 196, 255, 0.1);
  border: 1px solid rgba(127, 196, 255, 0.22);
  border-radius: 12px;
  font-size: 0.82rem;
  color: var(--fg);
}

.fw-callout__icon {
  font-size: 1rem;
  line-height: 1.2;
}

.fw-callout__sub {
  font-size: 0.75rem;
  color: var(--fg-muted);
  margin-top: 2px;
}

/* --- Tables --- */

.fw-table-wrap {
  background: rgba(255, 255, 255, 0.025);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.fw-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}

.fw-th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--fg-muted);
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  text-transform: uppercase;
}

.fw-th--right { text-align: right; }
.fw-th--check { width: 36px; padding-right: 6px; }
.fw-th--proto { width: 70px; }
.fw-th--port { width: 80px; }
.fw-th--act { width: 1%; text-align: right; }

.fw-tr {
  transition: background 0.15s ease;
}

.fw-tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.fw-tr + .fw-tr .fw-td {
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.fw-td {
  padding: 11px 14px;
  color: var(--fg);
  vertical-align: middle;
  letter-spacing: -0.005em;
}

.fw-td--right { text-align: right; }
.fw-td--act { text-align: right; white-space: nowrap; }
.fw-td--act > * + * { margin-left: 6px; }

.fw-td--port {
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 500;
  font-feature-settings: 'tnum';
}

.fw-mono {
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.8rem;
  color: var(--fg);
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 6px;
  border-radius: 5px;
}

.fw-muted {
  color: rgba(229, 237, 255, 0.4);
  font-size: 0.82rem;
}

/* --- Protocol pill --- */

.fw-proto {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
}

.fw-proto--tcp {
  color: rgba(127, 196, 255, 0.95);
  background: rgba(127, 196, 255, 0.12);
}

.fw-proto--udp {
  color: rgba(255, 198, 158, 0.95);
  background: rgba(255, 184, 122, 0.12);
}

/* --- Source tags --- */

.fw-tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 0.7rem;
  font-weight: 500;
  margin-right: 4px;
}

.fw-tag--listening {
  color: rgba(180, 230, 200, 0.95);
  background: rgba(48, 209, 88, 0.12);
}

.fw-tag--firewall {
  color: rgba(229, 237, 255, 0.85);
  background: rgba(255, 255, 255, 0.06);
}

/* --- Custom checkbox --- */

.fw-check {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.fw-check input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.fw-check span {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.04);
  transition: all 0.15s ease;
  position: relative;
}

.fw-check input:checked + span {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.fw-check input:checked + span::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 6px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 1.6px 1.6px 0;
  transform: rotate(45deg);
}

/* --- Inputs (rule add row + inline) --- */

.fw-rule-add {
  display: grid;
  grid-template-columns: 80px 100px minmax(180px, 1fr) minmax(140px, 1fr) auto;
  gap: 8px;
  margin-top: 4px;
}

.fw-input {
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg);
  font-size: 0.85rem;
  font-family: var(--font-primary);
  letter-spacing: -0.005em;
  transition: border-color 0.15s ease, background 0.15s ease;
  min-width: 0;
}

.fw-input::placeholder {
  color: rgba(229, 237, 255, 0.35);
}

.fw-input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.06);
}

.fw-input--proto { font-weight: 600; }
.fw-input--port { font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace; }
.fw-input--note {
  height: 28px;
  padding: 0 8px;
  border-radius: 7px;
  font-size: 0.78rem;
  background: transparent;
  border-color: transparent;
}

.fw-input--note:focus {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}

.fw-add-btn {
  height: 36px;
  padding: 0 18px;
}

/* --- Section internal action row (e.g. "将勾选项加入规则") --- */

.fw-section__action-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

/* --- Icon buttons (delete, etc) --- */

.fw-iconbtn {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg-muted);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  font-weight: 400;
}

.fw-iconbtn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--fg);
}

.fw-iconbtn--danger:hover {
  background: rgba(255, 69, 58, 0.14);
  color: rgba(255, 173, 168, 1);
  border-color: rgba(255, 69, 58, 0.25);
}

/* --- Footer --- */

.fw-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 6px;
}

.fw-apply {
  background: var(--accent-strong);
  color: #fff;
  font-weight: 600;
  border-color: transparent;
}

.fw-apply:hover {
  background: #1592ff;
}

/* --- Mobile --- */

@media (max-width: 640px) {
  .fw-card { padding: 16px; }
  .fw-card--hero { padding: 18px; }
  .fw-hero__title { font-size: 1.05rem; }
  .fw-status { grid-template-columns: 1fr; gap: 8px; }
  .fw-rule-add {
    grid-template-columns: 80px 1fr;
    grid-auto-rows: auto;
  }
  .fw-rule-add .fw-input--src,
  .fw-rule-add .fw-input--note {
    grid-column: 1 / -1;
  }
  .fw-rule-add .fw-add-btn {
    grid-column: 1 / -1;
    justify-self: stretch;
  }
  .fw-table { font-size: 0.78rem; }
  .fw-th, .fw-td { padding: 9px 10px; }
  .fw-th--proc, .fw-td--proc { display: none; }
}

/* ────────────────────────────────────────────────────────────────────────────
   DDNS modal
   ────────────────────────────────────────────────────────────────────────── */

#agentDdnsModalBody { display: flex; flex-direction: column; gap: 14px; }

/* Hero status card */
.ddns-hero { gap: 16px; }
.ddns-hero__state {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.78rem; letter-spacing: 0.02em; text-transform: uppercase;
  color: var(--fg-muted); font-weight: 600;
}
.ddns-hero__domain {
  margin: 6px 0 0; font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em;
  display: inline-flex; align-items: center; gap: 8px;
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
}
.ddns-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em;
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
}
.ddns-badge--v4 { background: rgba(48, 209, 88, 0.18); color: #6ed881; border: 1px solid rgba(48, 209, 88, 0.32); }
.ddns-badge--v6 { background: rgba(116, 167, 255, 0.18); color: #8fb4ff; border: 1px solid rgba(116, 167, 255, 0.32); }

/* Stats grid in hero */
.ddns-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 24px;
}
.ddns-stat { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ddns-stat__label {
  font-size: 0.72rem; color: var(--fg-muted); font-weight: 500;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.ddns-stat__value {
  font-size: 0.92rem; font-weight: 500; color: var(--fg);
  display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap;
  overflow-wrap: anywhere;
}
.ddns-stat__value--mono {
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.86rem;
}
.ddns-match {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.02em;
}
.ddns-match--ok { background: rgba(48, 209, 88, 0.18); color: #6ed881; }
.ddns-match--drift { background: rgba(255, 214, 10, 0.18); color: #ffd60a; }

/* Form card */
.ddns-form .fw-card__head { align-items: center; }
.ddns-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}
.ddns-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ddns-field--full { grid-column: 1 / -1; }
.ddns-field__label {
  font-size: 0.78rem; color: var(--fg-muted); font-weight: 500;
  letter-spacing: 0.02em;
}
.ddns-input {
  width: 100%; box-sizing: border-box;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  color: var(--fg);
  font-size: 0.92rem;
  font-family: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.ddns-input::placeholder { color: rgba(229, 237, 255, 0.3); }
.ddns-input:hover { border-color: rgba(255, 255, 255, 0.2); }
.ddns-input:focus {
  outline: none;
  border-color: rgba(116, 167, 255, 0.55);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 3px rgba(116, 167, 255, 0.12);
}
.ddns-input--mono { font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace; font-size: 0.86rem; letter-spacing: -0.01em; }

/* IPv4/IPv6 radio cards */
.ddns-radio-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ddns-radio {
  position: relative;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.ddns-radio:hover { background: rgba(255, 255, 255, 0.07); border-color: rgba(255, 255, 255, 0.18); }
.ddns-radio.is-active {
  background: rgba(116, 167, 255, 0.14);
  border-color: rgba(116, 167, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(116, 167, 255, 0.1);
}
.ddns-radio input { position: absolute; opacity: 0; pointer-events: none; }
.ddns-radio__title { font-size: 0.95rem; font-weight: 600; color: var(--fg); }
.ddns-radio__hint { font-size: 0.76rem; color: var(--fg-muted); }

/* Toggle switch in form head */
.ddns-toggle {
  display: inline-flex; align-items: center; gap: 10px;
  cursor: pointer; user-select: none;
}
.ddns-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.ddns-toggle__track {
  position: relative; width: 38px; height: 22px;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  transition: background 0.2s ease;
}
.ddns-toggle__thumb {
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff;
  transition: left 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.ddns-toggle input:checked + .ddns-toggle__track { background: rgba(48, 209, 88, 0.75); }
.ddns-toggle input:checked + .ddns-toggle__track .ddns-toggle__thumb { left: 18px; }
.ddns-toggle__label {
  font-size: 0.82rem; font-weight: 600; color: var(--fg-muted);
  letter-spacing: 0.02em;
}

.ddns-actions {
  display: flex; gap: 10px; padding-top: 4px;
}

/* Hero card sizing — must not horizontally overflow modal. min-width:0
   lets the 2-col grid shrink properly inside flex/grid parents.
   max-width:100% + box-sizing:border-box guarantees the card never
   exceeds its container even with long IPv6 + FQDN values. */
.ddns-hero { min-width: 0; max-width: 100%; box-sizing: border-box; }
.ddns-hero__domain { min-width: 0; overflow-wrap: anywhere; }

/* Hero stats stay 2x2 even on mobile — long values wrap via
   overflow-wrap:anywhere inside the cell. Collapsing to 1 column made
   the card so tall that the modal scroll cut content off. */
@media (max-width: 720px) {
  .ddns-grid, .ddns-radio-row { grid-template-columns: 1fr; }
  .ddns-stats { gap: 10px 12px; }
  .ddns-stat__value { font-size: 0.84rem; }
  .ddns-stat__value--mono { font-size: 0.78rem; }
  .fw-card--hero { padding: 16px 14px; }
  .ddns-hero__domain { font-size: 0.96rem; }
}

/* Phones — modal goes near-fullscreen so the form below the hero
   doesn't disappear under the bottom of the viewport. */
@media (max-width: 480px) {
  #agentDdnsModal .modal-card,
  #ddnsAccountsModal .modal-card {
    width: 100vw; max-width: 100vw; max-height: 95vh;
    padding: 0.85rem; border-radius: 18px 18px 0 0;
  }
  .modal { padding: 0.5rem 0 0; align-items: flex-end; }
  .fw-card--hero { padding: 14px 12px; }
  .ddns-stats { gap: 8px 10px; }
  .ddns-stat__label { font-size: 0.66rem; }
}

/* Manage-account icon button — heights matches the .ddns-input so it
   sits flush with the select on the same row. */
.ddns-manage-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  color: var(--fg-muted);
  font-size: 0.84rem; font-weight: 500;
  cursor: pointer; flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.ddns-manage-btn:hover {
  background: rgba(116, 167, 255, 0.12);
  border-color: rgba(116, 167, 255, 0.4);
  color: var(--fg);
}
.ddns-manage-btn svg { flex-shrink: 0; }
@media (max-width: 480px) {
  .ddns-manage-btn span { display: none; }
  .ddns-manage-btn { padding: 0; width: 40px; justify-content: center; }
}

/* fw-card__head — stack on mobile so the toggle label doesn't push
   off-screen or wrap behind the title hint. */
@media (max-width: 540px) {
  .fw-card__head { flex-direction: column; align-items: stretch; }
  .ddns-toggle { align-self: flex-end; }
}
.ddns-toggle__label { white-space: nowrap; }

/* Account dropdown + subdomain row */
.ddns-account-row { display: flex; gap: 10px; align-items: center; }
.ddns-account-row select.ddns-input { flex: 1 1 auto; }

.ddns-subdomain-row { display: flex; align-items: center; gap: 8px; }
.ddns-subdomain-row .ddns-input { flex: 1 1 auto; }
.ddns-subdomain-suffix {
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.86rem;
  color: var(--fg);
  white-space: nowrap;
}
.ddns-field__hint {
  font-size: 0.72rem; color: var(--fg-muted); margin-top: 2px;
}
.ddns-field__hint code {
  background: rgba(255, 255, 255, 0.08); padding: 1px 5px; border-radius: 4px;
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
}

/* Accounts management list */
#ddnsAccountsModalBody { display: flex; flex-direction: column; gap: 14px; }

.ddns-account-list { display: flex; flex-direction: column; gap: 10px; }
.ddns-account-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.ddns-account-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.18);
}
.ddns-account-card.is-editing {
  border-color: rgba(116, 167, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(116, 167, 255, 0.1);
}
.ddns-account-card__main { min-width: 0; flex: 1 1 auto; }
.ddns-account-card__name { font-weight: 600; font-size: 0.95rem; }
.ddns-account-card__meta {
  display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px;
  font-size: 0.78rem;
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
}
.ddns-account-card__root { color: var(--fg); }
.ddns-account-card__actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ────────────────────────────────────────────────────────────────────────────
   DDNS accounts modal redesign — grid of square account cards + slide-in
   edit panel; empty state with illustration; inline edit on agent modal.
   ────────────────────────────────────────────────────────────────────────── */

/* Empty state shared between accounts modal and agent modal */
.ddns-empty {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; padding: 36px 24px;
  text-align: center;
}
.ddns-empty--inline { padding: 28px 16px; }
.ddns-empty__icon {
  width: 84px; height: 84px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(116, 167, 255, 0.14), rgba(48, 209, 88, 0.08));
  color: rgba(229, 237, 255, 0.65);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 4px 24px rgba(0, 0, 0, 0.18);
}
.ddns-empty--inline .ddns-empty__icon { width: 72px; height: 72px; }
.ddns-empty__title {
  margin: 0; font-size: 1.05rem; font-weight: 600;
  letter-spacing: -0.01em; color: var(--fg);
}
.ddns-empty__hint {
  margin: 0 0 6px; font-size: 0.86rem;
  color: var(--fg-muted); max-width: 360px; line-height: 1.55;
}

/* Accounts grid — list of cards + a dashed "add" tile */
.ddns-acct-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.ddns-acct-card {
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  min-width: 0;
}
.ddns-acct-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}
.ddns-acct-card.is-editing {
  border-color: rgba(116, 167, 255, 0.55);
  background: rgba(116, 167, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(116, 167, 255, 0.1);
}
.ddns-acct-card__top {
  display: flex; align-items: center; gap: 12px; min-width: 0;
}
.ddns-acct-card__icon {
  width: 36px; height: 36px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(116, 167, 255, 0.2), rgba(48, 209, 88, 0.12));
  color: rgba(229, 237, 255, 0.85);
}
.ddns-acct-card__head { flex: 1 1 auto; min-width: 0; }
.ddns-acct-card__name {
  font-size: 0.95rem; font-weight: 600; letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ddns-acct-card__root {
  font-size: 0.78rem; color: var(--fg-muted);
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ddns-acct-card__menu { display: flex; gap: 4px; flex-shrink: 0; }
.ddns-icon-btn {
  width: 28px; height: 28px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--fg-muted);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.ddns-icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--fg);
}
.ddns-icon-btn--danger:hover {
  background: rgba(255, 69, 58, 0.16);
  border-color: rgba(255, 69, 58, 0.4);
  color: #ff7a72;
}
.ddns-acct-card__rows {
  display: flex; flex-direction: column; gap: 4px;
  padding-top: 4px; border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.ddns-acct-card__row {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  font-size: 0.78rem;
}
.ddns-acct-card__label {
  width: 64px; flex-shrink: 0; color: var(--fg-muted);
}
.ddns-acct-card__value {
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.76rem; color: rgba(229, 237, 255, 0.85);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0; flex: 1 1 auto;
}

/* "Add account" tile — dashed-border CTA in the grid */
.ddns-acct-card--add {
  align-items: center; justify-content: center;
  gap: 8px;
  border-style: dashed; border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.02);
  color: var(--fg-muted);
  font-size: 0.92rem; font-weight: 500;
  cursor: pointer;
  min-height: 140px;
}
.ddns-acct-card--add:hover {
  background: rgba(116, 167, 255, 0.08);
  border-color: rgba(116, 167, 255, 0.45);
  color: var(--fg);
}
.ddns-acct-card--add__icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 300;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* Edit card that slides in below the grid */
.ddns-edit-card {
  margin-top: 6px;
  padding: 20px 22px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(116, 167, 255, 0.35);
  border-radius: 18px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(116, 167, 255, 0.12);
  animation: ddnsSlideIn 0.18s ease-out;
}
@keyframes ddnsSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ddns-edit-card__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.ddns-edit-card__title {
  margin: 0; font-size: 1rem; font-weight: 600; letter-spacing: -0.01em;
}
.ddns-edit-card__hint {
  margin: 4px 0 0; font-size: 0.78rem; color: var(--fg-muted); max-width: 540px;
}
.ddns-edit-card__close {
  width: 28px; height: 28px; padding: 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--fg-muted); cursor: pointer;
  font-size: 1.1rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ddns-edit-card__close:hover {
  background: rgba(255, 255, 255, 0.1); color: var(--fg);
}
.ddns-edit-card__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}
.ddns-edit-card__actions {
  display: flex; gap: 10px; justify-content: flex-end;
  padding-top: 4px;
}
.ddns-field__hint-inline {
  margin-left: 6px; color: var(--fg-muted); font-weight: 400; font-size: 0.74rem;
}

/* FQDN live preview under subdomain row */
.ddns-fqdn-preview {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; margin-top: 2px;
  background: rgba(116, 167, 255, 0.1);
  border: 1px solid rgba(116, 167, 255, 0.28);
  border-radius: 8px;
  font-size: 0.78rem;
  color: rgba(229, 237, 255, 0.85);
}
.ddns-fqdn-preview strong {
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 600; color: var(--fg);
}

@media (max-width: 560px) {
  .ddns-acct-grid { grid-template-columns: 1fr; }
  .ddns-edit-card__grid { grid-template-columns: 1fr; }
}

/* Root-domain chip input for accounts edit form */
.ddns-chip-input {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  min-height: 40px;
  align-items: center;
  cursor: text;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.ddns-chip-input:focus-within {
  border-color: rgba(116, 167, 255, 0.55);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 3px rgba(116, 167, 255, 0.12);
}
.ddns-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 4px 3px 10px;
  background: rgba(116, 167, 255, 0.18);
  border: 1px solid rgba(116, 167, 255, 0.36);
  border-radius: 999px;
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.8rem;
  color: var(--fg);
}
.ddns-chip__del {
  width: 18px; height: 18px; padding: 0;
  background: transparent; border: none;
  color: rgba(229, 237, 255, 0.7);
  border-radius: 50%;
  cursor: pointer; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
}
.ddns-chip__del:hover { background: rgba(255, 255, 255, 0.12); color: var(--fg); }
.ddns-chip-input__entry {
  flex: 1 1 140px; min-width: 100px;
  padding: 6px 4px;
  background: transparent; border: none; outline: none;
  color: var(--fg);
  font-size: 0.86rem;
}
.ddns-chip-input__entry::placeholder { color: rgba(229, 237, 255, 0.3); }

/* Account card list of root domains (preview) */
.ddns-acct-card__sub {
  font-size: 0.74rem; color: var(--fg-muted); margin-top: 2px;
}
.ddns-acct-card__roots {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: -2px;
  max-height: 60px; overflow: hidden;
}
.ddns-acct-card__roots--empty {
  font-size: 0.78rem; color: var(--fg-muted); font-style: italic;
}
.ddns-acct-card__rootchip {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  background: rgba(116, 167, 255, 0.14);
  border: 1px solid rgba(116, 167, 255, 0.26);
  border-radius: 6px;
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.74rem;
  color: rgba(229, 237, 255, 0.88);
}

/* Preview chip row spans both columns on its own */
.ddns-field--preview {
  margin-top: -4px;
}

/* === Unassigned-project synthetic item + detail banner === */
.project-item--unassigned {
  border-left: 3px solid rgba(255, 180, 40, 0.7);
  background: rgba(255, 180, 40, 0.03);
}
.project-item--unassigned.selected {
  background: rgba(255, 180, 40, 0.08);
  border-left-color: rgba(255, 180, 40, 0.95);
}
.unassigned-banner {
  padding: 10px 14px;
  background: rgba(255, 180, 40, 0.08);
  border: 1px solid rgba(255, 180, 40, 0.25);
  border-radius: 8px;
  margin: 0 0 12px;
  color: rgba(255, 220, 160, 0.9);
  font-size: 0.84rem;
}

/* === Redesigned settings card: rail + panels === */
.settings-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  margin-top: 14px;
}
.settings-rail {
  display: flex; flex-direction: column; gap: 4px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  align-self: start;
}
.settings-rail__item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--fg-muted);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.12s ease;
}
.settings-rail__item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg);
}
.settings-rail__item.is-active {
  background: rgba(116, 167, 255, 0.14);
  border-color: rgba(116, 167, 255, 0.32);
  color: rgba(229, 237, 255, 0.98);
  box-shadow: inset 2px 0 0 0 rgba(116, 167, 255, 0.8);
}
.settings-rail__item:active { transform: translateY(1px); }
.settings-rail__glyph {
  flex: 0 0 32px;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(180, 210, 255, 0.92);
}
.settings-rail__item.is-active .settings-rail__glyph {
  background: rgba(116, 167, 255, 0.18);
  border-color: rgba(116, 167, 255, 0.38);
  color: rgba(229, 237, 255, 1);
}
.settings-rail__label {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
}
.settings-rail__title { font-size: 0.94rem; font-weight: 500; }
.settings-rail__sub { font-size: 0.74rem; opacity: 0.72; }

.settings-panels { min-width: 0; }
.settings-panel { display: none; }
.settings-panel.is-active {
  display: block;
  animation: settings-panel-fade 0.18s ease-out;
}
@keyframes settings-panel-fade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.settings-panel__head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.settings-panel__title {
  margin: 0 0 4px;
  font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em;
}
.settings-panel__sub {
  margin: 0;
  font-size: 0.84rem; color: var(--fg-muted);
}
.settings-panel__actions {
  display: flex; gap: 8px; flex-wrap: wrap;
  flex-shrink: 0;
}

/* setting-row replaces the old .row in panels — softer, with hover tint */
.setting-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  margin-bottom: 8px;
  align-items: center;
  transition: background 0.15s ease;
}
.setting-row:hover { background: rgba(255, 255, 255, 0.04); }
.setting-row__label {
  font-size: 0.84rem;
  color: var(--fg-muted);
  font-weight: 500;
}
.setting-row__value {
  font-size: 0.9rem;
  color: var(--fg);
  word-break: break-word;
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
}

/* Stat cards for at-a-glance numeric settings (failover) */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.stat-card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 16px 18px;
  background: linear-gradient(160deg, rgba(116, 167, 255, 0.08), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
}
.stat-card__label {
  font-size: 0.78rem; color: var(--fg-muted);
  font-weight: 500; letter-spacing: 0.01em;
}
.stat-card__value {
  font-size: 1.7rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  line-height: 1.1;
}
.stat-card__hint {
  font-size: 0.72rem; color: var(--fg-muted);
  opacity: 0.72;
}

/* Inline hint inside labels */
.label-hint {
  margin-left: 8px;
  font-size: 0.74rem;
  font-weight: 400;
  color: var(--fg-muted);
  opacity: 0.8;
}

.settings-status {
  margin-top: 10px;
  font-size: 0.84rem;
  color: var(--fg-muted);
  min-height: 1.2em;
}
.settings-status:not(:empty) {
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  display: inline-block;
}

.settings-subsection {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.settings-subsection__head {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 10px;
}
.settings-subsection__title {
  margin: 0;
  font-size: 0.96rem; font-weight: 600;
}
.settings-subsection__hint {
  font-size: 0.78rem; color: var(--fg-muted); opacity: 0.78;
}

/* "Danger hover" button: subtle until hovered, then red */
.btn.danger-hover {
  display: inline-flex; align-items: center; gap: 6px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn.danger-hover:hover {
  background: rgba(255, 70, 70, 0.14);
  border-color: rgba(255, 90, 90, 0.42);
  color: rgba(255, 200, 200, 0.96);
}

/* Mobile: rail becomes horizontal scrollable pill strip above the panel */
@media (max-width: 760px) {
  .settings-shell { grid-template-columns: 1fr; gap: 14px; }
  .settings-rail {
    flex-direction: row;
    overflow-x: auto;
    padding: 6px;
    gap: 6px;
    scrollbar-width: none;
  }
  .settings-rail::-webkit-scrollbar { display: none; }
  .settings-rail__item { flex: 0 0 auto; padding: 8px 12px; }
  .settings-rail__sub { display: none; }
  .settings-rail__item.is-active { box-shadow: none; }
  .setting-row { grid-template-columns: 1fr; gap: 4px; padding: 10px 12px; }
  .setting-row__label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; }
  .settings-panel__head { flex-direction: column; }
  .settings-panel__actions { width: 100%; }
}

/* Old .ddns-chip--locked still used by login chip input */
.ddns-chip--locked {
  background: rgba(255, 214, 10, 0.14);
  border-color: rgba(255, 214, 10, 0.42);
  color: rgba(255, 230, 130, 0.95);
  cursor: not-allowed;
  padding: 3px 10px;
}
.ddns-chip--locked .ddns-chip__del { display: none; }

.auth-subsection {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.auth-subsection .section-subtitle {
  margin-bottom: 8px;
}

.auth-sessions-list {
  display: flex; flex-direction: column; gap: 6px;
}
.auth-session-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto auto;
  gap: 12px; align-items: baseline;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  font-size: 0.86rem;
}
.auth-session-row__login {
  font-weight: 600;
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  color: rgba(229, 237, 255, 0.95);
}
.auth-session-row__meta {
  color: var(--fg-muted);
  font-size: 0.78rem;
}

.auth-table-wrap {
  overflow-x: auto;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  max-height: 320px;
  overflow-y: auto;
}
.auth-audit-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.84rem;
}
.auth-audit-table th,
.auth-audit-table td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}
.auth-audit-table th {
  position: sticky; top: 0;
  background: rgba(20, 30, 60, 0.92);
  font-weight: 500;
  color: var(--fg-muted);
  z-index: 1;
}
.auth-audit-table tr:hover { background: rgba(255, 255, 255, 0.03); }
.auth-audit-table .evt-login_success { color: rgba(120, 220, 140, 0.95); }
.auth-audit-table .evt-login_denied  { color: rgba(255, 140, 140, 0.95); }
.auth-audit-table .evt-revoke_all    { color: rgba(255, 200, 90, 0.95); }
.auth-audit-table .evt-logout        { color: var(--fg-muted); }

#loginRevokeAllBtn:hover {
  background: rgba(255, 70, 70, 0.12);
  border-color: rgba(255, 90, 90, 0.4);
  color: rgba(255, 180, 180, 0.95);
}
