:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #617085;
  --line: #d9e1ea;
  --soft: #f4f7fa;
  --paper: #ffffff;
  --blue: #2454c6;
  --green: #1f8a62;
  --red: #bf3347;
  --brand-red: #731305;
  --footer-bg: #25282b;
  --footer-text: #7a7f83;
  --shadow: 0 18px 45px rgba(26, 37, 52, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background: #ffffff;
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 78px;
  padding: 14px 28px;
  background: var(--brand-red);
}

.site-header img {
  width: 64px;
  max-height: 48px;
  object-fit: contain;
}

.site-title {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  border-radius: 8px;
  background: #ffffff;
  color: var(--brand-red);
  padding: 8px 14px;
  font-size: 23px;
  font-weight: 800;
  line-height: 1.15;
  text-decoration: none;
}

main {
  min-height: calc(100vh - 138px);
}

.login-screen {
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(244, 247, 250, 0.96);
}

.login-card {
  display: grid;
  gap: 16px;
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 26px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

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

.workspace {
  min-width: 0;
  padding: 28px;
  background: #ffffff;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
  background: rgb(37, 40, 43);
  color: #f7fbff;
}

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

.nav-item {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #c8d3e3;
  padding: 12px 14px;
  text-align: left;
  font-weight: 700;
  text-decoration: none;
}

.nav-item.active,
.nav-item:hover {
  background: #3a3f44;
  color: #ffffff;
}

.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.subnav-item {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: #ffffff;
  font-weight: 800;
  text-decoration: none;
}

.subnav-item.active,
.subnav-item:hover {
  color: #ffffff;
  border-color: var(--brand-red);
  background: var(--brand-red);
}

.side-panel {
  display: grid;
  gap: 10px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.side-panel.compact {
  margin-top: auto;
}

.mini-label {
  color: #aebbd0;
  font-size: 13px;
  font-weight: 700;
}

.user-chip {
  display: grid;
  gap: 2px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 10px 12px;
  background: #33383d;
}

.user-chip span {
  color: #aebbd0;
  font-size: 13px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #d8e3f1;
  font-size: 14px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #61d394;
}

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

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 34px;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 19px;
}

small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metrics article,
.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.metrics article {
  padding: 18px;
}

.metrics span {
  display: block;
  font-size: 32px;
  font-weight: 800;
}

.metrics p {
  margin: 6px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.panel {
  padding: 20px;
}

.panel.wide {
  min-width: 0;
}

.stacked-form {
  display: grid;
  gap: 14px;
}

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

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.field-name {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.required-field .field-name::after {
  content: "*";
  color: var(--red);
  font-weight: 900;
}

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

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

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(36, 84, 198, 0.22);
  outline-offset: 2px;
}

.form-actions,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.primary,
.secondary,
.small,
.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
  text-decoration: none;
}

.primary {
  color: #ffffff;
  border-color: var(--blue);
  background: var(--blue);
}

.primary:hover {
  background: #1e46a7;
}

.secondary {
  color: var(--ink);
  background: #ffffff;
}

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

.secondary.full {
  width: 100%;
}

.small {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
  color: var(--ink);
  background: #ffffff;
}

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

.checkbox-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #ffffff;
  color: var(--ink);
}

.checkbox-option input {
  width: 16px;
  min-height: 16px;
}

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

fieldset {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

.inline-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 18px;
}

.inline-form input,
.inline-form select,
.inline-form button {
  margin: 0;
}

.year-picker label {
  min-width: 160px;
  margin: 0;
}

.stats-filter {
  display: grid;
  grid-template-columns: minmax(130px, 180px) minmax(180px, 240px) minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

.stats-filter label {
  margin: 0;
}

.alert,
.ok {
  border-radius: 8px;
  padding: 13px 15px;
  margin-bottom: 16px;
  font-weight: 700;
}

.alert {
  background: #fff0f2;
  border: 1px solid #f3cbd2;
  color: var(--red);
}

.ok {
  background: #edf8f0;
  border: 1px solid #9fcbaa;
  color: #1f5d2c;
}

.flash {
  margin: 0 0 16px;
  border-radius: 8px;
  font-weight: 800;
  padding: 10px 12px;
}

.success {
  border: 1px solid #bfe8dd;
  background: #e8f8f3;
  color: var(--green);
}

.error {
  border: 1px solid #f3cbd2;
  background: #fff0f2;
  color: var(--red);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  background: #ffffff;
}

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

th {
  color: #ffffff;
  background: var(--brand-red);
  font-size: 13px;
}

tbody tr:nth-child(even) {
  background: var(--soft);
}

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

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

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 60px;
  padding: 16px 28px;
  background: var(--footer-bg);
  color: var(--footer-text);
  font-size: 14px;
}

.site-footer p {
  margin: 0;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: flex-end;
}

.site-footer a,
.site-footer span {
  border: 0;
  padding: 0;
  color: var(--footer-text);
  background: transparent;
  font-weight: 800;
  text-decoration: none;
}

.site-footer a:hover {
  color: #ffffff;
}

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

  .sidebar {
    gap: 16px;
  }

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

  .inline-form,
  .stats-filter,
  .form-grid {
    grid-template-columns: 1fr;
  }

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

  .side-panel.compact {
    margin-top: 0;
  }

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

@media (max-width: 760px) {
  .site-header,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px;
  }

  .site-title {
    max-width: 100%;
    font-size: 17px;
  }

  .site-header img {
    width: 86px;
    max-height: 42px;
  }

  .workspace,
  .sidebar {
    padding: 14px;
  }

  h1 {
    font-size: 24px;
  }

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

  .nav-list,
  .metrics {
    grid-template-columns: 1fr;
  }

  .subnav {
    display: grid;
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 12px;
  }

  .table-wrap {
    overflow-x: visible;
    border: 0;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  tr {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: #ffffff;
  }

  tbody tr:nth-child(even) {
    background: #ffffff;
  }

  td {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 8px;
    min-height: 42px;
    padding: 10px 11px;
    overflow-wrap: anywhere;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  .empty-cell {
    display: block;
  }

  .empty-cell::before {
    content: "";
  }

  td:first-child {
    color: #ffffff;
    background: var(--brand-red);
    font-weight: 800;
  }

  td:first-child::before {
    color: rgba(255, 255, 255, 0.78);
  }
}

@media (max-width: 430px) {
  .login-screen {
    padding: 14px;
  }

  .login-card {
    padding: 18px;
  }

  td {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 10px;
  }

  .site-footer nav {
    flex-direction: column;
    gap: 10px;
  }

  .checkbox-grid {
    grid-template-columns: 1fr;
  }
}
