:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --line: #e9edf2;
  --text: #2f3542;
  --muted: #7a8291;
  --green: #10b981;
  --green-dark: #059669;
  --blue: #3b82f6;
  --blue-dark: #2563eb;
  --warn: #f59e0b;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --shadow: 0 10px 28px rgba(31, 41, 55, 0.06);
  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-active: rgba(255, 255, 255, 0.1);
  --sidebar-hover: rgba(255, 255, 255, 0.05);
  --radius: 8px;
  --radius-sm: 6px;
  --transition: 0.2s ease;
}

/* ── Dark Mode ────────────────────────── */

body.dark {
  --bg: #0f172a;
  --surface: #1e293b;
  --line: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
  --sidebar-bg: #0b1120;
}

body.dark .topbar { border-bottom-color: var(--line); }
body.dark input, body.dark select { background: #1e293b; color: var(--text); border-color: var(--line); }
body.dark input:focus, body.dark select:focus { border-color: #34d399; box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15); }
body.dark .metric, body.dark .summary > div, body.dark .manager-shell, body.dark .table-shell { background: var(--surface); border-color: var(--line); }
body.dark .filters { background: var(--surface); box-shadow: 0 1px 0 var(--line), 0 8px 20px rgba(0,0,0,0.15); }
body.dark th { background: #1e293b; color: #cbd5e1; }
body.dark td { color: #94a3b8; }
body.dark tbody tr:hover { background: rgba(255,255,255,0.02); }
body.dark .manager-form, body.dark .pagination, body.dark .modal-header { border-color: var(--line); }
body.dark .modal-header, body.dark #sshStatus { background: #1e293b; }
body.dark .modal-shell { border-color: var(--line); }
body.dark .permission-box label, body.dark .toolbar.split { color: var(--muted); }
body.dark .mini-action, body.dark .secret { background: rgba(255,255,255,0.05); border-color: var(--line); color: var(--muted); }
body.dark .danger-link { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.2); }
body.dark .column-popover { background: var(--surface); border-color: var(--line); }
body.dark .column-popover label { color: var(--muted); }
body.dark .empty { color: var(--muted); }
body.dark .modal-backdrop { background: rgba(0,0,0,0.6); }
body.dark .cloud-tabs { background: var(--surface); border-color: var(--line); }
body.dark .cloud-tabs .tab { background: rgba(255,255,255,0.05); border-color: var(--line); color: var(--muted); }
body.dark .cloud-tabs .tab.active { background: var(--green); color: #fff; }
body.dark .mini-list > div { border-color: var(--line); }
body.dark .table-wrap { -ms-overflow-style: none; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
body.dark .toolbar button { color: var(--muted); }
body.dark .toolbar button:hover { background: rgba(255,255,255,0.05); border-color: var(--line); }
body.dark .session-actions { color: var(--muted); }
body.dark .session-actions button { background: var(--surface); border-color: var(--line); color: var(--text); }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  transition: background var(--transition), color var(--transition);
}

.app-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────── */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px 16px;
  margin-bottom: 4px;
  font-size: 18px;
  font-weight: 780;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand svg { width: 26px; height: 26px; flex-shrink: 0; }

.workspace { min-width: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--surface);
  color: var(--text);
  border-bottom: 1px solid var(--line);
  transition: background var(--transition), border-color var(--transition);
}

.topbar > div:first-child { display: flex; align-items: center; gap: 12px; }

#socketState {
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  background: #fef3c7;
  color: #92400e;
}
#socketState.connected { background: #d1fae5; color: #065f46; }
#socketState.error { background: #fee2e2; color: #991b1b; }

.session-actions { display: flex; align-items: center; gap: 12px; color: #647084; }
.session-actions form { margin: 0; }
.session-actions button { height: 30px; border-color: #dfe5ec; background: #fff; color: var(--text); }

/* ── Sidebar Nav ──────────────────────── */

.tabs { display: flex; gap: 2px; }
.side-nav { flex-direction: column; margin-top: 4px; flex: 1; }
.side-nav .tab {
  justify-content: flex-start;
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 18px;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  font-weight: 580;
  border-radius: 0;
  gap: 10px;
  transition: background var(--transition), color var(--transition);
}
.side-nav .tab svg { width: 18px; height: 18px; opacity: 0.6; flex-shrink: 0; }
.side-nav .tab:hover { background: var(--sidebar-hover); color: #fff; }
.side-nav .tab:hover svg { opacity: 1; }
.side-nav .tab.active { background: var(--sidebar-active); color: #fff; font-weight: 700; }
.side-nav .tab.active svg { opacity: 1; }

.sidebar-footer { margin-top: auto; padding: 12px 18px 0; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-footer button {
  display: flex; align-items: center; gap: 8px;
  width: 100%; height: 36px;
  border: 1px solid rgba(255,255,255,0.12);
  background: transparent;
  color: var(--sidebar-text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 550;
  transition: background var(--transition);
}
.sidebar-footer button:hover { background: var(--sidebar-hover); }
.sidebar-footer button svg { width: 16px; height: 16px; opacity: 0.5; }

/* ── Tabs ─────────────────────────────── */

.tab {
  flex: 0 0 auto;
  min-width: 96px;
  border-color: transparent;
  background: transparent;
  color: #d8e0ea;
  font-weight: 700;
  border-radius: var(--radius-sm);
}

.tab.active {
  border-color: rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .12);
  color: #fff;
}

/* ── Panels ───────────────────────────── */

.panel { display: none; }
.panel.active { display: block; }

main { padding: 24px; }

/* ── Dashboard ────────────────────────── */

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  max-width: 1880px;
  margin: 0 auto 18px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, .7fr);
  gap: 16px;
  max-width: 1880px;
  margin: 0 auto;
}

.metric {
  min-height: 92px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: background var(--transition), border-color var(--transition);
}

.metric span { display: block; font-size: 25px; font-weight: 780; }
.metric label { color: var(--muted); font-size: 13px; }

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  margin: 0 auto 18px;
  max-width: 1880px;
}

.summary > div {
  min-height: 76px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 3px 14px rgba(31, 41, 55, 0.04);
  transition: background var(--transition), border-color var(--transition);
}

.summary span { display: block; font-size: 24px; font-weight: 760; }
.summary label { color: var(--muted); font-size: 13px; }

/* ── Inputs ───────────────────────────── */

input, select, button {
  height: 38px;
  border: 1px solid #dfe5ec;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input, select { width: 100%; padding: 0 12px; outline: none; }

input:focus, select:focus {
  border-color: #6ee7b7;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, .12);
}

input.input-error { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(239,68,68,.12); }
.form-error { color: var(--danger); font-size: 12px; margin-top: 4px; }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 44px;
  padding: 0 14px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), opacity var(--transition);
}

button.primary {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
  font-weight: 650;
}
button.primary:hover { background: var(--green-dark); }

button.ghost:hover, .toolbar button:hover {
  border-color: #cbd3dd;
  background: #f8fafc;
}

button:disabled { cursor: not-allowed; opacity: .52; }

/* ── Filters ──────────────────────────── */

.filters {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: auto repeat(10, minmax(104px, 1fr)) auto auto;
  gap: 10px;
  align-items: center;
  margin: 0 auto 16px;
  max-width: 1880px;
  padding: 16px;
  background: var(--surface);
  box-shadow: 0 1px 0 var(--line), 0 12px 20px rgba(31, 41, 55, 0.05);
  border-radius: var(--radius);
}

.filter-label { font-weight: 650; color: #3e4654; white-space: nowrap; }

/* ── Tables ───────────────────────────── */

.table-shell {
  max-width: 1880px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.toolbar {
  position: relative;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px 8px;
}
.toolbar.split { justify-content: space-between; align-items: center; color: #3d4654; }
.toolbar button { width: 34px; height: 34px; min-width: 34px; padding: 0; color: #536071; }
.toolbar-left { display: flex; align-items: center; gap: 12px; }
.toolbar-left .batch-count { font-size: 12px; color: var(--muted); display: none; }
.toolbar-left .batch-count.visible { display: inline-flex; align-items: center; gap: 6px; }
.toolbar-left .batch-count button { width: auto; height: 28px; min-width: 48px; font-size: 12px; padding: 0 10px; }
.column-menu { position: relative; }
.column-popover {
  position: absolute;
  top: 40px;
  right: 0;
  z-index: 6;
  width: 190px;
  max-height: 360px;
  overflow: auto;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 32px rgba(0,0,0,0.12);
}
.column-popover label { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 6px; color: #475162; white-space: nowrap; }
.column-popover input { width: 14px; height: 14px; padding: 0; }

.table-wrap { overflow: auto; max-height: calc(100vh - 280px); min-height: 360px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
#nodeTable { min-width: 3320px; }
#nodeTable [hidden] { display: none !important; }
#lhTable [hidden] { display: none !important; }

/* ── Resizable columns ──────────────── */
#nodeTable th { position: relative; }
.col-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 9px;
  height: 100%;
  cursor: col-resize;
  z-index: 4;
  touch-action: none;
}
.col-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  right: 3px;
  width: 2px;
  height: 100%;
  background: transparent;
  transition: background var(--transition);
}
.col-resizer:hover::after, .col-resizer.resizing::after { background: var(--green); opacity: 0.7; }
.manager-table { min-width: 920px; }

th, td {
  height: 46px;
  padding: 0 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  transition: background var(--transition);
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
  color: #4c5564;
  font-weight: 700;
  user-select: none;
}

th[data-sort] { cursor: pointer; }
th[data-sort]::after { content: "↕"; margin-left: 6px; color: #b5bdc8; font-size: 12px; }
th[data-sort].sorted.asc::after { content: "↑"; color: #121826; }
th[data-sort].sorted.desc::after { content: "↓"; color: #121826; }

/* ── Lighthouse Table ───────────────────── */

#lhTable th[data-lh-sort] { cursor: pointer; user-select: none; }
#lhTable th[data-lh-sort] .sort-indicator { margin-left: 4px; font-size: 11px; color: #b5bdc8; opacity: 0.6; }
#lhTable th[data-lh-sort] .sort-indicator::before { content: "↕"; }
#lhTable th[data-lh-sort].sorted .sort-indicator { opacity: 1; }
#lhTable th[data-lh-sort].sorted.asc .sort-indicator::before { content: "↑"; color: #10b981; }
#lhTable th[data-lh-sort].sorted.desc .sort-indicator::before { content: "↓"; color: #10b981; }

.lh-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}
.lh-actions .mini-action, .lh-actions .danger-link {
  height: 24px;
  min-width: auto;
  padding: 0 7px;
  font-size: 11px;
  white-space: nowrap;
}

/* Fix cloud panel toolbar text buttons */
#cloudPanel .toolbar.split button {
  width: auto;
  min-width: auto;
  padding: 0 14px;
  white-space: nowrap;
}

/* ── Batch Dropdown ────────────────────── */

.batch-dropdown {
  position: relative;
  display: inline-block;
}
.batch-dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  min-width: 160px;
  padding: 4px 0;
  margin-top: 4px;
}
.batch-dropdown-menu.open {
  display: block;
}
.batch-dropdown-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text);
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 0;
  font-weight: 400;
}
.batch-dropdown-menu button:hover {
  background: var(--bg);
}
.batch-dropdown-menu hr {
  margin: 4px 0;
  border: none;
  border-top: 1px solid var(--line);
}

td { color: #5c6470; font-weight: 520; }
tbody tr:hover { background: #fbfcfd; }
tbody tr.selected { background: #ecfdf5; }
tr.deleted { opacity: 0; height: 0; padding: 0; transition: opacity 0.3s, height 0.3s; }

/* Compact */
.compact td, .compact th { height: 38px; padding-left: 10px; padding-right: 10px; }

/* ── Pills ────────────────────────────── */

.pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #065f46;
  font-size: 12px;
  font-weight: 700;
}
.pill.warn { background: #fef3c7; color: #92400e; }
.pill.danger { background: #fef2f2; color: #991b1b; }
.pill.neutral { background: #f1f5f9; color: #475569; }

/* ── Money / Factor ───────────────────── */

.money, .factor { color: var(--blue); font-weight: 760; }

/* ── Secrets ──────────────────────────── */

.secret { border: 1px solid #d7dde6; background: #f7f9fb; color: #303846; height: 26px; min-width: 48px; padding: 0 8px; font-size: 12px; }
.secret-value { display: inline-block; max-width: 190px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 12px; vertical-align: middle; }

/* ── Manager Shell ────────────────────── */

.manager-shell {
  max-width: 1880px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.manager-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr)) auto;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  animation: slideDown 0.25s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

#accountForm { grid-template-columns: repeat(4, minmax(130px, 1fr)) auto; }
#groupForm { grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) minmax(220px, 2fr) auto auto; }
#teamForm { grid-template-columns: minmax(180px, 1fr) minmax(260px, 2fr) minmax(160px, 1fr) auto auto; }
#userForm { grid-template-columns: repeat(6, minmax(130px, 1fr)) auto auto; }
#cloudForm { grid-template-columns: repeat(5, minmax(130px, 1fr)) auto; }

/* ── Management Stats ─────────────────── */

.mgmt-stats {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  padding: 16px;
  max-width: 1880px;
  margin: 0 auto;
}
.mgmt-stat {
  text-align: center;
  padding: 12px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.mgmt-stat span { display: block; font-size: 22px; font-weight: 760; }
.mgmt-stat label { color: var(--muted); font-size: 12px; }

/* ── Permission Box ───────────────────── */

.permission-box {
  grid-column: 1 / -2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  min-height: 38px;
}
.permission-box label { display: inline-flex; align-items: center; gap: 6px; color: #596375; white-space: nowrap; font-size: 13px; }
.permission-box input { width: 14px; height: 14px; padding: 0; }

/* ── Pagination ───────────────────────── */

.pagination {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}
.pagination select { width: 110px; }

/* ── Assign Controls ──────────────────── */

.assign-controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 6px;
  min-width: 430px;
}
.assign-controls select, .assign-controls button, .mini-action { height: 28px; min-width: 0; padding: 0 8px; font-size: 12px; }
.mini-action { border-color: #d7dde6; background: #f7f9fb; color: #303846; font-weight: 700; }

.inline-actions, .log-filters { display: flex; align-items: center; gap: 8px; }
.log-filters input { width: 160px; }
.log-filters select { width: 120px; }
.admin-tools { margin-top: 16px; }
.danger-link {
  height: 28px; min-width: 52px;
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--danger);
  font-size: 12px;
  font-weight: 650;
  border-radius: var(--radius-sm);
}
.danger-link:hover { background: #fee2e2; color: var(--danger-dark); border-color: var(--danger); }

.status-toggle { height: 28px; min-width: 52px; font-size: 12px; font-weight: 650; border-radius: var(--radius-sm); }
.status-toggle.enable { border-color: #a7f3d0; background: #ecfdf5; color: #065f46; }
.status-toggle.disable { border-color: #fecaca; background: #fef2f2; color: #991b1b; }

/* ── Badge for table counts ───────────── */

.row-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  background: #f1f5f9;
  color: #475569;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* ── Loading ──────────────────────────── */

#loadingOverlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(2px);
}
#loadingOverlay.active { display: flex; }
body.dark #loadingOverlay { background: rgba(15,23,42,0.6); }

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--line);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #1e293b;
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 550;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  animation: toastIn 0.3s ease;
  transition: opacity 0.3s;
}
.toast.success { border-left: 4px solid var(--green); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warn); }
.toast.fade-out { opacity: 0; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ── Confirm Modal ────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.45); }
.modal-shell {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  width: 90vw;
  max-width: 480px;
  overflow: hidden;
}
.ssh-modal-shell { max-width: 960px; }
.form-modal-shell { max-width: 580px; }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: #f8f9fb;
  font-weight: 650;
}
.modal-body { padding: 20px; color: var(--muted); line-height: 1.6; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}
.modal-footer button { min-width: 80px; height: 36px; }

/* ── Empty ────────────────────────────── */

.empty {
  height: 120px;
  text-align: center;
  color: var(--muted);
  vertical-align: middle;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 16px;
  color: var(--muted);
}
.empty-state svg { width: 48px; height: 48px; opacity: 0.3; }
.empty-state p { margin: 0; font-size: 14px; }

.mini-list { display: grid; }

.mini-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  padding: 0 16px;
  border-top: 1px solid var(--line);
}
.mini-list strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list span { color: var(--muted); white-space: nowrap; }
.empty-mini { justify-content: center !important; color: var(--muted); }

/* ── Cloud Management ─────────────────── */

.cloud-tabs {
  margin: 0 0 18px;
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 8px 10px;
  border-radius: var(--radius);
  flex-wrap: wrap;
  max-width: 1880px;
}
.cloud-tabs .tab {
  color: var(--text);
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-sm);
  height: 36px;
  min-width: 100px;
  font-weight: 650;
  font-size: 13px;
}
.cloud-tabs .tab.active { background: var(--green); color: #fff; border-color: var(--green); }

.cloud-sub-panel { display: none; max-width: 1880px; margin: 0 auto; }
.cloud-sub-panel.active { display: block; }

/* ── SSH ──────────────────────────────── */

#sshTerminalModal.modal { display: flex; }
#sshTerminalModal.modal.hidden { display: none; }

.ssh-cred-form {
  display: grid;
  grid-template-columns: minmax(140px, 1.5fr) minmax(100px, 0.8fr) minmax(110px, 0.7fr) minmax(180px, 2fr) auto;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  align-items: start;
}
.ssh-cred-form .ssh-auth-fields {
  grid-column: span 3;
}
.ssh-cred-form .ssh-default-label {
  grid-column: span 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  font-size: 13px;
  color: #596375;
  cursor: pointer;
}
.ssh-cred-form .ssh-default-label input[type="checkbox"] {
  width: 16px; height: 16px; padding: 0;
}

#sshForm textarea {
  grid-column: span 2;
  height: 60px;
  min-height: 60px;
  padding: 8px 12px;
  border: 1px solid #dfe5ec;
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  resize: vertical;
  outline: none;
}
#sshForm textarea:focus { border-color: #9fc7ad; box-shadow: 0 0 0 3px rgba(85, 184, 121, .12); }

/* ── Login ────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #f6f7f9 0%, #ecfdf5 100%);
}
body.dark .login-page { background: linear-gradient(135deg, #0f172a 0%, #064e3b 100%); }
.login-shell { width: min(100%, 420px); padding: 24px; }
.login-card {
  display: grid;
  gap: 14px;
  padding: 32px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 8px; font-size: 22px; }
.login-card button { width: 100%; height: 44px; }
.login-error { min-height: 32px; padding: 8px 12px; border: 1px solid #fecaca; background: #fef2f2; color: var(--danger); border-radius: var(--radius-sm); }

/* ── Responsive ───────────────────────── */

@media (max-width: 1200px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; padding: 10px 12px; }
  .brand { height: 34px; padding-bottom: 8px; margin-bottom: 0; }
  .side-nav { flex-direction: row; overflow-x: auto; margin-top: 4px; }
  .side-nav .tab { width: auto; min-width: 80px; height: 36px; padding: 0 10px; font-size: 12px; }
  .side-nav .tab svg { display: none; }
  .sidebar-footer { display: none; }
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 16px; }
  .filter-label { grid-column: 1 / -1; }
  .summary { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .dashboard-grid, .content-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .manager-form, #groupForm, #teamForm, #accountForm, #userForm, #cloudForm { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mgmt-stats { grid-template-columns: repeat(3, 1fr); }
  .topbar { padding: 10px 16px; }
}

@media (max-width: 720px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .summary { grid-template-columns: 1fr; }
  .dashboard-grid, .content-grid { grid-template-columns: 1fr; }
  .mgmt-stats { grid-template-columns: repeat(2, 1fr); }
  main { padding: 18px 10px 30px; }
  .topbar, .session-actions { align-items: flex-start; flex-direction: column; }
  .manager-form, #groupForm, #teamForm, #accountForm, #userForm, #cloudForm { grid-template-columns: 1fr; }
  .permission-box, .assign-controls, .inline-actions, .log-filters { grid-column: auto; flex-direction: column; align-items: stretch; }
  .assign-controls { grid-template-columns: 1fr; }
  .log-filters input, .log-filters select { width: 100%; }
}
