:root {
  --bg: #31363f;
  --nav: #1e232b;
  --card: #2a2f38;
  --inset: #232833;
  --line: rgba(255, 255, 255, 0.06);
  --text: #e8ecf3;
  --muted: #9aa3b5;
  --link: #8eb7ff;
  --gold: #e7b15a;
  --blue: #3c82f6;
  --max: 1140px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", "Noto Sans", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

img { border: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }

a { color: var(--link); }
.username { color: var(--gold); text-decoration: none; }
.username:hover { text-decoration: underline; }

.skip {
  position: absolute;
  left: -999px;
  top: 8px;
}
.skip:focus {
  left: 8px;
  background: #fff;
  color: #102033;
  padding: 6px 10px;
  z-index: 80;
}

.topbar {
  background: var(--nav);
  border-bottom: 1px solid #12151a;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-inner {
  width: min(var(--max), calc(100% - 32px));
  margin: 0 auto;
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  margin-right: 8px;
  flex: none;
}
.brand:hover { text-decoration: none; }
.brand img { display: block; }
.brand-name {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
}
.brand-seal { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: transparent; }

.nav-cluster { display: flex; align-items: center; flex: 1; min-width: 0; }
.primary-nav { display: flex; align-items: center; }
.nav-item { position: relative; }
.nav-link, .tool-link, .userchip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 54px;
  padding: 0 10px;
  color: #d5dbe6;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.userchip { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 650; color: #fff; }
.nav-link:hover, .tool-link:hover, .userchip:hover { color: #fff; text-decoration: none; }
.nav-link.active { color: #fff; }
.nav-link.active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 0;
  height: 3px;
  background: var(--blue);
  border-radius: 2px 2px 0 0;
}
.caret {
  width: 0;
  height: 0;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-top: 4px solid currentColor;
  opacity: 0.75;
}
.menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 230px;
  background: #262b34;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  padding: 6px 0;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  z-index: 40;
}
.menu-right { left: auto; right: 0; }
.menu a, .menu .linkish {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  color: var(--text);
  background: none;
  border: 0;
  text-decoration: none;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
}
.menu a:hover, .menu .linkish:hover { background: rgba(255, 255, 255, 0.05); text-decoration: none; }
.topbar-tools { margin-left: auto; display: flex; align-items: center; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 54px;
  color: #d5dbe6;
  text-decoration: none;
}
.icon-btn:hover { color: #fff; }
.userchip-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-lg { width: 26px; height: 26px; stroke-width: 1.6; }
.burger {
  display: none;
  width: 42px;
  height: 42px;
  margin-left: auto;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 10px;
}
.burger span { display: block; height: 2px; margin: 5px 0; background: #e8ecf3; border-radius: 1px; }

.page {
  width: min(var(--max), calc(100% - 32px));
  margin: 16px auto 40px;
}
.hero {
  text-align: center;
  color: #fff;
  padding: 28px 22px 22px;
  border-radius: 4px;
  background: linear-gradient(90deg, #49b4f5 0%, #318de9 46%, #2a72df 100%);
}
.hero h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }
.hero p {
  max-width: 740px;
  margin: 8px auto 14px;
  font-size: 13.5px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.95);
}
.hero-btn {
  display: inline-block;
  background: #fff;
  color: #1d6fce;
  font-weight: 700;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 3px;
  text-decoration: none;
}
.hero-btn:hover { background: #f4f8ff; text-decoration: none; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  margin-top: 16px;
}
.layout.wide { grid-template-columns: 1fr; }
.main-col, .sidebar { min-width: 0; }

.banner {
  border-radius: 4px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 14px;
}
.banner.ok { background: #173526; border: 1px solid #2d7a4e; color: #d9f6e4; }
.banner.error { background: #3a2226; border: 1px solid #8d424a; color: #ffd7dc; }
.banner ul { margin: 0; padding-left: 18px; }

.block, .side-card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.045);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 16px;
}
.block-header {
  margin: 0;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 650;
  color: #fff;
  background: linear-gradient(90deg, #7a66f0 0%, #6886f3 52%, #4f90ef 100%);
}
.side-card h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 12px 14px 8px;
  font-size: 14px;
  font-weight: 700;
  color: #f2f4f8;
}
.side-card h2 .icon { color: #a9b7d0; }

.node, .thread-row, .thread-head {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 72px 84px minmax(180px, 240px);
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
}
.thread-row, .thread-head { grid-template-columns: 36px minmax(0, 1fr) 72px minmax(140px, 180px); }
.node + .node, .thread-row + .thread-row, .thread-head + .thread-row { border-top: 1px solid var(--line); }
.node-head, .thread-head { padding-bottom: 0; padding-top: 8px; }
.node:hover, .thread-row:hover { background: rgba(255, 255, 255, 0.025); }
.node-head:hover, .thread-head:hover { background: transparent; }
.node-icon { display: flex; align-items: center; justify-content: center; color: #d5def2; }
.node h2 { margin: 0; font-size: 15px; font-weight: 650; }
.node-title, .thread-title, .latest-title {
  color: #f3f5f8;
  font-weight: 650;
  font-size: 15px;
  text-decoration: none;
}
.latest-title { font-size: 13px; font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-title:hover, .thread-title:hover, .latest-title:hover { text-decoration: underline; }
.node-desc, .latest-meta, .feed-meta, .feed-forum { color: var(--muted); font-size: 12.5px; }
.node-desc { margin-top: 2px; }
.node-mobile-meta { display: none; margin-top: 4px; color: var(--muted); font-size: 12px; }
.stat { text-align: center; }
.stat-num { font-weight: 650; font-size: 14px; }
.stat-label {
  display: block;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.node-latest { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 8px; align-items: center; min-width: 0; }
.badge-new {
  display: inline-block;
  margin-left: 6px;
  background: var(--blue);
  color: #fff;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: 1px;
}
.muted { color: var(--muted); }

.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: #1b2430; display: block; }
.avatar.sm { width: 28px; height: 28px; }

.online-names { padding: 0 14px 4px; font-size: 13px; line-height: 1.7; }
.presence {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: #3dd68c;
}
.online-total {
  margin: 8px 12px 12px;
  background: var(--inset);
  border-radius: 4px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12.5px;
}
.feed-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  padding: 8px 14px 10px;
  text-decoration: none;
  color: inherit;
}
a.feed-item:hover { text-decoration: none; background: rgba(255, 255, 255, 0.025); }
.feed-title { display: block; color: #e7ebf3; font-size: 13.5px; font-weight: 650; }
.feed-excerpt { display: block; margin-top: 2px; color: #d5dbe6; font-size: 13px; }
.feed-meta, .feed-forum, .feed-excerpt { display: block; }
.stat-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 14px;
  font-size: 13px;
  border-top: 1px solid var(--line);
}
.stat-line span:first-child { color: #c5cedc; }
.stat-line span:last-child { color: #f4f6fa; font-weight: 650; }
.side-pad, .pad { padding: 12px 16px 16px; }
.side-copy { color: var(--text); margin: 8px 0; }
.pad-inline { padding: 12px 16px 0; }
.crumbs { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.crumbs a { color: #b9c7e4; text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumb-sep { margin: 0 6px; color: #6d7788; }

.prose p, .prose ul, .prose h3 { margin: 0 0 10px; }
.prose h3 { margin-top: 14px; font-size: 16px; }
.prose ul { padding-left: 18px; }
.prose li + li { margin-top: 4px; }
.post { padding: 16px; }
.post-by { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.thread-main { min-width: 0; }
.thread-latest { min-width: 0; }

.field { display: block; margin-top: 12px; margin-bottom: 6px; font-size: 13px; font-weight: 650; color: #d5dbe6; }
.help { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; }
.counter-short { color: #f3d48a; }
.counter-ok { color: #8ee0a8; }
.stack-form, .search-form { padding: 4px 16px 18px; }
.stack-form input:not([type="checkbox"]):not([type="hidden"]),
.stack-form select,
.stack-form textarea { width: 100%; max-width: 720px; }
input[type="text"], input[type="number"], input[type="search"], select, textarea {
  width: 100%;
  background: #1b2028;
  color: #f4f6fa;
  border: 1px solid #3c4556;
  border-radius: 4px;
  padding: 8px 10px;
}
textarea { min-height: 120px; resize: vertical; }
input[readonly] { color: #c5d0e0; background: #232833; }
.check { display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; color: #d5dbe6; }
.check input { margin-top: 3px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.search-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.search-form .field { width: 100%; margin-top: 0; }
.search-form input { flex: 1 1 220px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 4px;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn.primary { background: #2f6fe0; color: #fff; }
.btn.ghost { background: transparent; color: #d5dbe6; border: 1px solid #4c5668; }
.btn.accept { background: #1f7a45; color: #fff; }
.btn.deny { background: #9d3b3b; color: #fff; }
.btn.small { padding: 4px 8px; font-size: 12px; }
.mock-choices { display: flex; flex-direction: column; align-items: flex-start; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 12px; }
.filters a {
  color: #d5dbe6;
  background: var(--inset);
  border-radius: 99px;
  padding: 4px 10px;
  font-size: 13px;
  text-decoration: none;
  text-transform: capitalize;
}
.filters a.active { background: #2f6fe0; color: #fff; }
.app-card { padding: 16px; border-top: 1px solid var(--line); }
.app-card h2 { margin: 0; font-size: 18px; }
.field-block { margin-top: 12px; }
.field-block h3 {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.field-block p, .review-note { white-space: pre-wrap; overflow-wrap: anywhere; }
.review-note { margin-top: 8px; }
.review-actions textarea { min-height: 70px; }
.pill {
  display: inline-block;
  border-radius: 99px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: 1px;
}
.pill.pending, .pill.owner { background: #4a3b16; color: #f3d48a; }
.pill.accepted { background: #16381f; color: #8ee0a8; }
.pill.denied { background: #3c1c1c; color: #f0b0b0; }
.pill.admin { background: #1a3058; color: #b9d4ff; }
.pill.reviewer { background: #1a3340; color: #b7e4f5; }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.person {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
.person-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
code.id { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: #d5dbe6; }
.grant-form { border-top: 1px solid var(--line); }

.drole {
  display: inline-block;
  margin: 2px 4px 2px 0;
  padding: 1px 8px;
  border-radius: 99px;
  background: #99aab5;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
.admin-person { align-items: start; }
.map-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
.map-checks { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.map-checks .check { margin-top: 0; }
.sheet-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
}
.sheet-filters input, .sheet-filters select { width: auto; min-width: 140px; }
.sheet-wrap { overflow-x: auto; background: #f4f6f8; color: #1c2430; }
.sheet { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 1100px; }
.sheet td:nth-child(1) { min-width: 120px; }
.sheet td:nth-child(2) { min-width: 170px; }
.sheet td:nth-child(3) { min-width: 200px; }
.sheet td:nth-child(4), .sheet td:nth-child(5), .sheet td:nth-child(6) { min-width: 140px; }
.sheet td:nth-child(10) { min-width: 240px; }
.sheet th {
  position: sticky;
  top: 0;
  background: #1e293b;
  color: #fff;
  text-align: left;
  padding: 8px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.sheet td { border-bottom: 1px solid #d5dbe3; padding: 6px 8px; vertical-align: top; }
.sheet input, .sheet select {
  width: 100%;
  min-width: 72px;
  background: #fff;
  color: #1c2430;
  border: 1px solid #c5ced8;
  border-radius: 3px;
  padding: 4px 6px;
}
.sheet-person { display: flex; align-items: center; gap: 6px; }
.sheet-meta, .sheet .id { color: #526074; }
.sheet-actions { display: flex; flex-direction: column; gap: 6px; white-space: nowrap; }
.sheet-add { margin: 0; padding: 14px 16px 0; font-size: 15px; }
.rank-band td { font-weight: 800; color: #fff; letter-spacing: 0.04em; text-transform: uppercase; }
.rank-chief td { background: #7f1d1d; }
.rank-assistant-chief td { background: #9a3412; }
.rank-captain td { background: #1e3a8a; }
.rank-lieutenant td { background: #1d4ed8; }
.rank-sergeant td { background: #166534; }
.rank-corporal td { background: #6d28d9; }
.rank-senior-officer td { background: #0f766e; }
.rank-officer td { background: #334155; }
.rank-cadet td { background: #0e7490; }
.rank-division td { background: #1e293b; }
.status { font-weight: 800; font-size: 12px; text-transform: uppercase; }
.status.active { color: #166534; }
.status.loa { color: #a16207; }
.status.inactive { color: #64748b; }
.status.removed { color: #991b1b; }
a.ticket-row {
  display: block;
  grid-template-columns: none;
  text-decoration: none;
  color: inherit;
  padding: 14px 16px;
}
.ticket-row .thread-title { white-space: normal; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pill.open { background: #1a3340; color: #b7e4f5; }
.pill.pending { background: #4a3b16; color: #f3d48a; }
.pill.closed { background: #3c1c1c; color: #f0b0b0; }

.footer { border-top: 1px solid rgba(255, 255, 255, 0.04); }
.footer-inner {
  width: min(var(--max), calc(100% - 32px));
  margin: 0 auto;
  padding: 16px 0 28px;
  color: var(--muted);
  font-size: 12.5px;
}

input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid #6aa4ff;
  outline-offset: 2px;
}

@media (min-width: 901px) {
  .nav-item:hover > .menu,
  .nav-item:focus-within > .menu { display: block; }
}

@media (max-width: 900px) {
  .burger { display: block; }
  .topbar-inner { width: min(var(--max), calc(100% - 16px)); }
  .page { width: min(var(--max), calc(100% - 16px)); }
  .brand-name { font-size: 12px; letter-spacing: 0.04em; }
  .nav-cluster {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    background: #1e232b;
    border-bottom: 1px solid #12151a;
    padding: 4px 0 10px;
  }
  .nav-cluster.is-open { display: flex; }
  .primary-nav, .topbar-tools { flex-direction: column; align-items: stretch; margin-left: 0; }
  .nav-link, .tool-link, .userchip, .icon-btn { height: 42px; }
  .nav-link.active::after { display: none; }
  .nav-link.active { color: var(--link); }
  .menu { position: static; box-shadow: none; border: 0; background: transparent; min-width: 0; padding: 0 0 4px 28px; }
  .layout { grid-template-columns: 1fr; }
  .hero { padding: 22px 14px; }
  .hero h1 { font-size: 22px; }
}

@media (max-width: 800px) {
  .map-row { grid-template-columns: 1fr; }
  .node-head, .thread-head { display: none; }
  .node, .thread-row {
    grid-template-columns: 36px minmax(0, 1fr);
    align-items: start;
  }
  .stat { display: none; }
  .node-mobile-meta { display: block; }
  .node-latest, .thread-latest { grid-column: 1 / -1; }
  .person { grid-template-columns: 40px minmax(0, 1fr); }
  .person-actions { grid-column: 2; justify-content: flex-start; }
}
