:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --accent: #0061ae;
  --accent-hover: #004c8a;
  --bg: #f2f2f2;
  --surface: #ffffff;
  --surface-strong: #ffffff;
  --text: #242427;
  --muted: #6c6d74;
  --line: #d7d8dc;
  --header: #ffffff;
  --header-text: #242427;
  --field: #ffffff;
  --shadow: 0 8px 28px rgb(22 24 28 / 8%);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --accent: #5aa9e6;
  --accent-hover: #80bdf0;
  --bg: #171719;
  --surface: #242427;
  --surface-strong: #303033;
  --text: #f7f7f7;
  --muted: #b4b5ba;
  --line: #44454a;
  --header: #0b0b0b;
  --header-text: #ffffff;
  --field: #1d1d20;
  --shadow: 0 10px 32px rgb(0 0 0 / 28%);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; color: var(--text); background: var(--bg); }
button, input, textarea, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 88px; padding: .8rem max(1rem, calc((100% - 760px) / 2)); color: var(--header-text); background: var(--header); border-bottom: 1px solid var(--line); box-shadow: 0 2px 12px rgb(0 0 0 / 6%); }
.brand-lockup, .login-brand, .header-actions { display: flex; align-items: center; gap: .65rem; }
.brand-lockup img { width: 118px; height: auto; }
:root[data-theme="dark"] .brand-lockup img, :root[data-theme="dark"] .login-brand img { filter: invert(1) brightness(1.7); }
.eyebrow { margin: 0 0 .1rem; color: var(--accent); font-size: .72rem; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(1.35rem, 5vw, 1.9rem); }
h2 { grid-column: 1 / -1; margin: 0 0 .1rem; font-size: 1.05rem; }
.icon-button { min-height: 42px; padding: .55rem .75rem; border: 1px solid var(--line); border-radius: 9px; color: var(--text); background: var(--surface); font-size: .8rem; font-weight: 750; cursor: pointer; }
.current-user { max-width: 180px; overflow: hidden; color: var(--muted); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.app-main { max-width: 760px; margin: 0 auto; padding: 1rem 1rem 7rem; }
.app-nav { display: flex; gap: .4rem; max-width: 760px; margin: .85rem auto 0; padding: 0 1rem; }
.app-nav button { min-height: 42px; padding: .55rem .9rem; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: var(--surface); font-weight: 800; cursor: pointer; }
.app-nav button.is-active { color: #fff; border-color: var(--accent); background: var(--accent); }
.type-switch { position: sticky; z-index: 3; top: .75rem; display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; margin-bottom: 1rem; padding: .35rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-strong); box-shadow: var(--shadow); }
.type-switch button { min-height: 48px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; font-weight: 850; cursor: pointer; }
.type-switch button.is-active { color: #fff; background: var(--accent); }
.card { margin: 0 0 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 2px 8px rgb(0 0 0 / 4%); }
.compact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }
.wide { grid-column: 1 / -1; }
label { display: grid; gap: .4rem; color: var(--text); font-size: .88rem; font-weight: 700; }
input, textarea, select { width: 100%; min-height: 46px; padding: .7rem .75rem; border: 1px solid var(--line); border-radius: 9px; color: var(--text); background: var(--field); }
textarea { min-height: auto; resize: vertical; }
input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent); outline-offset: 2px; border-color: var(--accent); }
.check-list { display: grid; gap: .55rem; margin-top: .9rem; }
.check-list label { display: flex; align-items: center; gap: .75rem; min-height: 50px; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-strong); cursor: pointer; }
.check-list input { flex: 0 0 26px; width: 26px; min-height: 26px; margin: 0; accent-color: var(--accent); }
.details { margin-top: 1rem; }
.export-bar { position: fixed; z-index: 4; right: 0; bottom: 0; left: 0; display: flex; align-items: center; justify-content: center; gap: 1rem; padding: .75rem max(1rem, calc((100% - 760px) / 2)); border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(8px); }
.export-bar p { flex: 1 1 420px; max-width: 480px; margin: 0; color: var(--muted); font-size: .78rem; }
.primary { min-height: 50px; padding: .75rem 1.2rem; border: 0; border-radius: 10px; color: #fff; background: var(--accent); font-weight: 850; cursor: pointer; }
.primary:hover { background: var(--accent-hover); }
.primary:disabled { cursor: wait; opacity: .6; }
.secondary { min-height: 42px; padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 9px; color: var(--text); background: var(--surface-strong); font-weight: 750; cursor: pointer; }
.full-width { width: 100%; }
.login-page { display: grid; min-height: 100vh; place-items: center; padding: 1rem; }
.login-card { width: min(100%, 410px); padding: 1.35rem; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.login-brand { justify-content: space-between; margin-bottom: 2.5rem; }
.login-brand img { width: 145px; height: auto; }
.login-copy { margin: .55rem 0 1.5rem; color: var(--muted); }
.login-card form { display: grid; gap: 1rem; }
.login-card input { font-size: 1rem; }
.error-message { min-height: 1.2em; margin: 0; color: #d63b46; font-size: .82rem; }
.button-row { display: flex; justify-content: flex-end; gap: .6rem; }

.admin-main { max-width: 1100px; }
.admin-section { margin-bottom: 1rem; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.section-status { margin: .6rem 0 1rem; color: var(--muted); font-size: .82rem; }
.section-intro { margin: .45rem 0 0; color: var(--muted); }
.report-overview-controls { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; }
.period-switch { display: grid; grid-template-columns: repeat(4, 1fr); gap: .3rem; padding: .3rem; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-strong); }
.period-switch button { min-height: 40px; padding: .45rem .8rem; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-weight: 800; cursor: pointer; }
.period-switch button.is-active { color: #fff; background: var(--accent); }
.new-only-filter { display: flex; align-items: center; gap: .5rem; min-height: 46px; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-strong); cursor: pointer; white-space: nowrap; }
.new-only-filter input { width: 22px; min-height: 22px; margin: 0; accent-color: var(--accent); }
.period-navigation { display: grid; grid-template-columns: auto minmax(180px, 1fr) auto auto; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.period-navigation strong { padding: .65rem .75rem; text-align: center; }
.period-navigation button:disabled { cursor: not-allowed; opacity: .45; }
.report-bulk-actions { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin: 0 0 .75rem; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-strong); }
.report-bulk-actions label { display: flex; align-items: center; gap: .55rem; cursor: pointer; }
.report-bulk-actions input, .report-select { width: 22px; min-height: 22px; margin: 0; accent-color: var(--accent); }
.report-bulk-actions button:disabled { cursor: not-allowed; opacity: .5; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .75rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
td { font-size: .86rem; }
.period-heading th { padding: .7rem .6rem .45rem; color: var(--text); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); font-size: .82rem; letter-spacing: 0; text-transform: none; }
.period-heading span { display: inline-flex; min-width: 22px; min-height: 22px; align-items: center; justify-content: center; margin-left: .35rem; border-radius: 999px; color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); font-size: .72rem; }
.is-downloaded-row { opacity: .7; }
.download-status { display: inline-flex; align-items: center; padding: .25rem .5rem; border-radius: 999px; font-size: .73rem; font-weight: 850; white-space: nowrap; }
.download-status.is-new { color: #fff; background: var(--accent); }
.download-status.is-downloaded { color: var(--muted); background: color-mix(in srgb, var(--muted) 14%, transparent); }
.selection-cell { width: 38px; padding-right: .25rem; padding-left: .25rem; text-align: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; clip-path: inset(50%); }
td small { display: block; margin-top: .2rem; color: var(--muted); }
.table-action { display: inline-flex; min-height: 38px; align-items: center; padding: .45rem .7rem; border-radius: 8px; color: #fff; background: var(--accent); font-weight: 800; text-decoration: none; white-space: nowrap; }
.empty-state { padding: 2rem; color: var(--muted); text-align: center; }
.create-user-form { margin: 1rem 0 1.25rem; padding: 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-strong); }
.users-list { display: grid; gap: .65rem; }
.user-card { display: grid; gap: .8rem; padding: .85rem; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-strong); }
.user-edit-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; gap: .65rem; }
.user-edit-form > button { justify-self: start; }
.user-card span { color: var(--muted); font-size: .8rem; }
.user-card .tag { width: max-content; padding: .2rem .45rem; border-radius: 999px; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); font-weight: 750; }
.user-actions { display: flex; align-items: center; gap: .45rem; }
.user-actions input { width: 190px; min-height: 40px; }
.user-actions button { min-height: 40px; padding: .45rem .65rem; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: var(--surface); font-weight: 700; cursor: pointer; }

@media (max-width: 580px) {
  .compact-grid { grid-template-columns: 1fr; }
  .wide, h2 { grid-column: auto; }
  .topbar { align-items: flex-start; }
  .brand-lockup img { width: 90px; }
  .header-actions { align-items: stretch; flex-direction: column; gap: .35rem; }
  .current-user { display: none; }
  .icon-button { min-height: 36px; padding: .4rem .55rem; }
  .export-bar { align-items: stretch; flex-direction: column; gap: .45rem; }
  .export-bar p { flex-basis: auto; max-width: none; text-align: center; }
  .primary { width: 100%; }
  .button-row { flex-direction: column-reverse; }
  .user-edit-form { grid-template-columns: 1fr; }
  .user-card, .user-actions { align-items: stretch; }
  .user-actions { flex-direction: column; }
  .user-actions input { width: 100%; }
  .report-bulk-actions { align-items: stretch; flex-direction: column; }
  .report-overview-controls { align-items: stretch; flex-direction: column; }
  .period-switch { width: 100%; }
  .new-only-filter { justify-content: center; }
  .period-navigation { grid-template-columns: 1fr 1fr; }
  .period-navigation strong { grid-column: 1 / -1; grid-row: 1; }
  #current-period { grid-column: 1 / -1; }
  th:nth-child(3), td:nth-child(3), th:nth-child(6), td:nth-child(6) { display: none; }
}
