:root {
  color-scheme: light;
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-alt: #f7fafd;
  --text: #07172f;
  --muted: #8391ad;
  --line: #d6e0eb;
  --field-bg: #ffffff;
  --nav: #0b2036;
  --nav-soft: #102a47;
  --nav-active: #183d7c;
  --brand: #2563eb;
  --brand-strong: #174ea6;
  --accent: #00a67d;
  --danger: #e11d48;
  --warning: #f97316;
  --success: #059669;
  --info: #2563eb;
  --purple: #7c3aed;
  --shadow: 0 8px 24px rgba(15, 35, 64, 0.08);
  --completed-bg: #dff7eb;
  --pending-bg: #fff0d6;
  --issue-bg: #ffe4eb;
  --review-bg: #dbeafe;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #071423;
  --surface: #0e2035;
  --surface-alt: #132842;
  --text: #eaf2ff;
  --muted: #8ea5c6;
  --line: #243a56;
  --field-bg: #091a2d;
  --nav: #061120;
  --nav-soft: #0d2239;
  --nav-active: #244a93;
  --brand: #70a3ff;
  --brand-strong: #9bbfff;
  --accent: #20d6a1;
  --danger: #ff5c7a;
  --warning: #ffb15f;
  --success: #33d28f;
  --info: #75a7ff;
  --purple: #b99cff;
  --shadow: 0 14px 38px rgba(0, 0, 0, 0.26);
  --completed-bg: rgba(32, 214, 161, 0.14);
  --pending-bg: rgba(255, 177, 95, 0.16);
  --issue-bg: rgba(255, 92, 122, 0.16);
  --review-bg: rgba(112, 163, 255, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

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

a:hover {
  text-decoration: underline;
}

.topbar {
  align-items: center;
  background: var(--nav);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  display: flex;
  gap: 18px;
  min-height: 58px;
  padding: 0 22px;
}

.brand {
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  margin-right: 10px;
  white-space: nowrap;
}

.nav {
  align-items: center;
  display: flex;
  flex: 1;
  gap: 4px;
  overflow-x: auto;
}

.nav a,
.logout-button {
  border: 0;
  color: #b9cbea;
  font: inherit;
  padding: 9px 10px;
  white-space: nowrap;
}

.nav a:hover,
.nav a.active,
.logout-button:hover {
  background: var(--nav-active);
  border-radius: 6px;
  color: #fff;
  text-decoration: none;
}

.logout-form {
  margin: 0;
}

.logout-button {
  background: transparent;
  cursor: pointer;
}

.user-pill {
  color: #9fb6d8;
  font-size: 13px;
  white-space: nowrap;
}

.theme-toggle {
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  color: #d9e7ff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  gap: 8px;
  min-height: 32px;
  padding: 5px 10px;
  white-space: nowrap;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
}

.auth-theme-toggle {
  background: var(--nav);
  position: fixed;
  right: 18px;
  top: 18px;
}

.theme-dot {
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
  height: 9px;
  width: 9px;
}

.page {
  margin: 0 auto;
  max-width: 1480px;
  padding: 22px;
}

.auth-page {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 28px;
}

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

.auth-panel {
  max-width: 430px;
  padding: 28px;
  width: 100%;
}

.auth-panel h1,
.page-title h1 {
  margin: 0;
}

.page-title {
  align-items: flex-end;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.page-title p {
  color: var(--muted);
  margin: 4px 0 0;
}

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

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

.panel-header h2 {
  font-size: 18px;
  margin: 0;
}

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

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

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

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

.kpis {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  margin-bottom: 18px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  padding: 14px;
}

.kpi:nth-child(2) {
  border-left-color: var(--accent);
}

.kpi:nth-child(3) {
  border-left-color: var(--warning);
}

.kpi:nth-child(4) {
  border-left-color: var(--danger);
}

.kpi:nth-child(5) {
  border-left-color: var(--purple);
}

.kpi:nth-child(6) {
  border-left-color: var(--info);
}

.kpi span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  text-transform: uppercase;
}

.kpi strong {
  display: block;
  font-size: 26px;
  margin-top: 4px;
}

label {
  color: #2e3b46;
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

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

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

.check-row {
  align-items: center;
  display: flex;
  gap: 8px;
  min-height: 38px;
}

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

.actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.button,
button.button {
  align-items: center;
  background: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 700;
  justify-content: center;
  min-height: 38px;
  padding: 8px 13px;
}

.button:hover {
  background: var(--brand-strong);
  color: #fff;
  text-decoration: none;
}

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

.button.secondary:hover {
  background: var(--surface-alt);
}

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

.flash {
  border-radius: 7px;
  margin-bottom: 14px;
  padding: 10px 12px;
}

.flash.success {
  background: var(--completed-bg);
  border: 1px solid rgba(5, 150, 105, 0.28);
  color: var(--success);
}

.flash.error {
  background: var(--issue-bg);
  border: 1px solid rgba(225, 29, 72, 0.28);
  color: var(--danger);
}

.flash.warning {
  background: var(--pending-bg);
  border: 1px solid rgba(249, 115, 22, 0.28);
  color: var(--warning);
}

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

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

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

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

tr:hover td {
  background: var(--surface-alt);
}

.status {
  border-radius: 999px;
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
  white-space: nowrap;
}

.status-completed {
  background: var(--completed-bg);
  color: var(--success);
}

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

.status-issue {
  background: var(--issue-bg);
  color: var(--danger);
}

.status-in-review {
  background: var(--review-bg);
  color: var(--info);
}

.overdue {
  color: var(--danger);
  font-weight: 700;
}

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

.qr {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  height: 210px;
  margin: 16px auto;
  width: 210px;
}

.secret {
  background: var(--surface-alt);
  border-radius: 6px;
  font-family: Consolas, monospace;
  overflow-wrap: anywhere;
  padding: 10px;
}

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

.calendar-head,
.calendar-cell {
  background: var(--surface);
  border: 1px solid var(--line);
  min-height: 92px;
  padding: 9px;
}

.calendar-head {
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  min-height: auto;
  text-transform: uppercase;
}

.calendar-cell.outside {
  background: color-mix(in srgb, var(--surface-alt) 76%, var(--bg));
  color: var(--muted);
}

.day-number {
  font-weight: 700;
}

.day-lines {
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

.nowrap {
  white-space: nowrap;
}

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

  .page-title {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
  }

  .nav {
    flex-wrap: wrap;
  }

  .page {
    padding: 14px;
  }

  .grid-2,
  .grid-3,
  .grid-4,
  .kpis {
    grid-template-columns: 1fr;
  }
}
