:root {
  --bg: #0b1017;
  --bg-elevated: #121a24;
  --card: rgba(26, 35, 50, 0.72);
  --card-solid: #1a2332;
  --border: rgba(45, 58, 77, 0.9);
  --border-soft: rgba(255, 255, 255, 0.06);
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --primary: #3b82f6;
  --primary-glow: rgba(59, 130, 246, 0.35);
  --danger: #ef4444;
  --success: #22c55e;
  --warn: #f59e0b;
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.28);
  --glass-blur: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans SC", sans-serif;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(59, 130, 246, 0.12), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(99, 102, 241, 0.08), transparent 50%),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.hidden { display: none !important; }
.error { color: var(--danger); }
.success { color: var(--success); }

/* —— Layout shell —— */
.app-layout {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.sidebar {
  width: var(--sidebar-w);
  background: rgba(18, 26, 36, 0.92);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1rem 0;
  padding-bottom: calc(1rem + var(--safe-bottom));
  flex-shrink: 0;
  z-index: 40;
}

.brand {
  padding: 0.25rem 1.15rem 1.15rem;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.brand strong {
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.side-nav {
  display: flex;
  flex-direction: column;
  padding: 0.85rem 0.65rem;
  flex: 1;
  gap: 0.2rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.side-nav a {
  padding: 0.7rem 0.9rem;
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--muted);
  border-radius: 10px;
  border-left: none;
  position: relative;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.side-nav a:hover {
  background: rgba(255, 255, 255, 0.04);
  text-decoration: none;
  color: var(--text);
}

.side-nav a.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.22), rgba(59, 130, 246, 0.08));
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.35), 0 0 20px rgba(59, 130, 246, 0.08);
}

.side-nav a.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
}

.sidebar-footer {
  padding: 1rem 1.15rem;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-footer .link-btn {
  min-height: 44px;
  padding: 0.5rem 0;
}

.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.page-header {
  padding: 1.1rem 1.5rem;
  padding-top: calc(1.1rem + var(--safe-top));
  border-bottom: 1px solid var(--border-soft);
  background: rgba(18, 26, 36, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.page-header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.page-content {
  padding: 1.5rem;
  padding-bottom: calc(1.5rem + var(--safe-bottom));
  flex: 1;
}

/* —— Mobile top bar / drawer —— */
.mobile-topbar {
  display: none;
}

.sidebar-overlay {
  display: none;
}

.menu-toggle {
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.menu-toggle:hover { opacity: 1; background: rgba(255, 255, 255, 0.1); }

.menu-toggle-bars,
.menu-toggle-bars::before,
.menu-toggle-bars::after {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  position: relative;
  transition: transform 0.25s ease, opacity 0.2s ease;
}

.menu-toggle-bars::before,
.menu-toggle-bars::after {
  content: "";
  position: absolute;
  left: 0;
}

.menu-toggle-bars::before { top: -6px; }
.menu-toggle-bars::after { top: 6px; }

body.sidebar-open .menu-toggle-bars { background: transparent; }
body.sidebar-open .menu-toggle-bars::before {
  top: 0;
  transform: rotate(45deg);
}
body.sidebar-open .menu-toggle-bars::after {
  top: 0;
  transform: rotate(-45deg);
}

/* —— Cards —— */
.card {
  background: var(--card);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1.15rem 1.35rem;
  margin-bottom: 1.15rem;
  box-shadow: var(--shadow-card);
}

.card h2 {
  margin: 0 0 0.85rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.15rem;
}

.stat-card {
  background: var(--card);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.stat-card:hover {
  border-color: rgba(59, 130, 246, 0.35);
}

.stat-label { color: var(--muted); font-size: 0.85rem; }
.stat-value { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; }
.stat-value.stat-small { font-size: 0.95rem; font-weight: 500; }

.service-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.badge {
  display: inline-block;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.85rem;
}
.badge.ok { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.badge.err { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge.warn { background: rgba(245, 158, 11, 0.15); color: var(--warn); }

/* —— Tables —— */
.table-wrap {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  margin: 0;
  padding-bottom: 0.15rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 520px;
}

th, td {
  padding: 0.75rem 0.65rem;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

td { min-width: 72px; }

.warn-cell { color: var(--warn); }

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

.trend-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.trend-label { font-size: 0.85rem; color: var(--muted); }

.trend-svg {
  width: 100%;
  height: 60px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
}

.trend-stat { font-size: 0.8rem; color: var(--muted); }

.trend-range.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 16px var(--primary-glow);
}

.disk-usage-block { margin-bottom: 1.25rem; }
.disk-usage-block h3 {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.disk-usage-block table,
.disk-usage-table {
  width: 100%;
  font-size: 0.85rem;
  min-width: 0;
}
.disk-usage-table .path-cell {
  max-width: 28rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  color: var(--muted);
}

#disk-table {
  min-width: 0;
}

/* —— Modals —— */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: max(1rem, var(--safe-top)) max(1rem, var(--safe-right)) max(1rem, var(--safe-bottom)) max(1rem, var(--safe-left));
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--card-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(900px, 100%);
  max-height: min(90vh, 900px);
  max-height: min(90dvh, 900px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}
.modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  -webkit-overflow-scrolling: touch;
}
.modal-footer {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-soft);
  background: var(--card-solid);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-soft);
  gap: 0.75rem;
}
.modal-header .link-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0.5rem 0.75rem;
}
.conf-pre {
  margin: 0;
  padding: 1rem;
  overflow: auto;
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 65vh;
}
.modal-wide { max-width: 960px; width: 92vw; }
.conf-editor {
  width: 100%;
  min-height: 360px;
  max-height: 65vh;
  margin: 0;
  padding: 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.45;
  border: none;
  background: #0d1117;
  color: var(--text);
  resize: vertical;
  box-sizing: border-box;
}
.create-site-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
#create-modal .conf-editor {
  min-height: 160px;
  max-height: 28vh;
  margin-top: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}
#create-modal .narrow-form label { margin-bottom: 0.75rem; }
#create-modal .narrow-form input {
  max-width: none;
}
.delete-preview {
  margin: 0.75rem 0 1rem;
  padding-left: 1.2rem;
  font-size: 0.85rem;
}
.delete-preview code { word-break: break-all; }
button.danger, .danger-text { color: var(--danger); }
button.danger { border: 1px solid rgba(239, 68, 68, 0.35); background: rgba(239, 68, 68, 0.12); }

.console-input { min-height: 100px; margin-top: 0.35rem; }
.console-form label { display: block; margin-bottom: 0.75rem; }
#console-output { min-height: 320px; max-height: 60vh; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.console-prompt { color: var(--primary); margin-top: 0.75rem; font-weight: 600; }
.console-stderr { color: var(--danger); }
.console-meta { color: var(--muted); font-size: 0.8rem; margin-bottom: 0.5rem; }

.muted-box { border-style: dashed; }

/* —— Buttons / forms —— */
button, .link-btn {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid transparent;
  padding: 0.55rem 1rem;
  min-height: 44px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}
button.primary {
  background: var(--primary);
  box-shadow: 0 4px 16px var(--primary-glow);
}
button:hover { opacity: 0.92; }
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.link-btn {
  background: transparent;
  padding: 0;
  text-align: left;
  min-height: auto;
  border: none;
}

.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(1rem, var(--safe-top)) max(1rem, var(--safe-right)) max(1rem, var(--safe-bottom)) max(1rem, var(--safe-left));
}

.auth-card {
  width: min(400px, 92vw);
  background: var(--card);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: var(--shadow-card), 0 0 60px rgba(59, 130, 246, 0.08);
}

.auth-card h1 { margin: 0 0 0.25rem; font-size: 1.35rem; }
.auth-card label { display: block; margin: 1rem 0 0.35rem; font-size: 0.9rem; color: var(--muted); }
.auth-card input {
  width: 100%;
  padding: 0.7rem 0.75rem;
  min-height: 44px;
  font-size: 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.auth-card button {
  width: 100%;
  margin-top: 1.25rem;
  min-height: 48px;
  font-size: 1rem;
}

.narrow-form label { display: block; margin-bottom: 0.75rem; }
.narrow-form input,
.narrow-form select,
.toolbar select,
.toolbar input[type="text"],
.toolbar input[type="search"],
.toolbar input[type="password"],
.toolbar input[type="datetime-local"],
input[type="text"],
input[type="password"],
input[type="datetime-local"],
select,
textarea {
  font-size: 16px;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 0.5rem 0.65rem;
}

/* Compact filter chip (证书临期 etc.) */
.filter-chip {
  display: inline-flex !important;
  align-items: center;
  gap: 0.45rem;
  min-height: 34px !important;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.filter-chip input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  min-width: 1rem;
  min-height: 1rem !important;
  margin: 0;
  padding: 0;
  accent-color: var(--primary);
  border-radius: 4px;
  flex-shrink: 0;
}

.filter-chip:has(input:checked) {
  border-color: rgba(59, 130, 246, 0.55);
  background: rgba(59, 130, 246, 0.14);
  color: var(--text);
}

.filter-chip span { line-height: 1.2; }

/* Table / row action button groups */
.table-actions,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  max-width: 16rem;
}

.table-actions button,
.row-actions button,
.row-actions .link-btn,
.table-actions .link-btn {
  min-height: 30px;
  min-width: 0;
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
  border-radius: 6px;
  white-space: nowrap;
  line-height: 1.2;
}

.row-actions .link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-soft);
  padding: 0.25rem 0.55rem;
  color: var(--text);
  text-decoration: none;
}

.row-actions .link-btn.danger-text,
.row-actions .danger-text {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
}
.narrow-form input {
  display: block;
  width: 100%;
  max-width: 320px;
  margin-top: 0.35rem;
}

.config-dl { display: grid; grid-template-columns: 120px 1fr; gap: 0.5rem 1rem; }
.config-dl dt { color: var(--muted); }
.config-dl dd { margin: 0; }

.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 16px var(--primary-glow);
}
.btn-link:hover { text-decoration: none; opacity: 0.9; }

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

.service-card {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 1rem;
  background: rgba(0, 0, 0, 0.2);
}

.service-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  gap: 0.5rem;
}

.service-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.service-card-actions button {
  min-height: 40px;
}

.service-card-actions button.danger {
  background: rgba(239, 68, 68, 0.25);
  color: var(--danger);
}

.cmd-output {
  margin: 0;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 240px;
  overflow: auto;
}

.cmd-output.output-ok { border-color: var(--success); }
.cmd-output.output-err { border-color: var(--danger); color: var(--danger); }

.status-ok { color: var(--success); }
.status-err { color: var(--danger); }

.audit-msg {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  margin-bottom: 1rem;
}

.toolbar label {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  min-height: 34px;
}

/* —— SSL iframe —— */
.iframe-wrap {
  height: calc(100vh - 140px);
  height: calc(100dvh - 140px);
  min-height: 320px;
  position: relative;
  padding: 0.75rem !important;
  display: flex;
  flex-direction: column;
}
.iframe-wrap iframe {
  width: 100%;
  flex: 1;
  min-height: 280px;
  height: 100%;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: #fff;
}
.iframe-fallback { margin-top: 1rem; }

/* —— Mobile ≤768px —— */
@media (max-width: 768px) {
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    height: calc(var(--topbar-h) + var(--safe-top));
    padding: var(--safe-top) max(0.75rem, var(--safe-right)) 0 max(0.75rem, var(--safe-left));
    background: rgba(11, 16, 23, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border-soft);
  }

  .mobile-topbar-title {
    font-size: 1rem;
    letter-spacing: 0.01em;
  }

  .mobile-topbar-spacer {
    width: 44px;
    margin-left: auto;
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  body.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

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

  body.sidebar-open .sidebar-overlay:not([hidden]) {
    display: block;
  }

  .app-layout {
    flex-direction: column;
    padding-top: calc(var(--topbar-h) + var(--safe-top));
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(var(--sidebar-w), 86vw);
    max-width: 300px;
    padding-top: calc(0.75rem + var(--safe-top));
    transform: translateX(-105%);
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 55;
    border-right: 1px solid var(--border);
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.4);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  /* When GSAP drives transform, CSS transition should not fight it */
  body.sidebar-open .sidebar,
  .sidebar.gsap-active {
    transition: none;
  }

  .page-header {
    position: static;
    padding: 0.65rem 0.85rem;
  }

  .page-header h1 {
    font-size: 1.15rem;
  }

  .page-content {
    padding: 0.75rem;
  }

  .card {
    padding: 0.75rem;
    border-radius: 12px;
    margin-bottom: 0.75rem;
  }

  .card h2 {
    margin-bottom: 0.55rem;
    font-size: 0.95rem;
  }

  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.75rem;
  }

  .stat-card {
    padding: 0.55rem 0.65rem;
    gap: 0.15rem;
    border-radius: 10px;
    min-height: 0;
  }

  .stat-label {
    font-size: 0.72rem;
    line-height: 1.25;
  }

  .stat-value {
    font-size: 1.15rem;
  }

  .stat-value.stat-small {
    font-size: 0.82rem;
  }

  .config-dl {
    grid-template-columns: 1fr;
    gap: 0.25rem 0;
  }

  .config-dl dt { margin-top: 0.5rem; }

  .narrow-form input,
  .narrow-form select {
    max-width: none;
  }

  .toolbar {
    gap: 0.5rem;
  }

  .toolbar input,
  .toolbar select {
    width: 100%;
    max-width: 100%;
  }

  .iframe-wrap {
    height: calc(100dvh - 120px - var(--topbar-h) - var(--safe-top));
    min-height: 420px;
    padding: 0.5rem !important;
  }

  .modal-content {
    width: 100%;
    max-height: calc(100dvh - 1.5rem);
  }

  .conf-editor {
    min-height: 240px;
    font-size: 16px;
  }

  .audit-msg {
    max-width: 160px;
  }

  table {
    font-size: 0.85rem;
  }

  th, td {
    padding: 0.7rem 0.55rem;
  }

  td button,
  td .link-btn,
  .service-card-actions button {
    min-height: 30px;
    min-width: 0;
  }

  .table-actions,
  .row-actions {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.28rem;
    max-width: 11.5rem;
  }

  .table-actions button,
  .row-actions button,
  .row-actions .link-btn {
    min-height: 28px;
    padding: 0.2rem 0.45rem;
    font-size: 0.72rem;
    writing-mode: horizontal-tb;
    letter-spacing: 0;
  }

  .service-card-actions {
    gap: 0.3rem;
  }

  .service-card-actions button {
    min-height: 32px;
    padding: 0.3rem 0.55rem;
    font-size: 0.78rem;
  }

  .toolbar button {
    min-height: 34px;
    padding: 0.35rem 0.7rem;
    font-size: 0.82rem;
  }

  .toolbar input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    min-height: 1rem;
    min-width: 1rem;
  }

  .filter-chip {
    order: 0;
    width: auto;
    max-width: 100%;
  }

  /* Homepage disk + Top 10: card stack on phone */
  table {
    min-width: 0 !important;
  }

  #disk-table thead,
  .disk-usage-table thead {
    display: none !important;
  }

  #disk-table,
  #disk-table tbody,
  #disk-table tr,
  #disk-table td,
  .disk-usage-table,
  .disk-usage-table tbody,
  .disk-usage-table tr,
  .disk-usage-table td {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
    min-width: 0 !important;
  }

  #disk-table tr,
  .disk-usage-table tr {
    background: rgba(11, 16, 23, 0.45);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    padding: 0.7rem 0.8rem;
    margin-bottom: 0.65rem;
  }

  #disk-table td,
  .disk-usage-table td {
    display: grid !important;
    grid-template-columns: minmax(4.5rem, 32%) 1fr;
    gap: 0.35rem 0.65rem;
    align-items: start;
    border: none;
    padding: 0.35rem 0;
  }

  #disk-table td::before,
  .disk-usage-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 500;
  }

  .disk-usage-table .path-cell {
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    overflow-wrap: anywhere;
    word-break: break-all;
  }

  .disk-usage-table tr.empty-row td {
    display: block !important;
  }

  .disk-usage-table tr.empty-row td::before {
    content: none;
  }

  .audit-msg {
    max-width: none;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 420px) {
  /* Keep 2-col on phones — single column wasted too much space */
  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
  }

  .stat-card {
    padding: 0.5rem 0.55rem;
  }

  .page-content {
    padding: 0.65rem;
  }
}

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

  .sidebar {
    transition: none !important;
  }
}
