:root {
  color-scheme: dark;
  --bg: #07101d;
  --surface: #132033;
  --surface-2: #17263a;
  --surface-3: #0b1627;
  --text: #f3f7ff;
  --muted: #9fb3ca;
  --line: #263752;
  --accent: #18c28d;
  --accent-strong: #2ee6aa;
  --accent-soft: rgba(24, 194, 141, 0.18);
  --danger: #d9564a;
  --warning: #f59e0b;
  --status-active: #22c55e;
  --shadow: none;
  --sidebar-width: clamp(232px, 13vw, 260px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Segoe UI, system-ui, sans-serif;
  letter-spacing: 0;
}

body.locked .sidebar,
body.locked .shell {
  display: none;
}

body:not(.locked) .lockscreen {
  display: none;
}

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

button {
  cursor: pointer;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(34px, 3vw, 44px);
  line-height: 1.05;
}

h2 {
  font-size: 19px;
}

h3 {
  font-size: 15px;
}

.muted,
.eyebrow,
small {
  color: var(--muted);
}

.lockscreen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 0.85fr) minmax(0, 1.15fr);
  background: var(--bg);
}

.lock-visual {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(90deg, rgba(7, 16, 29, 0.08), rgba(7, 16, 29, 0.82)),
    radial-gradient(circle at 32% 24%, rgba(24, 194, 141, 0.22), transparent 30%),
    linear-gradient(135deg, #0d4c4a 0%, #0b1627 48%, #132033 100%);
}

.lock-emblem {
  width: min(340px, 52vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(6, 24, 22, 0.44);
}

.lock-emblem img {
  width: 42%;
}

.lock-content {
  min-height: 100vh;
  padding: clamp(28px, 7vw, 84px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
}

.lock-content h1 {
  max-width: 620px;
}

.lock-content p {
  max-width: 560px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.lock-error {
  max-width: 560px;
  padding: 13px 14px;
  border-radius: 8px;
  background: rgba(217, 86, 74, 0.14);
  border: 1px solid rgba(217, 86, 74, 0.44);
  color: #ffd6d2;
  font-weight: 700;
}

.lock-error[hidden] {
  display: none;
}

.brand,
.panel-head,
.topbar,
.profile-chip,
.dialog-head {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  padding: 2px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  flex: 0 0 auto;
}

.brand strong {
  font-size: 15px;
}

.brand span {
  font-size: 14px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.profile-chip span {
  color: var(--muted);
}

.sidebar .brand span {
  color: rgba(247, 251, 255, 0.72);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow: hidden;
  color: #f7fbff;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(24, 194, 141, 0.09), transparent 34%),
    #091426;
}

.nav-list {
  display: grid;
  grid-auto-rows: max-content;
  align-content: start;
  gap: 6px;
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 3px;
  padding-bottom: 18px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.38) transparent;
}

.nav-divider {
  height: 1px;
  margin: 12px 0;
  background: rgba(148, 163, 184, 0.24);
}

.nav-section {
  margin: 4px 0 2px;
  padding: 0 4px;
  color: rgba(159, 179, 202, 0.9);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.nav-item,
.ghost {
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: inherit;
}

.nav-item {
  position: relative;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  text-align: left;
  font-weight: 800;
  font-size: 14px;
}

.nav-item::before {
  content: attr(data-nav-icon);
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: rgba(183, 197, 220, 0.78);
  font-size: 12px;
  font-weight: 900;
}

.nav-item:hover,
.nav-item.is-active {
  color: #effff8;
  background: rgba(19, 32, 51, 0.86);
  border-color: rgba(24, 194, 141, 0.48);
}

.nav-item:hover::before,
.nav-item.is-active::before {
  color: var(--accent-strong);
}

.shell {
  margin-left: var(--sidebar-width);
  padding: 30px 28px 42px;
}

.topbar {
  min-height: 76px;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-chip {
  gap: 12px;
  min-width: 260px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.profile-avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #06241a;
  font-weight: 900;
}

.profile-open-text {
  display: grid;
  gap: 2px;
  min-width: 130px;
  color: inherit;
  text-align: left;
}

.profile-open-text strong {
  color: var(--text);
}

.profile-open-text span {
  color: var(--muted);
  font-size: 13px;
}

.page,
.tab {
  display: none;
}

.page.is-active,
.tab.is-active {
  display: block;
}

.tab[hidden],
.page[hidden] {
  display: none !important;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.82fr) minmax(360px, 1.18fr);
  gap: 18px;
  align-items: stretch;
}

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

.panel {
  padding: 22px;
}

.panel:hover,
.people-card:hover {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.24);
}

.panel-head {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.member-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  min-height: 270px;
  border-left: 1px solid rgba(148, 163, 184, 0.15);
}

.stat-card,
.rank-legend-item,
.range-row,
.row,
.feed-item,
.discipline-item {
  border: 1px solid rgba(63, 82, 111, 0.54);
  border-radius: 8px;
  background: var(--surface-2);
}

.stat-card {
  position: relative;
  min-height: 110px;
  padding: 18px 24px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.stat-card::before {
  display: none;
}

.stat-card span {
  display: block;
  margin-bottom: 16px;
  color: var(--muted);
}

.stat-card strong {
  width: fit-content;
  font-size: 48px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-active::before {
  background: var(--status-active);
}

.stat-training::before {
  background: #60a5fa;
}

.stat-hours::before {
  background: var(--warning);
}

.stat-sanctions::before {
  background: var(--danger);
}

.stat-total {
  grid-column: 1;
}

.rank-panel {
  min-height: 220px;
}

.service-ranges-panel {
  grid-column: 1 / -1;
}

.rank-legend,
.number-ranges,
.feed,
.table,
.sanction-list {
  display: grid;
  gap: 9px;
}

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

.rank-legend-item,
.range-row {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) minmax(120px, 0.65fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 8px 10px;
  font-size: 14px;
}

.rank-swatch {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
}

.rank-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-bar {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #20314c;
}

.rank-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  opacity: 0.9;
}

.rank-count,
.range-row span:last-child {
  min-width: 30px;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  text-align: center;
  background: rgba(13, 76, 74, 0.82);
}

.range-row {
  grid-template-columns: minmax(180px, 0.4fr) minmax(0, 1fr) auto;
  border-width: 0 0 1px;
  border-radius: 0;
  background: transparent;
}

.range-row strong {
  font-weight: 900;
}

.range-header {
  min-height: 28px;
  color: #9fbce2;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.range-header span:last-child {
  background: transparent;
}

.people-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.people-card {
  padding: 14px;
}

.people-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.people-card p {
  color: var(--muted);
}

.call-sign,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #243338;
  color: var(--text);
  font-size: 13px;
}

.pill.danger {
  background: rgba(217, 86, 74, 0.16);
  color: #ffb4ad;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.row {
  min-height: 52px;
  display: grid;
  grid-template-columns: 1.2fr 0.9fr 0.7fr 0.8fr auto;
  align-items: center;
  gap: 12px;
  padding: 11px;
}

.feed-item {
  min-height: 38px;
  padding: 10px 11px;
}

.matrix {
  overflow-x: auto;
}

.matrix table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

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

.matrix th {
  color: var(--muted);
  font-size: 12px;
}

.primary,
.secondary,
.ghost,
.button-link {
  min-height: 38px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  text-decoration: none;
}

.primary {
  border: 1px solid rgba(24, 194, 141, 0.5);
  background: var(--accent);
  color: #06241a;
  font-weight: 800;
}

.secondary {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
}

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

.ghost:hover,
.secondary:hover {
  border-color: rgba(24, 194, 141, 0.45);
  color: var(--text);
}

.small {
  min-height: 32px;
  padding-inline: 10px;
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text);
  padding: 10px;
}

label,
.search {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.search {
  min-width: min(360px, 100%);
}

dialog {
  width: min(820px, calc(100vw - 28px));
  color: var(--text);
  padding: 0;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.dialog-form {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.dialog-head {
  justify-content: space-between;
  gap: 16px;
}

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

.checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 8px;
}

.checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.checks input {
  width: auto;
}

.check-section[hidden] {
  display: none;
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0;
  margin: 0;
}

.sanction-item {
  border-left: 4px solid var(--danger);
}

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

  .lock-visual {
    min-height: 260px;
  }

  .lock-content {
    min-height: auto;
  }

  .sidebar {
    position: static;
    width: auto;
    min-height: auto;
  }

  .shell {
    margin-left: 0;
    padding: 18px;
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

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

  .profile-chip {
    width: 100%;
  }

  .dashboard-grid,
  .form-grid,
  .row,
  .member-summary,
  .rank-legend {
    grid-template-columns: 1fr;
  }

  .member-summary {
    min-height: auto;
  }

  .rank-legend-item {
    grid-template-columns: auto minmax(0, 1fr) minmax(80px, 0.5fr) auto;
  }

  .range-row {
    grid-template-columns: minmax(130px, 0.8fr) minmax(0, 1fr) auto;
  }

  .service-ranges-panel {
    grid-column: auto;
  }
}
