:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --text: #18202b;
  --muted: #5a6575;
  --border: #dce0e6;
  --border-strong: #c5ccd6;
  --primary: #1d4f91;
  --primary-hover: #163f75;
  --primary-ink: #ffffff;
  --focus: #2b6fd6;
  --met: #17703f;
  --met-bg: #e1f3e8;
  --met-bar: #2e9b5c;
  --close: #8a5600;
  --close-bg: #fdf0d2;
  --close-bar: #d99a1c;
  --notmet: #b3261e;
  --notmet-bg: #fce6e4;
  --notmet-bar: #d9483f;
  --exempt: #5a6575;
  --exempt-bg: #eceef2;
  --pending: #3d4f9f;
  --pending-bg: #e6eafa;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --radius: 10px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151b;
    --surface: #1a2029;
    --surface-2: #202733;
    --text: #e7ebf0;
    --muted: #9aa5b4;
    --border: #2c3542;
    --border-strong: #3b4656;
    --primary: #5b93e0;
    --primary-hover: #77a7ea;
    --primary-ink: #0d1520;
    --focus: #7fb0f5;
    --met: #6fd39b;
    --met-bg: #163626;
    --met-bar: #3fb874;
    --close: #f2c062;
    --close-bg: #3a2d10;
    --close-bar: #e0a93a;
    --notmet: #ff8f86;
    --notmet-bg: #3d1a18;
    --notmet-bar: #e35d54;
    --exempt: #9aa5b4;
    --exempt-bg: #262e3a;
    --pending: #a9b8ff;
    --pending-bg: #232c4d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
}

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

h1 {
  font-size: 1.35rem;
}

h2 {
  font-size: 1.1rem;
}

h3 {
  font-size: 1rem;
}

a {
  color: var(--primary);
}

[hidden] {
  display: none !important;
}

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

.small {
  font-size: 0.85rem;
}

.nowrap {
  white-space: nowrap;
}

.num {
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ layout */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  margin-right: auto;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--primary-ink);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  flex: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-text strong {
  font-size: 0.98rem;
}

.brand-text span {
  font-size: 0.8rem;
  color: var(--muted);
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.page.narrow {
  max-width: 560px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card + .card {
  margin-top: 16px;
}

.card > h2 {
  margin-bottom: 12px;
}

.card > h2 + p {
  margin-top: -4px;
}

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

.stack > * + * {
  margin-top: 16px;
}

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.row > .grow {
  flex: 1 1 200px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 480px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ------------------------------------------------------------------- forms */

label,
.label {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 5px;
}

.field + .field {
  margin-top: 14px;
}

.hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
}

input,
select,
textarea,
button {
  font: inherit;
  color: inherit;
}

input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
input[type='date'],
input[type='time'],
input[type='search'],
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
}

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

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible,
.chip:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.input-with-button {
  display: flex;
  gap: 6px;
}

.input-with-button input {
  flex: 1;
  min-width: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-2);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-ink);
}

.btn.primary:hover {
  background: var(--primary-hover);
}

.btn.danger {
  color: var(--notmet);
}

.btn.primary.danger-fill {
  background: var(--notmet-bar);
  border-color: var(--notmet-bar);
  color: #fff;
}

.btn.big {
  width: 100%;
  min-height: 46px;
  font-size: 1rem;
}

.btn.sm {
  min-height: 30px;
  padding: 3px 10px;
  font-size: 0.82rem;
}

.btn.icon {
  padding: 0;
  width: 38px;
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
}

.btn.ghost:hover {
  background: var(--surface-2);
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  background: var(--surface);
  padding: 7px 14px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 38px;
}

.segmented button + button {
  border-left: 1px solid var(--border-strong);
}

.segmented button[aria-pressed='true'] {
  background: var(--primary);
  color: var(--primary-ink);
}

.alert {
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.9rem;
}

.alert.error {
  background: var(--notmet-bg);
  color: var(--notmet);
}

.alert.info {
  background: var(--pending-bg);
  color: var(--pending);
}

/* ---------------------------------------------------------------- statuses */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.s-met {
  color: var(--met);
  background: var(--met-bg);
}

.s-close {
  color: var(--close);
  background: var(--close-bg);
}

.s-not_met {
  color: var(--notmet);
  background: var(--notmet-bg);
}

.s-exempt,
.s-upcoming {
  color: var(--exempt);
  background: var(--exempt-bg);
}

.s-pending {
  color: var(--pending);
  background: var(--pending-bg);
}

.s-approved {
  color: var(--met);
  background: var(--met-bg);
}

.s-rejected {
  color: var(--notmet);
  background: var(--notmet-bg);
}

.bar {
  height: 8px;
  border-radius: 999px;
  background: var(--exempt-bg);
  overflow: hidden;
  min-width: 80px;
}

.bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
}

.bar.met > span {
  background: var(--met-bar);
}

.bar.close > span {
  background: var(--close-bar);
}

.bar.not_met > span {
  background: var(--notmet-bar);
}

.bar.exempt > span {
  background: var(--border-strong);
}

/* ---------------------------------------------------------------- log page */

.duration {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 8px;
  min-height: 1.3em;
}

.success {
  border: 1px solid var(--met-bar);
  background: var(--met-bg);
  border-radius: var(--radius);
  padding: 16px;
}

.success h2 {
  color: var(--met);
  margin-bottom: 6px;
}

.success .bar {
  margin-top: 10px;
  background: var(--surface);
}

.footer-link {
  text-align: center;
  margin-top: 22px;
  font-size: 0.88rem;
}

/* --------------------------------------------------------------- admin app */

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.tabs a {
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.tabs a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.tabs a[aria-current='page'] {
  background: var(--primary);
  color: var(--primary-ink);
}

.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.toolbar .spacer {
  flex: 1;
}

.toolbar select,
.toolbar input {
  width: auto;
}

.toolbar input[type='search'] {
  min-width: 220px;
}

.period-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.period-label {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0 4px;
}

.dash-note {
  margin-bottom: 12px;
}

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

@media (max-width: 900px) {
  .summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: left;
  box-shadow: var(--shadow);
  border-top-width: 4px;
}

button.stat {
  cursor: pointer;
  font: inherit;
  color: inherit;
}

button.stat:hover {
  background: var(--surface-2);
}

button.stat[aria-pressed='true'] {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.stat .value {
  font-size: 1.9rem;
  font-weight: 750;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat .label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 2px 0 0;
}

.stat.not_met {
  border-top-color: var(--notmet-bar);
}

.stat.not_met .value {
  color: var(--notmet);
}

.stat.close {
  border-top-color: var(--close-bar);
}

.stat.close .value {
  color: var(--close);
}

.stat.met {
  border-top-color: var(--met-bar);
}

.stat.met .value {
  color: var(--met);
}

.stat.neutral {
  border-top-color: var(--border-strong);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

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

th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--surface-2);
  white-space: nowrap;
  font-weight: 700;
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover {
  color: var(--text);
}

th[aria-sort='ascending']::after {
  content: ' ▲';
}

th[aria-sort='descending']::after {
  content: ' ▼';
}

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

tbody tr.clickable {
  cursor: pointer;
}

tbody tr.clickable:hover td {
  background: var(--surface-2);
}

tr.inactive td {
  color: var(--muted);
}

td.right,
th.right {
  text-align: right;
}

td.center,
th.center {
  text-align: center;
}

.member-cell strong {
  display: block;
}

.member-cell span {
  font-size: 0.8rem;
  color: var(--muted);
}

.progress-cell {
  min-width: 170px;
}

.progress-cell .numbers {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.82rem;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.week-cell {
  display: inline-block;
  min-width: 46px;
  padding: 3px 6px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.82rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.week-head {
  text-align: center;
  line-height: 1.2;
}

.week-head small {
  display: block;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
}

.empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--muted);
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
}

.filter-actions {
  margin-top: 14px;
  align-items: center;
}

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

.chip {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.chip:hover {
  background: var(--surface-2);
}

.result-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 16px 0 10px;
}

.result-bar .spacer {
  flex: 1;
}

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--pending-bg);
  color: var(--pending);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 10px;
  font-weight: 600;
  font-size: 0.9rem;
}

.actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.note {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}

.project-cell {
  max-width: 340px;
}

dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  width: min(480px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

dialog::backdrop {
  background: rgba(10, 15, 25, 0.45);
}

dialog form {
  padding: 20px;
}

dialog .dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.login-card {
  max-width: 400px;
  margin: 8vh auto 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
  align-items: start;
}

.settings-grid .card + .card {
  margin-top: 0;
}

.span-2 {
  grid-column: span 2;
}

@media (max-width: 760px) {
  .span-2 {
    grid-column: auto;
  }
}

.table-scroll {
  overflow-x: auto;
  margin-bottom: 14px;
}

.inline-table td {
  padding: 6px 8px;
}

.inline-table input {
  min-height: 34px;
  padding: 5px 8px;
}

.inline-table input[type='text'] {
  min-width: 160px;
}

.inline-table input[type='number'] {
  width: 90px;
}

.audit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 360px;
  overflow-y: auto;
  font-size: 0.85rem;
}

.audit-list li {
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}

.audit-list li:last-child {
  border-bottom: 0;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 100;
  max-width: calc(100vw - 32px);
}

#toast.error {
  background: var(--notmet);
  color: #fff;
}

@media print {
  .topbar,
  .toolbar,
  .no-print,
  #toast {
    display: none !important;
  }
  body {
    background: #fff;
  }
  .table-wrap,
  .stat {
    box-shadow: none;
  }
}
