:root {
  --bg-top: #111722;
  --bg-bottom: #0b1018;
  --panel: rgba(17, 24, 36, 0.94);
  --panel-soft: rgba(12, 18, 30, 0.9);
  --panel-border: rgba(138, 180, 255, 0.16);
  --panel-strong: rgba(138, 180, 255, 0.28);
  --text-main: #eef4ff;
  --text-muted: #b7c5d9;
  --text-faint: #8a9ab0;
  --accent: #8ab4ff;
  --accent-soft: rgba(138, 180, 255, 0.12);
  --success-soft: rgba(84, 208, 154, 0.14);
  --success-text: #8de4bc;
  --danger-soft: rgba(255, 108, 108, 0.14);
  --danger-text: #ff9f9f;
  --shadow: 0 20px 42px rgba(0, 0, 0, 0.32);
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(138, 180, 255, 0.08), transparent 38%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--text-main);
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  padding: 0;
}

.file-stats-shell {
  width: min(1380px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.surface-nav-wrap {
  margin: 18px 0 22px;
}

.surface-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.surface-nav-link {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(138, 180, 255, 0.12);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.92rem;
  line-height: 1;
  transition: 160ms ease;
}

.surface-nav-link:hover,
.surface-nav-link:focus-visible {
  color: var(--text-main);
  border-color: rgba(138, 180, 255, 0.32);
  background: rgba(138, 180, 255, 0.1);
}

.surface-nav-link.active {
  color: var(--text-main);
  background: rgba(138, 180, 255, 0.16);
  border-color: rgba(138, 180, 255, 0.38);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.kpi-row,
.surface-grid {
  display: grid;
  gap: 20px;
}

.kpi-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 22px;
}

.surface-grid-main {
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.95fr);
  margin-bottom: 22px;
}

.surface-grid-supporting {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
}

.kpi-card,
.surface-card {
  background: linear-gradient(180deg, rgba(19, 27, 41, 0.96), rgba(11, 16, 26, 0.98));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.kpi-card {
  padding: 18px 18px 16px;
  min-height: 152px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.surface-card {
  padding: 22px;
}

.kpi-label,
.panel-head p,
.metric-note,
.surface-status,
.kpi-meta,
.pair-label {
  color: var(--text-faint);
}

.kpi-label {
  font-size: 0.83rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.kpi-value,
.metric-emphasis {
  font-size: clamp(2rem, 2.6vw, 2.7rem);
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.kpi-meta,
.metric-note {
  font-size: 0.86rem;
  line-height: 1.4;
}

.kpi-split {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
}

.kpi-split-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.kpi-split-divider {
  color: var(--text-faint);
  font-size: 1.3rem;
}

.kpi-split-value {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.kpi-split-caption {
  color: var(--text-faint);
  font-size: 0.82rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 0 0 6px;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.panel-head p {
  margin: 0;
  font-size: 0.93rem;
  line-height: 1.45;
}

.compact-head {
  margin-bottom: 18px;
}

.distribution-list {
  display: grid;
  gap: 14px;
}

.distribution-item {
  display: grid;
  gap: 7px;
}

.distribution-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: baseline;
}

.distribution-label {
  font-weight: 600;
}

.distribution-count,
.distribution-share {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.distribution-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(138, 180, 255, 0.1);
  overflow: hidden;
  border: 1px solid rgba(138, 180, 255, 0.08);
}

.distribution-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(138, 180, 255, 0.55), rgba(138, 180, 255, 0.9));
}

.table-wrap {
  overflow: auto;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}

.stats-table th,
.stats-table td {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.stats-table thead th {
  color: var(--text-faint);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.stats-table tbody tr:last-child td {
  border-bottom: 0;
}

.stats-table .num,
.stats-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.extension-cell {
  font-weight: 600;
}

.share-pill {
  display: inline-flex;
  min-width: 62px;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text-main);
  border: 1px solid rgba(138, 180, 255, 0.14);
  font-size: 0.8rem;
}

.compact-table-wrap {
  max-height: 252px;
}

.compact-table th,
.compact-table td {
  padding: 9px 0;
}

.file-name {
  max-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.surface-status {
  min-height: 26px;
  padding: 8px 4px 0;
  font-size: 0.9rem;
}

.surface-status.error {
  color: var(--danger-text);
}

.surface-status.success {
  color: var(--success-text);
}

/* =========================================================
   FILE STATISTICS SURFACE ADJUSTMENTS
   - Remove 3-card lower band assumption
   - Limit long panels and make them scroll internally
   - Stabilize Largest Files table layout and header visibility
   ========================================================= */

.mix-scroll-wrap,
.granular-scroll-wrap {
  max-height: 560px;
  min-height: 560px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 8px;
  scrollbar-gutter: stable;
}

.largest-files-scroll-wrap {
  max-height: 260px;
  min-height: 260px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 10px;
  scrollbar-gutter: stable;
}

.largest-files-table {
  width: 100%;
  table-layout: fixed;
}

.largest-files-table th,
.largest-files-table td {
  box-sizing: border-box;
}

.largest-files-table th:first-child,
.largest-files-table td:first-child {
  width: 72%;
}

.largest-files-table th:last-child,
.largest-files-table td:last-child {
  width: 28%;
  text-align: right;
  white-space: nowrap;
  padding-right: 14px;
}

.largest-files-table .file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mix-scroll-wrap::-webkit-scrollbar,
.granular-scroll-wrap::-webkit-scrollbar,
.largest-files-scroll-wrap::-webkit-scrollbar {
  width: 8px;
}

.mix-scroll-wrap::-webkit-scrollbar-thumb,
.granular-scroll-wrap::-webkit-scrollbar-thumb,
.largest-files-scroll-wrap::-webkit-scrollbar-thumb {
  background: rgba(138, 180, 255, 0.25);
  border-radius: 999px;
}

.mix-scroll-wrap::-webkit-scrollbar-track,
.granular-scroll-wrap::-webkit-scrollbar-track,
.largest-files-scroll-wrap::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 1180px) {
  .kpi-row,
  .surface-grid-supporting {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .surface-grid-main {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .file-stats-shell {
    width: min(100% - 24px, 1380px);
    padding-top: 18px;
  }

  .kpi-row,
  .surface-grid-supporting {
    grid-template-columns: 1fr;
  }

  .surface-card,
  .kpi-card {
    padding: 18px;
  }

  .distribution-row {
    grid-template-columns: 1fr auto;
  }

  .distribution-share {
    grid-column: 2;
  }

  .mix-scroll-wrap,
  .granular-scroll-wrap {
    max-height: 420px;
    min-height: 420px;
  }

  .largest-files-scroll-wrap {
    max-height: 240px;
    min-height: 240px;
  }
}
