:root {
  --md-sys-color-primary: #7ee0b7;
  --md-sys-color-on-primary: #052018;
  --md-sys-color-primary-container: #123f32;
  --md-sys-color-secondary: #9bbcff;
  --md-sys-color-tertiary: #f2bd72;
  --md-sys-color-error: #ffb4ab;
  --md-sys-color-error-container: #5f1412;
  --md-sys-color-surface: #151a17;
  --md-sys-color-surface-container: #0f1412;
  --md-sys-color-surface-container-high: #222924;
  --md-sys-color-outline: #8a948d;
  --md-sys-color-outline-variant: #39443e;
  --md-sys-color-on-surface: #e6ece7;
  --md-sys-color-on-surface-variant: #bac6bf;
  --md-sys-color-input: #101512;
  --md-sys-color-list-item: #111713;
  --radius-card: 8px;
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.28), 0 8px 22px rgba(0, 0, 0, 0.24);
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  font-size: 15px;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

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

.side-nav {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 16px;
  background: #0b100d;
  border-right: 1px solid var(--md-sys-color-outline-variant);
}

.logout-form {
  margin-top: 18px;
  padding: 0 8px;
}

.brand {
  display: grid;
  gap: 4px;
  padding: 0 8px 24px;
}

.brand strong {
  font-size: 20px;
  line-height: 1.2;
}

.brand span {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 13px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--md-sys-color-on-surface-variant);
}

.nav-item:hover,
.nav-item:focus-visible {
  background: var(--md-sys-color-surface-container-high);
  outline: none;
}

.nav-item.active {
  background: var(--md-sys-color-primary-container);
  color: #c7f6de;
  font-weight: 700;
}

.page {
  min-width: 0;
  padding: 28px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.page-title {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
}

.page-subtitle {
  margin: 6px 0 0;
  color: var(--md-sys-color-on-surface-variant);
}

.grid {
  display: grid;
  gap: 16px;
}

.grid > *,
m3-card,
.table-wrap {
  min-width: 0;
}

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

.grid.two {
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
  align-items: start;
}

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

m3-card {
  display: block;
  padding: 18px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--radius-card);
  background: var(--md-sys-color-surface);
  box-shadow: var(--shadow-soft);
}

m3-card.compact {
  padding: 14px;
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
}

.card-title h2,
.card-title h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
}

.stat-value {
  margin: 0;
  font-size: 28px;
  font-weight: 760;
  line-height: 1.1;
}

.stat-label,
.meta,
.helptext {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 13px;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--md-sys-color-outline-variant);
}

.metric-row:first-child {
  border-top: 0;
  padding-top: 0;
}

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

.status-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 8px;
  background: var(--md-sys-color-list-item);
}

.status-item strong {
  display: block;
  margin-bottom: 4px;
}

.status-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--md-sys-color-secondary);
}

.status-item.good .status-dot,
.status-pill.good {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.status-item.warning .status-dot,
.status-pill.warning {
  background: var(--md-sys-color-tertiary);
  color: #291800;
}

.status-item.danger .status-dot,
.status-pill.danger {
  background: var(--md-sys-color-error);
  color: #3a0907;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
}

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

.recommendation-item {
  min-height: 120px;
  padding: 14px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 8px;
  background: var(--md-sys-color-list-item);
}

.recommendation-item.good {
  border-color: #2c7957;
}

.recommendation-item.warning {
  border-color: #8a641d;
}

.recommendation-item.danger {
  border-color: #8d4f49;
}

.recommendation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.recommendation-head strong {
  font-size: 17px;
}

.recommendation-item .meta {
  display: block;
  margin-top: 4px;
}

m3-progress {
  display: block;
  height: 8px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--md-sys-color-surface-container-high);
}

m3-progress span {
  display: block;
  width: var(--progress-value, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--md-sys-color-primary);
}

.progress-secondary span {
  background: var(--md-sys-color-secondary);
}

.progress-tertiary span {
  background: var(--md-sys-color-tertiary);
}

.button,
button,
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  cursor: pointer;
  font-weight: 700;
}

.button.secondary,
button.secondary {
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
}

.button.ghost,
button.ghost {
  background: transparent;
  color: var(--md-sys-color-primary);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.button.danger,
button.danger {
  background: transparent;
  color: var(--md-sys-color-error);
  border: 1px solid #ffdad6;
}

button:hover,
.button:hover {
  filter: brightness(0.96);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dashboard-main {
  margin-top: 16px;
}

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

.form-grid.full {
  grid-template-columns: 1fr;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
}

.auth-card {
  width: min(100%, 420px);
}

.auth-brand {
  padding: 0 0 20px;
}

form p {
  margin: 0 0 12px;
}

label {
  display: block;
  margin: 0 0 6px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 13px;
  font-weight: 650;
}

.field-control,
input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: 8px;
  background: var(--md-sys-color-input);
  color: var(--md-sys-color-on-surface);
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input[type="checkbox"] {
  width: auto;
  min-height: 0;
}

.errorlist {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--md-sys-color-error-container);
  color: #ffdad6;
  list-style: none;
}

.messages {
  display: grid;
  gap: 8px;
  margin: 0 0 18px;
}

.message {
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--md-sys-color-primary-container);
  color: #c7f6de;
}

.message.error {
  background: var(--md-sys-color-error-container);
  color: #ffdad6;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 12px;
  font-weight: 760;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

m3-chip,
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 12px;
  font-weight: 700;
}

m3-chip[tone="good"],
.chip.good {
  background: #173f2e;
  color: #aef2ca;
}

m3-chip[tone="test"],
.chip.test {
  background: #57370c;
  color: #ffddb0;
}

m3-chip[tone="avoid"],
.chip.avoid {
  background: var(--md-sys-color-error-container);
  color: #ffdad6;
}

.split-list {
  display: grid;
  gap: 10px;
}

.list-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 8px;
  background: var(--md-sys-color-list-item);
}

.list-item strong {
  display: block;
  margin-bottom: 4px;
}

.empty-state {
  padding: 20px;
  border: 1px dashed var(--md-sys-color-outline-variant);
  border-radius: 8px;
  color: var(--md-sys-color-on-surface-variant);
}

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

  .side-nav {
    position: static;
    height: auto;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
  }

  .nav-list {
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  }

  .brand {
    padding-bottom: 10px;
  }

  .grid.stats,
  .grid.two,
  .grid.three,
  .recommendation-bar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 16px;
  }

  .page-header {
    display: grid;
  }

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

  .form-grid,
  .status-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .stat-value {
    font-size: 24px;
  }
}
