@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=IBM+Plex+Mono:wght@400;500;600&family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* base — dark grey, not pure black */
  --bg:          #1a1a1d;
  --bg-inset:    #202024;
  --surface:     #26262b;
  --surface-2:   #303036;
  --border:      #3a3a41;
  --border-soft: #2f2f35;

  /* text */
  --text:      #ece8e9;
  --text-mid:  #a5a1a7;
  --text-dim:  #75727a;

  /* the one accent — neon red */
  --red:       #ff1e3c;
  --red-hover: #ff4258;
  --red-deep:  #6e1a24;
  --red-wash:  rgba(255, 30, 60, 0.14);
  --red-glow:  rgba(255, 30, 60, 0.55);

  /* status (kept quiet so red stays the signal) */
  --amber:      #c98a3a;
  --amber-wash: rgba(201, 138, 58, 0.12);
  --green:      #4f9c6d;
  --green-wash: rgba(79, 156, 109, 0.12);
  --slate:      #756f8a;
  --slate-wash: rgba(117, 111, 138, 0.12);

  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --display: 'Space Grotesk', var(--sans);
  --mono: 'IBM Plex Mono', 'Courier New', monospace;

}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

a { color: var(--red); text-decoration: none; }
a:hover { color: var(--red-hover); text-decoration: underline; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 4px; border: 1px solid var(--border); }
::-webkit-scrollbar-thumb:hover { background: var(--red-deep); }

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 3px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--red); color: #fff; box-shadow: 0 0 10px var(--red-glow); }
.btn-primary:hover { background: var(--red-hover); box-shadow: 0 0 18px var(--red-glow); }
.btn-success { background: var(--green); color: #0a090b; }
.btn-success:hover { filter: brightness(1.1); }
.btn-danger  { background: transparent; color: var(--red); border-color: var(--red-deep); }
.btn-danger:hover { background: var(--red-wash); border-color: var(--red); }
.btn-warning { background: var(--red); color: #fff; box-shadow: 0 0 10px var(--red-glow); }
.btn-warning:hover { background: var(--red-hover); }
.btn-ghost   { background: transparent; color: var(--text-mid); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--text-dim); color: var(--text); }
.btn-sm { padding: 6px 11px; font-size: 12px; }

/* BADGES */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.badge-high    { background: var(--red-wash);   color: #ff5468; border: 1px solid var(--red); box-shadow: 0 0 8px var(--red-glow); }
.badge-medium  { background: var(--amber-wash); color: var(--amber); border: 1px solid rgba(201,138,58,0.35); }
.badge-low     { background: var(--green-wash); color: var(--green); border: 1px solid rgba(79,156,109,0.35); }
.badge-info    { background: var(--slate-wash); color: #a6a0c2; border: 1px solid rgba(117,111,138,0.35); }
.badge-online  { background: var(--green-wash); color: var(--green); border: 1px solid rgba(79,156,109,0.35); }
.badge-offline { background: var(--surface-2);  color: var(--text-dim); border: 1px solid var(--border); }

/* FORM */
.form-group { margin-bottom: 15px; }

label {
  display: block;
  font-weight: 600;
  margin-bottom: 5px;
  font-size: 13px;
  color: var(--text-mid);
}

input, select, textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: var(--sans);
  font-size: 13px;
  background: var(--bg-inset);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-wash); }
input::placeholder { color: var(--text-dim); }

/* LAYOUT */
.layout { display: flex; height: 100vh; overflow: hidden; background: var(--bg); }
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.content { flex: 1; overflow-y: auto; padding: 20px; background: var(--bg); }

/* SIDEBAR */
.sidebar {
  width: 210px;
  background: var(--bg-inset);
  color: var(--text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  border-right: 1px solid var(--border-soft);
}

.sidebar-brand { padding: 16px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; gap: 9px; }
.sidebar-brand::before {
  content: "";
  width: 8px; height: 8px;
  background: var(--red);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--red-glow);
  flex-shrink: 0;
}
.sidebar-brand-name { font-family: var(--display); font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: 0.2px; }
.sidebar-brand-sub  { font-size: 10px; color: var(--text-dim); margin-top: 2px; }

.sidebar-section { padding: 14px 10px 4px; }

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  padding: 0 8px;
  margin-bottom: 4px;
  display: block;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 3px;
  color: var(--text-mid);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  margin-bottom: 2px;
  border-left: 2px solid transparent;
}
.nav-item:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--red-wash); color: #ff5468; border-left-color: var(--red); box-shadow: inset 0 0 12px var(--red-glow); }
.nav-item-icon { font-size: 14px; width: 16px; text-align: center; flex-shrink: 0; }
.nav-item-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
}

.sidebar-footer { margin-top: auto; padding: 12px 10px; border-top: 1px solid var(--border-soft); }
.sidebar-user { display: flex; align-items: center; gap: 9px; padding: 8px; border-radius: 3px; cursor: pointer; }
.sidebar-user:hover { background: var(--surface); }

.sidebar-avatar {
  width: 30px; height: 30px;
  background: var(--red-deep);
  color: #ff8a97;
  border: 1px solid var(--red-deep);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}

.sidebar-user-name { font-size: 13px; font-weight: 600; color: var(--text); }
.sidebar-user-role { font-size: 11px; color: var(--text-dim); }

/* TOPBAR */
.topbar {
  height: 52px;
  background: var(--bg-inset);
  color: var(--text);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-soft);
}
.topbar-title    { font-family: var(--display); font-size: 15px; font-weight: 600; color: var(--text); }
.topbar-subtitle { font-size: 11px; color: var(--text-dim); }
.topbar-right    { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar-time {
  font-family: var(--mono);
  font-size: 12px; color: var(--text-mid);
  background: var(--surface); padding: 4px 10px;
  border-radius: 3px; border: 1px solid var(--border);
}

/* LIVE BADGE */
.live-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px;
  background: var(--red-wash); border: 1px solid var(--red-deep);
  border-radius: 20px;
  font-size: 11px; font-weight: 600; color: #ff5468;
}
.live-dot {
  width: 6px; height: 6px;
  background: #22c55e; border-radius: 50%;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* CARD */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 2px solid var(--red);
  border-radius: 4px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 -6px 16px -8px var(--red-glow);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border-soft);
}
.card-title    { font-family: var(--display); font-size: 14px; font-weight: 600; color: var(--text); }
.card-subtitle { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* STAT CARDS */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px; margin-bottom: 16px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; padding: 14px 16px;
  border-top: 2px solid var(--red-deep);
}
.stat-card-label  { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.stat-card-val    { font-size: 26px; font-weight: 600; font-family: var(--mono); margin-bottom: 4px; color: var(--text); }
.stat-card-change { font-size: 11px; color: var(--text-dim); }
.change-up   { color: var(--red); font-weight: 600; }
.change-down { color: var(--green); font-weight: 600; }

/* TABLE */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--bg-inset); border-bottom: 1px solid var(--border); }
th {
  text-align: left; font-size: 11px; font-weight: 600;
  color: var(--text-dim); padding: 9px 12px; text-transform: uppercase;
  letter-spacing: 0.5px;
}
td { padding: 10px 12px; font-size: 13px; border-bottom: 1px solid var(--border-soft); color: var(--text); }
tbody tr:hover { background: var(--surface); }
tbody tr:last-child td { border-bottom: none; }
.td-mono { font-family: var(--mono); font-size: 12px; }
.td-dim  { color: var(--text-dim); }

/* neon line under the dashboard's log table */
.logs-card .table-wrap {
  position: relative;
  padding-bottom: 14px;
}
.logs-card .table-wrap::after {
  content: "";
  display: block;
  height: 2px;
  margin-top: 14px;
  border-radius: 2px;
  background: var(--red);
  box-shadow:
    0 0 4px var(--red),
    0 0 14px var(--red-glow),
    0 0 28px var(--red-glow);
}

/* FILTER BAR */
.filter-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.search-wrap { position: relative; flex: 1; min-width: 180px; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-dim); pointer-events: none; }
.search-input {
  width: 100%; padding: 8px 10px 8px 30px;
  border: 1px solid var(--border); border-radius: 3px;
  font-family: var(--sans); font-size: 13px; outline: none;
  background: var(--bg-inset); color: var(--text);
}
.search-input:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-wash); }
.search-input::placeholder { color: var(--text-dim); }
.filter-select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 3px;
  font-family: var(--sans); font-size: 13px;
  background: var(--bg-inset); color: var(--text); cursor: pointer; outline: none;
}

/* LOG ENTRY */
.log-line    { font-family: var(--mono); font-size: 12px; color: var(--text-mid); line-height: 1.6; }
.log-keyword { color: #ff5468; font-weight: 600; }
.log-host    { color: #a6a0c2; }
.log-ip      { color: var(--amber); }
.log-ok      { color: var(--green); }

/* ALERT FEED */
.alert-feed { display: flex; flex-direction: column; gap: 8px; }
.alert-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; background: var(--bg-inset);
  border: 1px solid var(--border-soft); border-left: 3px solid var(--border); border-radius: 3px;
}
.alert-item.high   { border-left-color: var(--red); }
.alert-item.medium { border-left-color: var(--amber); }
.alert-item.low    { border-left-color: var(--green); }
.alert-icon  { font-size: 16px; flex-shrink: 0; }
.alert-body  { flex: 1; }
.alert-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; color: var(--text); }
.alert-meta  { font-size: 11px; color: var(--text-dim); font-family: var(--mono); }
.alert-time  { font-size: 11px; color: var(--text-dim); font-family: var(--mono); flex-shrink: 0; }

/* CHART */
.chart-bars { display: flex; align-items: flex-end; gap: 3px; height: 70px; }
.chart-bar {
  flex: 1; background: var(--surface-2);
  border-radius: 2px 2px 0 0; border: 1px solid var(--border);
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.chart-bar:hover           { background: var(--red-deep); border-color: var(--red); }
.chart-bar.alert-bar       { background: var(--red-wash); border-color: var(--red-deep); }
.chart-bar.alert-bar:hover { background: var(--red); border-color: var(--red); }
.chart-labels { display: flex; justify-content: space-between; margin-top: 5px; }
.chart-labels span { font-size: 10px; color: var(--text-dim); font-family: var(--mono); }

/* DEVICES */
.devices-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.device-card { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 16px; }
.device-card-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border-soft);
}
.device-icon {
  width: 36px; height: 36px; background: var(--red-wash);
  border: 1px solid var(--red-deep); border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0;
}
.device-name { font-size: 14px; font-weight: 600; color: var(--text); }
.device-id   { font-size: 11px; color: var(--text-dim); font-family: var(--mono); }
.device-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.device-stat { background: var(--bg-inset); border: 1px solid var(--border-soft); border-radius: 3px; padding: 8px 10px; }
.device-stat-val   { font-size: 18px; font-weight: 600; font-family: var(--mono); color: var(--text); }
.device-stat-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.4px; }
.device-apikey {
  background: var(--bg-inset); border: 1px solid var(--border-soft); border-radius: 3px;
  padding: 7px 10px; font-family: var(--mono);
  font-size: 11px; color: var(--text-dim); margin-bottom: 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.device-apikey-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-actions    { display: flex; gap: 8px; }

/* PAGINATION */
.pagination { display: flex; align-items: center; gap: 4px; justify-content: center; margin-top: 16px; }
.page-btn {
  width: 30px; height: 30px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--text-mid);
  cursor: pointer; transition: all 0.15s;
}
.page-btn:hover  { border-color: var(--red); color: var(--red); }
.page-btn.active { background: var(--red); color: #fff; border-color: var(--red); box-shadow: 0 0 10px var(--red-glow); }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px;
  padding: 24px; width: 440px; max-width: 90vw;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.modal-title   { font-family: var(--display); font-size: 16px; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.modal-sub     { font-size: 12px; color: var(--text-dim); margin-bottom: 18px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* ALERT STATS */
.alert-stats { display: flex; gap: 10px; margin-bottom: 16px; }
.alert-stat-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; padding: 12px 18px; text-align: center; flex: 1;
}
.alert-stat-val   { font-size: 22px; font-weight: 600; font-family: var(--mono); }
.alert-stat-label { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.val-red    { color: #ff5468; }
.val-yellow { color: var(--amber); }
.val-green  { color: var(--green); }

/* REPORT BOX */
.report-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px;
  padding: 14px 18px; margin-bottom: 16px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
}
.report-box-title { font-size: 14px; font-weight: 600; margin-bottom: 3px; color: var(--text); }
.report-box-sub   { font-size: 12px; color: var(--text-dim); }
.report-box-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* UTILS */
.flex        { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.ml-auto     { margin-left: auto; }
.mb-16       { margin-bottom: 16px; }
.grid-2      { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-main   { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }

/* LOGIN */
.login-page {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #120a0b 0%, #050303 70%, #000 100%);
  position: relative;
  z-index: 0;      /* establishes a stacking context so the layers below can't leak behind the page background */
  overflow: hidden;
}

/* pure-CSS matrix code rain — two parallax layers of tiled SVG digits, animated with background-position */
.login-page::before,
.login-page::after {
  content: "";
  position: absolute; inset: 0;
  z-index: 0;
  pointer-events: none;
}

.login-page::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='240'%3E%3Ctext x='2' y='16' font-family='monospace' font-size='15' fill='%23ff1e3c'%3E1%3C/text%3E%3Ctext x='2' y='36' font-family='monospace' font-size='15' fill='%23ff1e3c' opacity='0.75'%3E0%3C/text%3E%3Ctext x='2' y='56' font-family='monospace' font-size='15' fill='%23ff1e3c' opacity='0.55'%3E1%3C/text%3E%3Ctext x='2' y='76' font-family='monospace' font-size='15' fill='%23ff1e3c' opacity='0.85'%3E0%3C/text%3E%3Ctext x='2' y='96' font-family='monospace' font-size='15' fill='%23ff1e3c' opacity='0.4'%3E1%3C/text%3E%3Ctext x='2' y='116' font-family='monospace' font-size='15' fill='%23ff1e3c' opacity='0.9'%3E0%3C/text%3E%3Ctext x='2' y='136' font-family='monospace' font-size='15' fill='%23ff1e3c' opacity='0.6'%3E1%3C/text%3E%3Ctext x='2' y='156' font-family='monospace' font-size='15' fill='%23ff1e3c' opacity='0.3'%3E0%3C/text%3E%3Ctext x='2' y='176' font-family='monospace' font-size='15' fill='%23ff1e3c' opacity='0.7'%3E1%3C/text%3E%3Ctext x='2' y='196' font-family='monospace' font-size='15' fill='%23ff1e3c' opacity='0.5'%3E0%3C/text%3E%3Ctext x='2' y='216' font-family='monospace' font-size='15' fill='%23ff1e3c' opacity='0.8'%3E1%3C/text%3E%3Ctext x='2' y='236' font-family='monospace' font-size='15' fill='%23ff1e3c' opacity='0.45'%3E0%3C/text%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 22px 240px;
  opacity: 0.55;
  animation: matrixFall 5.5s linear infinite;
  filter: drop-shadow(0 0 5px rgba(255,30,60,0.5));
}

/* second, dimmer layer offset horizontally and running at a different speed for depth */
.login-page::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='200'%3E%3Ctext x='2' y='14' font-family='monospace' font-size='13' fill='%23ff4258'%3E0%3C/text%3E%3Ctext x='2' y='32' font-family='monospace' font-size='13' fill='%23ff4258' opacity='0.6'%3E1%3C/text%3E%3Ctext x='2' y='50' font-family='monospace' font-size='13' fill='%23ff4258' opacity='0.9'%3E0%3C/text%3E%3Ctext x='2' y='68' font-family='monospace' font-size='13' fill='%23ff4258' opacity='0.4'%3E1%3C/text%3E%3Ctext x='2' y='86' font-family='monospace' font-size='13' fill='%23ff4258' opacity='0.7'%3E0%3C/text%3E%3Ctext x='2' y='104' font-family='monospace' font-size='13' fill='%23ff4258' opacity='0.5'%3E1%3C/text%3E%3Ctext x='2' y='122' font-family='monospace' font-size='13' fill='%23ff4258' opacity='0.85'%3E0%3C/text%3E%3Ctext x='2' y='140' font-family='monospace' font-size='13' fill='%23ff4258' opacity='0.3'%3E1%3C/text%3E%3Ctext x='2' y='158' font-family='monospace' font-size='13' fill='%23ff4258' opacity='0.65'%3E0%3C/text%3E%3Ctext x='2' y='176' font-family='monospace' font-size='13' fill='%23ff4258' opacity='0.5'%3E1%3C/text%3E%3Ctext x='2' y='194' font-family='monospace' font-size='13' fill='%23ff4258' opacity='0.75'%3E0%3C/text%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 18px 200px;
  background-position: 9px 0;
  opacity: 0.32;
  animation: matrixFallSlow 8s linear infinite;
  animation-delay: -2s;
}

@keyframes matrixFall {
  from { background-position-y: 0; }
  to   { background-position-y: 240px; }
}
@keyframes matrixFallSlow {
  from { background-position-y: 0; }
  to   { background-position-y: 200px; }
}

.login-page > * { position: relative; z-index: 1; }
.login-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  width: 860px; max-width: 95vw; min-height: 500px;
  border: 1px solid var(--border); border-radius: 6px; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.login-left {
  background: var(--bg-inset);
  padding: 48px 40px;
  display: flex; flex-direction: column; justify-content: space-between;
  border-right: 1px solid var(--border-soft);
  position: relative;
}
.login-left::before {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--red), transparent);
}
.login-brand        { display: flex; align-items: center; gap: 12px; }
.login-brand-icon   { width: 36px; height: 36px; background: var(--red-wash); border: 1px solid var(--red-deep); border-radius: 6px; }
.login-brand-name   { font-family: var(--display); font-size: 16px; font-weight: 700; color: var(--text); }
.login-brand-sub    { font-size: 11px; color: var(--text-dim); }
.login-tagline h1      { font-family: var(--display); font-size: 27px; font-weight: 600; color: var(--text); line-height: 1.3; margin-bottom: 12px; }
.login-tagline h1 span { color: var(--red); }
.login-tagline p       { font-size: 13px; color: var(--text-mid); line-height: 1.6; }
.login-stats      { display: flex; gap: 24px; }
.login-stat-val   { font-family: var(--mono); font-size: 22px; font-weight: 600; color: var(--red); }
.login-stat-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.login-right {
  background: var(--surface);
  padding: 48px 40px;
  display: flex; flex-direction: column; justify-content: center;
}
.login-right h2 { font-family: var(--display); font-size: 22px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.login-right p  { color: var(--text-dim); font-size: 13px; margin-bottom: 24px; }
.login-box {
  background: var(--surface); border: 1px solid var(--red-deep); border-radius: 4px;
  padding: 36px 40px; width: 400px; max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 30px var(--red-glow);
  animation: box-flicker 3.2s infinite;
}
@keyframes box-flicker {
  0%, 80%, 100% { box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 30px var(--red-glow); }
  82%           { box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 46px rgba(255, 90, 150, 0.55); }
  85%           { box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 14px var(--red-glow); }
  88%           { box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 40px rgba(255, 90, 150, 0.5); }
}
.login-logo    { text-align: center; margin-bottom: 24px; }
.login-logo h1 {
  font-family: var(--display); font-size: 22px; font-weight: 700; color: var(--text);
  display: inline-block;
  animation: title-glitch 3.2s infinite;
}
@keyframes title-glitch {
  0%, 80%, 100% { text-shadow: none; transform: translate(0,0); }
  81% { text-shadow: -3px 0 var(--red), 3px 0 #ff3c7d; transform: translate(-1px, 0); }
  83% { text-shadow: 3px 0 var(--red), -3px 0 #ff3c7d; transform: translate(1px, 0); }
  85% { text-shadow: -2px 0 var(--red), 2px 0 #ff3c7d; transform: translate(0, -1px); }
  87% { text-shadow: 2px 0 var(--red), -2px 0 #ff3c7d; transform: translate(0, 1px); }
  89% { text-shadow: none; transform: translate(0,0); }
}
.login-logo p  { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.form-label  { display: block; font-weight: 600; margin-bottom: 5px; font-size: 13px; color: var(--text-mid); }
.form-input  {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border);
  border-radius: 3px; background: var(--bg-inset); color: var(--text);
  font-family: var(--sans); font-size: 13px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-wash); }
.form-input::placeholder { color: var(--text-dim); }
.login-footer { text-align: center; margin-top: 16px; font-size: 11px; color: var(--text-dim); }

@media (max-width: 860px) {
  .login-grid { grid-template-columns: 1fr; }
  .login-left { display: none; }
}

/* ===================== MANUAL PAGE ===================== */
.manual-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 2px solid var(--red);
  border-radius: 4px;
  padding: 20px 24px;
  margin-bottom: 16px;
  box-shadow: 0 -6px 16px -8px var(--red-glow);
}

.manual-section-title {
  font-family: var(--display);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}

.manual-section-sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 14px;
  margin-top: 4px;
}

.manual-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
}

.manual-step:last-child { border-bottom: none; }

.manual-step-num {
  width: 26px;
  height: 26px;
  background: var(--red-wash);
  border: 1px solid var(--red);
  color: #ff5468;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 1px;
  box-shadow: 0 0 8px var(--red-glow);
}

.manual-step-body { flex: 1; }

.manual-step-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}

.manual-step-desc {
  font-size: 12px;
  color: var(--text-mid);
  line-height: 1.6;
}

.manual-note {
  background: var(--amber-wash);
  border: 1px solid rgba(201,138,58,0.35);
  border-left: 3px solid var(--amber);
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--amber);
  margin-top: 12px;
  line-height: 1.6;
}

.manual-tip {
  background: var(--slate-wash);
  border: 1px solid rgba(117,111,138,0.35);
  border-left: 3px solid var(--slate);
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 12px;
  color: #b5b0d6;
  margin-top: 12px;
  line-height: 1.6;
}

.manual-warning {
  background: var(--red-wash);
  border: 1px solid var(--red-deep);
  border-left: 3px solid var(--red);
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 12px;
  color: #ff8a97;
  margin-top: 12px;
  line-height: 1.6;
}

.manual-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 13px;
}

.manual-table th {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.manual-table td {
  border: 1px solid var(--border-soft);
  padding: 8px 12px;
  color: var(--text);
  vertical-align: top;
}

.manual-table tbody tr:hover { background: var(--surface-2); }

.manual-code {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  margin-top: 8px;
  overflow-x: auto;
}

.manual-toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 16px 20px;
  margin-bottom: 20px;
  border-left: 2px solid var(--red);
  box-shadow: -6px 0 16px -10px var(--red-glow);
}

.manual-toc-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.manual-toc ol {
  padding-left: 18px;
  margin: 0;
}

.manual-toc li {
  font-size: 13px;
  padding: 3px 0;
  color: var(--text);
}

.manual-toc li:hover { text-decoration: underline; cursor: pointer; color: var(--red-hover); }

/* ===================== LIGHT THEME ===================== */
:root[data-theme="light"] {
  --bg:          #f3f3f6;
  --bg-inset:    #ffffff;
  --surface:     #ffffff;
  --surface-2:   #ececf1;
  --border:      #d5d5dd;
  --border-soft: #e5e5eb;

  --text:      #1c1c21;
  --text-mid:  #55535c;
  --text-dim:  #85828d;

  --red:       #e0112d;
  --red-hover: #c20e26;
  --red-deep:  #f2b5be;
  --red-wash:  rgba(224, 17, 45, 0.08);
  --red-glow:  rgba(224, 17, 45, 0.22);

  --amber:      #a86a1c;
  --amber-wash: rgba(201, 138, 58, 0.14);
  --green:      #2f7d4f;
  --green-wash: rgba(79, 156, 109, 0.14);
  --slate:      #5f5a78;
  --slate-wash: rgba(117, 111, 138, 0.12);

}

/* colours that were hard-coded for dark mode */
:root[data-theme="light"] .badge-high,
:root[data-theme="light"] .nav-item.active,
:root[data-theme="light"] .live-badge,
:root[data-theme="light"] .val-red,
:root[data-theme="light"] .log-keyword,
:root[data-theme="light"] .manual-step-num,
:root[data-theme="light"] .manual-warning,
:root[data-theme="light"] .sidebar-avatar { color: var(--red); }
:root[data-theme="light"] .log-host,
:root[data-theme="light"] .badge-info,
:root[data-theme="light"] .manual-tip { color: var(--slate); }
:root[data-theme="light"] .nav-item.active { box-shadow: none; }
:root[data-theme="light"] .modal-overlay,
:root[data-theme="light"] .help-overlay { background: rgba(20, 20, 25, 0.45); }

/* ===================== TOPBAR ICON BUTTON ===================== */
.icon-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  color: var(--text-mid);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 15px; line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.icon-btn:hover { border-color: var(--red); color: var(--red); box-shadow: 0 0 8px var(--red-glow); }

/* sun shows in dark mode (click = go light), moon shows in light mode */
.theme-toggle .i-moon { display: none; }
:root[data-theme="light"] .theme-toggle .i-sun  { display: none; }
:root[data-theme="light"] .theme-toggle .i-moon { display: inline; }

/* ===================== HELP MODAL ===================== */
.help-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center; justify-content: center;
  z-index: 200;
  padding: 20px;
}
.help-overlay.open { display: flex; }

.help-modal {
  width: 860px; max-width: 100%;
  max-height: 88vh;
  display: flex; flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: 2px solid var(--red);
  border-radius: 4px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 24px var(--red-glow);
  overflow: hidden;
}
.help-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-inset);
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.help-title { font-family: var(--display); font-size: 16px; font-weight: 600; color: var(--text); }
.help-sub   { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.help-body  { padding: 20px; overflow-y: auto; scroll-behavior: smooth; }

/* sidebar user block is now a link */
a.sidebar-user { text-decoration: none; color: inherit; }
a.sidebar-user:hover { text-decoration: none; }
a.sidebar-user.active { background: var(--red-wash); }

/* profile page */
.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 4px; }
.profile-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--red-deep); color: var(--red);
  border: 1px solid var(--red);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-size: 22px; font-weight: 700;
  box-shadow: 0 0 10px var(--red-glow);
}
.form-msg { padding: 10px 14px; border-radius: 3px; font-size: 13px; margin-bottom: 14px; }
.form-msg.ok  { background: var(--green-wash); border: 1px solid var(--green); color: var(--green); }
.form-msg.err { background: var(--red-wash);   border: 1px solid var(--red);   color: var(--red); }

/* ===================== SECURITY ANALYTICS ===================== */
/* posture gauge */
.posture-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.gauge {
  --c: var(--green);
  width: 130px; height: 130px; border-radius: 50%;
  background: conic-gradient(var(--c) calc(var(--pct) * 1%), var(--surface-2) 0);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 14px var(--red-glow);
}
.gauge.score-good { --c: var(--green); box-shadow: none; }
.gauge.score-fair { --c: var(--amber); box-shadow: none; }
.gauge.score-risk { --c: var(--red);   box-shadow: 0 0 14px var(--red-glow); }
.gauge-inner {
  width: 100px; height: 100px; border-radius: 50%;
  background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.gauge-val   { font-family: var(--mono); font-size: 30px; font-weight: 600; color: var(--text); line-height: 1; }
.gauge-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }

.posture-factors { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 6px; }
.factor {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 7px 10px; font-size: 12px; color: var(--text-mid);
  background: var(--bg-inset); border: 1px solid var(--border-soft); border-radius: 3px;
}

/* 7-day trend */
.trend-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); margin: 18px 0 8px; }
.trend-bars  { display: flex; gap: 8px; align-items: flex-end; }
.trend-col   { flex: 1; text-align: center; }
.trend-bar-wrap {
  height: 70px; display: flex; align-items: flex-end;
  background: var(--bg-inset); border: 1px solid var(--border-soft); border-radius: 3px; overflow: hidden;
}
.trend-bar { width: 100%; border-radius: 2px 2px 0 0; }
.tb-good { background: var(--green); }
.tb-fair { background: var(--amber); }
.tb-risk { background: var(--red); }
.trend-val { font-size: 11px; color: var(--text); margin-top: 4px; }
.trend-lbl { font-size: 10px; color: var(--text-dim); }

/* heatmap */
.heat-scroll { overflow-x: auto; }
.heat {
  display: grid;
  grid-template-columns: 38px repeat(24, minmax(18px, 1fr));
  gap: 3px;
  min-width: 620px;
}
.heat-hour   { font-size: 10px; font-family: var(--mono); color: var(--text-dim); text-align: center; }
.heat-day    { font-size: 11px; color: var(--text-dim); display: flex; align-items: center; }
.heat-cell   { aspect-ratio: 1; min-height: 18px; border-radius: 3px; border: 1px solid var(--border-soft); }
.heat-cell.lv0 { background: var(--bg-inset); }
.heat-cell.lv1 { background: rgba(255, 30, 60, 0.22); border-color: rgba(255, 30, 60, 0.25); }
.heat-cell.lv2 { background: rgba(255, 30, 60, 0.45); border-color: rgba(255, 30, 60, 0.5); }
.heat-cell.lv3 { background: rgba(255, 30, 60, 0.72); border-color: var(--red); }
.heat-cell.lv4 { background: var(--red); border-color: var(--red); box-shadow: 0 0 8px var(--red-glow); }
.heat-cell:hover { outline: 1px solid var(--text); }
.heat-legend {
  display: flex; align-items: center; gap: 4px; justify-content: flex-end;
  margin-top: 12px; font-size: 11px; color: var(--text-dim);
}
.heat-legend .heat-cell { width: 16px; min-height: 16px; aspect-ratio: auto; height: 16px; }
.heat-legend span { margin: 0 4px; }

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* ===================== PROFILE PAGE ===================== */
.profile-name { font-family: var(--display); font-size: 18px; font-weight: 600; color: var(--text); }

/* user info under Save Changes */
.info-list { margin-top: 20px; border-top: 1px solid var(--border-soft); }
.info-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 0;
  font-family: var(--sans); font-size: 13px;
  color: var(--text-mid);
  border-bottom: 1px solid var(--border-soft);
}
.info-row span:last-child { color: var(--text); font-family: var(--sans); }
.info-row:last-child { border-bottom: none; }

/* password strength */
.strength { height: 4px; background: var(--surface-2); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.strength-fill { height: 100%; width: 0; transition: width 0.2s, background 0.2s; }
.strength-text { font-family: var(--sans); font-size: 11px; color: var(--text-dim); margin-top: 5px; }

/* permissions list */
.perm-list { display: flex; flex-direction: column; gap: 6px; }
.perm-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  font-family: var(--sans); font-size: 13px;
  background: var(--bg-inset);
  border: 1px solid var(--border-soft);
  border-radius: 3px;
}
.perm-mark { width: 18px; text-align: center; font-weight: 700; }
.perm-yes .perm-mark { color: var(--green); }
.perm-no { color: var(--text-dim); }
.perm-no .perm-mark { color: var(--red); }

/* hero + messages (skip any of these you already pasted) */
.profile-head { display: flex; align-items: center; gap: 16px; }
.profile-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--red-deep); color: var(--red);
  border: 1px solid var(--red);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--sans); font-size: 22px; font-weight: 700;
  box-shadow: 0 0 10px var(--red-glow);
}
.form-msg { padding: 10px 14px; border-radius: 3px; font-size: 13px; margin-bottom: 14px; }
.form-msg.ok  { background: var(--green-wash); border: 1px solid var(--green); color: var(--green); }
.form-msg.err { background: var(--red-wash);   border: 1px solid var(--red);   color: var(--red); }

button, input, select, textarea { font-family: var(--sans); }

/* ===================== PASSWORD FIELD HELPERS ===================== */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 40px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--text-dim); font-size: 15px; line-height: 1; padding: 4px 6px;
}
.pw-toggle:hover { color: var(--red); }

.log-cell { cursor: pointer; }
.log-cell:hover { text-decoration: underline; color: var(--red); }

.log-modal-body {
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  background: var(--bg-inset);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 14px;
  max-height: 60vh;
  overflow-y: auto;
}

.log-cell { cursor: pointer; }
.log-cell:hover { text-decoration: underline; color: var(--red); }

.log-modal-body {
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  background: var(--bg-inset);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 14px;
  max-height: 60vh;
  overflow-y: auto;
}