*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #080a10; --surface: #0e1018; --surface2: #141620; --surface3: #1c1f2e;
  --border: #232640; --border2: #2d3154; --text: #d8daf0; --text2: #9196bb; --text3: #c8cbdf;
  --muted: #9499be; --accent: #7b68ee; --accent-glow: rgba(123,104,238,0.25);
  --green: #3dd68c; --green-bg: rgba(61,214,140,0.08); --green-border: rgba(61,214,140,0.2); --green-border-lg: rgba(61,214,140,0.4); --green-row: rgba(61,214,140,0.04);
  --red: #f05c6e;   --red-bg: rgba(240,92,110,0.08);   --red-border: rgba(240,92,110,0.2);   --red-border-lg: rgba(240,92,110,0.3);   --red-row: rgba(240,92,110,0.07); --red-row-hover: rgba(240,92,110,0.13);
  --yellow: #f5c842; --yellow-bg: rgba(245,200,66,0.08);
  --progress-bg: #2a2d42; --shadow: rgba(0,0,0,0.4); --discord: #5865f2;
  --radius: 10px; --gap: 20px;
}

body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; font-size: 18px; line-height: 1.6; min-height: 100vh; }

/* Nav */
nav { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 1.867em; display: flex; align-items: center; gap: 0.267em; height: 3.467em; position: sticky; top: 0; z-index: 50; backdrop-filter: blur(0.533em); }
.nav-brand { color: var(--accent); font-weight: 700; font-size: 1em; letter-spacing: -0.02em; margin-right: 1.067em; display: flex; align-items: center; gap: 0.4em; }
nav a { color: var(--text2); text-decoration: none; font-size: 0.867em; font-weight: 500; padding: 0.462em 0.923em; border-radius: 0.462em; transition: color 0.15s, background 0.15s; }
nav a:hover { color: var(--text); background: var(--surface3); }
nav a.active { color: var(--text); background: var(--surface3); }

/* Layout */
main { max-width: 1200px; margin: 0 auto; padding: 1.333em 1.867em; }
h1 { font-size: 1.467em; font-weight: 700; letter-spacing: -0.018em; margin-bottom: 0.636em; }
h2 { font-size: 1em; font-weight: 600; margin-bottom: 0.667em; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.067em 1.333em; margin-bottom: 0.933em; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.933em; }

/* Table */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.08em; padding: 0.583em 1em; border-bottom: 1px solid var(--border2); }
td { padding: 0.571em 0.857em; border-bottom: 1px solid var(--border); font-size: 0.933em; color: var(--text3); }
tr:last-child td { border-bottom: none; }
tr.row-ok:hover td { background: var(--green-row); }
tr.row-missing { background: var(--red-row); }
tr.row-missing:hover td { background: var(--red-row-hover); }
tr.row-ok    td:first-child { border-left: 2px solid transparent; }
tr.row-missing td:first-child { border-left: 2px solid var(--red); }

/* Forms */
.form-row { display: flex; gap: 0.667em; align-items: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 0.333em; flex: 1; min-width: 8.667em; }
label { font-size: 0.75em; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
input, select { background: var(--surface2); border: 1px solid var(--border2); color: var(--text); border-radius: 0.467em; padding: 0.615em 0.846em; font-size: 0.867em; width: 100%; outline: none; transition: border-color 0.15s, box-shadow 0.15s; appearance: none; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23555878' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.667em center; padding-right: 1.867em; }

/* Buttons */
button, .btn { background: var(--accent); color: #fff; border: none; border-radius: 0.467em; padding: 0.533em 1.2em; font-size: 0.867em; cursor: pointer; font-weight: 600; letter-spacing: 0.01em; transition: opacity 0.15s, box-shadow 0.15s; white-space: nowrap; }
button:hover, .btn:hover { opacity: 0.88; box-shadow: 0 0.133em 0.8em var(--accent-glow); }
.btn-sm { padding: 0.417em 0.917em; font-size: 0.8em; border-radius: 0.5em; }
.btn-secondary { background: var(--surface3); color: var(--text2); border: 1px solid var(--border2); box-shadow: none; }
.btn-secondary:hover { color: var(--text); background: var(--surface2); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 0.333em; padding: 0.25em 0.833em; border-radius: 1.667em; font-size: 0.8em; font-weight: 600; }
.badge-green { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.badge-red   { background: var(--red-bg);   color: var(--red);   border: 1px solid var(--red-border); }

/* Stats */
.stat-row { display: flex; gap: 0.533em; flex-wrap: wrap; margin-bottom: 0.8em; }
.stat { background: var(--surface2); border: 1px solid var(--border2); border-radius: 0.533em; padding: 0.533em 0.933em; min-width: 6.667em; flex: 1; }
.stat-label { font-size: 0.75em; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 0.273em; font-weight: 600; }
.stat-value { font-size: 1.733em; font-weight: 700; letter-spacing: -0.019em; }
.stat-value.ok  { color: var(--green); }
.stat-value.err { color: var(--red); }
.stat-value.neu { color: var(--text3); }

/* Progress */
.progress-bar { background: var(--progress-bg); border-radius: 99px; height: 7px; overflow: hidden; min-width: 5.333em; }
.progress-fill { height: 100%; border-radius: 99px; transition: width 0.4s ease; }

/* Status */
.missing { color: var(--red); font-weight: 700; font-size: 0.867em; }
.ok { color: var(--green); }

/* Char pill */
.char-pill { display: inline-flex; align-items: center; gap: 0.4em; background: var(--surface2); border: 1px solid var(--border2); border-radius: 1.333em; padding: 0.267em 0.8em; font-size: 0.867em; font-weight: 500; }
.char-pill button { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0; font-size: 0.933em; line-height: 1; transition: color 0.15s; }
.char-pill button:hover { color: var(--red); opacity: 1; box-shadow: none; }

/* Misc */
.tag { display: inline-block; background: var(--surface3); border-radius: 0.267em; padding: 0.091em 0.636em; font-size: 0.75em; color: var(--text2); }
.breakdown { color: var(--muted); font-size: 0.75em; margin-top: 0.182em; }
.htmx-indicator { opacity: 0; transition: opacity 200ms; color: var(--muted); font-size: 0.8em; }
.htmx-request .htmx-indicator { opacity: 1; }
#loading-bar { position: fixed; top: 0; left: 0; height: 3px; width: 100%; z-index: 1000; overflow: hidden; opacity: 0; transition: opacity 150ms; pointer-events: none; }
#loading-bar.active { opacity: 1; }
#loading-bar::after { content: ''; position: absolute; top: 0; height: 100%; width: 45%; background: var(--accent); box-shadow: 0 0 8px var(--accent); left: -45%; animation: loading-slide 1.2s ease-in-out infinite; }
@keyframes loading-slide { 0% { left: -45%; } 100% { left: 100%; } }
@keyframes spin { to { transform: rotate(360deg); } }
#toast { position: fixed; bottom: 1.333em; right: 1.333em; background: var(--surface2); border: 1px solid var(--border2); border-radius: 0.533em; padding: 0.667em 1.2em; font-size: 0.867em; display: none; z-index: 200; box-shadow: 0 0.267em 1.6em var(--shadow); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
hr { border: none; border-top: 1px solid var(--border); margin: 1.067em 0; }

/* Utility */
.hidden { display: none !important; }
.text-muted { color: var(--muted); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-sm { font-size: 0.867em; }
.text-xs { font-size: 0.75em; }
.text-xxs { font-size: 0.75em; color: var(--muted); margin-top: 0.2em; text-align: right; }
.font-bold { font-weight: 600; }
.mb-sm { margin-bottom: 0.8em; }
.mt-sm { margin-top: 0.533em; }
.mt-xs { margin-top: 0.133em; }

/* Craft form layout */
.form-row-top { align-items: flex-start; }
.field-search { min-width: 17.333em; position: relative; }
.field-qty { max-width: 6.667em; }
.field-view { max-width: 8em; }
.btn-end { align-self: flex-end; }

/* Search dropdown */
#search-results { position: absolute; top: 100%; left: 0; right: 0; z-index: 20; background: var(--surface2); border: 1px solid var(--border2); border-radius: 0.533em; margin-top: 0.267em; overflow: hidden; display: none; }
.search-result-row { padding: 0.6em 0.933em; cursor: pointer; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); }
.search-result-row:hover { background: var(--surface3); }
.search-result-name { font-size: 0.867em; font-weight: 500; }
.search-result-meta { font-size: 0.75em; color: var(--muted); }
.search-empty { padding: 0.667em; color: var(--muted); font-size: 0.867em; }
.search-error { padding: 0.667em; color: var(--red); font-size: 0.867em; }
.search-more { padding: 0.533em 0.933em; color: var(--muted); font-size: 0.8em; font-style: italic; border-top: 1px solid var(--border); }

/* Team pills container */
#team-pills { display: flex; flex-wrap: wrap; gap: 0.4em; margin-top: 0.667em; }
#no-team-warn { color: var(--yellow); font-size: 0.867em; margin-top: 0.533em; display: none; }

/* Roster */
#roster { display: flex; flex-wrap: wrap; gap: 0.533em; margin-bottom: 0.8em; }

/* Alerts */
.alert-warn { color: var(--yellow); font-size: 0.867em; margin-bottom: 0.533em; }
.alert-error { color: var(--red); }
.hint { color: var(--muted); font-size: 0.867em; margin-bottom: 0.533em; }

/* Card result states */
.card-ready   { border-color: var(--green-border-lg); }
.card-missing { border-color: var(--red-border-lg); }

/* Card header */
.card-header-actions { display: flex; gap: 0.533em; align-items: center; }
.result-title { font-size: 1.067em; margin-bottom: 0.2em; }
.result-station { color: var(--text2); font-size: 0.8em; margin-bottom: 0.25em; }
.result-sub { color: var(--muted); font-size: 0.8em; }
.result-sub-spaced { color: var(--muted); font-size: 0.8em; margin-top: 0.167em; }
.result-qty { color: var(--muted); font-weight: 400; }
.badge-have { margin-left: 0.533em; font-size: 0.8em; }

/* Table cells */
th.col-progress { min-width: 6.667em; }
td.col-progress { min-width: 6.667em; }
.item-name { font-weight: 500; }
.item-station { font-size: 0.75em; color: var(--muted); margin-top: 0.15em; }
.tag-crafted { margin-left: 0.4em; }
.qty-have-missing { font-weight: 600; }
.qty-have-ok { font-weight: 400; }
.qty-sep { color: var(--muted); }
.status-ok { font-size: 1.067em; }
.pct-label { font-size: 0.75em; color: var(--muted); margin-top: 0.3em; text-align: right; }

/* Footer note */
.result-footer { color: var(--muted); font-size: 0.75em; margin-top: 1.273em; padding-top: 1.091em; border-top: 1px solid var(--border); }

/* Site footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 2.667em; padding: 1.6em; text-align: center; color: var(--muted); font-size: 0.8em; line-height: 1.8; }
.site-footer-links { margin-bottom: 0.333em; }
.footer-link { color: var(--text2); }
.footer-link-discord { color: var(--discord); font-weight: 500; }

/* Progress fill colors */
.progress-fill--ok   { background: var(--green); }
.progress-fill--warn { background: var(--yellow); }
.progress-fill--err  { background: var(--red); }

/* Inventory table */
td.col-tag { color: var(--muted); font-size: 0.867em; }
td.col-breakdown { color: var(--muted); font-size: 0.8em; }

/* Card section header */
.card-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.8em; }
.card-section-title { margin: 0; display: flex; align-items: baseline; gap: 0.8em; flex-wrap: wrap; }
.card-section-meta { color: var(--text2); font-size: 0.867em; font-weight: 400; }

/* Share button icon */
.icon-share { margin-right: 0.333em; vertical-align: -2px; }
