:root {
  --bg: #121211;
  --card: #1c1c1a;
  --card-hi: #252522;
  --sunk: #161615;
  --line: #2f2e2b;
  --text: #ecebe6;
  --soft: #c9c7c0;
  --muted: #8f8d86;
  --accent: #ffd500;
  --accent-ink: #1a1700;
  --good: #67f835;
  --warn: #ffb020;
  --bad: #ff5a4f;
  --discord: #5865f2;
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); }
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 10px; line-height: 1.2; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
h2 .muted, h3 .muted { font-weight: 400; font-size: 14px; }
p { margin: 0 0 10px; }
img { border-radius: 50%; }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--sunk); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; min-width: 0; max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; flex: none; }
input[type="number"] { width: 9em; }
textarea { width: 100%; resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 6px; padding: 8px 14px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: progress; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.big { padding: 12px 20px; font-size: 16px; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.ghost { background: transparent; color: var(--soft); border: 1px solid var(--line); }
.btn.discord { background: var(--discord); color: #fff; }
.link { background: none; border: 0; padding: 4px; color: var(--muted); cursor: pointer; text-decoration: underline; }
.link:hover { color: var(--text); }
.link.danger:hover { color: var(--bad); }

/* Shell ------------------------------------------------------------------------------------- */
.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 16px;
  background: var(--sunk); border-bottom: 1px solid var(--line);
}
.top[hidden], .tabs[hidden] { display: none; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .3px; }
.logo {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 6px; background: var(--accent); color: var(--accent-ink);
  font-weight: 900; font-style: italic; font-size: 14px;
}
.logo.big { width: 64px; height: 64px; font-size: 28px; border-radius: 12px; margin: 0 auto 14px; }
.wipe { color: var(--soft); font-size: 13px; flex: 1 1 auto; }
.me { display: flex; align-items: center; gap: 8px; font-size: 14px; }

.tabs {
  position: sticky; top: 0; z-index: 5; display: flex; gap: 2px; overflow-x: auto; padding: 0 12px;
  background: var(--sunk); border-bottom: 1px solid var(--line); scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 11px 12px; color: var(--muted); text-decoration: none; font-weight: 600; white-space: nowrap; border-bottom: 3px solid transparent; }
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }

.view { max-width: 1100px; margin: 0 auto; padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.view > * { min-width: 0; }
.view > section > h2 { margin-top: 4px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card.inner { background: var(--card-hi); }
.card.admin { border-color: #5a2a26; }

.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.stack { display: grid; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.warn { color: var(--warn); }
.bad { color: var(--bad); }
p.warn { background: #2b2210; border: 1px solid #4d3a12; border-radius: 6px; padding: 8px 10px; }
.note { color: var(--soft); overflow-wrap: anywhere; }

.badge { display: inline-block; padding: 1px 7px; border-radius: 99px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.badge.admin { background: #3a2f00; color: var(--accent); }
.badge.warn { background: #3a2a08; color: var(--warn); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 4px; background: var(--sunk); border: 1px solid var(--line); color: var(--soft); font-size: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 20; max-width: calc(100vw - 32px);
  padding: 10px 16px; border-radius: 8px; background: #20341a; border: 1px solid #36632b; box-shadow: 0 6px 24px #0008;
}
.toast.bad { background: #3a1714; border-color: #6d2a24; }

.login { max-width: 380px; margin: 10vh auto 0; text-align: center; display: grid; gap: 10px; padding: 28px; }
.notice { max-width: 520px; margin: 12vh auto; padding: 24px 16px; text-align: center; }

/* Segmented radio buttons -------------------------------------------------------------------- */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-block; padding: 6px 11px; border-radius: 99px; border: 1px solid var(--line); background: var(--sunk); cursor: pointer; font-size: 14px; }
.seg input:checked + span { border-color: currentColor; background: var(--card-hi); font-weight: 700; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }

/* Status ------------------------------------------------------------------------------------- */
#status-form input[name="note"] { flex: 1 1 220px; }
.members { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.member { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; }
.member.me { border-color: #4d4300; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--card-hi); font-weight: 700; flex: none; }
.pill { display: inline-block; font-size: 12px; padding: 0 8px; border-radius: 99px; border: 1px solid currentColor; }
.st-online { color: var(--good); }
.st-base { color: #4fc3ff; }
.st-raiding { color: var(--bad); }
.st-farming { color: var(--accent); }
.st-away { color: var(--warn); }
.st-offline { color: var(--muted); }

/* Progress ----------------------------------------------------------------------------------- */
.stats { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-bottom: 12px; }
.stats div { display: grid; }
.stats b { font-size: 24px; }
.stats span { color: var(--muted); font-size: 13px; }
.filters input[type="search"] { flex: 1 1 200px; }
.filters { margin-bottom: 8px; }
.nodes { list-style: none; padding: 0; margin: 0; }
.nodes li { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(90px, 220px); gap: 4px 12px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); }
.nodes li:first-child { border-top: 0; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; min-width: 0; }
.nname { overflow-wrap: anywhere; }
.meta { display: flex; gap: 10px; align-items: baseline; justify-content: flex-end; font-size: 13px; color: var(--soft); flex-wrap: wrap; }
.tier { display: inline-block; min-width: 2.2em; text-align: center; font-weight: 700; color: var(--muted); }
.who { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; font-size: 12px; min-width: 0; }
.chip { display: inline-block; padding: 1px 7px; border-radius: 99px; background: var(--card-hi); border: 1px solid var(--line); color: var(--soft); white-space: nowrap; }
.chip.more { color: var(--muted); }
.nodes li.has .nname { color: var(--text); font-weight: 600; }
.nodes input:disabled { opacity: .6; cursor: default; }
.roster { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.member-pick {
  display: grid; gap: 6px; width: 100%; text-align: left; padding: 10px 12px; cursor: pointer;
  background: var(--sunk); border: 1px solid var(--line); border-radius: var(--radius);
}
.member-pick:hover { border-color: var(--muted); }
.member-pick.on { border-color: var(--accent); background: var(--card-hi); }
.member-pick strong { overflow-wrap: anywhere; }
.bar { display: block; height: 6px; border-radius: 99px; background: linear-gradient(90deg, var(--accent) var(--p), var(--line) var(--p)); }
.rar { display: inline-block; width: 9px; height: 9px; border-radius: 2px; background: var(--r); flex: none; }
@media (max-width: 640px) {
  .nodes li { grid-template-columns: minmax(0, 1fr); }
  .nodes .meta, .nodes .who { justify-content: flex-start; padding-left: 26px; }
  .roster { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* Money -------------------------------------------------------------------------------------- */
.biz { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin-bottom: 10px; }
.biz header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.biz h3 { margin: 0; flex: 1; }
.rank { color: var(--accent); font-weight: 900; font-style: italic; }
.figs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, .8fr); gap: 8px; margin: 0 0 8px; }
.figs div { background: var(--sunk); border-radius: 6px; padding: 8px; min-width: 0; }
.figs dt { color: var(--muted); font-size: 12px; }
.figs dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.figs dd.big { color: var(--good); font-size: 17px; white-space: nowrap; }
details summary { cursor: pointer; color: var(--soft); font-size: 13px; }
details ul { padding-left: 18px; margin: 8px 0; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 7px 8px; border-top: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 13px; border-top: 0; }
table.mini { margin-top: 8px; font-size: 13px; }
table.mini td, table.mini th { padding: 4px 6px; }
.table-wrap { overflow-x: auto; }
table.inputs input[type="number"] { width: 6.5em; }
table.inputs td:nth-child(4) { min-width: 220px; }
table.items td { vertical-align: middle; }
table.items input[type="number"] { width: 7.5em; }
.edited { color: var(--warn); }

/* Plan --------------------------------------------------------------------------------------- */
.plan { list-style: none; padding: 0; margin: 0 0 12px; }
.plan li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.plan li:first-child { border-top: 0; }
.plan li .check { flex: 1 1 220px; }
.plan li.done .check span { text-decoration: line-through; color: var(--muted); }
#plan-form input[name="title"] { flex: 2 1 240px; }
#plan-form select[name="item_id"] { flex: 1 1 200px; }

/* Raids -------------------------------------------------------------------------------------- */
.k-defend { color: var(--bad); }
.k-attack { color: var(--accent); }
.k-info { color: #4fc3ff; }
.raids { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.raid { border-left: 3px solid currentColor; }
.raid > * { color: var(--text); }
.raid .muted { color: var(--muted); }
#raid-form .btn { justify-self: start; }

@media (max-width: 520px) {
  .view { padding: 12px; gap: 12px; }
  .card { padding: 12px; }
  .figs dd.big { font-size: 16px; }
  table.items .hide-sm { display: none; }
  table.items td, table.items th { padding: 7px 4px; }
  .wipe { order: 3; flex-basis: 100%; }
}
