:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --surface: #111821;
  --surface-2: #16202b;
  --surface-3: #1c2936;
  --text: #f6f8fb;
  --muted: #a1acbd;
  --line: #293747;
  --blue: #4f8cff;
  --green: #35d07f;
  --amber: #ffb545;
  --red: #ff5f62;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(79, 140, 255, 0.16), transparent 36%),
    linear-gradient(180deg, #111923 0%, var(--bg) 42%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1160px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 44px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: clamp(2.15rem, 9vw, 4rem);
  line-height: 0.98;
}

h2 {
  margin-bottom: 0;
  font-size: 1.08rem;
}

h3 {
  margin-bottom: 6px;
  font-size: 1.05rem;
}

.hero-copy {
  max-width: 34rem;
  margin-bottom: 0;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button,
.text-button,
button[type="submit"] {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.icon-button {
  width: 48px;
  background: var(--surface);
  color: var(--text);
  font-weight: 900;
}

.text-button {
  padding: 0 16px;
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
}

button[type="submit"] {
  padding: 0 16px;
  border-color: var(--green);
  background: var(--green);
  color: #04120a;
  font-weight: 900;
}

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

.panel,
.summary-hero,
.metric-card,
.activity {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 24, 33, 0.94);
  box-shadow: var(--shadow);
}

.panel {
  margin-bottom: 16px;
  padding: 16px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.login-panel {
  max-width: 430px;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 48px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d131a;
  color: var(--text);
}

input:focus,
select:focus,
button:focus-visible {
  outline: 2px solid rgba(79, 140, 255, 0.85);
  outline-offset: 2px;
}

.summary-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
  padding: 20px;
  background:
    linear-gradient(135deg, rgba(53, 208, 127, 0.18), transparent 42%),
    var(--surface);
}

.summary-hero h2 {
  margin-bottom: 8px;
  font-size: clamp(1.6rem, 5vw, 2.4rem);
}

.status-copy {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.hero-stat {
  min-width: 112px;
  padding: 14px;
  border: 1px solid rgba(53, 208, 127, 0.28);
  border-radius: 8px;
  background: rgba(53, 208, 127, 0.1);
  text-align: center;
}

.hero-stat span,
.metric-card span,
.metric-card small {
  color: var(--muted);
}

.hero-stat strong {
  display: block;
  margin-top: 4px;
  color: var(--green);
  font-size: 2.1rem;
}

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

.metric-card {
  min-height: 124px;
  padding: 15px;
  background: var(--surface-2);
}

.metric-card strong {
  display: block;
  margin: 9px 0 4px;
  font-size: clamp(1.7rem, 6vw, 2.35rem);
  line-height: 1;
}

.attention-card {
  border-color: rgba(255, 181, 69, 0.46);
  background: rgba(255, 181, 69, 0.09);
}

.pill,
.category-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid rgba(53, 208, 127, 0.35);
  border-radius: 999px;
  color: var(--green);
  background: rgba(53, 208, 127, 0.1);
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

.category-pill.pending {
  border-color: rgba(255, 181, 69, 0.42);
  color: var(--amber);
  background: rgba(255, 181, 69, 0.1);
}

.muted {
  color: var(--muted);
}

canvas {
  display: block;
  width: 100%;
  max-height: 300px;
  border-radius: 8px;
  background: #10151d;
}

.activity-list {
  display: grid;
  gap: 12px;
}

.activity {
  padding: 14px;
  background: #101720;
}

.activity.is-unclassified {
  border-color: rgba(255, 181, 69, 0.62);
}

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

.activity-main p,
.activity-notes {
  margin-bottom: 0;
  color: var(--muted);
}

.activity-date {
  display: block;
  margin-bottom: 4px;
  color: var(--blue);
  font-size: 0.8rem;
  font-weight: 900;
}

.activity-stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}

.activity-stats div {
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-3);
}

.activity-stats dt {
  color: var(--muted);
  font-size: 0.72rem;
}

.activity-stats dd {
  margin: 4px 0 0;
  font-weight: 900;
}

.activity-notes {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(79, 140, 255, 0.08);
}

.classification-form {
  display: grid;
  grid-template-columns: minmax(160px, 1.1fr) repeat(2, minmax(120px, 0.9fr)) minmax(180px, 1.2fr) auto;
  gap: 10px;
  align-items: end;
}

.app-tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 14px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 15, 20, 0.9);
  backdrop-filter: blur(14px);
}

.tab-button,
.filter-chip {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
  cursor: pointer;
}

.tab-button.is-active,
.filter-chip.is-active {
  border-color: rgba(79, 140, 255, 0.42);
  background: rgba(79, 140, 255, 0.14);
  color: var(--text);
}

.tab-button span {
  display: inline-flex;
  justify-content: center;
  min-width: 22px;
  margin-left: 3px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--amber);
  color: #1a1000;
  font-size: 0.72rem;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.recommendation-card {
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid rgba(79, 140, 255, 0.32);
  border-radius: 8px;
  background: rgba(79, 140, 255, 0.1);
}

.recommendation-card span {
  display: block;
  margin-bottom: 6px;
  color: var(--blue);
  font-weight: 900;
}

.recommendation-card p {
  margin-bottom: 0;
  line-height: 1.5;
}

#state-label[data-severity="danger"] {
  color: var(--red);
}

#state-label[data-severity="warning"] {
  color: var(--amber);
}

#state-label[data-severity="good"] {
  color: var(--green);
}

#state-label[data-severity="fresh"] {
  color: var(--blue);
}

.pending-panel {
  border-color: rgba(255, 181, 69, 0.5);
  background:
    linear-gradient(135deg, rgba(255, 181, 69, 0.08), transparent 34%),
    rgba(17, 24, 33, 0.96);
}

.empty-state {
  margin: 0;
  padding: 18px;
  border: 1px dashed rgba(53, 208, 127, 0.45);
  border-radius: 8px;
  color: var(--green);
  background: rgba(53, 208, 127, 0.08);
  font-weight: 900;
  text-align: center;
}

.activity.compact {
  box-shadow: none;
}

.activity.compact .activity-stats {
  margin-bottom: 0;
}

.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.filter-chip {
  flex: 0 0 auto;
  padding: 0 13px;
  border-color: var(--line);
  background: var(--surface-2);
}

.date-search {
  max-width: 260px;
  margin-bottom: 14px;
}

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

.chart-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101720;
}

.chart-card h3 {
  margin-bottom: 10px;
}

.mini-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.mini-stat-grid article {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.mini-stat-grid span {
  color: var(--muted);
}

.mini-stat-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 1.35rem;
}

.distribution {
  grid-column: span 2;
}

.distribution div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.distribution div span {
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(79, 140, 255, 0.12);
  color: var(--text);
}

.distribution div strong {
  display: inline;
  margin-left: 4px;
  font-size: inherit;
}

.classification-form button {
  min-width: 108px;
}

.error {
  color: var(--red);
}

@media (max-width: 980px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .activity-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .stats-grid,
  .mini-stat-grid {
    grid-template-columns: 1fr;
  }

  .distribution {
    grid-column: auto;
  }

  .notes-field,
  .classification-form button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100% - 20px, 1160px);
    padding-top: 16px;
  }

  .topbar,
  .summary-hero,
  .activity-main {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .text-button {
    flex: 1;
  }

  .summary-hero {
    display: grid;
  }

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

  .hero-stat {
    width: 100%;
    text-align: left;
  }

  .metric-grid,
  .classification-form {
    grid-template-columns: 1fr;
  }

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

  .panel {
    padding: 14px;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }
}
