/* Fonts are self-hosted: loading them from Google would send every visitor's IP address to Google. */
@font-face { font-family: Inter; font-style: normal; font-weight: 400; font-display: swap; src: url(../fonts/inter-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: Inter; font-style: normal; font-weight: 500; font-display: swap; src: url(../fonts/inter-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: Inter; font-style: normal; font-weight: 600; font-display: swap; src: url(../fonts/inter-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: Rajdhani; font-style: normal; font-weight: 500; font-display: swap; src: url(../fonts/rajdhani-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: Rajdhani; font-style: normal; font-weight: 600; font-display: swap; src: url(../fonts/rajdhani-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: Rajdhani; font-style: normal; font-weight: 700; font-display: swap; src: url(../fonts/rajdhani-latin-700-normal.woff2) format('woff2'); }

:root {
  --bg: #0b1016;
  --bg-2: #111821;
  --panel: #151e29;
  --panel-2: #1b2633;
  --line: #263445;
  --line-2: #33465c;
  --text: #dfe7ef;
  --muted: #8a9bb0;
  --faint: #5f7186;
  --accent: #e8a33d;
  --accent-2: #f5c26b;
  --accent-ink: #1a1206;
  --good: #4cc38a;
  --bad: #ef6b6b;
  --warn: #e5c15a;
  --info: #5fb3e8;
  --radius: 10px;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, rgba(232,163,61,.07), transparent 60%), var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1, h2, h3, .tabs button, .stat .v { font-family: Rajdhani, Inter, sans-serif; letter-spacing: .02em; }
h2 { font-size: 20px; margin: 0 0 4px; font-weight: 700; }
h3 { font-size: 16px; margin: 0 0 8px; font-weight: 700; color: var(--accent-2); text-transform: uppercase; letter-spacing: .06em; }
p.hint, .hint { color: var(--muted); margin: 0 0 12px; font-size: 13px; }
a { color: var(--accent-2); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 10px 20px;
  background: rgba(11,16,22,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand svg { width: 30px; height: 30px; fill: var(--accent); }
.brand h1 { font-size: 19px; margin: 0; line-height: 1.1; }
.brand p { margin: 0; color: var(--muted); font-size: 12px; }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.tabs button {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font-size: 16px; font-weight: 600; padding: 8px 12px; border-radius: 8px;
}
.tabs button:hover { color: var(--text); background: var(--panel); }
.tabs button.active { color: var(--accent-ink); background: var(--accent); }
.toolbar { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
#profession { max-width: 100%; }

main { flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; padding: 20px; }
.foot { color: var(--faint); font-size: 12px; text-align: center; padding: 16px; border-top: 1px solid var(--line); }

/* ---------- layout ---------- */
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.grid.two { grid-template-columns: minmax(320px, 420px) 1fr; align-items: start; }
.grid.halves { grid-template-columns: 1fr 1fr; align-items: start; }
.grid.two.wide-left { grid-template-columns: 1fr minmax(300px, 380px); }
@media (max-width: 1000px) { .grid.two, .grid.halves, .grid.two.wide-left { grid-template-columns: 1fr; } }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); min-width: 0;
}
.card + .card { margin-top: 0; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.section-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.section-head h3 { margin: 0; }

/* ---------- controls ---------- */
input, select, button, .button {
  font: inherit; color: var(--text);
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 7px 10px; min-height: 34px;
}
input:focus, select:focus { outline: 2px solid rgba(232,163,61,.5); outline-offset: 0; border-color: var(--accent); }
input[type=number] { width: 110px; text-align: right; font-variant-numeric: tabular-nums; }
input.qty { width: 90px; }
input.wide { width: 100%; }
button, .button { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; user-select: none; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover { background: var(--accent-2); }
button.ghost, .button.ghost { background: transparent; }
button.ghost:hover, .button.ghost:hover { background: var(--panel-2); }
button.icon { padding: 4px 8px; min-height: 28px; background: transparent; border-color: transparent; color: var(--muted); }
button.icon:hover { color: var(--bad); background: var(--panel-2); }
button:disabled { opacity: .5; cursor: default; }
button.small { min-height: 28px; padding: 3px 9px; font-size: 13px; }
.switch { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; font-size: 13px; }
.switch input { min-height: auto; accent-color: var(--accent); width: 16px; height: 16px; }

/* ---------- combobox ---------- */
.combo { position: relative; flex: 1; min-width: 200px; }
.combo input { width: 100%; }
.combo ul {
  position: fixed; z-index: 60; /* placed by JS so scroll boxes can't clip it */
  list-style: none; margin: 0; padding: 4px; max-height: 340px; overflow: auto;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: 0 12px 30px rgba(0,0,0,.45);
}
.combo li { padding: 6px 8px; border-radius: 6px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; }
.combo li small { color: var(--faint); margin-left: auto; font-size: 11px; white-space: nowrap; }
.combo li.group { color: var(--accent-2); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; cursor: default; padding-top: 8px; }
.combo li.active, .combo li:not(.group):hover { background: rgba(232,163,61,.15); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 8px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--text); }
td.num, th.num { text-align: right; white-space: nowrap; }
tr:hover td { background: rgba(255,255,255,.015); }
tfoot td { font-weight: 600; border-top: 1px solid var(--line-2); border-bottom: 0; }
.name-cell { min-width: 180px; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

.badge {
  display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap; vertical-align: 1px;
}
.badge.arch { border-color: rgba(232,163,61,.4); color: var(--accent-2); }
.badge.other { border-color: rgba(95,179,232,.4); color: var(--info); }
.badge.good { border-color: rgba(76,195,138,.4); color: var(--good); }
.badge.bad { border-color: rgba(239,107,107,.45); color: var(--bad); }
.badge.warn { border-color: rgba(229,193,90,.45); color: var(--warn); }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat .s { color: var(--faint); font-size: 12px; }

/* ---------- plan list ---------- */
.plan-list { list-style: none; margin: 12px 0 0; padding: 0; }
.plan-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.plan-list li .nm { flex: 1; min-width: 0; }
.plan-list li .nm div { overflow: hidden; text-overflow: ellipsis; }
.empty { color: var(--faint); padding: 20px 0; text-align: center; }

/* ---------- tree ---------- */
details.tree { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: var(--bg-2); }
details.tree > summary { cursor: pointer; padding: 8px 12px; font-weight: 600; }
details.tree > .body { padding: 0 12px 10px; }
.tree ul { list-style: none; margin: 0; padding-left: 18px; border-left: 1px dashed var(--line-2); }
.tree > .body > ul { padding-left: 4px; border-left: 0; }
.tree li { padding: 3px 0; }
.tree .q { font-variant-numeric: tabular-nums; color: var(--accent-2); font-weight: 600; margin-right: 6px; }
.tree .slot { color: var(--faint); font-size: 12px; }
.tree .res { color: var(--info); }

/* ---------- resource class tree in market ---------- */
.indent-1 { padding-left: 18px !important; }
.indent-2 { padding-left: 34px !important; }
.indent-3 { padding-left: 50px !important; }
.indent-4 { padding-left: 66px !important; }
.indent-5 { padding-left: 82px !important; }

.progress { height: 6px; background: var(--bg-2); border-radius: 99px; overflow: hidden; min-width: 80px; }
.progress > span { display: block; height: 100%; background: var(--good); }
.progress.short > span { background: var(--bad); }

.callout { border: 1px solid var(--line-2); border-left: 3px solid var(--accent); background: var(--panel-2); border-radius: 8px; padding: 10px 12px; color: var(--muted); font-size: 13px; }
.callout strong { color: var(--text); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel-2); border: 1px solid var(--line-2); padding: 10px 16px; border-radius: 8px;
  opacity: 0; transition: .2s; pointer-events: none; z-index: 50;
}
#toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 640px) {
  main { padding: 16px; }
  .topbar { padding: 10px 16px; gap: 10px; }
  .toolbar { margin-left: 0; }
  input[type=number] { width: 90px; }
}

/* ---------- account ---------- */
.account { position: relative; display: flex; align-items: center; gap: 8px; }
.discord-btn { background: #5865f2; border-color: #5865f2; color: #fff; font-weight: 600; }
.discord-btn:hover { background: #4752c4; }
.discord-btn svg { width: 18px; height: 18px; fill: currentColor; }
.sync { font-size: 12px; color: var(--faint); white-space: nowrap; }
.sync.err { color: var(--warn); }
button.avatar { width: 32px; height: 32px; min-height: 32px; padding: 0; border: 0; border-radius: 50%; background: var(--accent); color: var(--accent-ink); justify-content: center; display: grid; place-items: center; font-weight: 700; font-family: Rajdhani, sans-serif; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 240px;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 6px; box-shadow: 0 12px 30px rgba(0,0,0,.45);
}
.menu .who { padding: 8px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu .who small { color: var(--faint); display: block; }
.menu button, .menu a { display: flex; width: 100%; background: none; border: 0; text-align: left; padding: 8px 10px; border-radius: 6px; color: var(--text); text-decoration: none; min-height: auto; font-size: 14px; }
.menu button:hover, .menu a:hover { background: rgba(232,163,61,.12); }
.menu .danger { color: var(--bad); }
dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--line-2); border-radius: 12px;
  padding: 20px; max-width: min(460px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(0,0,0,.6);
}
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog p { color: var(--muted); margin: 0 0 8px; }
button.danger-btn { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 600; }
button.avatar:hover { background: var(--accent-2); }
button.avatar { overflow: hidden; }
button.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
