/* ============================================================
   SYSADMIN DASHBOARD - SHARED BASE STYLES
   Includes all layout, spacing, typography, and component
   styles. Colors are defined via CSS custom properties.
   ============================================================ */

/* RESET */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ROOT & HTML/BODY */
html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

body {
  font-family: var(--font-body);
  color: var(--text);
}

/* ===== TOPBAR ===== */
.topbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border2);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 0;
  box-shadow: 0 1px 6px rgba(100, 80, 40, 0.06);
}

.tb-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 24px;
}

.tb-logo-mark {
  width: 34px;
  height: 34px;
  background: var(--green);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tb-logo-mark svg {
  width: 18px;
  height: 18px;
}

.tb-brand-text {
  line-height: 1.1;
}

.tb-brand-name {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

.tb-brand-sub {
  font-size: 10px;
  color: var(--text3);
  font-weight: 400;
}

.tb-sep {
  width: 1px;
  height: 28px;
  background: var(--border2);
  margin: 0 20px;
}

.tb-title {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  color: var(--text2);
  letter-spacing: 0.01em;
}

.tb-spacer {
  flex: 1;
}

.tb-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 20px;
}

.tb-chip {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 11px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.chip-green {
  background: var(--green-bg2);
  color: var(--green);
  border: 1px solid var(--green-bd);
}

.chip-amber {
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid var(--amber-bd);
}

.chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.tb-clock {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
  text-align: right;
}

.tb-date {
  font-size: 10px;
  color: var(--text3);
  font-weight: 400;
  text-align: right;
}

/* ===== BODY LAYOUT ===== */
.body {
  height: calc(100vh - 60px);
  display: grid;
  grid-template-columns: 248px 1fr 248px;
  overflow: hidden;
}

.col {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.col::-webkit-scrollbar {
  width: 4px;
}

.col::-webkit-scrollbar-track {
  background: transparent;
}

.col::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 2px;
}

.left-col {
  background: var(--bg2);
  border-right: 1px solid var(--border);
}

.center-col {
  background: var(--bg);
  padding: 16px 20px;
}

.right-col {
  background: var(--bg2);
  border-left: 1px solid var(--border);
}

/* ===== CARD COMPONENT ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  flex-shrink: 0;
}

.card-header {
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
}

.card-title {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 800;
  color: var(--text2);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex: 1;
}

.card-badge {
  font-family: var(--font);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 20px;
}

.badge-green {
  background: var(--green-bg2);
  color: var(--green);
}

.badge-amber {
  background: var(--amber-bg);
  color: var(--amber);
}

.badge-accent {
  background: var(--acc-bg2);
  color: var(--accent);
}

.badge-neutral {
  background: var(--bg3);
  color: var(--text3);
}

.card-body {
  padding: 14px 16px;
}

/* ===== STAT TILES ===== */
.stat-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
}

.tile {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.tile:hover {
  box-shadow: var(--shadow2);
}

.tile::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.tile-g::before {
  background: var(--green);
}

.tile-a::before {
  background: var(--amber);
}

.tile-t::before {
  background: var(--gold);
}

.tile-s::before {
  background: var(--text2);
}

.tile-val {
  font-family: var(--font);
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}

.tile-g .tile-val {
  color: var(--green);
}

.tile-a .tile-val {
  color: var(--amber);
}

.tile-t .tile-val {
  color: var(--gold);
}

.tile-s .tile-val {
  color: var(--text2);
}

.tile-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tile-delta {
  font-size: 10px;
  font-weight: 700;
  margin-top: 3px;
}

.delta-up {
  color: var(--green);
}

.delta-flat {
  color: var(--text3);
}

.delta-down {
  color: var(--red);
}

/* ===== BAR METERS ===== */
.bar-row {
  margin-bottom: 10px;
}

.bar-row:last-child {
  margin-bottom: 0;
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
}

.bar-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
}

.bar-pct {
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
}

.bar-track {
  height: 6px;
  background: var(--bg3);
  border-radius: 6px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 2s cubic-bezier(0.4, 0, 0.2, 1);
}

.fill-green {
  background: var(--green);
}

.fill-amber {
  background: var(--amber);
}

.fill-teal {
  background: var(--gold);
}

.fill-warm {
  background: var(--text2);
}

/* ===== HEALTH STATUS ROWS ===== */
.health-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.health-row:last-child {
  border-bottom: none;
}

.h-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.h-ok {
  background: var(--green);
}

.h-warn {
  background: var(--amber);
}

.h-err {
  background: var(--red);
}

.h-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.h-meta {
  font-size: 10px;
  color: var(--text3);
}

.h-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
}

.hb-ok {
  background: var(--green-bg2);
  color: var(--green);
}

.hb-warn {
  background: var(--amber-bg);
  color: var(--amber);
}

.hb-err {
  background: var(--red-bg);
  color: var(--red);
}

/* ===== TOPIC ROWS ===== */
.topic-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 6px;
  border-radius: var(--radius-sm);
  cursor: default;
  transition: background 0.15s;
}

.topic-row:hover {
  background: var(--bg2);
}

.t-rank {
  font-family: var(--font);
  font-size: 10px;
  font-weight: 800;
  color: var(--text3);
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.t-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.t-bar-wrap {
  width: 72px;
  flex-shrink: 0;
}

.t-bar-track {
  height: 5px;
  background: var(--bg3);
  border-radius: 5px;
  overflow: hidden;
}

.t-bar-fill {
  height: 100%;
  border-radius: 5px;
  background: var(--green);
  transition: width 2.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.t-count {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  width: 32px;
  text-align: right;
  flex-shrink: 0;
}

.t-trend {
  font-size: 10px;
  font-weight: 700;
  width: 28px;
  text-align: right;
  flex-shrink: 0;
}

/* ===== VOLUME CHART ===== */
.vol-wrap {
  padding: 8px 16px 14px;
}

.vol-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 64px;
}

.vol-bar {
  flex: 1;
  border-radius: 4px 4px 0 0;
  min-height: 3px;
  cursor: default;
  transition: filter 0.15s;
}

.vol-bar:hover {
  filter: brightness(1.15);
}

.vol-labels {
  display: flex;
  gap: 4px;
  margin-top: 5px;
}

.vol-lbl {
  flex: 1;
  text-align: center;
  font-size: 8px;
  font-weight: 600;
  color: var(--text3);
  letter-spacing: 0.02em;
}

/* ===== FILE TYPE GRID ===== */
.ft-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  padding: 12px;
}

.ft-item {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
}

.ft-pill {
  font-size: 8px;
  font-weight: 800;
  padding: 3px 6px;
  border-radius: 5px;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}

.fp-pdf {
  background: #fde8e8;
  color: #b03030;
}

.fp-doc {
  background: #e8eefe;
  color: #3050b0;
}

.fp-xls {
  background: #e8f5eb;
  color: #2e7d3a;
}

.fp-csv {
  background: #fef6e8;
  color: #a06010;
}

.fp-txt {
  background: var(--bg3);
  color: var(--text3);
}

.fp-htm {
  background: #f0eafd;
  color: #6040a0;
}

.ft-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ft-count {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}

/* ===== DONUT CHART ===== */
.donut-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
}

.donut-legend {
  flex: 1;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ===== FOLDER TREE ===== */
.folder-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: default;
  border: 1px solid transparent;
  transition: all 0.15s;
  margin-bottom: 2px;
}

.folder-row:hover {
  background: var(--bg3);
}

.folder-row.active {
  background: var(--green-bg2);
  border-color: var(--green-bd);
}

.folder-icon {
  font-size: 13px;
  flex-shrink: 0;
}

.folder-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.folder-row.active .folder-name {
  color: var(--green);
}

.folder-ct {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
}

.folder-row.active .folder-ct {
  color: var(--green);
}

.folder-sz {
  font-size: 10px;
  color: var(--text3);
}

/* ===== RECENT QUERIES ===== */
.query-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.query-item:last-child {
  border-bottom: none;
}

.query-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.4;
}

.query-meta {
  display: flex;
  gap: 8px;
  align-items: center;
}

.q-time {
  font-size: 10px;
  color: var(--text3);
}

.q-src {
  font-size: 10px;
  color: var(--text3);
  flex: 1;
}

.q-conf {
  font-size: 10px;
  font-weight: 700;
}

.conf-hi {
  color: var(--green);
}

.conf-md {
  color: var(--amber);
}

/* ===== EVENT LOG ===== */
.event-item {
  display: flex;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}

.event-item:last-child {
  border-bottom: none;
}

.ev-time {
  font-size: 9px;
  color: var(--text3);
  width: 40px;
  flex-shrink: 0;
  margin-top: 2px;
  font-weight: 600;
}

.ev-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 3px;
}

.evd-ok {
  background: var(--green);
}

.evd-info {
  background: var(--gold);
}

.evd-warn {
  background: var(--amber);
}

.ev-msg {
  color: var(--text2);
  line-height: 1.4;
  font-weight: 500;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 960px) {
  .topbar {
    padding: 0 12px;
    height: auto;
    min-height: 60px;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .tb-sep {
    display: none;
  }

  .tb-chips {
    margin-right: 0;
  }

  .tb-title {
    display: none;
  }

  .body {
    grid-template-columns: 1fr;
    height: auto;
    overflow-y: auto;
  }

  .left-col,
  .center-col,
  .right-col {
    border: none;
  }

  .stat-tiles {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .topbar {
    padding: 0 10px;
  }

  .tb-chips {
    order: 10;
    width: 100%;
    justify-content: center;
  }

  .tb-chip {
    font-size: 10px;
    padding: 3px 8px;
  }

  .stat-tiles {
    grid-template-columns: 1fr;
  }

  .ft-grid {
    grid-template-columns: 1fr;
  }

  /* Stack the bottom row file types + donut */
  .center-col > div:last-child {
    grid-template-columns: 1fr !important;
  }

  .tile-val {
    font-size: 22px;
  }

  .topic-row {
    flex-wrap: wrap;
    gap: 4px;
  }

  .t-bar-wrap {
    width: 100%;
    order: 10;
  }

  .t-count {
    width: auto;
  }

  .t-trend {
    width: auto;
  }
}
