/* =============================================================
   SPanel — Design System (light, ocean-blue)
   ============================================================= */

:root {
  /* Ocean blue scale */
  --ocean-50:  #f0f9ff;
  --ocean-100: #e0f2fe;
  --ocean-200: #bae6fd;
  --ocean-300: #7dd3fc;
  --ocean-400: #38bdf8;
  --ocean-500: #0ea5e9;
  --ocean-600: #0284c7;
  --ocean-700: #0369a1;
  --ocean-800: #075985;
  --ocean-900: #0c4a6e;

  /* Neutrals (slate) */
  --bg:            #ffffff;
  --bg-soft:       #f8fafc;
  --bg-muted:      #f1f5f9;
  --surface:       #ffffff;
  --surface-2:     #f8fafc;
  --border:        #e2e8f0;
  --border-strong: #cbd5e1;
  --text:          #0f172a;
  --text-soft:     #334155;
  --muted:         #64748b;
  --muted-2:       #94a3b8;

  /* Semantic */
  --primary:        var(--ocean-600);
  --primary-hover:  var(--ocean-700);
  --primary-soft:   var(--ocean-50);
  --accent:         var(--ocean-500);
  --success:        #10b981;
  --success-soft:   #ecfdf5;
  --success-border: #a7f3d0;
  --warn:           #f59e0b;
  --warn-soft:      #fffbeb;
  --warn-border:    #fde68a;
  --danger:         #ef4444;
  --danger-soft:    #fef2f2;
  --danger-border:  #fecaca;

  /* Geometry */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow:    0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 12px 32px -8px rgba(2, 132, 199, 0.18), 0 4px 12px -4px rgba(15, 23, 42, 0.08);
  --ring:      0 0 0 3px rgba(14, 165, 233, 0.18);

  /* Motion */
  --ease:     cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 150ms;

  /* Layout */
  --sidebar-w: 248px;
  --content-max: 1280px;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, "JetBrains Mono", Consolas, monospace;
}

/* =============================================================
   Base / Reset
   ============================================================= */

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

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg-soft);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, svg { max-width: 100%; vertical-align: middle; }

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--duration) var(--ease);
}
a:hover { color: var(--primary-hover); }

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.4em;
  color: var(--text-soft);
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

::selection {
  background: var(--ocean-200);
  color: var(--ocean-900);
}

/* =============================================================
   Typography
   ============================================================= */

h1, h2, h3, h4, h5, h6 {
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin: 0 0 0.75rem;
}

h1 {
  font-size: 1.75rem;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}
h2 {
  font-size: 1.25rem;
  margin: 1.75rem 0 0.85rem;
}
h3 { font-size: 1.05rem; }

p { margin: 0 0 0.85rem; }
p:last-child { margin-bottom: 0; }

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

/* =============================================================
   App layout — sidebar + main
   ============================================================= */

.nav-toggle { display: none; }

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0.75rem 1rem;
  z-index: 30;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.25rem 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.85rem;
}
.sidebar-brand .brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  color: #fff;
  background: linear-gradient(135deg, var(--ocean-500), var(--ocean-700));
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.15);
}
.sidebar-brand .brand-mark svg { width: 18px; height: 18px; }
.sidebar-brand .brand-name {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
  color: var(--text);
}
.sidebar-brand .brand-sub {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Sidebar nav */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}
.sidebar-section {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  padding: 0.85rem 0.85rem 0.4rem;
}
.sidebar-nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-soft);
  border-radius: var(--radius);
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}
.sidebar-nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--muted);
  transition: color var(--duration) var(--ease);
}
.sidebar-nav-link:hover {
  background: var(--bg-muted);
  color: var(--text);
  text-decoration: none;
}
.sidebar-nav-link:hover svg { color: var(--text-soft); }
.sidebar-nav-link.active,
.sidebar-nav-link[aria-current="page"] {
  background: var(--primary-soft);
  color: var(--ocean-800);
}
.sidebar-nav-link.active svg,
.sidebar-nav-link[aria-current="page"] svg { color: var(--ocean-600); }
.sidebar-nav-link.active::before,
.sidebar-nav-link[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -0.75rem;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--ocean-600);
}

/* Sidebar footer */
.sidebar-footer {
  border-top: 1px solid var(--border);
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.sidebar-footer .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ocean-100), var(--ocean-200));
  color: var(--ocean-800);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  border: 1px solid var(--ocean-200);
  flex-shrink: 0;
}
.sidebar-footer .user-meta {
  display: flex;
  flex-direction: column;
  font-size: 0.78rem;
  line-height: 1.25;
  flex: 1;
  min-width: 0;
}
.sidebar-footer .user-name {
  font-weight: 600;
  color: var(--text);
}
.sidebar-footer .user-role { color: var(--muted); font-size: 0.72rem; }
.sidebar-footer a.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--muted);
  border-radius: var(--radius-sm);
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}
.sidebar-footer a.icon-btn:hover {
  color: var(--danger);
  background: var(--danger-soft);
}
.sidebar-footer a.icon-btn svg { width: 16px; height: 16px; }

/* Main area */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.content {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 1.75rem 1.75rem 4rem;
}

/* Mobile topbar (hidden on desktop) */
.topbar-mobile {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.nav-toggle-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  transition: background var(--duration) var(--ease);
}
.nav-toggle-label:hover { background: var(--bg-muted); }
.nav-toggle-label svg { width: 18px; height: 18px; }
.topbar-mobile .brand-name {
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  z-index: 25;
}

@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .topbar-mobile { display: flex; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 220ms var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .nav-toggle:checked ~ .app .sidebar { transform: translateX(0); }
  .nav-toggle:checked ~ .nav-overlay { display: block; }
  .content { padding: 1.25rem 1rem 3rem; }
}

/* =============================================================
   Cards
   ============================================================= */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}

.card h2:first-child,
.card h3:first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

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

.card.feature {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.card.feature .feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--primary-soft);
  color: var(--ocean-700);
  margin-bottom: 0.25rem;
  border: 1px solid var(--ocean-100);
}
.card.feature .feature-icon svg { width: 20px; height: 20px; }
.card.feature h2 { font-size: 1rem; margin: 0; }

/* Stat numeric */
.stat-value {
  font-family: var(--font-sans);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.stat-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

/* =============================================================
   Hero (used for dashboard / login)
   ============================================================= */

.hero {
  margin-bottom: 1.75rem;
}
.hero h1 { margin-bottom: 0.35rem; }
.hero p { color: var(--muted); font-size: 0.95rem; max-width: 56ch; }

/* =============================================================
   Buttons
   ============================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.5rem 0.95rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--duration) var(--ease),
              border-color var(--duration) var(--ease),
              color var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease),
              transform var(--duration) var(--ease);
}
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn:hover {
  background: var(--bg-muted);
  border-color: var(--border-strong);
  color: var(--text);
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-color: var(--ocean-400);
}
.btn[disabled],
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}
.btn + .btn { margin-left: 0.4rem; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,0.15) inset, 0 1px 2px rgba(2, 132, 199, 0.25);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}
.btn-primary:focus-visible { box-shadow: var(--ring); }

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

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-soft);
}
.btn-ghost:hover { background: var(--bg-muted); color: var(--text); border-color: transparent; }

.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-block { width: 100%; }

/* Inline forms inside table cells / action groups */
.btn-row { display: inline-flex; gap: 0.4rem; flex-wrap: wrap; }

form.inline { display: inline; }

/* =============================================================
   Form controls
   ============================================================= */

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-soft);
  margin-bottom: 0.35rem;
}

.input, .select, .textarea,
input[type="text"].input,
input[type="password"].input,
input[type="email"].input,
input[type="number"].input,
input[type="search"].input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease), background var(--duration) var(--ease);
  appearance: none;
  -webkit-appearance: none;
}
.textarea {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  resize: vertical;
  min-height: 8rem;
}
.input::placeholder,
.textarea::placeholder { color: var(--muted-2); }

.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--ocean-400);
  box-shadow: var(--ring);
}

.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--bg-muted);
  color: var(--muted);
  cursor: not-allowed;
}

.select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 52%,
    calc(100% - 13px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}

.field { margin-bottom: 0.95rem; }
.field:last-child { margin-bottom: 0; }
.field-help {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0.35rem 0 0;
}

.form-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}
.form-row > .input,
.form-row > .select { flex: 1 1 auto; min-width: 160px; }

/* Database Manager: tab nav + log viewer */
.db-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0 1.25rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.log-view {
  margin: 0;
  padding: 1rem 1.1rem;
  max-height: 62vh;
  overflow: auto;
  background: var(--text);
  color: var(--ocean-100);
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Role binding rows: keep role select + db select + remove button inline */
.form-row.db-role-row { flex-wrap: nowrap; align-items: center; }
.form-row.db-role-row > .select { min-width: 0; flex: 1 1 0; }
.db-role-remove { flex: 0 0 auto; }

/* Auth/login layout */
.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(1200px 600px at 0% -10%, var(--ocean-100) 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 110%, var(--ocean-50) 0%, transparent 65%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 2rem 1.85rem;
}
.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1.4rem;
}
.auth-brand .brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--ocean-500), var(--ocean-700));
  color: #fff;
  box-shadow: 0 8px 20px -8px rgba(2, 132, 199, 0.55), inset 0 1px 0 rgba(255,255,255,0.2);
}
.auth-brand .brand-mark svg { width: 22px; height: 22px; }
.auth-brand h1 {
  margin: 0;
  font-size: 1.35rem;
  text-align: center;
}
.auth-brand p { margin: 0; color: var(--muted); font-size: 0.85rem; }

/* =============================================================
   Tables
   ============================================================= */

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  font-size: 0.9rem;
}
th, td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
th {
  background: var(--bg-muted);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
tbody tr {
  transition: background var(--duration) var(--ease);
}
tbody tr:hover { background: var(--ocean-50); }
tbody tr:last-child td { border-bottom: none; }

td code {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--text-soft);
}

.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--font-mono); font-size: 0.85rem; }

/* =============================================================
   Badges
   ============================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.55rem;
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.4;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--bg-muted);
  color: var(--text-soft);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.8;
}
.badge-plain::before { display: none; }

.badge-success {
  background: var(--success-soft);
  color: #047857;
  border-color: var(--success-border);
}
.badge-warn {
  background: var(--warn-soft);
  color: #b45309;
  border-color: var(--warn-border);
}
.badge-danger {
  background: var(--danger-soft);
  color: #b91c1c;
  border-color: var(--danger-border);
}
.badge-info {
  background: var(--ocean-50);
  color: var(--ocean-800);
  border-color: var(--ocean-200);
}
.badge-muted {
  background: var(--bg-muted);
  color: var(--muted);
  border-color: var(--border);
}

/* =============================================================
   Flash messages
   ============================================================= */

.flash {
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-left-width: 3px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
}
.flash code { background: rgba(15,23,42,0.05); }
.flash-error {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  border-left-color: var(--danger);
  color: #991b1b;
}
.flash-success {
  background: var(--success-soft);
  border-color: var(--success-border);
  border-left-color: var(--success);
  color: #065f46;
}
.flash-warn {
  background: var(--warn-soft);
  border-color: var(--warn-border);
  border-left-color: var(--warn);
  color: #92400e;
}
.flash-info {
  background: var(--ocean-50);
  border-color: var(--ocean-200);
  border-left-color: var(--ocean-500);
  color: var(--ocean-900);
}

/* =============================================================
   Code / pre blocks
   ============================================================= */

.codeblock {
  display: block;
  background: var(--bg-muted);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.825rem;
  line-height: 1.5;
  white-space: pre;
  overflow: auto;
  max-height: 75vh;
  margin: 0 0 1rem;
  -webkit-overflow-scrolling: touch;
}
.codeblock-sm {
  font-size: 0.75rem;
  padding: 0.65rem 0.8rem;
  max-height: 220px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* details / summary refinement */
details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 1rem;
  overflow: hidden;
}
details > summary {
  cursor: pointer;
  padding: 0.6rem 0.85rem;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text-soft);
  list-style: none;
  user-select: none;
  background: var(--surface-2);
  border-bottom: 1px solid transparent;
  transition: background var(--duration) var(--ease);
}
details > summary::-webkit-details-marker { display: none; }
details[open] > summary {
  border-bottom-color: var(--border);
  background: var(--bg-muted);
}
details > summary:hover { background: var(--bg-muted); }
details > *:not(summary) { padding: 0.85rem; }
details > .codeblock { margin: 0; border: none; border-radius: 0; }

/* =============================================================
   Page-level helpers
   ============================================================= */

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.page-header h1 { margin: 0; }
.page-header .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.875rem;
}
.toolbar .sep { color: var(--muted-2); }

.empty {
  text-align: center;
  padding: 2.5rem 1.5rem !important;
  color: var(--muted);
}

.tag-mono {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}

/* =============================================================
   Reduced-motion
   ============================================================= */

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

/* =============================================================
   Tabs (CSS-only, used by compose new page)
   ============================================================= */

.tab-radio { display: none; }

.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.25rem;
}
.tab-label {
  display: inline-flex;
  align-items: center;
  padding: 0.6rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--duration) var(--ease), border-color var(--duration) var(--ease);
  user-select: none;
}
.tab-label:hover {
  color: var(--text);
}

.tab-panel { display: none; }

#tab-templates:checked ~ .tab-bar [for="tab-templates"],
#tab-wizard:checked ~ .tab-bar [for="tab-wizard"],
#tab-editor:checked ~ .tab-bar [for="tab-editor"] {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

#tab-templates:checked ~ #panel-templates,
#tab-wizard:checked ~ #panel-wizard,
#tab-editor:checked ~ #panel-editor {
  display: block;
}

#ws-tab-static:checked ~ .tab-bar [for="ws-tab-static"],
#ws-tab-node:checked ~ .tab-bar [for="ws-tab-node"] {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

#ws-tab-static:checked ~ #ws-panel-static,
#ws-tab-node:checked ~ #ws-panel-node {
  display: block;
}

/* =============================================================
   Template card grid
   ============================================================= */

.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.tpl-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.1rem 1.25rem;
}
.tpl-card h3 { margin: 0; font-size: 1rem; }
.tpl-card p { font-size: 0.85rem; margin: 0; flex: 1; }
.tpl-card .badge { align-self: flex-start; }
.tpl-icon {
  font-size: 1.5rem;
  line-height: 1;
  margin-bottom: 0.25rem;
}

/* =============================================================
   Images page
   ============================================================= */

.img-repo { font-weight: 600; color: var(--text); }
.img-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.45rem;
  font-size: 0.74rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  background: var(--ocean-50);
  color: var(--ocean-800);
  border: 1px solid var(--ocean-200);
  font-family: var(--font-mono);
  margin-left: 0.35rem;
}
.img-tag-none {
  background: var(--bg-muted);
  color: var(--muted);
  border-color: var(--border);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 3rem 2rem;
  text-align: center;
}
.empty-state svg {
  width: 48px;
  height: 48px;
  color: var(--muted-2);
  margin-bottom: 0.25rem;
}
.empty-state h3 {
  margin: 0;
  color: var(--text-soft);
}
.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  max-width: 36ch;
}

/* =============================================================
   Pull dialog (side-by-side layout)
   ============================================================= */

#pull-dialog {
  max-width: 920px;
  padding: 0;
  max-height: 80vh;
}
#pull-dialog[open] {
  display: flex;
  flex-direction: column;
}
#pull-dialog-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.pull-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.pull-dialog-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.pull-dialog-left {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  padding: 0.75rem;
}
.pull-dialog-list {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.pull-dialog-right {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
}
.pull-dialog-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-muted);
}
.pull-dialog-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 2rem 1rem;
  text-align: center;
}

/* Left panel list items */
.pull-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--duration) var(--ease);
  font-size: 0.84rem;
}
.pull-list-item:last-child { border-bottom: none; }
.pull-list-item:hover { background: var(--ocean-50); }
.pull-list-item.active {
  background: var(--ocean-100);
  border-left: 2px solid var(--primary);
}
.pull-list-name {
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pull-list-stats {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.pull-list-pulls {
  font-size: 0.7rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.search-result-stars {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}
.search-result-stars svg {
  width: 11px;
  height: 11px;
  color: var(--warn);
}

/* Right panel detail */
.detail-header { margin-bottom: 0.5rem; }
.detail-desc {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 0.75rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}
.detail-tags-section { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.detail-tag-list {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.tag-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--duration) var(--ease);
}
.tag-row:last-child { border-bottom: none; }
.tag-row:hover { background: var(--ocean-50); }
.tag-row-name { font-size: 0.82rem; }
.tag-row-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}
.tag-row-date {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}
.tag-row-size {
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Responsive: stack on small screens */
@media (max-width: 640px) {
  #pull-dialog { max-width: calc(100% - 1rem); }
  .pull-dialog-body { flex-direction: column; }
  .pull-dialog-left {
    width: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 200px;
  }
}

/* Pull progress */
.pull-progress {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.pull-progress-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.pull-progress-body {
  flex: 1;
  padding: 1.25rem;
  overflow-y: auto;
}
.pull-progress-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg-muted);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 300ms var(--ease);
  min-width: 0;
}
.pull-layers {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.pull-layer-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.3rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
.pull-layer-row:last-child { border-bottom: none; }

/* =============================================================
   Print
   ============================================================= */

@media print {
  .sidebar, .topbar-mobile, .nav-overlay { display: none !important; }
  .app { display: block; }
  .content { max-width: none; padding: 0; }
}

/* =============================================================
   Dashboard (live home page)
   ============================================================= */

.dash-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  background:
    radial-gradient(800px 300px at 0% 0%, var(--ocean-50) 0%, transparent 60%),
    linear-gradient(180deg, var(--surface) 0%, var(--surface) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.dash-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(2px 2px at 12% 30%, rgba(14,165,233,0.08), transparent 50%),
    radial-gradient(2px 2px at 80% 70%, rgba(14,165,233,0.06), transparent 50%);
  pointer-events: none;
}
.dash-hero-main { min-width: 0; flex: 1 1 320px; position: relative; z-index: 1; }
.dash-hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.18rem 0.6rem 0.18rem 0.55rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 0.65rem;
}
.dash-hero-title {
  font-size: 1.7rem;
  letter-spacing: -0.02em;
  margin: 0 0 0.25rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}
.dash-hero-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.dash-hero-sub strong {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.dash-hero-sep { color: var(--muted-2); margin: 0 0.4rem; }

.dash-hero-stats {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}
.dash-hero-stat {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.55rem 0.95rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 88px;
}
.dash-hero-stat-label {
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.dash-hero-stat-value {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
  animation: dash-pulse 1.6s var(--ease) infinite;
}
@keyframes dash-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45); }
  70%  { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.kpi-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem 1.1rem 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
  min-height: 168px;
}
.kpi-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}
.kpi-head {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
}
.kpi-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.kpi-sub {
  font-size: 0.74rem;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-value-row { display: flex; align-items: baseline; }
.kpi-value {
  font-size: 2.15rem;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.025em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.kpi-unit {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
  margin-left: 0.18rem;
  letter-spacing: 0;
}
.kpi-spark {
  margin: 0 -1.1rem;
  height: 60px;
  display: block;
}
.kpi-spark .spark-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.dash-updated {
  font-size: 0.78rem;
  margin: 0.5rem 0 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.65rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.quick-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-soft);
  transition: background var(--duration) var(--ease),
              border-color var(--duration) var(--ease),
              transform var(--duration) var(--ease);
}
.quick-link:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
  text-decoration: none;
  transform: translateY(-1px);
}
.quick-link-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--ocean-700);
  border: 1px solid var(--ocean-100);
  flex-shrink: 0;
}
.quick-link-icon svg { width: 16px; height: 16px; }
.quick-link-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.quick-link-title {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
}
.quick-link-sub {
  font-size: 0.72rem;
  color: var(--muted);
}

@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-hero { padding: 1rem 1.1rem; }
  .dash-hero-title { font-size: 1.4rem; }
  .kpi-card { min-height: 152px; padding: 0.85rem 0.95rem 0; }
  .kpi-spark { margin: 0 -0.95rem; }
  .kpi-value { font-size: 1.85rem; }
}
@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; box-shadow: 0 0 0 3px rgba(16,185,129,0.18); }
  .quick-link:hover { transform: none; }
}

/* =============================================================
   Dialog / Modal
   ============================================================= */

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  max-width: 480px;
  width: calc(100% - 2rem);
  color: var(--text);
}
dialog::backdrop {
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
}
dialog h2 { margin-top: 0; }
dialog .dialog-footer {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

/* =============================================================
   Recent requests log (Traffic show page)
   ============================================================= */

.req-log-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-top: 0.5rem;
}

.req-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.95rem 1.1rem;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border-bottom: 1px solid var(--border);
}

.req-log-title {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  min-width: 0;
}

.req-log-heading {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.req-log-count {
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding: 0.12rem 0.5rem;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.req-log-controls {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
  align-items: center;
}

.req-log-chip-group {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.35rem 0.2rem 0.65rem;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.req-log-chip-label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-right: 0.15rem;
}

.req-log-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.95rem;
  padding: 0.22rem 0.6rem;
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}
.req-log-chip:hover {
  background: var(--surface);
  color: var(--text-soft);
  text-decoration: none;
}
.req-log-chip-active,
.req-log-chip-active:hover {
  background: var(--surface);
  color: var(--ocean-700);
  box-shadow: var(--shadow-xs), inset 0 0 0 1px var(--ocean-200);
}

.req-log-empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.req-log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 640px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

.req-log-row {
  display: grid;
  grid-template-columns:
    [time] 9.5rem
    [method] 4rem
    [path] minmax(0, 1fr)
    [status] auto
    [dur] auto
    [bytes] auto
    [actions] auto;
  align-items: center;
  column-gap: 0.85rem;
  row-gap: 0.3rem;
  padding: 0.7rem 1.1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  transition: background var(--duration) var(--ease);
  position: relative;
}
.req-log-row:last-child { border-bottom: none; }
.req-log-row:hover { background: var(--ocean-50); }

.req-log-time {
  grid-column: time;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.req-log-method {
  grid-column: method;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.16rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  text-transform: uppercase;
  width: fit-content;
  justify-self: start;
}
.req-log-method-get {
  background: var(--ocean-50);
  color: var(--ocean-800);
  border-color: var(--ocean-200);
}
.req-log-method-post {
  background: var(--success-soft);
  color: #047857;
  border-color: var(--success-border);
}
.req-log-method-put,
.req-log-method-patch {
  background: var(--warn-soft);
  color: #b45309;
  border-color: var(--warn-border);
}
.req-log-method-delete {
  background: var(--danger-soft);
  color: #b91c1c;
  border-color: var(--danger-border);
}
.req-log-method-other {
  background: var(--bg-muted);
  color: var(--muted);
  border-color: var(--border);
}

.req-log-path {
  grid-column: path;
  font-family: var(--font-mono);
  font-size: 0.83rem;
  color: var(--text);
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.req-log-status { grid-column: status; }

.req-log-dur {
  grid-column: dur;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
  min-width: 4.5rem;
}

.req-log-bytes {
  grid-column: bytes;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
  min-width: 4.5rem;
}

.req-log-meta {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  min-width: 0;
  padding-left: calc(9.5rem + 4rem + 1.7rem);
  color: var(--muted);
}

.req-log-meta-item {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  min-width: 0;
  font-size: 0.74rem;
  font-family: var(--font-mono);
}
.req-log-meta-flex { flex: 1 1 0; min-width: 0; }

.req-log-meta-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--muted-2);
  text-transform: uppercase;
  flex-shrink: 0;
}

.req-log-meta-value {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

@media (max-width: 1024px) {
  .req-log-row {
    grid-template-columns:
      [time] auto
      [method] auto
      [path] minmax(0, 1fr)
      [status] auto
      [actions] auto;
    column-gap: 0.6rem;
  }
  .req-log-dur,
  .req-log-bytes {
    grid-column: 1 / -1;
    text-align: left;
    display: inline-flex;
    gap: 0.85rem;
  }
  .req-log-dur { grid-row: auto; order: 1; }
  .req-log-bytes { display: none; }
  .req-log-meta {
    padding-left: 0;
    flex-wrap: wrap;
    gap: 0.6rem 1rem;
  }
}

@media (max-width: 640px) {
  .req-log-header {
    padding: 0.85rem 0.95rem;
  }
  .req-log-row {
    padding: 0.7rem 0.95rem;
    grid-template-columns: auto auto 1fr auto auto;
  }
  .req-log-time { font-size: 0.74rem; }
  .req-log-path { font-size: 0.8rem; }
  .req-log-meta {
    font-size: 0.72rem;
  }
}

/* =============================================================
   Traffic — filter form & per-row actions
   ============================================================= */

.req-log-filters {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(140px, 1fr) minmax(180px, 2fr) auto;
  gap: 0.6rem 0.85rem;
  align-items: end;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-muted);
}
.req-log-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}
.req-log-field-grow { min-width: 0; }
.req-log-field-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.req-log-input {
  width: 100%;
  padding: 0.4rem 0.65rem;
  font-size: 0.82rem;
  font-family: var(--font-mono);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.req-log-input:focus {
  border-color: var(--ocean-500, #0284c7);
  box-shadow: 0 0 0 3px var(--ring, rgba(2, 132, 199, 0.15));
}
.req-log-field-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.req-log-actions {
  grid-column: actions;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}
.req-log-mini-form {
  display: inline-flex;
  margin: 0;
}
.req-log-mini-btn {
  padding: 0.22rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
  transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease), color var(--duration) var(--ease);
}
.req-log-mini-btn:hover {
  background: var(--bg-muted);
  border-color: var(--text-soft);
  color: var(--text);
}
.req-log-mini-btn-danger {
  color: #b91c1c;
  border-color: var(--danger-border, #fecaca);
  background: var(--danger-soft, #fef2f2);
}
.req-log-mini-btn-danger:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}
.req-log-mini-link {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.45rem;
  font-size: 0.72rem;
  color: var(--muted);
  text-decoration: none;
  border-radius: var(--radius-sm, 6px);
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}
.req-log-mini-link:hover {
  background: var(--bg-muted);
  color: var(--text);
  text-decoration: none;
}

@media (max-width: 768px) {
  .req-log-filters {
    grid-template-columns: 1fr 1fr;
  }
  .req-log-field-grow { grid-column: 1 / -1; }
  .req-log-field-actions { grid-column: 1 / -1; justify-content: flex-end; }
}

.req-log-row-clickable { cursor: pointer; }
.req-log-row-clickable:focus-within { background: var(--ocean-50); outline: 0; }
.req-log-row-clickable:active { background: var(--ocean-100, #e0f2fe); }

[data-viewer-only] { display: none !important; }
.is-viewer-ip [data-viewer-only],
[data-viewer-only].is-viewer-ip { display: inline-flex !important; }
.is-viewer-ip [data-viewer-hidden] { display: none !important; }

.hide-viewer-rows .req-log-row.is-viewer-ip { display: none !important; }

.req-log-you-tag {
  margin-left: 0.25rem;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.req-log-you-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ocean-700, #0369a1);
  background: var(--ocean-50);
  border: 1px solid var(--ocean-200, #bae6fd);
  border-radius: var(--radius-sm, 6px);
  cursor: default;
}

.req-detail-modal {
  width: min(720px, 92vw);
  max-height: 86vh;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 24px 48px -12px rgba(15, 23, 42, 0.25);
  color: var(--text);
}
.req-detail-modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}
.req-detail-modal[open] {
  animation: req-detail-pop 160ms var(--ease, cubic-bezier(0.2, 0, 0.2, 1));
}
@keyframes req-detail-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.req-detail {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.2rem 1.35rem 1.35rem;
  max-height: 86vh;
  overflow-y: auto;
}
.req-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
}
.req-detail-headline {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.req-detail-close {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 6px);
  background: var(--surface);
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}
.req-detail-close:hover { background: var(--bg-muted); color: var(--text); }

.req-detail-path {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
}
.req-detail-query {
  font-size: 0.82rem;
  color: var(--muted);
  word-break: break-all;
}

.req-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem 1rem;
  margin: 0;
  padding: 0.85rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.req-detail-field { display: flex; flex-direction: column; gap: 0.18rem; min-width: 0; }
.req-detail-field-wide { grid-column: 1 / -1; }
.req-detail-field dt {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.req-detail-field dd {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text);
  word-break: break-all;
  white-space: pre-wrap;
}

.req-detail-footer {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

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

/* =============================================================
   Traffic chart (requests over time)
   ============================================================= */

.traffic-chart {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.traffic-chart-plot {
  position: relative;
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 0.5rem;
  height: 220px;
}

.traffic-chart-yaxis {
  position: relative;
  height: 100%;
}

.traffic-chart-ytick {
  position: absolute;
  right: 0;
  transform: translateY(50%);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  line-height: 1;
  white-space: nowrap;
  padding-right: 2px;
}

.traffic-chart-canvas {
  position: relative;
  height: 100%;
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 0 var(--radius-sm) 0 0;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(14, 165, 233, 0.05), transparent 70%),
    linear-gradient(180deg, var(--surface) 0%, var(--ocean-50) 120%);
  overflow: hidden;
  cursor: crosshair;
}

.traffic-chart-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.traffic-chart-grid line {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 2 4;
  opacity: 0.7;
  vector-effect: non-scaling-stroke;
}

.traffic-chart-area {
  transition: opacity var(--duration) var(--ease);
}

.traffic-chart-canvas:hover .traffic-chart-area {
  opacity: 0.85;
}

.traffic-chart-line {
  filter: drop-shadow(0 1px 2px rgba(2, 132, 199, 0.25));
}

.traffic-chart-hits rect {
  transition: fill var(--duration) var(--ease);
}

.traffic-chart-hits rect:hover {
  fill: rgba(14, 165, 233, 0.08);
}

.traffic-chart-pulse {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
  transform: translate(-50%, 50%);
}

.traffic-chart-pulse-ring,
.traffic-chart-pulse-dot {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.traffic-chart-pulse-ring {
  width: 18px;
  height: 18px;
  background: rgba(14, 165, 233, 0.35);
  animation: traffic-chart-pulse 1.8s ease-out infinite;
}

.traffic-chart-pulse-dot {
  width: 8px;
  height: 8px;
  background: var(--ocean-500);
  box-shadow: 0 0 0 2px var(--surface), 0 0 8px rgba(14, 165, 233, 0.5);
}

@keyframes traffic-chart-pulse {
  0%   { transform: translate(-50%, -50%) scale(0.6); opacity: 0.7; }
  80%  { transform: translate(-50%, -50%) scale(2.4); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(2.4); opacity: 0; }
}

.traffic-chart-xaxis {
  position: relative;
  height: 1.1rem;
  margin-left: calc(44px + 0.5rem);
}

.traffic-chart-xtick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  line-height: 1;
  white-space: nowrap;
}

.traffic-chart-xtick:first-child { transform: translateX(0); }
.traffic-chart-xtick:last-child  { transform: translateX(-100%); }

.traffic-chart-caption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.traffic-chart-caption .sep { color: var(--border-strong); }
.traffic-chart-caption strong { color: var(--text-soft); font-weight: 600; }

.traffic-chart-live {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ocean-700);
}

.traffic-chart-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ocean-500);
  box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.6);
  animation: traffic-chart-live 1.6s ease-out infinite;
}

@keyframes traffic-chart-live {
  0%   { box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.55); }
  70%  { box-shadow: 0 0 0 6px rgba(14, 165, 233, 0); }
  100% { box-shadow: 0 0 0 0 rgba(14, 165, 233, 0); }
}

@media (max-width: 640px) {
  .traffic-chart-plot { height: 180px; grid-template-columns: 36px 1fr; }
  .traffic-chart-xaxis { margin-left: calc(36px + 0.5rem); }
  .traffic-chart-xtick:nth-child(2),
  .traffic-chart-xtick:nth-child(4) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .traffic-chart-pulse-ring,
  .traffic-chart-live-dot { animation: none; }
}

/* =============================================================
   Domain Proxy pages
   ============================================================= */

.muted-sm { color: var(--muted); font-size: 0.82rem; margin: 0.2rem 0 0; }

.crumbs {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.2rem;
}
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text-soft); text-decoration: underline; }
.crumbs .sep { color: var(--muted-2); margin: 0 0.15rem; }

.card-head {
  margin-bottom: 1.1rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}
.card-head h2 { margin: 0; font-size: 1.02rem; }
.card-head .muted-sm { margin-top: 0.3rem; }

.card-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1.1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.card-flush { padding: 0; overflow: hidden; }
.card-flush .table-clean { margin: 0; }

.table-clean { width: 100%; border-collapse: collapse; }
.table-clean th {
  text-align: left;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-muted);
}
.table-clean td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table-clean tbody tr:last-child td { border-bottom: none; }
.table-clean tbody tr:hover { background: var(--bg-muted); }

.route-domain strong { font-weight: 600; }
.route-sub { margin-top: 0.15rem; }

/* Labeled form rows: fields sit side-by-side but keep their own labels. */
.form-row-labeled {
  align-items: flex-end;
  gap: 0.75rem;
}
.form-row-labeled .field { margin-bottom: 0; flex: 1 1 200px; }
.form-row-labeled .field-port { flex: 0 1 200px; }
.form-row-labeled .field-prefix { flex: 0 1 160px; }
.form-row-labeled .field-submit { flex: 0 0 auto; }

/* Sub-path visual map (prefix → upstream). */
.path-map {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0.25rem 0 1.25rem;
}
.path-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.path-row-default {
  background: var(--bg-muted);
  border-style: dashed;
}
.path-prefix {
  min-width: 90px;
  font-weight: 600;
  color: var(--ocean-700);
}
.path-arrow { color: var(--muted-2); }
.path-target { flex: 1 1 auto; display: inline-flex; align-items: center; gap: 0.3rem; }
.path-tag {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.68rem;
}
.path-actions { margin-left: auto; }
.path-empty {
  padding: 1.1rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-muted);
}

.subpath-add {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* Container vs URL target segmented toggle. */
.target-tabs {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  margin: 0.25rem 0 0.9rem;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.target-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.target-tab input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}
.target-tab span {
  padding: 0.35rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  border-radius: calc(var(--radius) - 3px);
  transition: background 0.12s, color 0.12s;
}
.target-tab input:checked + span {
  background: var(--bg);
  color: var(--ocean-700);
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(15, 23, 42, 0.08));
}
.target-tab input:focus-visible + span { box-shadow: var(--ring); }

.hint-list {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.hint-list li { line-height: 1.45; }

.check-inline {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 0.85rem;
  font-size: 0.85rem;
  color: var(--text-soft);
  cursor: pointer;
}
.check-inline input { margin-top: 0.2rem; flex-shrink: 0; }
.check-inline .muted-sm { display: inline; }

.auth-match {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.auth-match .muted-sm { display: inline; }
.select-inline {
  width: auto;
  padding: 0.25rem 1.8rem 0.25rem 0.6rem;
  font-size: 0.82rem;
}

@media (max-width: 640px) {
  .form-row-labeled { flex-direction: column; align-items: stretch; }
  .form-row-labeled .field { flex: 1 1 auto; }
  .path-row { flex-wrap: wrap; }
  .path-prefix { min-width: 0; }
}
