/* ── Cartoon Mac Design System ── */
:root {
  --font: "Nunito", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;

  --desktop-1: #7c9cff;
  --desktop-2: #b794f6;
  --desktop-3: #f687b3;

  --menubar-bg: rgba(255, 255, 255, 0.78);
  --menubar-border: rgba(0, 0, 0, 0.08);

  --window-bg: #f6f6f8;
  --window-border: rgba(0, 0, 0, 0.12);
  --titlebar-bg: linear-gradient(180deg, #fafafa 0%, #ebebeb 100%);

  --surface: #ffffff;
  --sidebar: #ececf1;
  --sidebar-hover: #e0e0e8;
  --sidebar-active: #ffffff;
  --sidebar-w: 210px;

  --text: #1d1d1f;
  --text-muted: #6e6e73;
  --border: #d2d2d7;
  --border-light: #e8e8ed;

  --aqua: #007aff;
  --aqua-light: #5ac8fa;
  --aqua-dark: #0056b3;
  --aqua-grad: linear-gradient(180deg, #64b5ff 0%, #007aff 55%, #0062cc 100%);

  --success: #34c759;
  --success-bg: #e8f9ed;
  --error: #ff3b30;
  --error-bg: #ffebea;
  --warning: #ff9500;
  --warning-bg: #fff4e5;
  --info: #5ac8fa;
  --info-bg: #e8f6ff;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-window: 14px;

  --shadow-window: 0 24px 80px rgba(0, 0, 0, 0.22), 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --shadow-btn: 0 2px 6px rgba(0, 122, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  --shadow-inset: inset 0 1px 3px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

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

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

/* ── Desktop wallpaper ── */
.mac-body {
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 40%),
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 28px,
      rgba(255, 255, 255, 0.04) 28px,
      rgba(255, 255, 255, 0.04) 56px
    ),
    linear-gradient(145deg, var(--desktop-1) 0%, var(--desktop-2) 45%, var(--desktop-3) 100%);
  background-attachment: fixed;
}

.mac-body--auth { overflow: hidden; }

/* ── Menu bar ── */
.mac-menubar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 28px;
  padding: 0 16px;
  background: var(--menubar-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--menubar-border);
  font-size: 13px;
  font-weight: 600;
}

.menubar-left,
.menubar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.menubar-apple {
  width: 14px;
  height: 14px;
  background: var(--text);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 814 1000'%3E%3Cpath d='M788.1 340.9c-5.8 4.5-108.2 62.2-108.2 190.5 0 148.4 130.3 200.9 134.2 202.2-.6 3.2-20.7 71.9-68.7 141.9-42.8 61.6-87.5 123.1-155.5 123.1s-85.5-39.5-163-39.5c-76.5 0-103.7 40.8-165.9 40.8s-105.6-57-155.5-127C46.7 790.7 0 663 0 541.8c0-194.4 126.4-297.5 250.8-297.5 66.1 0 121.2 43.4 162.7 43.4 39.5 0 101.1-46 176.3-46 28.2 0 129.9 2.6 196.3 99.2zM554.1 159.4c31.1-36.9 53.1-88.1 53.1-139.3 0-7.1-.6-14.3-1.9-20.1-50.6 1.9-110.8 33.7-147.1 75.8-28.2 32.4-54.4 83.6-54.4 135.5 0 7.8 1.3 15.6 1.9 18.1 3.2.6 8.4 1.3 13.6 1.3 45.4 0 102.5-30.4 134.8-71.3z'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 814 1000'%3E%3Cpath d='M788.1 340.9c-5.8 4.5-108.2 62.2-108.2 190.5 0 148.4 130.3 200.9 134.2 202.2-.6 3.2-20.7 71.9-68.7 141.9-42.8 61.6-87.5 123.1-155.5 123.1s-85.5-39.5-163-39.5c-76.5 0-103.7 40.8-165.9 40.8s-105.6-57-155.5-127C46.7 790.7 0 663 0 541.8c0-194.4 126.4-297.5 250.8-297.5 66.1 0 121.2 43.4 162.7 43.4 39.5 0 101.1-46 176.3-46 28.2 0 129.9 2.6 196.3 99.2zM554.1 159.4c31.1-36.9 53.1-88.1 53.1-139.3 0-7.1-.6-14.3-1.9-20.1-50.6 1.9-110.8 33.7-147.1 75.8-28.2 32.4-54.4 83.6-54.4 135.5 0 7.8 1.3 15.6 1.9 18.1 3.2.6 8.4 1.3 13.6 1.3 45.4 0 102.5-30.4 134.8-71.3z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.menubar-app { font-weight: 800; }
.menubar-item { color: var(--text-muted); font-weight: 600; cursor: default; }
.menubar-user { color: var(--text-muted); font-weight: 700; }
.menubar-link {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  padding: 2px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}
.menubar-link:hover {
  background: rgba(0, 0, 0, 0.06);
  text-decoration: none;
}

/* ── Main window ── */
.mac-desktop {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px 24px 32px;
  min-height: calc(100vh - 28px);
}

.mac-desktop--auth {
  align-items: center;
  min-height: 100vh;
  padding: 24px;
}

.mac-window {
  width: 100%;
  max-width: 1180px;
  background: var(--window-bg);
  border: 1px solid var(--window-border);
  border-radius: var(--radius-window);
  box-shadow: var(--shadow-window);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: window-in 0.45s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.mac-window--login {
  max-width: 420px;
  animation: window-in 0.5s cubic-bezier(0.34, 1.5, 0.64, 1);
}

@keyframes window-in {
  from { opacity: 0; transform: scale(0.92) translateY(16px); }
  to { opacity: 1; transform: none; }
}

.mac-titlebar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 14px;
  background: var(--titlebar-bg);
  border-bottom: 1px solid var(--border);
  user-select: none;
}

.traffic-lights {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.tl {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 0.5px solid rgba(0, 0, 0, 0.12);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.45);
  transition: transform 0.15s, filter 0.15s;
}

.mac-titlebar:hover .tl { filter: brightness(1.05); }
.mac-titlebar:hover .tl-red { background: #ff6157; }
.mac-titlebar:hover .tl-yellow { background: #ffbd2e; }
.mac-titlebar:hover .tl-green { background: #28ca42; }

.tl-red { background: #ff5f57; }
.tl-yellow { background: #febc2e; }
.tl-green { background: #28c840; }

.mac-window-title {
  flex: 1;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  margin-right: 52px;
}

.mac-window-body {
  display: flex;
  flex: 1;
  min-height: 520px;
  align-items: stretch;
}

.mac-window-body--auth {
  display: block;
  flex: none;
  min-height: auto;
  padding: 8px;
  background: var(--window-bg);
}

/* ── Sidebar (Finder style) ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-icon {
  font-size: 28px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.sidebar-brand .logo {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.sidebar-brand .tagline {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  overflow-y: auto;
}

.nav-section {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 12px 12px 6px;
  margin-top: 4px;
}

.nav-section:first-child { margin-top: 0; padding-top: 4px; }

.sidebar-nav a.nav-ext::after {
  content: "↗";
  margin-left: auto;
  font-size: 11px;
  opacity: 0.45;
}

.ops-workspace {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: calc(100vh - 160px);
  margin: -8px -4px 0;
}

.ops-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ops-toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ops-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
}

.ops-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ops-tab {
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
  background: #fff;
  border: 1px solid var(--border);
  text-decoration: none;
  transition: all 0.15s;
}

.ops-tab:hover {
  color: var(--text);
  border-color: #90caf9;
  text-decoration: none;
}

.ops-tab.active {
  color: #fff;
  background: var(--aqua-grad);
  border-color: var(--aqua-dark);
  box-shadow: var(--shadow-btn);
}

.ops-frame-wrap {
  flex: 1;
  min-height: 620px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.ops-frame {
  display: block;
  width: 100%;
  height: min(78vh, 900px);
  min-height: 620px;
  border: 0;
  background: #f6f6f8;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 2px;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

.sidebar-nav a:hover {
  background: var(--sidebar-hover);
  text-decoration: none;
  transform: translateX(2px);
}

.sidebar-nav a.active {
  background: var(--sidebar-active);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08), inset 0 0 0 1px rgba(0, 0, 0, 0.04);
  color: var(--aqua-dark);
}

.sidebar-nav .nav-icon {
  width: 22px;
  text-align: center;
  font-size: 16px;
  line-height: 1;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border-light);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px rgba(52, 199, 89, 0.6);
  animation: pulse-dot 2s ease infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.main-content {
  flex: 1;
  padding: 24px 28px 36px;
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

/* ── Page header ── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
}

.page-header h1 {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
}

.page-subtitle {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
}

.page-back {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  color: var(--aqua);
  margin-bottom: 8px;
  padding: 4px 10px;
  background: rgba(0, 122, 255, 0.08);
  border-radius: 999px;
}

.page-back:hover {
  background: rgba(0, 122, 255, 0.15);
  text-decoration: none;
}

/* ── Cards (nested panels) ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}

.card-title {
  margin: 0 0 14px;
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
}

.card-desc {
  margin: -6px 0 14px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s, box-shadow 0.15s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-value {
  font-size: 1.85rem;
  font-weight: 800;
  margin-top: 4px;
  line-height: 1.2;
  color: var(--text);
}

.stat-card.highlight {
  border-color: #90caf9;
  background: linear-gradient(135deg, #e3f2fd 0%, #fff 100%);
}

/* ── Alerts ── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  animation: alert-in 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
}

@keyframes alert-in {
  from { opacity: 0; transform: scale(0.95) translateY(-8px); }
  to { opacity: 1; transform: none; }
}

.alert-success { background: var(--success-bg); color: #1a7f37; border-color: #a8e6bc; }
.alert-error { background: var(--error-bg); color: #c41e16; border-color: #ffb4b0; }
.alert-warning { background: var(--warning-bg); color: #b45309; border-color: #ffd699; }
.alert-info { background: var(--info-bg); color: #0369a1; border-color: #a8dcff; }

.alert-icon {
  font-weight: 800;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  font-size: 12px;
}

.alert-body { flex: 1; }
.alert-close {
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.45;
  padding: 0 0 0 8px;
  color: inherit;
  border-radius: 4px;
}
.alert-close:hover { opacity: 1; background: rgba(0, 0, 0, 0.05); }

/* ── Toast (mac notification style) ── */
#toast-root {
  position: fixed;
  top: 40px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: min(380px, calc(100vw - 40px));
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  animation: toast-in 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
  font-size: 14px;
  font-weight: 700;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px) scale(0.9); }
  to { opacity: 1; transform: none; }
}

.toast.toast-out { animation: toast-out 0.25s ease forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px) scale(0.9); } }

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--error); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-info { border-left: 4px solid var(--info); }

.toast-icon { font-weight: 800; font-size: 16px; }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--error); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--info); }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.ad-item-card {
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: #fff;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}

.ad-item-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.ad-item-head .ad-item-title { flex: 1; min-width: 120px; }

.ad-item-head .ad-remove-btn { margin-left: auto; }

label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}

label.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 0;
}

label.checkbox-label input { width: auto; }

.form-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

input, select, textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  font-weight: 600;
  background: #fff;
  box-shadow: var(--shadow-inset);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--aqua);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.18), var(--shadow-inset);
}

input:disabled {
  background: #f5f5f7;
  color: var(--text-muted);
}

textarea.mono {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  line-height: 1.6;
  font-weight: 400;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding-top: 4px;
}

.form-divider {
  margin: 24px 0;
  border: none;
  border-top: 1px solid var(--border-light);
}

.form-section-title {
  font-size: 0.95rem;
  font-weight: 800;
  margin: 0 0 14px;
}

/* ── Buttons (Aqua glossy) ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  background: var(--aqua-grad);
  color: #fff;
  border: 1px solid var(--aqua-dark);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;
  font-family: var(--font);
  box-shadow: var(--shadow-btn);
  transition: filter 0.15s, transform 0.1s, box-shadow 0.15s;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}

.btn:hover {
  filter: brightness(1.06);
  text-decoration: none;
  color: #fff;
}

.btn:active {
  transform: scale(0.97);
  filter: brightness(0.95);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15);
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; filter: grayscale(0.3); }

.btn-aqua { /* alias, same as default */ }

.btn-secondary {
  background: linear-gradient(180deg, #a1a1aa 0%, #71717a 100%);
  border-color: #52525b;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-secondary:hover { filter: brightness(1.08); color: #fff; }

.btn-danger {
  background: linear-gradient(180deg, #ff6961 0%, #ff3b30 55%, #d70015 100%);
  border-color: #c41e16;
  box-shadow: 0 2px 6px rgba(255, 59, 48, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-danger:hover { filter: brightness(1.06); color: #fff; }

.btn-ghost {
  background: linear-gradient(180deg, #fff 0%, #f5f5f7 100%);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  text-shadow: none;
}

.btn-ghost:hover {
  background: linear-gradient(180deg, #fff 0%, #ebebed 100%);
  color: var(--text);
  filter: none;
}

.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; }
form.inline { display: inline; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; margin: 0 -4px; }

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

th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  background: #f5f5f7;
}

th:first-child { border-radius: var(--radius-sm) 0 0 0; }
th:last-child { border-radius: 0 var(--radius-sm) 0 0; }

td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
  font-weight: 600;
  vertical-align: middle;
}

tr:hover td { background: rgba(0, 122, 255, 0.04); }
td.actions { white-space: nowrap; }
td.actions .btn { margin-right: 4px; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid transparent;
}

.badge-ok { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.badge-info { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }

.source-labels {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.source-labels li {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.badge-off { background: #ffe4e6; color: #be123c; border-color: #fecdd3; }
.badge-warn { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.badge-muted { background: #f4f4f5; color: #71717a; border-color: #e4e4e7; }

.badge-live {
  background: #dcfce7;
  color: #15803d;
  border-color: #86efac;
  animation: badge-glow 2s ease infinite;
}

.badge-live::before {
  content: "● ";
  font-size: 8px;
  vertical-align: middle;
}

@keyframes badge-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.4); }
  50% { box-shadow: 0 0 8px 2px rgba(52, 199, 89, 0.25); }
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.empty-state p { font-weight: 700; margin: 0; }
.empty-hint { font-size: 13px; margin-top: 6px; font-weight: 600; }

/* ── Login ── */
.login-card {
  width: 100%;
  padding: 28px 32px 32px;
}

.login-brand {
  text-align: center;
  margin-bottom: 24px;
}

.login-mascot {
  font-size: 3rem;
  margin-bottom: 8px;
  animation: mascot-bounce 2s ease infinite;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

@keyframes mascot-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.login-brand h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login-brand p {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

/* ── Filter bar ── */
.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding-bottom: 16px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.filter-bar .form-group { margin-bottom: 0; min-width: 140px; }
.meta-line { font-size: 13px; color: var(--text-muted); margin: 12px 0; font-weight: 600; }

/* ── Pagination ── */
.pagination { display: flex; gap: 8px; margin-top: 16px; }

/* ── Code / pre ── */
code {
  background: #f0f0f5;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border-light);
}

pre.code-block {
  background: #f5f5f7;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  overflow: auto;
  border: 1px solid var(--border);
  margin: 0;
  box-shadow: var(--shadow-inset);
}

/* ── Loading overlay ── */
form.is-submitting { opacity: 0.65; pointer-events: none; }

form.is-submitting .btn[type=submit]::after {
  content: "";
  width: 14px;
  height: 14px;
  margin-left: 6px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Mobile ── */
.menu-toggle {
  display: none;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 10px;
  margin-left: auto;
}

@media (max-width: 768px) {
  .mac-menubar { padding: 0 10px; }
  .menubar-item { display: none; }

  .mac-desktop { padding: 12px; }
  .mac-window-body { flex-direction: column; min-height: auto; }

  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar-brand { padding: 12px; }
  .sidebar-nav { display: none; flex-direction: row; flex-wrap: wrap; padding: 8px; }
  .sidebar-nav.open { display: flex; }
  .sidebar-nav a { flex: 1 1 auto; min-width: 90px; justify-content: center; font-size: 12px; }
  .sidebar-footer { display: none; }

  .menu-toggle { display: block; }
  .main-content { padding: 16px; }
  .mac-window-title { font-size: 12px; margin-right: 0; }

  .agent-grid { grid-template-columns: 1fr; }
  .agent-actions { flex-wrap: wrap; }
}

/* ── Glass panels (dice-group-simulator style) ── */
.glass-card {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 22px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.04);
  padding: 20px;
  margin-bottom: 16px;
}

.glass-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 800;
  margin: 0 0 14px;
  color: var(--text);
}

.glass-title .ico { font-size: 1.15rem; }

.hidden { display: none !important; }

.deploy-panel { margin-bottom: 16px; padding: 0; overflow: hidden; }
.deploy-panel.glass-card { padding: 0; }

.deploy-panel-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-weight: 800;
  list-style: none;
  width: 100%;
}

.deploy-panel-toggle::-webkit-details-marker { display: none; }

.deploy-panel-toggle::after {
  content: "▸";
  margin-left: auto;
  color: var(--text-muted);
  font-size: 14px;
  transition: transform 0.2s;
}

.deploy-panel[open] .deploy-panel-toggle::after { transform: rotate(90deg); }

.deploy-panel-icon { font-size: 1.2rem; }
.deploy-panel-label { font-size: 15px; color: var(--text); }
.deploy-panel-hint { font-size: 12px; color: var(--text-muted); font-weight: 600; }

.deploy-panel-body {
  padding: 0 20px 20px;
  animation: panel-open 0.25s ease;
}

@keyframes panel-open {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

/* ── Status bar & filters ── */
.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.status-pill-warn { background: #fff4e5; color: #b45309; border-color: #ffd699; }

.status-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-on { background: #34c759; box-shadow: 0 0 6px rgba(52, 199, 89, 0.6); }
.dot-off { background: #aeaeb2; }

.agent-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1.5px solid rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
  transition: all 0.15s;
}

.filter-chip:hover { color: var(--text); border-color: rgba(0, 0, 0, 0.1); }

.filter-chip .chip-count {
  font-size: 11px;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.06);
  min-width: 1.4em;
  text-align: center;
}

.filter-chip.active {
  background: #007aff;
  color: #fff;
  border-color: #007aff;
  box-shadow: 0 3px 12px rgba(0, 122, 255, 0.28);
}

.filter-chip.active .chip-count { background: rgba(255, 255, 255, 0.25); color: #fff; }

.filter-chip.active[data-agent-filter="live"] {
  background: #34c759;
  border-color: #34c759;
  box-shadow: 0 3px 12px rgba(52, 199, 89, 0.28);
}

.filter-chip.active[data-agent-filter="sleep"] {
  background: #8e8e93;
  border-color: #8e8e93;
}

.filter-chip.active[data-agent-filter="unbound"] {
  background: #ff9500;
  border-color: #ff9500;
  box-shadow: 0 3px 12px rgba(255, 149, 0, 0.28);
}

/* ── Agent cards (dice-group-simulator) ── */
.agent-section { margin-top: 0; }

.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.agent-card {
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.8);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.agent-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
}

.agent-card--sleep { opacity: 0.88; filter: saturate(0.7); }

.agent-card--idle {
  border-color: rgba(255, 149, 0, 0.35);
  box-shadow: 0 8px 28px rgba(255, 149, 0, 0.1);
}

.agent-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 12px;
  background: linear-gradient(135deg, var(--head-bg, #e8f2ff) 0%, rgba(255, 255, 255, 0) 100%);
}

.agent-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  background: linear-gradient(145deg, var(--av1, #5ac8fa), var(--av2, #007aff));
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.agent-meta { flex: 1; min-width: 0; }

.agent-meta h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-meta .uid {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.agent-meta .arch {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 2px;
}

.surv-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 4px;
  vertical-align: middle;
}

.surv-badge.alive { background: #e8f9ed; color: #248a3d; }
.surv-badge.sleep { background: #f4f4f5; color: #71717a; }
.surv-badge.danger { background: #fff4e5; color: #c93400; }

.agent-body { padding: 0 16px 16px; }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 4px 0 8px;
}

.tag {
  font-size: 11px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--tag-bg, #e8f2ff);
  color: var(--tag-color, #007aff);
}

.mood-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0;
}

.mood-chip {
  flex: 1;
  min-width: 80px;
  padding: 8px 10px;
  border-radius: 14px;
  background: #f5f5f7;
  text-align: center;
}

.mood-chip .lbl {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mood-chip .val {
  font-size: 1.1rem;
  font-weight: 800;
  margin-top: 2px;
}

.mood-chip.win .val { color: #34c759; }
.mood-chip.neg .val { color: #ff2d55; }

.channel-box {
  padding: 12px;
  border-radius: 14px;
  background: linear-gradient(135deg, #e8f9ed 0%, #fff 100%);
  border: 1px solid rgba(52, 199, 89, 0.15);
  font-size: 12px;
  font-weight: 600;
  margin: 10px 0;
}

.channel-box-title {
  font-weight: 800;
  font-size: 12px;
  margin-bottom: 8px;
  color: #248a3d;
}

.channel-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
}

.channel-grid span { color: var(--text-muted); font-weight: 700; }
.channel-grid b { font-weight: 800; word-break: break-all; text-align: right; }
.channel-grid code { font-size: 11px; }

.pnl-pos { color: #34c759; font-weight: 800; }

.mono {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  font-style: italic;
  padding: 8px 12px;
  background: #f9f9fb;
  border-radius: 14px;
  margin-top: 8px;
}

.react {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 8px;
  padding: 8px 12px;
  background: #fff4e5;
  border-radius: 14px;
}

.pred-bubble {
  margin: 10px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, #f3e8ff 0%, #fff 100%);
  border: 1.5px dashed rgba(175, 82, 222, 0.25);
  font-size: 12px;
  font-weight: 600;
  position: relative;
}

.pred-bubble.empty {
  background: #f5f5f7;
  border-color: rgba(0, 0, 0, 0.06);
  color: var(--text-muted);
}

.agent-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed rgba(0, 0, 0, 0.06);
}

.agent-actions form.inline { flex: 1; display: flex; }
.agent-actions form.inline:last-child { flex: 0; }

.agent-actions button,
.agent-actions .act-edit {
  flex: 1;
  padding: 8px 10px;
  border: none;
  border-radius: 999px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.act-test { background: #e8f2ff; color: #005ecb; }
.act-test:hover { background: #007aff; color: #fff; }

.act-edit { background: #f5f5f7; color: var(--text); border: 1px solid rgba(0, 0, 0, 0.06); }
.act-edit:hover { background: #ebebed; text-decoration: none; }

.act-toggle { background: #fff4e5; color: #b35c00; width: 100%; }
.act-toggle:hover { background: #ff9500; color: #fff; }

.act-delete {
  flex: 0 0 auto !important;
  min-width: 40px;
  background: #ffe8ed;
  color: #ff2d55;
}
.act-delete:hover { background: #ff2d55; color: #fff; }

.agent-filter-empty { padding: 20px 0; }

/* ── Route groups ── */
.route-list-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.group-manage {
  font-size: 13px;
  font-weight: 700;
}

.group-manage summary {
  cursor: pointer;
  color: var(--aqua);
  list-style: none;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 122, 255, 0.08);
}

.group-manage summary::-webkit-details-marker { display: none; }

.group-manage[open] summary { margin-bottom: 10px; }

.group-manage-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.group-manage-form input {
  flex: 1;
  min-width: 100px;
  padding: 8px 10px;
}

.group-manage-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.group-manage-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px dashed var(--border-light);
  font-weight: 700;
}

.route-filter-bar { margin-bottom: 18px; }

.route-group-section {
  margin-bottom: 20px;
  padding: 14px;
  border-radius: var(--radius);
  background: #f8f8fa;
  border: 1px solid var(--border-light);
}

.route-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.route-group-title {
  font-size: 1rem;
  font-weight: 800;
}

.route-group-count {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
  padding: 3px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border-light);
}

.route-group-empty {
  margin: 0;
  padding: 12px;
  text-align: center;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
}

.route-group-section .table-wrap {
  background: #fff;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.route-filter-empty { padding: 12px 0; }

.route-sources-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  max-width: 280px;
}

.route-sources-cell code {
  font-size: 11px;
}
