/* =====================================================================
   KHAERON — Dwarven royal interface
   Stone, iron, bronze and gold. One bold element: the level seal + forge bar.
   ===================================================================== */
@font-face { font-family: "Cinzel"; font-weight: 600; font-display: swap; src: url(../fonts/cinzel-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Cinzel"; font-weight: 700; font-display: swap; src: url(../fonts/cinzel-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Alegreya Sans"; font-weight: 400; font-display: swap; src: url(../fonts/alegreya-sans-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Alegreya Sans"; font-weight: 500; font-display: swap; src: url(../fonts/alegreya-sans-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Alegreya Sans"; font-weight: 700; font-display: swap; src: url(../fonts/alegreya-sans-latin-700-normal.woff2) format("woff2"); }
:root {
  --stone: #1c1e21;
  --stone-deep: #151719;
  --slate: #272a2e;
  --slate-2: #30343a;
  --line: #3d4148;
  --bronze: #8c6a3e;
  --copper: #b8733f;
  --copper-hi: #d38a4f;
  --gold: #c9a54a;
  --gold-hi: #e6c46a;
  --parchment: #e8dfcf;
  --ash: #8d9198;
  --moss: #6f9a5b;
  --rust: #b5523b;
  --ember: #e07a2e;
  --c-gameplay: #b5523b;
  --c-roleplay: #8f7bb8;
  --c-bouw: #c9a54a;
  --c-grinden: #6f9a8a;
  --chamfer: 10px;
  --display: "Cinzel", "Trajan Pro", Georgia, serif;
  --body: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;
  --step--1: .875rem; --step-0: 1rem; --step-1: 1.25rem; --step-2: 1.563rem; --step-3: 1.953rem; --step-4: 2.441rem;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--stone);
  background-image:
    radial-gradient(ellipse at 20% -10%, rgba(201,165,74,.06), transparent 50%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.012) 0 2px, transparent 2px 160px),
    repeating-linear-gradient(0deg, rgba(0,0,0,.08) 0 1px, transparent 1px 80px);
  color: var(--parchment);
  font-family: var(--body);
  font-size: var(--step-0);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--gold); text-underline-offset: 3px; }
a:hover { color: var(--gold-hi); }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: .02em; line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: var(--step-3); color: var(--gold); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }
p { margin: 0 0 .8em; max-width: 72ch; }
small, .muted { color: var(--ash); }
:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.hall {
  background: linear-gradient(180deg, var(--stone-deep), #191b1e);
  border-right: 1px solid var(--line);
  padding: 1.25rem .75rem 2rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.crest { display: flex; align-items: center; gap: .6rem; padding: 0 .5rem 1.2rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; text-decoration: none; }
.crest svg { width: 38px; height: 38px; flex: none; }
.crest b { font-family: var(--display); font-size: 1.35rem; color: var(--gold); letter-spacing: .08em; display: block; }
.crest span { font-size: .8rem; color: var(--ash); }
.navgroup { margin: 1rem 0 .3rem .6rem; font-family: var(--display); font-size: .8rem; color: var(--bronze); letter-spacing: .06em; }
.nav a {
  display: flex; align-items: center; gap: .65rem; padding: .48rem .6rem; color: var(--parchment);
  text-decoration: none; border-left: 2px solid transparent; font-size: .97rem;
}
.nav a .rune { font-size: 1.05rem; width: 1.2rem; text-align: center; color: var(--bronze); }
.nav a:hover { background: rgba(255,255,255,.03); }
.nav a[aria-current="page"] { border-left-color: var(--gold); background: rgba(201,165,74,.08); color: var(--gold-hi); }
.nav a[aria-current="page"] .rune { color: var(--gold); }
.nav .badge-count { margin-left: auto; background: var(--copper); color: #1a1208; font-size: .75rem; padding: 0 .45rem; border-radius: 9px; font-weight: 700; }
.userbox { margin-top: 1.4rem; padding: .8rem .6rem 0; border-top: 1px solid var(--line); display: flex; gap: .6rem; align-items: center; }
.userbox img, .avatar, .avatar-fallback { width: 36px; height: 36px; image-rendering: pixelated; background: var(--slate); clip-path: polygon(15% 0, 85% 0, 100% 15%, 100% 85%, 85% 100%, 15% 100%, 0 85%, 0 15%); }
.userbox .who { line-height: 1.2; font-size: .9rem; min-width: 0; }
.userbox .who b { display: block; overflow: hidden; text-overflow: ellipsis; }
main { padding: 2rem clamp(1rem, 3vw, 2.5rem) 5rem; min-width: 0; max-width: 1280px; }
.page-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; justify-content: space-between; margin-bottom: 1.5rem; padding-bottom: .9rem; border-bottom: 1px solid var(--line); position: relative; }
.page-head::after { content: ""; position: absolute; left: 0; bottom: -1px; width: 90px; height: 1px; background: var(--gold); }
.page-head h1 { margin: 0; }
.page-head p { margin: .2rem 0 0; color: var(--ash); }
.mobilebar { display: none; }

/* ---------- Panels (chamfered stone slabs) ---------- */
.panel {
  background: linear-gradient(180deg, var(--slate), #24272b);
  border: 1px solid var(--line);
  padding: 1.1rem 1.2rem;
  clip-path: polygon(var(--chamfer) 0, calc(100% - var(--chamfer)) 0, 100% var(--chamfer), 100% calc(100% - var(--chamfer)), calc(100% - var(--chamfer)) 100%, var(--chamfer) 100%, 0 calc(100% - var(--chamfer)), 0 var(--chamfer));
  position: relative; min-width: 0;
}
.panel > h2, .panel > h3 { font-size: var(--step-1); color: var(--parchment); display: flex; align-items: center; gap: .5rem; }
.panel.royal { border-color: var(--bronze); }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }

/* ---------- The level seal & forge bar ---------- */
.forge { display: grid; grid-template-columns: auto 1fr; gap: 1.6rem; align-items: center; padding: 1.4rem 1.6rem; }
.seal { width: 128px; height: 140px; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; padding-top: 10px; }
.seal > span:first-child { position: absolute; inset: 0; }
.seal svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.seal .num { position: relative; font-family: var(--display); font-size: 2.7rem; font-weight: 700; color: var(--gold-hi); text-shadow: 0 2px 0 #5a4416; line-height: 1; }
.seal .lbl { position: relative; margin-top: .35rem; font-size: .7rem; color: var(--bronze); letter-spacing: .1em; font-family: var(--display); }
.forge .name { font-family: var(--display); font-size: var(--step-3); color: var(--parchment); line-height: 1.1; }
.forge .title { font-family: var(--display); color: var(--gold); font-size: var(--step-1); margin: .15rem 0 1rem; }
.channel {
  height: 22px; background: #0f1012; border: 1px solid #000; position: relative; overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,.8), 0 1px 0 rgba(255,255,255,.05);
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 8px 100%, 0 50%);
}
.molten {
  position: absolute; inset: 0 auto 0 0;
  background: linear-gradient(180deg, #ffd27a 0%, var(--ember) 45%, #9c3e12 100%);
  box-shadow: 0 0 18px rgba(224,122,46,.6);
}
.molten::after {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(115deg, transparent 0 14px, rgba(255,240,200,.25) 14px 18px);
  animation: flow 3.5s linear infinite;
}
@keyframes flow { from { background-position: 0 0; } to { background-position: 72px 0; } }
.forge-meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; margin-top: .45rem; font-size: .92rem; color: var(--ash); }
.forge-meta b { color: var(--parchment); }

/* thin progress bars elsewhere */
.bar { height: 10px; background: #111214; border: 1px solid #000; position: relative; overflow: hidden; }
.bar > i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--bronze), var(--gold)); }
.bar.copper > i { background: linear-gradient(90deg, #7a4a24, var(--copper-hi)); }

/* ---------- Stats ---------- */
.stat { display: flex; flex-direction: column; gap: .1rem; }
.stat .v { font-family: var(--display); font-size: var(--step-2); color: var(--parchment); font-variant-numeric: tabular-nums; }
.stat .k { color: var(--ash); font-size: .9rem; }
.cat { display: flex; align-items: center; gap: .55rem; }
.cat svg { width: 26px; height: 26px; flex: none; }
.cat-gameplay { --cc: var(--c-gameplay); } .cat-roleplay { --cc: var(--c-roleplay); }
.cat-bouw { --cc: var(--c-bouw); } .cat-grinden { --cc: var(--c-grinden); }
.catpanel { border-top: 3px solid var(--cc, var(--line)); }
.catpanel .cat svg { color: var(--cc); }
.pill { display: inline-flex; align-items: center; gap: .3rem; padding: .05rem .55rem; font-size: .82rem; border: 1px solid var(--line); border-radius: 3px; white-space: nowrap; }
.st-in_afwachting, .st-geclaimd, .st-aangevraagd { color: var(--gold); border-color: #5c4c25; }
.st-ingediend { color: var(--copper-hi); border-color: #6b4425; }
.st-goedgekeurd, .st-afgehandeld, .st-open, .st-actief { color: #9cc78a; border-color: #3f5a35; }
.st-afgewezen, .st-verlopen, .st-geannuleerd, .st-geweigerd, .st-gesloten, .st-geblokkeerd { color: #d98b78; border-color: #5c3027; }
.medal { display: inline-grid; place-items: center; width: 28px; height: 28px; font-family: var(--display); font-weight: 700; font-size: .95rem;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); color: #1a1208; }
.medal.goud { background: linear-gradient(180deg, #f2d88a, #b08a2e); }
.medal.zilver { background: linear-gradient(180deg, #e8ebee, #8f979f); }
.medal.brons { background: linear-gradient(180deg, #e0a774, #8a5428); }
.medal.plain { background: transparent; color: var(--ash); clip-path: none; font-family: var(--body); font-weight: 600; }
.trend { font-size: .85rem; font-weight: 700; }
.trend.up { color: #9cc78a; } .trend.down { color: #d98b78; } .trend.same { color: var(--ash); } .trend.new { color: var(--gold); }
tr.me td { background: rgba(201,165,74,.07); }

/* ---------- Tables ---------- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th { text-align: left; font-weight: 600; color: var(--ash); padding: .5rem .6rem; border-bottom: 1px solid var(--bronze); white-space: nowrap; font-size: .88rem; }
td { padding: .55rem .6rem; border-bottom: 1px solid rgba(255,255,255,.05); vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover td { background: rgba(255,255,255,.02); }

/* ---------- Forms ---------- */
label { display: block; font-size: .9rem; color: var(--ash); margin-bottom: .25rem; }
.field { margin-bottom: .85rem; min-width: 0; }
.field .hint { font-size: .82rem; color: var(--ash); margin-top: .2rem; }
input, select, textarea {
  width: 100%; background: #16181b; color: var(--parchment); border: 1px solid var(--line);
  padding: .55rem .65rem; font: inherit; border-radius: 2px;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 0 2px rgba(201,165,74,.2); }
textarea { min-height: 90px; resize: vertical; }
input[type="checkbox"] { width: auto; accent-color: var(--gold); }
.check { display: flex; gap: .5rem; align-items: center; color: var(--parchment); font-size: .95rem; }
.formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; cursor: pointer;
  background: linear-gradient(180deg, #c98549, #9b5a2b); color: #1d1108; border: 1px solid #6e3f1c;
  padding: .5rem 1rem; font: 600 .95rem var(--body); text-decoration: none;
  clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 0 calc(100% - 6px), 0 6px);
}
.btn:hover { filter: brightness(1.1); color: #1d1108; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.gold { background: linear-gradient(180deg, var(--gold-hi), #a3822f); border-color: #6b5420; }
.btn.ghost { background: transparent; color: var(--parchment); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--gold); color: var(--gold-hi); }
.btn.danger { background: linear-gradient(180deg, #c0634c, #8a3826); color: #fff2ec; border-color: #5c2216; }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs button { background: none; border: 0; color: var(--ash); padding: .55rem .85rem; font: 600 .95rem var(--body); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--gold-hi); border-bottom-color: var(--gold); }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; align-items: end; margin-bottom: 1rem; }
.filters .field { margin: 0; }

/* ---------- Calc breakdown ---------- */
.calc { font-size: .92rem; border-left: 2px solid var(--bronze); padding: .4rem .8rem; background: rgba(0,0,0,.18); }
.calc div { display: flex; justify-content: space-between; gap: 1rem; }
.calc .total { border-top: 1px solid var(--line); margin-top: .3rem; padding-top: .3rem; font-weight: 700; color: var(--gold-hi); }

/* ---------- Lists ---------- */
.item { border-bottom: 1px solid rgba(255,255,255,.06); padding: .85rem 0; }
.item:last-child { border-bottom: 0; }
.item h3 { font-family: var(--body); font-weight: 700; font-size: 1.05rem; margin: 0 0 .2rem; }
.evidence { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .9rem; margin-top: .35rem; }
.empty { color: var(--ash); padding: 1.2rem 0; }
.priv { display: flex; gap: .7rem; align-items: flex-start; padding: .55rem 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.priv .lv { font-family: var(--display); color: var(--gold); min-width: 3.2rem; font-size: .9rem; padding-top: .1rem; }
.priv.locked { opacity: .55; }
.alert { padding: .7rem 1rem; border-left: 3px solid var(--gold); background: rgba(201,165,74,.08); margin-bottom: 1rem; }
.alert.warn { border-color: var(--copper); background: rgba(184,115,63,.1); }
.alert.bad { border-color: var(--rust); background: rgba(181,82,59,.12); }
.weeks { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; }
.weeks span { height: 34px; background: #16181b; border: 1px solid var(--line); display: grid; place-items: center; font-size: .72rem; color: var(--ash); }
.weeks span.ok { background: rgba(111,154,91,.3); border-color: #3f5a35; color: #cfe5c4; }
.weeks span.exc { background: rgba(143,123,184,.25); border-color: #57497a; color: #ddd3f2; }
.weeks span.bad { background: rgba(181,82,59,.18); border-color: #5c3027; }
.weeks span.pending { border-color: var(--gold); }
.weeks span.pre { opacity: .3; }

/* ---------- Toast & modal ---------- */
#toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 100; display: flex; flex-direction: column; gap: .5rem; max-width: min(420px, calc(100vw - 2rem)); }
.toast { background: var(--slate-2); border: 1px solid var(--line); border-left: 3px solid var(--moss); padding: .7rem 1rem; box-shadow: 0 6px 24px rgba(0,0,0,.5); }
.toast.err { border-left-color: var(--rust); }
dialog { background: var(--slate); color: var(--parchment); border: 1px solid var(--bronze); padding: 0; width: min(680px, calc(100vw - 1.5rem)); max-height: calc(100vh - 2rem); }
dialog::backdrop { background: rgba(8,9,10,.75); }
dialog .dh { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
dialog .dh h2 { margin: 0; font-size: var(--step-1); }
dialog .db { padding: 1.1rem 1.2rem; overflow-y: auto; max-height: calc(100vh - 9rem); }
.tokenbox { font-family: ui-monospace, Consolas, monospace; font-size: 1rem; background: #0f1012; border: 1px dashed var(--gold); padding: .9rem; word-break: break-all; color: var(--gold-hi); user-select: all; }

/* ---------- Login ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.gate .panel { width: min(460px, 100%); padding: 2.2rem 2rem; text-align: center; }
.gate .crest { justify-content: center; border: 0; padding: 0; margin-bottom: .6rem; }
.gate .crest svg { width: 72px; height: 72px; }
.gate h1 { font-size: var(--step-4); letter-spacing: .12em; margin-bottom: .1rem; }
.gate form { text-align: left; margin-top: 1.6rem; }
.runeline { color: var(--bronze); letter-spacing: .5em; font-size: .9rem; margin: .2rem 0 0; }

/* charts */
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .85rem; color: var(--ash); margin-top: .4rem; }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: .35rem; vertical-align: -1px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .hall { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .hall.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.6); }
  .mobilebar { display: flex; position: sticky; top: 0; z-index: 40; align-items: center; justify-content: space-between; padding: .6rem 1rem; background: var(--stone-deep); border-bottom: 1px solid var(--line); }
  .mobilebar b { font-family: var(--display); color: var(--gold); letter-spacing: .08em; }
  main { padding: 1.2rem 1rem 4rem; }
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: auto; }
  .forge { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 1.2rem; }
  .forge > div:last-child { width: 100%; }
  .seal { width: 108px; height: 118px; }
  .seal .num { font-size: 2.2rem; }
  .forge .name { font-size: var(--step-2); }
  h1 { font-size: var(--step-2); }
  .weeks span { height: 28px; font-size: .62rem; }
  table.responsive thead { display: none; }
  table.responsive tr { display: block; border-bottom: 1px solid var(--line); padding: .4rem 0; }
  table.responsive td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .25rem .2rem; text-align: right; }
  table.responsive td::before { content: attr(data-label); color: var(--ash); text-align: left; }
}
.avatar-fallback { display: inline-grid; place-items: center; font-family: var(--display); color: var(--gold); border: 1px solid var(--bronze); flex: none; }
.filters > .row { grid-column: 1 / -1; }
@media (max-width: 820px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g4 .stat .v { font-size: var(--step-1); } }
@media (max-width: 380px) { .g4 { grid-template-columns: minmax(0, 1fr); } }
