:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #eef2f6;
  --line: #d8dee6;
  --text: #17202a;
  --muted: #657386;
  --brand: #176b87;
  --brand-strong: #0f4f64;
  --accent: #2f7d32;
  --danger: #a33a32;
  --warning: #9b6a12;
  --radius: 8px;
  --shadow: 0 10px 30px rgba(20, 28, 38, 0.08);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

.sidebar {
  background: #18242f;
  color: #f7fafc;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand,
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 750;
  color: inherit;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius);
  background: #2aa7a0;
  color: #071217;
  font-weight: 850;
}

.nav {
  display: grid;
  gap: 4px;
  margin-top: 28px;
}

.nav a {
  color: #dbe6ee;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: var(--radius);
}

.nav a:hover,
.nav a.active {
  background: #233545;
  color: #ffffff;
  text-decoration: none;
}

.nav svg,
.icon-button svg {
  width: 18px;
  height: 18px;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 17px;
}

.logout-form {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.icon-button,
.small-button,
.primary-button,
.secondary-button,
.danger-button {
  border: 0;
  border-radius: var(--radius);
  min-height: 38px;
  padding: 0 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.icon-button {
  width: 38px;
  padding: 0;
  background: var(--surface-soft);
  color: var(--text);
}

.primary-button {
  background: var(--brand);
  color: #ffffff;
}

.secondary-button {
  background: var(--surface-soft);
  color: var(--text);
}

.danger-button {
  background: var(--danger);
  color: #ffffff;
}

.small-button {
  min-height: 32px;
  padding: 0 10px;
  background: var(--surface-soft);
  color: var(--text);
}

.primary-button:hover,
.secondary-button:hover,
.danger-button:hover,
.small-button:hover {
  filter: brightness(0.96);
  text-decoration: none;
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.flash {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 12px 14px;
  border-radius: var(--radius);
}

.flash.success {
  border-color: rgba(47, 125, 50, 0.3);
  color: var(--accent);
}

.flash.error {
  border-color: rgba(163, 58, 50, 0.3);
  color: var(--danger);
}

.metric-grid,
.two-column,
.three-column {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

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

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

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

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
}

.metric span {
  color: var(--muted);
  display: block;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 32px;
}

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

.summary-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

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

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  white-space: nowrap;
}

td code,
pre,
code {
  font-family: "SFMono-Regular", Consolas, monospace;
}

pre {
  white-space: pre-wrap;
  max-height: 360px;
  overflow: auto;
  background: #101820;
  color: #eaf2f8;
  padding: 14px;
  border-radius: var(--radius);
}

.empty {
  color: var(--muted);
  text-align: center;
}

.table-actions {
  width: 1%;
  white-space: nowrap;
}

.form-grid {
  display: grid;
  gap: 12px;
}

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

.wide-grid .full {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 38px;
  padding: 8px 10px;
  font: inherit;
  color: var(--text);
  background: #ffffff;
}

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

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.check-row input {
  width: auto;
  min-height: auto;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.detail-list {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr;
  gap: 10px 14px;
  margin: 0 0 16px;
}

.detail-list dt {
  color: var(--muted);
  font-weight: 700;
}

.detail-list dd {
  margin: 0;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #eef2f6;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
}

.login-brand {
  color: var(--text);
  margin-bottom: 22px;
}

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

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

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

  .metric-grid,
  .two-column,
  .three-column,
  .wide-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .main {
    padding: 18px;
  }

  .topbar,
  .summary-band {
    align-items: flex-start;
    flex-direction: column;
  }

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