:root {
  --bg: #0f1115;
  --bg-card: #171a21;
  --border: #262b35;
  --text: #e6e8ec;
  --text-dim: #9aa1ad;
  --accent: #5eead4;
  --accent-dim: #2dd4bf;
  --accent-soft: #113c37;
  --live: #f59e0b;
  --live-soft: #3a2a0d;
  --now-red: #f87171;
  --tab-active-text: #06231f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}
.mono { font-family: "JetBrains Mono", ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums; }

.wrap { max-width: 980px; margin: 0 auto; padding: 28px 20px 80px; }

#page-loading-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 17, 21, 0.82);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  color: var(--text-dim); font-size: 0.9rem;
}
#page-loading-overlay .spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  #page-loading-overlay .spinner { animation-duration: 2s; }
}

/* --- Top nav: full-width, sticky --- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg-card); border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 980px; margin: 0 auto; padding: 14px 20px;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px;
}
.brand { font-weight: 700; font-size: 1.25rem; color: var(--text); text-decoration: none; }
.brand span { color: var(--accent); }

.tabs { display: flex; gap: 4px; }
.tab {
  border: none; background: transparent; color: var(--text-dim); text-decoration: none;
  padding: 8px 16px; border-radius: 7px; font-size: 0.88rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--accent); color: var(--tab-active-text); }

section { margin-bottom: 40px; }
h2 {
  font-size: 0.86rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-dim); margin: 0 0 6px; font-weight: 700;
}
.hint, .section-sub { color: var(--text-dim); font-size: 0.85rem; margin: 0 0 16px; }
.dim { color: var(--text-dim); }

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

.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; text-decoration: none; color: inherit; display: block;
  transition: border-color 0.15s ease;
}
a.card:hover { border-color: var(--accent-dim); }
.card-icon { width: 30px; height: 30px; border-radius: 6px; margin-bottom: 8px; object-fit: cover; }
.card-title { font-weight: 600; font-size: 0.94rem; margin-bottom: 2px; }
.card-desc { color: var(--text-dim); font-size: 0.82rem; }

table { width: 100%; border-collapse: collapse; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
th { color: var(--text-dim); font-weight: 600; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: none; }
.row-icon { width: 20px; height: 20px; vertical-align: middle; border-radius: 4px; }
td.num, th.num { text-align: right; }
td.dim { color: var(--text-dim); }
.table-scroll { overflow-x: auto; }

.coin { white-space: nowrap; }
.coin.gold { color: #e1b746; }
.coin.silver { color: #b6bcc4; }
.coin.copper { color: #c17a4e; }

.profit-pos { color: #4ade80; font-weight: 700; }
.profit-neg { color: #f87171; font-weight: 700; }

.recipe-toggle {
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 6px; padding: 4px 10px; font-size: 0.76rem; font-weight: 600;
  cursor: pointer; font-family: inherit; white-space: nowrap;
}
.recipe-toggle:hover { border-color: var(--accent); color: var(--accent); }
.recipe-toggle.open { color: var(--accent); border-color: var(--accent); }

.recipe-row td { padding: 0; border-bottom: 1px solid var(--border); }
.recipe-detail { padding: 14px 20px; background: var(--bg); }
.recipe-title { font-weight: 700; font-size: 0.85rem; margin-bottom: 10px; }
.ingredient-line {
  display: flex; align-items: center; gap: 10px; padding: 6px 0;
  border-bottom: 1px dashed var(--border); font-size: 0.85rem;
}
.ingredient-line:last-child { border-bottom: none; }
.ingredient-line img { width: 20px; height: 20px; border-radius: 4px; }
.ing-qty { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.ing-name { flex: 1; }
.ing-price { color: var(--text-dim); }
.ing-subtotal { min-width: 90px; text-align: right; }
.recipe-total { font-weight: 700; padding-top: 10px; }
.recipe-total:not(:last-child) { border-bottom: 1px dashed var(--border); }

.flip-caveat {
  background: var(--accent-soft); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 16px; font-size: 0.85rem; color: var(--text); line-height: 1.5;
}
.flip-caveat strong { color: var(--accent); }

/* --- Market tab layout: sidebar + main --- */
.market-bleed {
  width: 100vw; margin-left: calc(50% - 50vw); margin-right: calc(50% - 50vw);
  padding: 0 24px; box-sizing: border-box;
}
.market-layout { max-width: 1360px; margin: 0 auto; display: flex; gap: 28px; align-items: flex-start; }
.market-sidebar { width: 250px; flex-shrink: 0; }
.market-main { flex: 1; min-width: 0; }
.market-main .section-sub { max-width: none; }

.gem-list { display: flex; flex-direction: column; gap: 10px; }
.gem-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px;
}
.gem-item img { width: 32px; height: 32px; border-radius: 6px; flex-shrink: 0; object-fit: cover; }
.gem-item .gi-text { min-width: 0; }
.gem-item .gi-name { font-weight: 600; font-size: 0.84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gem-item .gi-desc { color: var(--text-dim); font-size: 0.74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 860px) {
  .market-layout { flex-direction: column; }
  .market-sidebar { width: 100%; }
}

/* --- Dashboard layout: same sidebar + main pattern as Market --- */
.dash-bleed {
  width: 100vw; margin-left: calc(50% - 50vw); margin-right: calc(50% - 50vw);
  padding: 0 24px; box-sizing: border-box;
}
.dash-layout { max-width: 1360px; margin: 0 auto; display: flex; gap: 28px; align-items: flex-start; }
.dash-sidebar { width: 320px; flex-shrink: 0; }
.dash-main { flex: 1; min-width: 0; }

@media (max-width: 860px) {
  .dash-layout { flex-direction: column; }
  .dash-sidebar { width: 100%; }
}

/* --- Boss/meta timeline (Gantt-style, lebusmagique-inspired) --- */
.timeline-header {
  width: 100vw; margin-left: calc(50% - 50vw); margin-right: calc(50% - 50vw);
  padding: 0 24px; margin-bottom: 16px; box-sizing: border-box;
  display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap;
}
.timeline-desc { color: var(--text-dim); font-size: 1rem; margin: 0; max-width: 80ch; line-height: 1.5; }
.clocks { display: flex; gap: 10px; flex-shrink: 0; }
.clock {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 12px; display: flex; flex-direction: column; align-items: center; min-width: 84px;
}
.clock-label { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); }
.clock-value { font-size: 1rem; font-weight: 700; color: var(--accent); }

.filter-bleed {
  width: 100vw; margin-left: calc(50% - 50vw); margin-right: calc(50% - 50vw);
  padding: 0 24px; margin-bottom: 16px; box-sizing: border-box;
}
.cat-filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 16px;
}
.cat-filter { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 0.82rem; font-weight: 600; color: var(--text); user-select: none; }
.cat-filter input { cursor: pointer; accent-color: var(--accent); width: 15px; height: 15px; }
.cat-filter img { height: 16px; width: auto; max-width: 42px; object-fit: contain; }
.cat-filter:has(input:not(:checked)) { opacity: 0.4; }
.filter-toggle-all {
  margin-left: auto; background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 7px; padding: 6px 12px; font-size: 0.78rem; font-weight: 600; cursor: pointer; font-family: inherit;
}
.filter-toggle-all:hover { border-color: var(--accent); color: var(--accent); }
.category-group.cat-hidden { display: none; }

.timeline-bleed {
  width: 100vw; margin-left: calc(50% - 50vw); margin-right: calc(50% - 50vw);
  padding: 0 24px;
}
.timeline-scroll {
  overflow-x: auto; overflow-y: hidden;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  scrollbar-width: thin;
}
.timeline-inner { position: relative; padding: 22px 0 14px; }

.ruler { position: relative; height: 26px; border-bottom: 1px solid var(--border); }
.tick {
  position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--border);
  font-size: 0.68rem; color: var(--text-dim); padding-left: 4px; padding-top: 5px; white-space: nowrap;
}
.tick.hour { border-left-color: var(--text-dim); font-weight: 700; color: var(--text); }

.now-line {
  position: absolute; top: 0; bottom: 14px; width: 2px; background: var(--now-red);
  z-index: 6; box-shadow: 0 0 6px rgba(248, 113, 113, 0.6);
}
.now-line::before {
  content: "NOW"; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  background: var(--now-red); color: #fff; font-size: 0.6rem; font-weight: 800;
  padding: 1px 6px; border-radius: 4px; letter-spacing: 0.04em; white-space: nowrap;
}

.category-group {
  --cat-color: hsl(var(--cat-h) 75% 64%);
  border: 2px solid var(--cat-color);
  border-radius: 12px;
  margin: 18px 0;
  padding: 6px 0 12px;
  background: hsla(var(--cat-h), 70%, 45%, 0.07);
}

.category-heading {
  position: sticky; left: 0; z-index: 4; width: fit-content; max-width: 90vw;
  display: flex; align-items: center; gap: 9px;
  font-size: 1rem; font-weight: 900; letter-spacing: 0.01em; color: var(--cat-color);
  background: var(--bg-card); border: 1.5px solid var(--cat-color);
  border-radius: 7px; padding: 5px 14px; margin: 6px 0 10px 12px;
}
.cat-icon { height: 22px; width: auto; max-width: 68px; object-fit: contain; flex-shrink: 0; }

.track-label {
  position: sticky; left: 0; z-index: 4; width: fit-content; max-width: 90vw;
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-dim); background: var(--bg-card); padding: 8px 10px 6px 14px;
  border-radius: 0 6px 6px 0; box-shadow: 6px 0 8px -6px rgba(0,0,0,0.4);
}
.track-label a { color: var(--text-dim); text-decoration: none; }
.track-label a:hover { color: var(--accent); }
.track { position: relative; height: 80px; margin: 0 0 5px; }

.boss-block {
  position: absolute; top: 4px; bottom: 4px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--border);
  overflow: hidden; display: block; text-decoration: none; color: inherit;
  transition: border-color 0.12s ease, transform 0.12s ease;
  min-width: 96px;
}
.boss-block:not(.empty) { cursor: pointer; }
.boss-block:not(.empty):hover { border-color: var(--accent); transform: translateY(-1px); z-index: 3; }
.boss-block .inner { padding: 6px 9px; height: 100%; display: flex; flex-direction: column; justify-content: center; gap: 3px; }
.boss-block .bname {
  font-size: 0.85rem; font-weight: 700; line-height: 1.15; flex-shrink: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.boss-block .btime { font-size: 0.68rem; line-height: 1.2; color: var(--text-dim); display: flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.boss-block .tp-code { font-family: "JetBrains Mono", ui-monospace, monospace; opacity: 0.75; }
.boss-block.past { opacity: 0.35; }
.boss-block.soon { border-color: var(--accent); background: rgba(94, 234, 212, 0.12); }
.boss-block.empty { border-style: dashed; opacity: 0.35; pointer-events: none; }
.boss-block.copied { border-color: var(--accent); background: var(--accent-soft); }
.boss-block.copied .bname::after { content: " ✓ copied"; color: var(--accent); font-weight: 700; }

footer {
  text-align: center; color: var(--text-dim); font-size: 0.8rem;
  margin-top: 50px; border-top: 1px solid var(--border); padding-top: 20px;
}

.panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 20px 24px; max-width: 520px; }
.panel + .panel { margin-top: 20px; }
.panel p { color: var(--text-dim); font-size: 0.88rem; }
.panel a { color: var(--accent); }
label { font-size: 0.82rem; font-weight: 600; display: block; margin-bottom: 4px; }

input[type="text"], input[type="password"] {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 0.95rem; margin: 8px 0 14px; font-family: inherit;
}

button, .btn {
  display: inline-block; background: var(--accent-dim); color: #0b1013; border: none;
  border-radius: 8px; padding: 10px 18px; font-weight: 600; cursor: pointer;
  font-size: 0.92rem; text-decoration: none; font-family: inherit;
}
button.secondary, .btn.secondary { background: transparent; border: 1px solid var(--border); color: var(--text-dim); }

.notice { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 0.88rem; }
.notice.error { background: #3b1a1a; color: #fca5a5; border: 1px solid #7f1d1d; }
.notice.success { background: #14332c; color: #6ee7b7; border: 1px solid #065f46; }

.wallet-headline { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.wh-item { display: flex; align-items: center; gap: 10px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 12px 18px; }
.wh-item img { width: 28px; height: 28px; }
.wh-value { font-size: 1.15rem; font-weight: 700; }
.wh-label { color: var(--text-dim); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }

.wallet-list { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.wallet-row { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--border); }
.wallet-row:last-child { border-bottom: none; }
.wallet-row:nth-child(odd) { background: var(--bg-card); }
.wallet-row img { width: 18px; height: 18px; flex-shrink: 0; }
.wr-name { flex: 1; }
.wr-value { color: var(--text-dim); }

.objective { padding: 8px 0; border-bottom: 1px solid var(--border); }
.objective:last-child { border-bottom: none; }
.objective.done { color: var(--accent); }

.character-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.character-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.char-name { font-weight: 700; }
.char-level { color: var(--text-dim); font-size: 0.85rem; margin-top: 4px; }
.char-spec { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 0.85rem; }
.char-spec img { width: 18px; height: 18px; border-radius: 3px; }
.char-crafting { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.craft-badge { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; font-size: 0.78rem; color: var(--text-dim); }
