/* ============================================================
   Lantek Support Cloud Portal — design tokens
   Indigo/blue accent palette: indigo #0005EE (CTAs, footer), electric
   blue #0089FF (links/nav), black on white, Open Sans.
   ============================================================ */
:root {
  --indigo: #0005EE;
  --indigo-600: #0004BD;
  --indigo-100: #ECEDFE;
  --blue: #0089FF;
  --blue-100: #E5F3FF;
  --ink: #000000;
  --bg: #F4F5F7;
  --card: #ffffff;
  --card-alt: #fafafc;
  --header-bg: rgba(255,255,255,0.92);
  --text: #17181c;
  --text-soft: #52565f;
  --muted: #858992;
  --border: #e4e6ec;
  --red: #d9453f;
  --red-100: #fdeceb;
  --green: #1e9e5a;
  --green-100: #e8f8ef;
  --amber: #d98c1f;
  --amber-100: #fdf3e3;
  --radius: 12px;
  --pill: 999px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 43, 0.06);
  --shadow-md: 0 8px 24px rgba(20, 20, 43, 0.08);
  --shadow-lg: 0 24px 64px rgba(0, 2, 40, 0.35);
  /* Intentionally NOT redefined under [data-theme="dark"] — a couple of
     surfaces (toasts, the inspect pill) are meant to always read as a dark
     chip regardless of overall theme, unlike --ink which flips to near-white
     text in dark mode and would go invisible if used for these backgrounds. */
  --near-black: #17181c;
}

/* Bare :root above is the light default; [data-theme="dark"] (set by the
   toggle in the header, persisted to localStorage) overrides every token. */
:root[data-theme="dark"] {
  --indigo: #6d84ff;
  --indigo-600: #5c71e6;
  --indigo-100: #1c2242;
  --blue: #5ab6ff;
  --blue-100: #15263a;
  --ink: #f5f6f8;
  --bg: #0b0d14;
  --card: #12141c;
  --card-alt: #181b26;
  --header-bg: rgba(11,13,20,0.92);
  --text: #e5e7eb;
  --text-soft: #a8adba;
  --muted: #767c8a;
  --border: #262b38;
  --red: #f87171;
  --red-100: #3a1a1c;
  --green: #34d399;
  --green-100: #113328;
  --amber: #f2b84b;
  --amber-100: #3a2c12;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.35);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.45);
  --shadow-lg: 0 24px 64px rgba(0,0,0,0.65);
}

* { box-sizing: border-box; }

body {
  font-family: 'Open Sans', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  height: 100vh;
  overflow: hidden;
  font-size: 14px;
}

.app-shell { display: flex; height: 100vh; }

/* ---------------- Auth gate ---------------- */
.auth-gate {
  position: fixed; inset: 0; z-index: 20000; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.auth-gate.hidden { display: none; }
.auth-gate-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 44px 48px;
  width: min(360px, calc(100vw - 40px)); text-align: center; box-shadow: var(--shadow-lg); box-sizing: border-box;
}
.auth-gate-mark { width: 52px; height: 52px; border-radius: 14px; font-size: 18px; margin: 0 auto 20px; }
.auth-gate-card h1 { font-size: 18px; margin: 0 0 10px; color: var(--ink); }
.auth-gate-card p { font-size: 13px; color: var(--text-soft); margin: 0 0 26px; display: flex; align-items: center; justify-content: center; gap: 9px; }
.auth-gate-btn { display: none; width: 100%; background: var(--indigo); }
.auth-gate-spinner {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--indigo);
  animation: auth-spin .7s linear infinite; flex-shrink: 0;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }

/* ---------------- Sidebar ---------------- */
.sidebar {
  width: 272px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  color: var(--text);
}
.sidebar-header { padding: 24px 22px 20px; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(155deg, var(--indigo), var(--indigo-600));
  box-shadow: 0 6px 14px rgba(0,5,238,0.28);
  display: flex; align-items: center; justify-content: center; font-weight: 800;
  font-size: 14px; letter-spacing: 0.5px; color: #fff; flex-shrink: 0;
}
.brand-text { font-weight: 700; font-size: 16px; letter-spacing: -0.1px; color: var(--ink); }
.brand-text b { color: var(--indigo); font-weight: 800; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 14px 14px; }
.nav-group-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted);
  font-weight: 700; margin: 22px 10px 10px;
  padding-top: 18px; border-top: 1px solid var(--border);
}
.nav-group-label:first-child { margin-top: 6px; padding-top: 0; border-top: none; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; margin-bottom: 2px;
  border-radius: 9px; cursor: pointer; color: var(--text-soft); font-size: 13.5px;
  font-weight: 600; transition: all .15s;
}
.nav-icon { flex-shrink: 0; opacity: 0.7; width: 19px; height: 19px; transition: opacity .15s; }
.nav-item:hover { color: var(--indigo); background: var(--indigo-100); }
.nav-item:hover .nav-icon { opacity: 1; }
.nav-item.active { background: var(--indigo); color: #fff; box-shadow: 0 8px 18px rgba(0,5,238,0.3); }
.nav-item.active .nav-icon { opacity: 1; }

.tenant-filter-list { padding: 0 10px; display: flex; flex-direction: column; gap: 2px; }
.tenant-filter-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 7px;
  font-size: 12.5px; color: var(--text-soft); cursor: pointer;
}
.tenant-filter-item:hover { background: var(--indigo-100); color: var(--indigo); }
.tenant-filter-item input { accent-color: var(--indigo); }
.tenant-filter-item .t-count {
  margin-left: auto; font-size: 10px; background: var(--bg); padding: 1px 7px; border-radius: 10px; color: var(--muted);
}
.filter-empty { padding: 6px 8px; font-size: 12px; color: var(--muted); font-style: italic; }

.tenant-select {
  width: 100%; margin: 0 10px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: 12.5px; font-weight: 600; font-family: inherit;
  box-sizing: border-box; cursor: pointer;
}
.tenant-select:hover, .tenant-select:focus { border-color: var(--indigo); outline: none; }

.sidebar-footer { padding: 16px 20px 20px; border-top: 1px solid var(--border); }
.api-status-pill {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase;
  padding: 7px 12px; border-radius: var(--pill); display: flex; align-items: center; gap: 8px;
}
.api-status-pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.api-status-pill.offline { background: var(--red-100); color: var(--red); }
.api-status-pill.online { background: var(--green-100); color: var(--green); }
.api-status-pill.demo { background: var(--amber-100); color: #a56a13; }

/* ---------------- Main ---------------- */
.main { flex: 1; display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; background: var(--bg); min-width: 0; }
header {
  background: var(--header-bg); backdrop-filter: blur(8px);
  padding: 14px 32px; border-bottom: 1px solid var(--border); position: sticky; top: 0;
  display: flex; justify-content: space-between; align-items: center; z-index: 100; gap: 20px;
}
.header-left { display: flex; align-items: center; gap: 20px; min-width: 0; }
.only-mobile { display: none; }
.view-label { font-weight: 700; color: var(--ink); font-size: 16px; white-space: nowrap; }
.search-box {
  display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--pill); padding: 8px 16px; min-width: 320px; color: var(--muted);
}
.search-box input { border: none; background: transparent; outline: none; font-size: 13px; width: 100%; color: var(--text); }

.header-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: var(--card);
  color: var(--text-soft); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all .15s;
}
.icon-btn:hover { border-color: var(--indigo); color: var(--indigo); }
.portal-btn {
  background: var(--indigo); color: #fff; padding: 9px 18px; border-radius: var(--pill); text-decoration: none;
  font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 8px; transition: all .15s;
}
.portal-btn:hover { background: var(--indigo-600); }
.refresh-pill {
  font-size: 11px; color: var(--text-soft); font-family: 'Consolas', monospace; font-weight: 700;
  border: 1px solid var(--border); padding: 7px 12px; border-radius: var(--pill); white-space: nowrap;
}
.user-chip { display: flex; align-items: center; gap: 9px; padding-left: 10px; border-left: 1px solid var(--border); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--indigo); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px;
}
.user-meta { line-height: 1.25; }
.user-name { font-size: 12.5px; font-weight: 700; color: var(--ink); }
.user-action { font-size: 11px; color: var(--blue); text-decoration: none; font-weight: 600; }
.user-action:hover { text-decoration: underline; }

.content { padding: 28px 32px 60px; }

/* ---------------- Banners ---------------- */
.banner {
  border-radius: var(--radius); padding: 12px 18px; margin-bottom: 18px; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
}
.banner-warn { background: var(--amber-100); color: #8a5a10; border: 1px solid #f2d8a1; }

/* ---------------- Stat cards ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat-card {
  background: var(--card); padding: 18px 20px; border-radius: var(--radius); border: 1px solid var(--border);
  cursor: pointer; transition: all .15s; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--indigo); opacity: 0;
  transition: opacity .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card:hover::before { opacity: 1; }
.stat-card b { display: block; font-size: 26px; color: var(--ink); font-weight: 800; line-height: 1.1; }
.stat-card small { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; font-weight: 700; }
.stat-card.stat-alert b { color: var(--red); }

/* ---------------- Tenant overview ---------------- */
.tenant-overview { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-bottom: 26px; }
.tenant-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.tenant-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.tenant-card-name { font-weight: 700; color: var(--ink); font-size: 13.5px; }
.tenant-pill { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: var(--pill); text-transform: uppercase; letter-spacing: .5px; }
.tenant-pill.ok { background: var(--green-100); color: var(--green); }
.tenant-pill.warn { background: var(--red-100); color: var(--red); }
.tenant-card-meta { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }

/* ---------------- Alerts ---------------- */
.alert-container { margin-bottom: 26px; border: 1px solid #f3c9c7; border-radius: var(--radius); background: var(--card); box-shadow: 0 8px 24px rgba(217,69,63,0.1); max-width: 100%; overflow-x: auto; overflow-y: hidden; }
.alert-header { background: var(--red); color: #fff; padding: 11px 20px; font-weight: 700; font-size: 11.5px; letter-spacing: 0.8px; display: flex; align-items: center; gap: 10px; text-transform: uppercase; }
.alert-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.alert-table th { text-align: left; padding: 11px 20px; background: var(--red-100); color: var(--red); font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; }
.alert-table td { padding: 11px 20px; border-top: 1px solid #f9e1e1; color: var(--text); }

.status-badge { padding: 3px 9px; border-radius: var(--pill); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; }
.status-healthy { background: var(--green-100); color: var(--green); }
.status-unhealthy { background: var(--red-100); color: var(--red); }
.status-unknown { background: var(--card-alt); color: var(--muted); }
.power-badge { padding: 3px 9px; border-radius: var(--pill); font-size: 10px; font-weight: 700; text-transform: uppercase; background: var(--card-alt); color: var(--text-soft); }
.power-badge.running { background: var(--green-100); color: var(--green); }
.power-badge.stopped { background: var(--red-100); color: var(--red); }

/* ---------------- Sections / tables ---------------- */
.section {
  background: var(--card); padding: 22px; border-radius: var(--radius); border: 1px solid var(--border);
  margin-bottom: 22px; scroll-margin-top: 90px; box-shadow: var(--shadow-sm);
  /* Wide tables scroll inside their own card instead of stretching .main and
     dragging the header/sidebar along with them — see the mobile section below. */
  max-width: 100%; overflow-x: auto;
}
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.section h2 { margin: 0; font-size: 15.5px; color: var(--ink); border-left: 3px solid var(--indigo); padding-left: 12px; font-weight: 700; }
.section-count { font-size: 11px; color: var(--muted); font-weight: 600; }
.tenant-text { color: var(--text) !important; font-weight: 600; }
.ip-text { color: var(--blue) !important; font-family: 'Consolas', monospace; font-weight: 700; font-size: 12px; }
.inspect-btn { cursor: pointer; background: var(--near-black); color: #fff; border: none; padding: 6px 14px; border-radius: var(--pill); font-size: 10.5px; font-weight: 700; transition: background .15s; }
.inspect-btn:hover { background: var(--indigo); }
.row-actions { display: flex; gap: 6px; }
.mini-action { cursor: pointer; border: 1px solid var(--border); background: var(--card); padding: 5px 11px; border-radius: var(--pill); font-size: 10px; font-weight: 700; color: var(--text-soft); transition: all .15s; }
.mini-action:hover { border-color: var(--indigo); color: var(--indigo); }
.mini-action.danger { border-color: var(--red); color: var(--red); background: var(--red-100); }
.mini-action.danger:hover { border-color: var(--red); color: var(--red); opacity: 0.8; }
.mini-action:disabled { opacity: 0.35; cursor: not-allowed; }

/* ---------------- Modal ---------------- */
#modal { display: none; position: fixed; z-index: 9999; inset: 0; background: rgba(0,2,40,0.6); backdrop-filter: blur(4px); }
.modal-content { background: var(--card); margin: 3vh auto; width: 90%; max-width: 1200px; height: 94vh; border-radius: 16px; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.modal-header { padding: 22px 34px; background: var(--card); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: flex-start; }
.modal-header small { color: var(--blue); font-weight: 800; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; }
.modal-header h1 { margin: 4px 0 0; color: var(--ink); font-size: 20px; }
.modal-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.modal-close { background: transparent; border: none; color: var(--muted); font-size: 26px; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--ink); }
.modal-body { display: grid; grid-template-columns: 380px 1fr; gap: 1px; background: var(--border); flex: 1; overflow: hidden; }
.drill-left { background: var(--card); padding: 32px; overflow-y: auto; }
.drill-right { background: #0b0d17; padding: 20px; overflow-y: auto; position: relative; }
.prop-box { margin-bottom: 22px; }
.prop-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 700; margin-bottom: 6px; }
.json-label { margin-bottom: 15px; color: rgba(255,255,255,0.5); }
.prop-val { font-size: 15px; color: var(--ink); font-weight: 600; word-break: break-word; }
.json-viewer { font-family: 'Consolas', monospace; color: #8fd6ff; font-size: 12px; white-space: pre-wrap; background: #0b0d17; padding: 15px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.08); }

.device-tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.device-tab { background: none; border: none; border-bottom: 2px solid transparent; padding: 0 2px 10px; margin-right: 18px; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; }
.device-tab:hover { color: var(--text); }
.device-tab.active { color: var(--indigo); border-bottom-color: var(--indigo); }
.device-tab-panel .prop-box:last-child { margin-bottom: 0; }
.table-scroll { max-width: 100%; overflow-x: auto; }
.compliance-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.compliance-table th { text-align: left; padding: 10px 14px; background: var(--card-alt); color: var(--text-soft); font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
.compliance-table td { padding: 10px 14px; border-top: 1px solid var(--border); color: var(--text); white-space: nowrap; }
.action-bar { padding: 18px 34px; background: var(--card); border-top: 1px solid var(--border); display: flex; gap: 12px; align-items: center; }
.action-bar-spacer { flex: 1; }

.btn-manage { text-decoration: none; padding: 11px 24px; border-radius: var(--pill); font-weight: 700; font-size: 12.5px; display: inline-flex; align-items: center; gap: 9px; }
.btn-secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); padding: 11px 24px; border-radius: var(--pill); font-weight: 700; font-size: 12.5px; cursor: pointer; }
.btn-secondary:hover { background: var(--bg); border-color: var(--muted); }
.btn-action { border: none; padding: 11px 22px; border-radius: var(--pill); font-weight: 700; font-size: 12.5px; cursor: pointer; color: #fff; background: var(--indigo); transition: opacity .15s; }
.btn-action:hover { opacity: 0.85; }
.btn-action:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-start { background: var(--green); }
.btn-restart { background: var(--amber); }
.btn-stop { background: var(--red); }

/* ---------------- Confirm dialog ---------------- */
.confirm-overlay { display: none; position: fixed; inset: 0; z-index: 10050; background: rgba(0,2,40,0.5); align-items: center; justify-content: center; }
.confirm-overlay.show { display: flex; }
.confirm-box { background: var(--card); border-radius: 16px; padding: 28px 30px; width: min(400px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); box-sizing: border-box; }
.confirm-box h3 { margin: 0 0 10px; color: var(--ink); font-size: 16px; }
.confirm-box p { margin: 0 0 22px; color: var(--text-soft); font-size: 13.5px; line-height: 1.5; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }
.confirm-actions .btn-secondary { background: var(--card); color: var(--text-soft); border: 1px solid var(--border); }
.confirm-actions .btn-secondary:hover { background: var(--bg); border-color: var(--muted); }
.confirm-actions .btn-action, .confirm-actions .btn-danger { padding: 9px 20px; border-radius: var(--pill); }
.btn-danger { background: var(--red); color: #fff; border: none; padding: 9px 20px; border-radius: var(--pill); font-weight: 700; font-size: 12.5px; cursor: pointer; }

/* ---------------- Toasts ---------------- */
.toast-container { position: fixed; top: 16px; right: 16px; left: 16px; z-index: 10001; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; pointer-events: none; }
.status-notification {
  background: var(--near-black); color: #fff; padding: 14px 20px; border-left: 4px solid var(--indigo); border-radius: 10px;
  box-shadow: var(--shadow-lg); font-size: 13px; transition: all .4s ease; opacity: 0; transform: translateX(20px);
  width: 100%; max-width: 340px; box-sizing: border-box; pointer-events: auto;
}
.status-notification.show { opacity: 1; transform: translateX(0); }
.status-notification.success { border-left-color: var(--green); }
.status-notification.error { border-left-color: var(--red); }

/* ---------------- Uptime Monitoring ---------------- */
.heatmap { display: flex; gap: 2px; }
.heatmap-tile { width: 6px; height: 16px; border-radius: 1px; background: var(--border); flex-shrink: 0; cursor: pointer; transition: transform .1s; }
.heatmap-tile:hover { transform: scaleY(1.25); }
.heatmap-tile.up { background: var(--green); }
.heatmap-tile.down { background: var(--red); }
.heatmap-empty { font-size: 11.5px; color: var(--muted); font-style: italic; }

.uptime-bar { display: flex; gap: 1px; }
.uptime-bar-seg { width: 6px; height: 14px; border-radius: 1px; background: var(--border); flex-shrink: 0; }
.uptime-bar-seg.full { background: var(--green); }
.uptime-bar-seg.partial { background: #d99a1e; }
.uptime-bar-seg.bad { background: var(--red); }
.uptime-pct { font-size: 11px; color: var(--muted); margin-top: 4px; font-weight: 700; }

.confirm-box.form-box { width: min(480px, calc(100vw - 32px)); text-align: left; }
.form-field { margin-bottom: 16px; }
.form-field label { display: block; font-size: 12px; font-weight: 700; color: var(--text-soft); margin-bottom: 6px; }
.form-field-inline label { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); }
.form-field input[type="text"], .form-field input[type="number"], .form-field select {
  width: 100%; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: 13px; font-family: inherit; box-sizing: border-box;
}
.form-field input:focus, .form-field select:focus { border-color: var(--indigo); outline: none; }
.form-hint { display: block; margin-top: 6px; font-size: 11px; color: var(--muted); }
.form-row { display: flex; gap: 14px; }
.form-row .form-field { flex: 1; min-width: 0; }

/* Uptime Monitoring uses the same design tokens as the rest of the
   dashboard (card/border/text) so it themes identically with the
   light/dark toggle instead of being a permanently-dark island. */
.monitor-console-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.monitor-console-header h2 { color: var(--ink); font-size: 19px; margin: 0; }
.monitor-console-sub { color: var(--muted); font-size: 12px; margin-top: 5px; }
.monitor-clear-filter { color: var(--indigo); font-weight: 700; text-decoration: none; margin-left: 4px; }
.monitor-console-actions { display: flex; gap: 10px; flex-shrink: 0; }
.btn-secondary-dark {
  background: var(--card); color: var(--text); border: 1px solid var(--border); padding: 9px 18px;
  border-radius: var(--pill); font-size: 12.5px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.btn-secondary-dark:hover { background: var(--card-alt); border-color: var(--muted); }

.monitor-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.monitor-stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px;
  cursor: pointer; transition: border-color .15s, background .15s; box-shadow: var(--shadow-sm);
}
.monitor-stat-card:hover { border-color: var(--muted); }
.monitor-stat-card.active { border-color: var(--indigo); background: var(--indigo-100); }
.monitor-stat-card b { display: block; font-size: 26px; color: var(--ink); font-weight: 800; }
.monitor-stat-card small { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.monitor-stat-card.alert b { color: var(--red); }

.monitor-panel { background: var(--card); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 16px; overflow: hidden; box-shadow: var(--shadow-sm); }
.monitor-panel-head {
  padding: 12px 18px; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--muted); border-bottom: 1px solid var(--border);
}

.monitor-two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 16px; }
.monitor-two-col .monitor-panel { margin-bottom: 0; }
.monitor-panel-badge { background: var(--indigo-100); color: var(--indigo); font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: var(--pill); margin-left: 6px; text-transform: none; letter-spacing: 0; }

.status-mosaic { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; padding: 14px; max-height: 340px; overflow-y: auto; }

.response-time-list { padding: 10px 14px; max-height: 340px; overflow-y: auto; }
.response-time-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; cursor: pointer; }
.response-time-value { font-size: 12px; font-weight: 700; color: var(--text-soft); width: 42px; flex-shrink: 0; text-align: right; font-family: 'Consolas', monospace; }
.response-time-bar-track { flex: 1; height: 14px; background: var(--card-alt); border-radius: 3px; overflow: hidden; min-width: 60px; }
.response-time-bar-fill { height: 100%; background: var(--indigo); border-radius: 3px; }
.response-time-name { font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; flex-shrink: 0; }
.response-time-row:hover .response-time-name { color: var(--indigo); }
.status-tile { background: var(--card-alt); border: 1px solid var(--border); border-left: 3px solid var(--muted); border-radius: 6px; padding: 10px 12px; cursor: pointer; transition: border-color .15s; }
.status-tile:hover { border-color: var(--indigo); }
.status-tile.up { border-left-color: var(--green); }
.status-tile.down { border-left-color: var(--red); background: var(--red-100); }
.status-tile.pending, .status-tile.stale { border-left-color: var(--muted); opacity: .65; }
.status-tile-name { font-size: 12.5px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-tile-target { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

.monitor-config-table { width: 100%; border-collapse: collapse; }
.monitor-config-table th { text-align: left; padding: 11px 18px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.monitor-config-table td { padding: 13px 18px; border-bottom: 1px solid var(--card-alt); font-size: 13px; color: var(--text); }
.monitor-config-table tbody tr:hover td { background: var(--card-alt); }

/* ---------------- DataTables overrides ---------------- */
.dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter, .dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_processing, .dataTables_wrapper .dataTables_paginate { color: var(--text-soft) !important; font-size: 12px; }
.dataTables_wrapper .dataTables_filter input, .dataTables_wrapper .dataTables_length select { background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 6px; }
.dataTables_wrapper .dataTables_paginate .paginate_button { color: var(--text-soft) !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current { background: var(--card-alt) !important; border-color: var(--border) !important; color: var(--ink) !important; }
table.dataTable.cell-border tbody tr th, table.dataTable.cell-border tbody tr td { border-color: var(--card-alt) !important; color: var(--text); padding: 10px 12px !important; font-size: 12.5px; background: var(--card); }
table.dataTable thead th { background: var(--card-alt); color: var(--ink); border-bottom: 2px solid var(--border) !important; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }

/* ---------------- Responsive ---------------- */
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,2,40,0.4); z-index: 499; }
.sidebar-backdrop.show { display: block; }

@media (max-width: 980px) {
  .sidebar { position: fixed; left: -280px; top: 0; bottom: 0; z-index: 500; transition: left .2s; width: 260px; }
  .sidebar.open { left: 0; }
  .only-mobile { display: flex; }
  .search-box { min-width: 160px; }
  .modal-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
}

@media (max-width: 640px) {
  .content { padding: 16px 16px 40px; }

  header { padding: 10px 14px; gap: 8px; }
  .header-left { min-width: 0; flex: 1; gap: 10px; }
  .view-label { display: none; }
  .search-box { min-width: 0; flex: 1; padding: 7px 12px; }
  .header-right { gap: 8px; }
  .portal-btn, .refresh-pill { display: none; }
  .user-meta { display: none; }
  .user-chip { padding-left: 0; border-left: none; }

  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 10px; margin-bottom: 18px; }
  .stat-card { padding: 14px 16px; }
  .stat-card b { font-size: 22px; }
  .tenant-overview { gap: 10px; margin-bottom: 18px; }

  .section { padding: 16px; margin-bottom: 16px; }
  .section-head { margin-bottom: 12px; }

  /* Full-screen sheet instead of a floating card — a fixed-size modal has
     nowhere good to go on a phone-width viewport. */
  .modal-content { margin: 0; width: 100%; height: 100%; max-width: none; border-radius: 0; }
  .modal-header { padding: 16px 18px; }
  .drill-left { padding: 18px; }
  .drill-right { padding: 16px; }
  .action-bar { padding: 14px 18px; flex-wrap: wrap; }
  .action-bar-spacer { flex-basis: 100%; height: 0; }
  .btn-manage { width: 100%; justify-content: center; }
}
