:root {
  color-scheme: light;
  --ink: #18201d;
  --muted: #66716d;
  --line: #d7ddd8;
  --paper: #f7f8f3;
  --panel: #ffffff;
  --accent: #0c7c59;
  --accent-2: #c84c31;
  --accent-3: #2d5b9f;
  --shadow: 0 16px 48px rgba(24, 32, 29, 0.08);
  font-family: "Aptos", "Segoe UI", sans-serif;
  font-size: 15px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, rgba(24, 32, 29, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(24, 32, 29, 0.04) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

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

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 18px;
  background: #f0f2eb;
  border-right: 1px solid var(--line);
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 750;
  letter-spacing: 0;
  min-width: 0;
}

.brand span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  color: white;
  background: var(--ink);
  border-radius: 6px;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-list a {
  color: var(--muted);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 6px;
}

.nav-list a:hover,
.nav-list a[aria-current="page"] {
  color: var(--ink);
  background: rgba(12, 124, 89, 0.1);
}

.run-status {
  margin-top: auto;
  display: grid;
  gap: 4px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
}

#run-period {
  color: var(--ink);
  font-weight: 700;
}

.workspace {
  padding: 24px;
  min-width: 0;
}

body[data-auth="locked"] .app-shell {
  display: grid;
  grid-template-columns: 1fr;
}

body[data-auth="locked"] .rail,
body[data-auth="locked"] .dashboard {
  display: none !important;
}

body[data-auth="locked"] .workspace {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-panel {
  width: min(460px, 100%);
  margin: 0;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 18px;
  color: white;
  background: var(--ink);
  border-radius: 7px;
  font-weight: 800;
}

.login-panel h1 {
  margin-bottom: 24px;
  font-size: 1.35rem;
  line-height: 1.1;
}

body[data-auth="unlocked"] .login-panel {
  display: none !important;
}

.login-panel label,
.period-picker label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

.login-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 8px;
}

input,
select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 0 12px;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  color: white;
  background: var(--accent);
  font-weight: 750;
  cursor: pointer;
}

button:hover {
  background: #086d4e;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

#login-error {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--accent-2);
}

.dashboard {
  display: grid;
  gap: 20px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.9rem, 3.5vw, 3.05rem);
  line-height: 1;
  text-wrap: balance;
}

h2 {
  font-size: 1rem;
}

.period-picker {
  display: grid;
  grid-template-columns: minmax(180px, 240px) auto;
  align-items: end;
  gap: 12px;
}

.period-picker select,
.period-picker input {
  width: 100%;
  margin-top: 6px;
}

.date-range {
  display: grid;
  grid-template-columns: minmax(120px, 150px) minmax(120px, 150px);
  gap: 8px;
}

.date-range label:nth-of-type(1) {
  grid-column: 1;
  grid-row: 1;
}

.date-range label:nth-of-type(2) {
  grid-column: 2;
  grid-row: 1;
}

.date-range input:nth-of-type(1) {
  grid-column: 1;
  grid-row: 2;
}

.date-range input:nth-of-type(2) {
  grid-column: 2;
  grid-row: 2;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric-strip article,
.panel {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(24, 32, 29, 0.05);
}

.metric-strip article {
  display: grid;
  gap: 7px;
  min-height: 104px;
  padding: 16px;
}

.metric-strip span,
.panel-heading span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-strip strong {
  font-size: clamp(1.45rem, 2.6vw, 2.15rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.view-panel {
  display: grid;
  gap: 20px;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.overview-grid .panel:nth-child(1),
.overview-grid .panel:nth-child(2),
.overview-grid .panel:nth-child(3),
.overview-grid .panel:nth-child(4) {
  grid-column: span 2;
}

.overview-grid .panel:nth-child(5) {
  grid-column: 1 / -1;
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(230px, 0.75fr);
  gap: 12px;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.panel.wide {
  grid-row: span 3;
}

.team-breakdown-panel {
  min-height: calc(100vh - 190px);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.rank-list,
.quality-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 16px 18px 18px 36px;
}

.compact-list {
  padding-left: 32px;
}

.rank-list li,
.quality-list li {
  padding: 6px 0;
}

.rank-list strong,
.quality-list strong {
  display: block;
}

.rank-list span,
.quality-list span {
  color: var(--muted);
  font-size: 0.88rem;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .rail {
    position: static;
    height: auto;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-strip,
  .panel-grid,
  .overview-grid {
    grid-template-columns: 1fr;
  }

  .overview-grid .panel:nth-child(n) {
    grid-column: auto;
  }
}

@media (max-width: 560px) {
  .workspace,
  .rail {
    padding: 16px;
  }

  .topbar,
  .login-row,
  .period-picker,
  .date-range {
    display: grid;
  }

  .period-picker,
  .date-range {
    grid-template-columns: 1fr;
  }

  .date-range label,
  .date-range input {
    grid-column: auto;
    grid-row: auto;
  }

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