:root {
  --bg: #12141a;
  --surface: #1a1d26;
  --border: #2a3040;
  --text: #e8eaed;
  --muted: #9aa0ae;
  --font-numeric: ui-monospace, "Cascadia Mono", "Cascadia Code", "Segoe UI Mono",
    "Roboto Mono", Menlo, Consolas, monospace;
  --craft-idx-col: 40px;
  --craft-icon-col: 44px;
  --craft-tier-col: 48px;
  --craft-skill-col: 220px;
  --craft-num-col: 80px;
  --craft-progress-col: 160px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2.5rem;
}

header.summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
  margin: 0 0 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.site-nav__link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}

.site-nav__link:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.site-nav__link[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
  pointer-events: none;
  text-decoration: none;
}

.site-nav__sep {
  color: var(--border);
  user-select: none;
}

header.summary h1 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  overflow: visible;
}

.filter-line {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.65rem;
}

.filter-line:last-child {
  margin-bottom: 0;
}

.filter-line-label {
  flex: 0 0 auto;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding-top: 0.35rem;
  min-width: 3.25rem;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.55rem;
  flex: 1 1 auto;
  min-width: 0;
  overflow: visible;
}

.filter-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  overflow: visible;
}

.filter-btn__label {
  flex: 0 1 auto;
}

/* Neutral unread-style count; absolutely positioned so label sets button width. */
.filter-count-badge {
  position: absolute;
  top: 0;
  right: 0;
  transform: translate(42%, -42%);
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  min-height: 1.25rem;
  padding: 0.16rem 0.48rem;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.15;
  border-radius: 999px;
  font-family: var(--font-numeric);
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.5);
  color: rgba(255, 255, 255, 0.95);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.filter-tier--10 .filter-count-badge {
  background: rgba(255, 255, 255, 0.92);
  color: rgba(26, 29, 38, 0.88);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.filter-toggle .filter-count-badge {
  background: rgba(154, 160, 174, 0.22);
  color: var(--muted);
}

.filter-toggle.filter-toggle--on .filter-count-badge {
  background: rgba(154, 160, 174, 0.3);
  color: var(--text);
}

.filter-toggle {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.filter-toggle:hover {
  color: var(--text);
  border-color: #3d4458;
}

.filter-toggle:focus-visible {
  outline: 2px solid #5b8cff;
  outline-offset: 2px;
}

.filter-toggle--on {
  background: #252a38;
  color: var(--text);
  border-color: #4a5a8a;
}

.loading {
  color: var(--muted);
  padding: 2rem 0;
}

.error-wrap {
  background: #3d2226;
  border: 1px solid #7a3e45;
  color: #f0d0d3;
  padding: 1rem 1.25rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.error-wrap code {
  background: rgba(0, 0, 0, 0.25);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.97rem;
}

table.crafts-table {
  table-layout: fixed;
  width: 100%;
}

/* Explicit column widths (colgroup); avoids rowspan/colspan mis-counting ~200px progress cols */
.crafts-table col.craft-col-idx {
  width: var(--craft-idx-col);
}

.crafts-table col.craft-col-icon {
  width: var(--craft-icon-col);
}

.crafts-table col.craft-col-item {
  /* no fixed width: takes remaining space in table-layout: fixed */
  min-width: 8rem;
}

.crafts-table col.craft-col-tier {
  width: var(--craft-tier-col);
}

.crafts-table col.craft-col-skill {
  width: var(--craft-skill-col);
}

.crafts-table col.craft-col-num {
  width: var(--craft-num-col);
}

.crafts-table col.craft-col-progress {
  width: var(--craft-progress-col);
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #222631;
  color: var(--text);
  text-align: left;
  padding: 0.65rem 0.5rem;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  font-weight: 600;
}

thead th.sortable {
  cursor: pointer;
  user-select: none;
}

thead th.sortable:hover {
  background: #2a3140;
}

thead th.sortable:focus-visible {
  outline: 2px solid #6b9bd1;
  outline-offset: -2px;
}

thead th .sort-ind {
  display: inline-block;
  margin-left: 0.3em;
  min-width: 0.85em;
  opacity: 0.28;
  font-size: 0.72em;
  vertical-align: middle;
  color: var(--muted);
}

thead th.sorted-asc .sort-ind,
thead th.sorted-desc .sort-ind {
  opacity: 1;
  color: var(--text);
}

thead th.sorted-asc .sort-ind::after {
  content: "▲";
}

thead th.sorted-desc .sort-ind::after {
  content: "▼";
}

thead th.progress-group-header {
  text-align: center;
}

thead th.th-craft-num,
thead th.th-craft-progress {
  text-align: right;
  font-feature-settings: "tnum" 1, "lnum" 1;
  font-weight: 600;
  font-size: 0.8rem;
}

thead th.th-craft-tier {
  text-align: center;
  background: #2a3142;
  color: var(--text);
}

thead th.row-num-header {
  text-align: center;
}

thead th.th-craft-icon {
  width: var(--craft-icon-col);
  padding: 0.35rem 0.2rem;
}

.craft-icon-cell {
  width: var(--craft-icon-col);
  min-width: var(--craft-icon-col);
  max-width: var(--craft-icon-col);
  text-align: center;
  vertical-align: middle;
  padding: 0.3rem 0.25rem;
}

.craft-item-icon {
  display: block;
  margin: 0 auto;
  max-height: 40px;
  max-width: 40px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.craft-icon-cell--missing,
.craft-icon-cell--empty {
  color: rgba(154, 160, 174, 0.4);
  font-size: 0.7rem;
}

tbody td {
  padding: 0.5rem 0.45rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:hover td:not(.craft-tier-cell) {
  background: rgba(255, 255, 255, 0.03);
}

tbody tr:hover td.craft-tier-cell {
  filter: brightness(1.08);
}

.row-num-cell {
  font-family: var(--font-numeric);
  font-feature-settings: "tnum" 1, "lnum" 1;
  width: var(--craft-idx-col);
  min-width: var(--craft-idx-col);
  max-width: var(--craft-idx-col);
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.925rem;
}

.craft-item-cell {
  font-weight: 500;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.th-craft-tier,
.craft-tier-cell {
  font-family: var(--font-numeric);
  font-feature-settings: "tnum" 1, "lnum" 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.th-craft-num,
.craft-num-col {
  box-sizing: border-box;
}

.th-craft-progress,
.craft-progress-cell {
  box-sizing: border-box;
}

.craft-num-cell {
  font-family: var(--font-numeric);
  font-feature-settings: "tnum" 1, "lnum" 1;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: 0.875rem;
}

.craft-pct-cell {
  border-right: none;
}

tbody td:last-child {
  border-right: none;
}

/* Tier colors (aligned with empire-viewer skill tier strip) */
.tier-1 { background: #636a74; color: #f0f2f5; }
.tier-2 { background: #875f45; color: #f8f0eb; }
.tier-3 { background: #556748; color: #eef2e8; }
.tier-4 { background: #49619c; color: #eef1fb; }
.tier-5 { background: #814f87; color: #f6eef7; }
.tier-6 { background: #983a44; color: #fdeef0; }
.tier-7 { background: #947014; color: #fff8e6; }
.tier-8 { background: #538484; color: #e8f6f6; }
.tier-9 { background: #464953; color: #e4e6ec; }
.tier-10 { background: #96afbe; color: #1a1d26; }

/* Tier filter buttons: same palette */
.filter-tier {
  border: 1px solid rgba(0, 0, 0, 0.35);
  border-radius: 6px;
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  font-weight: 600;
  transition: filter 0.12s ease, box-shadow 0.12s ease;
}

.filter-tier:hover {
  filter: brightness(1.12);
}

.filter-tier:focus-visible {
  outline: 2px solid #5b8cff;
  outline-offset: 2px;
}

.filter-tier--1 { background: #636a74; color: #f0f2f5; }
.filter-tier--2 { background: #875f45; color: #f8f0eb; }
.filter-tier--3 { background: #556748; color: #eef2e8; }
.filter-tier--4 { background: #49619c; color: #eef1fb; }
.filter-tier--5 { background: #814f87; color: #f6eef7; }
.filter-tier--6 { background: #983a44; color: #fdeef0; }
.filter-tier--7 { background: #947014; color: #fff8e6; }
.filter-tier--8 { background: #538484; color: #e8f6f6; }
.filter-tier--9 { background: #464953; color: #e4e6ec; }
.filter-tier--10 { background: #96afbe; color: #1a1d26; }

.filter-tier.filter-tier--on {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55);
  filter: brightness(1.05);
}
