:root {
  color-scheme: dark;
  --bg: #050b11;
  --bg-elevated: #081621;
  --panel: rgba(12, 31, 43, .88);
  --panel-solid: #0c1f2b;
  --panel-2: #102b39;
  --line: rgba(142, 210, 225, .18);
  --line-strong: rgba(142, 210, 225, .42);
  --text: #edf7f8;
  --muted: #9bb6bd;
  --faint: #69828a;
  --cyan: #80d9e8;
  --cyan-strong: #b8f3f9;
  --gold: #d7ad58;
  --gold-soft: #f0d796;
  --red: #ff7a7a;
  --green: #78e0b0;
  --orange: #ffc477;
  --shadow: 0 16px 50px rgba(0, 0, 0, .38);
  --radius: 14px;
  --radius-sm: 8px;
  --sidebar: 264px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body {
  background-image:
    radial-gradient(circle at 80% 0%, rgba(86, 185, 205, .12), transparent 36%),
    radial-gradient(circle at 12% 55%, rgba(215, 173, 88, .08), transparent 30%),
    linear-gradient(120deg, rgba(255,255,255,.012) 1px, transparent 1px),
    linear-gradient(30deg, rgba(255,255,255,.009) 1px, transparent 1px);
  background-size: auto, auto, 44px 44px, 44px 44px;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--cyan); }
button { color: inherit; }
img { max-width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.warning { color: var(--orange); }
.error-text { color: var(--red); }
.success-text { color: var(--green); }
.eyebrow { margin: 0 0 8px; color: var(--gold-soft); font-size: 11px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.app-shell { min-height: 100vh; }
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 24px 16px calc(20px + var(--safe-bottom));
  border-right: 1px solid var(--line); background: rgba(4, 13, 20, .92); backdrop-filter: blur(20px);
  display: flex; flex-direction: column; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 13px; padding: 4px 8px 24px; }
.brand h1 { font-size: 17px; margin: 0; letter-spacing: .03em; }
.brand p { font-size: 11px; color: var(--muted); margin: 3px 0 0; }
.brand-mark { position: relative; width: 46px; height: 46px; flex: 0 0 auto; filter: drop-shadow(0 0 14px rgba(128,217,232,.24)); }
.brand-mark.small { width: 56px; height: 56px; margin-bottom: 12px; }
.brand-mark::before, .brand-mark::after, .brand-mark span::before, .brand-mark span::after {
  content: ""; position: absolute; left: 50%; top: 50%; transform-origin: center;
  border: 2px solid var(--cyan); border-radius: 70% 12% 70% 12%;
}
.brand-mark::before { width: 25px; height: 38px; transform: translate(-62%, -50%) rotate(22deg); border-right-color: transparent; }
.brand-mark::after { width: 25px; height: 38px; transform: translate(-38%, -50%) rotate(-22deg); border-left-color: transparent; }
.brand-mark span::before { width: 7px; height: 24px; transform: translate(-50%, -52%) rotate(45deg); border-color: var(--gold); border-width: 1px; }
.brand-mark span::after { width: 4px; height: 4px; transform: translate(-50%, -50%) rotate(45deg); background: var(--cyan-strong); border: 0; box-shadow: 0 0 16px var(--cyan); }
.nav { display: grid; gap: 5px; }
.nav-button {
  width: 100%; display: flex; gap: 12px; align-items: center; border: 1px solid transparent; border-radius: 9px;
  padding: 11px 12px; background: transparent; color: var(--muted); cursor: pointer; text-align: left;
}
.nav-button:hover { background: rgba(128,217,232,.06); color: var(--text); }
.nav-button.active { color: var(--cyan-strong); background: linear-gradient(90deg, rgba(128,217,232,.13), rgba(128,217,232,.025)); border-color: var(--line); }
.nav-icon { width: 20px; text-align: center; color: var(--gold-soft); font-size: 14px; }
.sidebar-foot { margin-top: auto; padding: 16px 8px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.sync-pill { display: inline-flex; align-items: center; gap: 7px; margin-top: 8px; padding: 6px 9px; border-radius: 999px; background: rgba(120,224,176,.08); color: var(--green); }
.sync-pill::before { content:""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 9px currentColor; }
.sync-pill.saving { color: var(--orange); }
.sync-pill.error { color: var(--red); }
.main { min-width: 0; padding: 24px 28px 64px; }
.topbar { display: flex; align-items: center; gap: 16px; justify-content: space-between; min-height: 52px; margin-bottom: 24px; }
.topbar h2 { margin: 0; font-size: clamp(22px, 3vw, 34px); font-weight: 650; letter-spacing: -.025em; }
.topbar-actions { display: flex; gap: 9px; align-items: center; }
.mode-badge { padding: 7px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.mode-badge.read { color: var(--gold-soft); }
.mobile-menu { display: none; }
.section { margin-bottom: 28px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 0 0 14px; }
.section-head h3 { margin: 0; font-size: 18px; }
.section-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.grid { display: grid; gap: 14px; }
.grid.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.card {
  position: relative; border: 1px solid var(--line); background: linear-gradient(145deg, rgba(15,39,52,.9), rgba(7,20,29,.9));
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.card::before { content:""; position: absolute; inset: 0 auto auto 0; width: 54px; height: 2px; background: var(--gold); opacity: .8; }
.card-body { padding: 17px; }
.stat-card { padding: 16px; min-height: 120px; }
.stat-card .value { font-size: 31px; font-weight: 750; margin: 10px 0 3px; }
.stat-card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .09em; }
.stat-card .detail { color: var(--faint); font-size: 12px; }
.progress { height: 7px; border-radius: 999px; background: rgba(255,255,255,.06); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--gold)); }
.progress-row { display: grid; grid-template-columns: minmax(120px,1fr) minmax(110px, 2fr) 52px; gap: 12px; align-items: center; margin: 10px 0; font-size: 13px; }
.button {
  border: 1px solid var(--line-strong); background: rgba(128,217,232,.055); border-radius: 8px; padding: 9px 13px; cursor: pointer;
  color: var(--text); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.button:hover { background: rgba(128,217,232,.12); border-color: rgba(128,217,232,.7); }
.button.primary { background: linear-gradient(135deg, rgba(128,217,232,.22), rgba(215,173,88,.15)); border-color: var(--cyan); color: var(--cyan-strong); font-weight: 700; }
.button.danger { border-color: rgba(255,122,122,.45); color: #ffadad; background: rgba(255,122,122,.06); }
.button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.button.small { padding: 6px 9px; font-size: 12px; }
.button.full { width: 100%; }
.button:disabled { opacity: .42; cursor: not-allowed; }
.filters { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 15px; }
.search { position: relative; min-width: min(340px, 100%); flex: 1; }
.search input { width: 100%; padding-left: 37px; }
.search::before { content:"⌕"; position: absolute; left: 13px; top: 9px; color: var(--faint); font-size: 18px; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); background: rgba(1,9,14,.68); color: var(--text); border-radius: 8px; padding: 10px 11px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(128,217,232,.08); }
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 650; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 13px; }
.form-stack { display: grid; gap: 14px; }
.form-span { grid-column: 1 / -1; }
.loadout-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 13px; }
.loadout-card { cursor: pointer; transition: transform .15s ease, border-color .15s ease; }
.loadout-card:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.loadout-card .card-body { display: grid; gap: 12px; min-height: 225px; }
.loadout-head { display: flex; align-items: start; gap: 12px; }
.slot-number { width: 38px; height: 38px; border: 1px solid var(--line-strong); color: var(--gold-soft); border-radius: 9px; display: grid; place-items: center; font-size: 12px; font-weight: 800; flex: 0 0 auto; }
.loadout-title { min-width: 0; }
.loadout-title h4 { margin: 0 0 4px; font-size: 15px; line-height: 1.25; }
.loadout-title p { margin: 0; color: var(--muted); font-size: 12px; }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 5px 8px; font-size: 10px; border: 1px solid var(--line); color: var(--muted); background: rgba(255,255,255,.025); }
.pill.gold { color: var(--gold-soft); border-color: rgba(215,173,88,.34); }
.pill.green { color: var(--green); border-color: rgba(120,224,176,.3); }
.pill.red { color: #ffabab; border-color: rgba(255,122,122,.3); }
.pill.cyan { color: var(--cyan-strong); border-color: rgba(128,217,232,.35); }
.status-select { appearance: none; padding: 6px 26px 6px 8px; width: auto; min-width: 112px; font-size: 11px; background-image: linear-gradient(45deg,transparent 50%,var(--muted) 50%),linear-gradient(135deg,var(--muted) 50%,transparent 50%); background-position: calc(100% - 13px) 50%,calc(100% - 9px) 50%; background-size:4px 4px,4px 4px; background-repeat:no-repeat; }
.card-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.readiness { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.readiness span { height: 4px; border-radius: 99px; background: rgba(255,255,255,.07); }
.readiness span.on { background: var(--cyan); }
.detail-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: start; margin-bottom: 18px; }
.detail-hero h3 { font-size: clamp(24px, 4vw, 38px); margin: 5px 0 9px; line-height: 1.1; }
.detail-hero p { margin: 0; color: var(--muted); max-width: 850px; line-height: 1.55; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: end; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab { border: 0; background: transparent; color: var(--muted); padding: 11px 13px; cursor: pointer; white-space: nowrap; border-bottom: 2px solid transparent; }
.tab.active { color: var(--cyan-strong); border-bottom-color: var(--cyan); }
.info-list { display: grid; gap: 0; }
.info-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.info-row:last-child { border-bottom: 0; }
.info-key { color: var(--muted); font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.info-value { line-height: 1.55; min-width: 0; }
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(180px,1fr)); gap: 8px; }
.mod-chip { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(0,0,0,.18); font-size: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mod-chip.owned { border-color: rgba(120,224,176,.25); }
.mod-chip.missing { border-color: rgba(255,122,122,.28); }
.inventory-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.inventory-table th { text-align: left; padding: 10px; color: var(--muted); border-bottom: 1px solid var(--line-strong); position: sticky; top: 0; background: var(--panel-solid); z-index: 1; }
.inventory-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.inventory-table tr:hover td { background: rgba(128,217,232,.025); }
.item-cell { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.item-image { width: 38px; height: 38px; border-radius: 8px; background: rgba(255,255,255,.04); object-fit: contain; border: 1px solid var(--line); }
.table-wrap { max-height: calc(100vh - 245px); overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(7,20,29,.76); }
.priority-list { display: grid; gap: 9px; }
.priority-item { display: grid; grid-template-columns: 40px minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.018); }
.priority-num { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; border: 1px solid rgba(215,173,88,.5); color: var(--gold-soft); font-weight: 800; }
.priority-item h4 { margin: 0 0 3px; }
.priority-item p { margin: 0; color: var(--muted); font-size: 12px; }
.empty { text-align: center; padding: 50px 18px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.72); backdrop-filter: blur(7px); display: grid; place-items: center; padding: 20px; z-index: 100; }
.modal { width: min(900px, 100%); max-height: calc(100vh - 40px); overflow: auto; border: 1px solid var(--line-strong); border-radius: 16px; background: #091923; box-shadow: 0 30px 90px rgba(0,0,0,.7); }
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 17px 20px; background: rgba(9,25,35,.96); border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 20px; }
.modal-foot { position: sticky; bottom: 0; display: flex; justify-content: end; gap: 9px; padding: 14px 20px; background: rgba(9,25,35,.97); border-top: 1px solid var(--line); }
.close-button { border: 0; background: transparent; color: var(--muted); font-size: 24px; cursor: pointer; }
#toast-root { position: fixed; right: 18px; bottom: calc(18px + var(--safe-bottom)); z-index: 200; display: grid; gap: 8px; }
.toast { padding: 11px 14px; border: 1px solid var(--line-strong); border-radius: 9px; background: #0d2430; box-shadow: var(--shadow); font-size: 13px; animation: toast-in .18s ease; }
.toast.error { border-color: rgba(255,122,122,.5); color: #ffb1b1; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
.access-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.access-card, .setup-card { width: min(600px, 100%); padding: 28px; border: 1px solid var(--line-strong); border-radius: 18px; background: rgba(8,22,33,.93); box-shadow: var(--shadow); }
.access-card h1, .setup-card h1 { margin: 0 0 11px; font-size: clamp(28px, 6vw, 44px); letter-spacing: -.04em; }
.access-card .brand-mark { margin-bottom: 15px; }
.setup-page { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.setup-card { width: min(680px,100%); }
.setup-card h2 { margin-top: 28px; }
.status-box { margin: 16px 0; padding: 11px 13px; border: 1px solid rgba(120,224,176,.3); background: rgba(120,224,176,.06); border-radius: 8px; color: var(--green); }
.status-box.error { border-color: rgba(255,122,122,.35); background: rgba(255,122,122,.06); color: #ffb0b0; }
.copy-row { display: flex; gap: 7px; }
.copy-row input { flex: 1; }
.callout { border-left: 3px solid var(--gold); background: rgba(215,173,88,.055); padding: 13px 15px; border-radius: 0 9px 9px 0; line-height: 1.5; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; }
.mobile-bottom { display: none; }
@media (max-width: 1050px) {
  .grid.stats { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid.three { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 780px) {
  :root { --sidebar: 0px; }
  .shell { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(310px, 88vw); transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .shell.menu-open .sidebar { transform: translateX(0); }
  .main { padding: 17px 15px calc(84px + var(--safe-bottom)); }
  .topbar { margin-bottom: 17px; }
  .mobile-menu { display: inline-flex; }
  .topbar-actions .button:not(.keep-mobile) { display: none; }
  .grid.stats, .grid.two, .grid.three { grid-template-columns: 1fr 1fr; }
  .detail-hero { grid-template-columns: 1fr; }
  .detail-actions { justify-content: start; }
  .form-grid { grid-template-columns: 1fr; }
  .form-span { grid-column: auto; }
  .info-row { grid-template-columns: 1fr; gap: 4px; }
  .table-wrap { max-height: none; overflow-x: auto; }
  .inventory-table { min-width: 720px; }
  .mobile-bottom { position: fixed; inset: auto 0 0; z-index: 20; display: grid; grid-template-columns: repeat(5,1fr); padding: 7px 7px calc(7px + var(--safe-bottom)); background: rgba(4,13,20,.95); border-top: 1px solid var(--line); backdrop-filter: blur(16px); }
  .mobile-bottom button { border: 0; background: transparent; color: var(--muted); padding: 7px 3px; font-size: 10px; display: grid; gap: 3px; justify-items: center; }
  .mobile-bottom button.active { color: var(--cyan-strong); }
  .mobile-bottom .nav-icon { font-size: 16px; }
}
@media (max-width: 520px) {
  .grid.stats, .grid.two, .grid.three { grid-template-columns: 1fr; }
  .loadout-list { grid-template-columns: 1fr; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; }
  .filters .search { grid-column: 1 / -1; }
  .priority-item { grid-template-columns: 35px minmax(0,1fr); }
  .priority-item > :last-child { grid-column: 2; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal { width: 100%; max-height: 94vh; border-radius: 16px 16px 0 0; }
  .access-card, .setup-card { padding: 22px 18px; }
}
@media print {
  body { background: white; color: #111; }
  .sidebar, .topbar-actions, .mobile-bottom, .button, .filters { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .card { box-shadow: none; background: white; border-color: #bbb; break-inside: avoid; }
  .muted, .faint { color: #555; }
  .pill { color: #333; border-color: #aaa; }
}
