/* WebPanel - Responsive UI v2 */

/* === CSS Variables === */
:root {
  --sidebar-width: 260px;
  --sidebar-collapsed: 64px;
  --topbar-height: 52px;
  --mobile-nav-height: 56px;
  --bg-body: #0b1120;
  --bg-surface: #111827;
  --bg-surface-hover: #1a2234;
  --bg-inset: #0a0f1a;
  --border-color: #1e293b;
  --border-hover: #334155;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --green: #059669;
  --red: #dc2626;
  --orange: #f59e0b;
  --purple: #8b5cf6;
  --cyan: #06b6d4;
}

/* === Base === */
* { box-sizing: border-box; }
body {
  background: var(--bg-body);
  min-height: 100vh;
  overflow-x: hidden;
}
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-accent { color: var(--accent) !important; }

/* === Topbar === */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  z-index: 1040;
  display: flex;
  align-items: center;
  padding: 0 1rem;
}
.topbar .brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.topbar .brand i { color: var(--accent); font-size: 1.3rem; }
.topbar-actions { margin-left: auto; display: flex; gap: .5rem; align-items: center; }

/* Topbar terminal button */
.topbar-terminal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: .375rem;
  background: var(--bg-inset);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: .95rem;
  text-decoration: none;
  transition: all .15s;
}
.topbar-terminal-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(59,130,246,.08);
}

/* Topbar compact stats */
.topbar-stats {
  display: flex;
  gap: .125rem;
  align-items: center;
}
.topbar-stat {
  display: flex;
  align-items: center;
  gap: .3rem;
  font-size: .7rem;
  color: var(--text-muted);
  padding: .25rem .45rem;
  border-radius: .25rem;
  background: var(--bg-inset);
  border: 1px solid var(--border-color);
  white-space: nowrap;
}
.topbar-stat i { font-size: .75rem; color: var(--text-secondary); }
.topbar-stat span { font-weight: 600; color: var(--text-primary); font-size: .65rem; font-family: 'SFMono-Regular',Consolas,monospace; }

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.3rem;
  padding: .25rem .5rem;
  cursor: pointer;
  border-radius: .375rem;
  margin-right: .5rem;
}
.sidebar-toggle:hover { color: var(--text-primary); background: var(--bg-surface-hover); }

/* === Sidebar === */
.sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  z-index: 1030;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .3s cubic-bezier(.4,0,.2,1), width .25s ease;
  display: flex;
  flex-direction: column;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

.sidebar-section {
  padding: .5rem 0;
  border-bottom: 1px solid var(--border-color);
}
.sidebar-section:last-child { border-bottom: none; }

.sidebar-label {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: .5rem 1rem .25rem;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .5rem 1rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: .875rem;
  transition: all .15s;
  border-left: 3px solid transparent;
  white-space: nowrap;
  cursor: pointer;
}
.sidebar-item:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}
.sidebar-item.active {
  color: var(--accent);
  background: rgba(59,130,246,.08);
  border-left-color: var(--accent);
}
.sidebar-item i { font-size: 1.1rem; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-item .item-label { overflow: hidden; text-overflow: ellipsis; }
.sidebar-item .badge {
  margin-left: auto;
  font-size: .65rem;
  padding: .2em .5em;
  flex-shrink: 0;
}

/* Sidebar domain sub-items */
.sidebar-domain-sub { padding-left: 2.8rem; font-size: .8rem; }

/* Sidebar logout */
.sidebar-logout {
  color: var(--text-muted) !important;
  font-size: .8rem;
  border-left-color: transparent !important;
}
.sidebar-logout:hover { color: var(--red) !important; background: rgba(220,38,38,.06); }
.sidebar-logout i { color: var(--text-muted); }
.sidebar-logout:hover i { color: var(--red); }

/* Server stats widget in sidebar */
.sidebar-stats { padding: .75rem 1rem; }
.stat-bar {
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
  margin-top: .25rem;
}
.stat-bar-fill { height: 100%; border-radius: 2px; transition: width .5s ease; }
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .75rem;
  color: var(--text-secondary);
  margin-bottom: .5rem;
}
.stat-row:last-child { margin-bottom: 0; }
.stat-value { font-weight: 600; color: var(--text-primary); font-size: .7rem; }

/* Status dots */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  margin-left: auto;
}
.status-dot.green { background: var(--green); box-shadow: 0 0 6px rgba(5,150,105,.5); }
.status-dot.red { background: var(--red); box-shadow: 0 0 6px rgba(220,38,38,.5); }
.status-dot.gray { background: var(--text-muted); }
.status-dot.orange { background: var(--orange); }

/* Sidebar collapsed state on desktop */
.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed); }
.sidebar-collapsed .sidebar .item-label,
.sidebar-collapsed .sidebar .sidebar-label,
.sidebar-collapsed .sidebar .badge,
.sidebar-collapsed .sidebar .sidebar-stats,
.sidebar-collapsed .sidebar .sidebar-domain-sub { display: none; }
.sidebar-collapsed .sidebar .sidebar-item { justify-content: center; padding: .6rem; }
.sidebar-collapsed .main-content { margin-left: var(--sidebar-collapsed); }

/* === Main Content === */
.main-content {
  margin-top: var(--topbar-height);
  margin-left: var(--sidebar-width);
  padding: 1.25rem;
  min-height: calc(100vh - var(--topbar-height));
  transition: margin-left .25s ease;
}

/* === Mobile Bottom Nav === */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--mobile-nav-height);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  z-index: 1050;
  padding: 0;
}
.mobile-nav-inner {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: space-around;
}
.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .15rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: .6rem;
  padding: .25rem .4rem;
  border-radius: .375rem;
  transition: color .15s;
  flex: 1;
  min-width: 0;
}
.mobile-nav-item i { font-size: 1.15rem; }
.mobile-nav-item:hover, .mobile-nav-item.active { color: var(--accent); }
.mobile-nav-item.active { font-weight: 600; }

/* === Cards === */
.wp-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: .5rem;
  transition: border-color .2s;
}
.wp-card:hover { border-color: var(--border-hover); }
.wp-card-body { padding: 1rem; }
.wp-card-footer {
  padding: .5rem 1rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: .375rem;
  flex-wrap: wrap;
}

/* === Server Dashboard Cards === */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: .5rem;
  padding: 1rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.stat-card .stat-icon {
  font-size: 2rem;
  margin-bottom: .5rem;
  display: block;
}
.stat-card .stat-big {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}
.stat-card .stat-sub {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .25rem;
}
.stat-card .stat-bar-lg {
  height: 6px;
  background: var(--border-color);
  border-radius: 3px;
  overflow: hidden;
  margin-top: .75rem;
}
.stat-card .stat-bar-lg .fill {
  height: 100%;
  border-radius: 3px;
  transition: width .5s ease;
}

/* Port list */
.port-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--border-color);
  font-size: .8rem;
}
.port-item:last-child { border-bottom: none; }
.port-num {
  font-family: 'SFMono-Regular',Consolas,monospace;
  font-weight: 600;
  font-size: .85rem;
  color: var(--accent);
  min-width: 50px;
}
.port-proto {
  font-size: .65rem;
  padding: .1em .4em;
  border-radius: .25rem;
  text-transform: uppercase;
  font-weight: 600;
}

/* Service card */
.svc-card {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem .85rem;
  background: var(--bg-inset);
  border: 1px solid var(--border-color);
  border-radius: .5rem;
  transition: border-color .2s, background .2s;
}
.svc-card:hover { border-color: var(--border-hover); background: var(--bg-surface-hover); }
.svc-icon { font-size: 1.1rem; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: .375rem; flex-shrink: 0; color: var(--accent); }
.svc-info { flex: 1; min-width: 0; }
.svc-name { font-weight: 600; font-size: .8rem; color: var(--text-primary); }
.svc-status { font-size: .65rem; color: var(--text-muted); display: flex; align-items: center; }
.svc-actions { display: flex; gap: .25rem; flex-shrink: 0; }

/* Domain card */
.domain-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .5rem;
}
.domain-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 0;
}
.domain-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.domain-badges { display: flex; gap: .25rem; flex-shrink: 0; }
.domain-meta {
  font-size: .75rem;
  color: var(--text-muted);
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: .5rem;
}

/* Action button toolbar */
.action-bar { display: flex; gap: .25rem; flex-wrap: wrap; align-items: center; }
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: .375rem;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-size: .875rem;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  padding: 0;
}
.action-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(59,130,246,.08); }
.action-btn.danger:hover { border-color: var(--red); color: var(--red); background: rgba(220,38,38,.08); }
.action-btn.success:hover { border-color: var(--green); color: var(--green); background: rgba(5,150,105,.08); }
.action-btn.warning:hover { border-color: var(--orange); color: var(--orange); background: rgba(245,158,11,.08); }

/* SSH compact */
.ssh-compact {
  background: var(--bg-inset);
  border: 1px solid var(--border-color);
  border-radius: .375rem;
  padding: .4rem .6rem;
  font-size: .75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--text-secondary);
  margin-bottom: .5rem;
}
.ssh-compact code { font-size: .7rem; color: #67e8f9; }

/* Password blur */
.pass-blur { filter: blur(4px); transition: filter .2s; user-select: none; }
.pass-blur.revealed { filter: none; user-select: auto; }

/* Detail panel */
.detail-panel {
  position: fixed;
  top: var(--topbar-height);
  right: -400px;
  width: 380px;
  bottom: 0;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  z-index: 1035;
  transition: right .3s ease;
  overflow-y: auto;
  padding: 1.25rem;
}
.detail-panel.open { right: 0; }
.detail-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1034;
}
.detail-overlay.open { display: block; }

/* View toggle */
.view-toggle .btn { padding: .25rem .5rem; font-size: .8rem; }
.view-toggle .btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* List view for domains */
.domain-list-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
  transition: background .15s;
}
.domain-list-item:hover { background: var(--bg-surface-hover); }
.domain-list-item:last-child { border-bottom: none; }

/* === Responsive File Manager === */
.file-list-mobile { display: none; }
.file-item-mobile {
  display: flex;
  align-items: center;
  padding: .65rem .75rem;
  border-bottom: 1px solid var(--border-color);
  gap: .65rem;
  text-decoration: none;
  color: var(--text-primary);
  transition: background .15s;
}
.file-item-mobile:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.file-item-mobile .file-icon { font-size: 1.3rem; width: 28px; text-align: center; flex-shrink: 0; }
.file-item-mobile .file-info { flex: 1; min-width: 0; }
.file-item-mobile .file-name {
  font-size: .875rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-item-mobile .file-meta { font-size: .7rem; color: var(--text-muted); }
.file-item-mobile .file-actions { flex-shrink: 0; display: flex; gap: .25rem; }

/* FAB */
.fab-container {
  position: fixed;
  bottom: calc(var(--mobile-nav-height) + 1rem);
  right: 1rem;
  z-index: 1020;
  display: none;
}
.fab {
  width: 50px; height: 50px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none;
  font-size: 1.3rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(59,130,246,.4);
  cursor: pointer;
  transition: transform .2s, background .2s;
}
.fab:hover { background: var(--accent-hover); transform: scale(1.08); }
.fab-menu { position: absolute; bottom: 60px; right: 0; display: none; flex-direction: column; gap: .5rem; }
.fab-menu.open { display: flex; }
.fab-menu-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .75rem; background: var(--bg-surface);
  border: 1px solid var(--border-color); border-radius: .5rem;
  color: var(--text-primary); font-size: .8rem; white-space: nowrap;
  cursor: pointer; text-decoration: none; transition: background .15s;
}
.fab-menu-item:hover { background: var(--bg-surface-hover); color: var(--text-primary); }

/* Editor mobile */
.editor-toolbar-mobile {
  display: none;
  position: fixed;
  bottom: var(--mobile-nav-height);
  left: 0; right: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: .5rem;
  z-index: 1020;
  gap: .5rem;
  justify-content: center;
}

/* === Tabs === */
.wp-tabs {
  display: flex; gap: 0;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-surface);
  border-radius: .5rem .5rem 0 0;
  padding: 0 .25rem;
}
.wp-tabs::-webkit-scrollbar { display: none; }
.wp-tab {
  padding: .55rem .85rem;
  font-size: .8rem;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: all .2s;
  cursor: pointer;
  background: none;
  border-top: none; border-left: none; border-right: none;
  display: flex;
  align-items: center;
  gap: .35rem;
}
.wp-tab i { font-size: .85rem; }
.wp-tab:hover { color: var(--text-primary); background: rgba(59,130,246,.04); }
.wp-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }
.wp-tab-content { display: none; }
.wp-tab-content.active { display: block; }

/* === Collapsible === */
.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.collapsible-header .chevron { transition: transform .2s; }
.collapsible-header.collapsed .chevron { transform: rotate(-90deg); }

/* === Info row === */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .45rem 0;
  border-bottom: 1px solid var(--border-color);
  font-size: .8rem;
}
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text-muted); font-size: .75rem; }
.info-value { color: var(--text-primary); font-weight: 500; font-family: 'SFMono-Regular',Consolas,monospace; font-size: .75rem; text-align: right; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Resource bar (server pages) */
.resource-bar {
  height: 6px;
  background: var(--border-color);
  border-radius: 3px;
  overflow: hidden;
  margin-top: .35rem;
}
.resource-bar .fill {
  height: 100%;
  border-radius: 3px;
  transition: width .6s ease;
}

/* === Action card (server actions tab) === */
.action-card {
  background: var(--bg-inset);
  border: 1px solid var(--border-color);
  border-radius: .5rem;
  padding: .85rem;
  transition: border-color .2s;
}
.action-card:hover { border-color: var(--border-hover); }
.action-card-title {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-bottom: .6rem;
}
.action-card-title i { font-size: 1rem; }

/* === Page Header (compact toolbar) === */
.page-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: .5rem;
  margin-bottom: .75rem;
  min-height: 38px;
}
.page-header .back-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: .375rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: .8rem;
  transition: all .15s;
  flex-shrink: 0;
  border: 1px solid var(--border-color);
  background: transparent;
}
.page-header .back-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--accent);
  border-color: var(--accent);
}
.page-header-title {
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: .35rem;
}
.page-header-title .sep {
  color: var(--text-muted);
  font-size: .6rem;
}
.page-header-title .muted {
  color: var(--text-muted);
  font-weight: 400;
}
.page-header-actions {
  display: flex;
  gap: .25rem;
  align-items: center;
  flex-shrink: 0;
}
.page-header-actions .action-btn {
  width: 28px;
  height: 28px;
  font-size: .75rem;
}

/* === Responsive helpers === */
.d-desktop-only { display: flex !important; }
.d-mobile-only { display: none !important; }

/* ==== MEDIA QUERIES ==== */

/* Tablet: collapse sidebar to icons */
@media (max-width: 991.98px) {
  .sidebar { width: var(--sidebar-collapsed); }
  .sidebar .item-label,
  .sidebar .sidebar-label,
  .sidebar .badge,
  .sidebar .sidebar-stats,
  .sidebar .sidebar-domain-sub { display: none; }
  .sidebar .sidebar-item { justify-content: center; padding: .6rem; }
  .main-content { margin-left: var(--sidebar-collapsed); }
  /* When mobile-open, expand fully */
  .sidebar.mobile-open {
    width: var(--sidebar-width);
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.5);
  }
  .sidebar.mobile-open .item-label,
  .sidebar.mobile-open .sidebar-label,
  .sidebar.mobile-open .badge,
  .sidebar.mobile-open .sidebar-stats,
  .sidebar.mobile-open .sidebar-domain-sub { display: revert; }
  .sidebar.mobile-open .sidebar-item { justify-content: flex-start; padding: .5rem 1rem; }
}

/* Mobile: sidebar off-screen, bottom nav visible */
@media (max-width: 767.98px) {
  :root {
    --mobile-nav-height: 58px;
    --topbar-height: 48px;
  }

  .sidebar {
    width: var(--sidebar-width);
    transform: translateX(-100%);
    box-shadow: none;
    z-index: 1055;
  }
  .sidebar .item-label,
  .sidebar .sidebar-label,
  .sidebar .badge,
  .sidebar .sidebar-stats,
  .sidebar .sidebar-domain-sub { display: revert; }
  .sidebar .sidebar-item { justify-content: flex-start; padding: .5rem 1rem; }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.6);
  }
  .detail-overlay { z-index: 1054; }

  .main-content {
    margin-left: 0;
    padding: .5rem;
    padding-bottom: calc(var(--mobile-nav-height) + .5rem);
  }

  .mobile-nav { display: block; }

  .d-desktop-only { display: none !important; }
  .d-mobile-only { display: flex !important; }

  /* Topbar compact */
  .topbar { padding: 0 .5rem; height: 48px; }
  .topbar .brand { font-size: 1rem; gap: .35rem; }
  .topbar .brand i { font-size: 1.15rem; }
  .sidebar-toggle { font-size: 1.2rem; padding: .2rem .35rem; margin-right: .25rem; }
  .topbar-terminal-btn { width: 30px; height: 30px; font-size: .85rem; }

  /* Mobile bottom nav improved */
  .mobile-nav { height: var(--mobile-nav-height); padding-bottom: env(safe-area-inset-bottom, 0); }
  .mobile-nav-inner { padding: 0 .25rem; }
  .mobile-nav-item { font-size: .6rem; gap: .1rem; padding: .2rem .25rem; }
  .mobile-nav-item i { font-size: 1.2rem; }

  /* File manager mobile */
  .file-table-desktop { display: none; }
  .file-list-mobile { display: block; }
  .fab-container { display: block; }

  /* Editor */
  .editor-toolbar-mobile { display: flex; }

  /* Page header compact on mobile */
  .page-header {
    padding: .3rem .5rem;
    margin-bottom: .5rem;
    border-radius: .375rem;
    min-height: 34px;
    gap: .35rem;
  }
  .page-header-actions .action-btn { width: 28px; height: 28px; font-size: .75rem; }
  .page-header .back-btn { width: 28px; height: 28px; font-size: .8rem; }
  .page-header-title { font-size: .8rem; }

  /* Stat cards responsive */
  .stat-card { padding: .5rem .4rem; }
  .stat-card .stat-big { font-size: 1.25rem; }
  .stat-card .stat-icon { font-size: 1.3rem; margin-bottom: .2rem; }
  .stat-card .stat-sub { font-size: .65rem; margin-top: .15rem; }
  .stat-card .stat-bar-lg { margin-top: .4rem; }

  /* Cards tighter */
  .wp-card-body { padding: .6rem; }
  .wp-card-footer { padding: .4rem .6rem; gap: .2rem; }
  .wp-card-footer .action-btn { width: 32px; height: 32px; font-size: .8rem; }

  /* Services */
  .svc-card { padding: .45rem .6rem; gap: .4rem; margin-bottom: .35rem !important; }
  .svc-icon { width: 28px; height: 28px; font-size: .85rem; }
  .svc-name { font-size: .75rem; }
  .svc-status { font-size: .6rem; }
  .svc-actions .action-btn { width: 28px; height: 28px; font-size: .75rem; }

  /* Action cards */
  .action-card { padding: .55rem; }
  .action-card-title { font-size: .75rem; margin-bottom: .35rem; }

  /* Info rows */
  .info-row { padding: .3rem 0; font-size: .75rem; }
  .info-label { font-size: .7rem; }
  .info-value { font-size: .7rem; max-width: 55%; }
  .section-label { font-size: .75rem; margin-bottom: .4rem; }

  /* Domain cards */
  .domain-header { margin-bottom: .35rem; }
  .domain-name { font-size: .9rem; gap: .35rem; }
  .domain-name i { font-size: .85rem; }
  .domain-meta { font-size: .7rem; gap: .5rem; margin-bottom: .35rem; }
  .ssh-compact { padding: .3rem .5rem; font-size: .7rem; gap: .35rem; margin-bottom: .35rem; }
  .ssh-compact code { font-size: .65rem; }

  /* Tabs scroll on mobile */
  .wp-tabs { padding: 0; border-radius: .375rem .375rem 0 0; }
  .wp-tab { padding: .4rem .55rem; font-size: .7rem; }
  .wp-tab i { font-size: .75rem; }

  /* Table compact */
  .ports-table th { font-size: .6rem; padding: .3rem .25rem; }
  .ports-table td { font-size: .65rem; padding: .25rem; }
  .port-item { padding: .35rem .5rem; font-size: .75rem; gap: .5rem; }
  .port-num { font-size: .8rem; min-width: 42px; }

  /* Quick action buttons */
  .quick-action-btn { font-size: .7rem; padding: .3rem .5rem; }

  /* Detail panel full width */
  .detail-panel { width: 100%; right: -100%; }

  /* Modals */
  .modal-dialog { margin: .5rem; }
  .modal-content { border-radius: .5rem; }
  .modal-header { padding: .6rem .75rem; }
  .modal-body { padding: .75rem; }
  .modal-footer { padding: .5rem .75rem; }
  .modal-title { font-size: .9rem; }

  /* Form controls compact */
  .form-control, .form-select { font-size: .8rem; padding: .35rem .6rem; }
  .form-control-sm, .input-group-sm .form-control { font-size: .75rem; }
  .form-label { font-size: .75rem; margin-bottom: .25rem; }
  .btn { font-size: .8rem; }
  .btn-sm { font-size: .7rem; padding: .25rem .5rem; }

  /* Row gutters tighter */
  .row.g-3 { --bs-gutter-y: .5rem; --bs-gutter-x: .5rem; }
  .row.g-2 { --bs-gutter-y: .35rem; --bs-gutter-x: .35rem; }
  .mb-3 { margin-bottom: .65rem !important; }

  /* Resource bars */
  .resource-bar { height: 5px; }
  .stat-bar { height: 3px; }

  /* Domain list items */
  .domain-list-item { padding: .5rem .6rem; gap: .5rem; }

  /* Alerts compact */
  .alert { font-size: .8rem !important; padding: .5rem .75rem; }
}

/* Small phones */
@media (max-width: 380px) {
  .main-content { padding: .35rem; }
  .stat-card .stat-big { font-size: 1.1rem; }
  .stat-card .stat-icon { font-size: 1.1rem; }
  .stat-card { padding: .4rem .3rem; }
  .domain-name { font-size: .8rem; }
  .wp-card-footer .action-btn { width: 28px; height: 28px; font-size: .7rem; }
  .page-header-title { font-size: .75rem; }
  .mobile-nav-item { font-size: .55rem; }
  .mobile-nav-item i { font-size: 1.05rem; }
}

/* Large screens */
@media (min-width: 1200px) {
  .main-content { padding: 1.5rem 2rem; }
}

/* === Alerts === */
.alert { border: none; }
.modal-content { background: var(--bg-surface); border: 1px solid var(--border-color); }

/* === Utility === */
.bg-inset { background: var(--bg-inset); }
.gap-xs { gap: .25rem; }
.text-purple { color: var(--purple) !important; }
.text-cyan { color: var(--cyan) !important; }

/* Section header inside cards (replaces h6 inside card bodies) */
.section-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: .35rem;
  margin-bottom: .6rem;
}
.section-label i { font-size: .9rem; }

/* Ports table improvements */
.ports-table { font-size: .75rem; }
.ports-table th {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-muted);
  padding: .45rem .5rem;
  border-color: var(--border-color);
}
.ports-table td {
  padding: .4rem .5rem;
  border-color: var(--border-color);
  vertical-align: middle;
}
.ports-table .port-cell {
  font-family: 'SFMono-Regular',Consolas,monospace;
  font-weight: 600;
  color: var(--accent);
}

/* Quick action btn improvements */
.quick-action-btn {
  font-size: .75rem;
  padding: .3rem .65rem;
  border-radius: .375rem;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  transition: all .15s;
}

/* Card section header (lightweight) */
.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .65rem;
}

/* Copy button feedback */
.copy-ok i { color: var(--green) !important; }

/* Touch-friendly: min tap targets */
@media (pointer: coarse) {
  .action-btn { width: 38px; height: 38px; font-size: .85rem; }
  .page-header-actions .action-btn { width: 32px; height: 32px; }
  .sidebar-item { padding: .65rem 1rem; min-height: 44px; }
  .mobile-nav-item { min-height: 44px; }
  .btn-sm { min-height: 36px; }
  .form-control, .form-select { min-height: 40px; }
  .wp-tab { min-height: 40px; }
}

/* Landscape mobile: hide bottom nav, compact terminal */
@media (max-width: 767.98px) and (orientation: landscape) {
  .mobile-nav { display: none !important; }
  .main-content { padding-bottom: .5rem; }
}

/* Safe area for notched devices */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .mobile-nav {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
  }
  @media (max-width: 767.98px) {
    .main-content {
      padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + .5rem);
    }
  }
}
