* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--bgimg);
  background-size: var(--bgsize);
  background-repeat: var(--bgrep);
  background-attachment: fixed;
  animation: var(--anim);
  font-size: 15px;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--acc2); }
:focus-visible { outline: 3px solid var(--acc2); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.boot { padding: 40px; color: var(--muted); }

/* Layout */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side {
  flex: 1 1 236px; padding: 20px 16px; background: var(--side); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 18px;
}
.main { flex: 999 1 560px; min-width: 0; padding: 28px 32px 56px; display: flex; flex-direction: column; gap: 22px; }

.brand { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
.brand-mark { width: 34px; height: 34px; border-radius: var(--r); background: var(--acc); box-shadow: var(--glow); display: grid; place-items: center; flex: none; }
.brand-name { font-family: var(--head); text-transform: var(--hcase); letter-spacing: var(--hspace); font-size: calc(17px * var(--hs)); text-shadow: var(--hshadow); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: block; padding: 10px 12px; min-height: 44px; border-radius: var(--r); color: var(--muted);
  text-decoration: none; font-weight: 500; transition: background .15s, color .15s;
}
.nav a:hover { background: var(--raised); color: var(--text); }
.nav a[aria-current="page"] { background: var(--raised); color: var(--text); box-shadow: inset 3px 0 0 var(--acc); }

/* Building blocks */
.card {
  background: var(--cardimg), var(--panel); border: var(--border); border-radius: var(--r); box-shadow: var(--shadow);
  clip-path: var(--clip); padding: 20px; transition: border-color .2s;
}
.card:hover { border-color: var(--acc); }
.h { font-family: var(--head); text-transform: var(--hcase); letter-spacing: var(--hspace); margin: 0; line-height: 1.25; text-shadow: var(--hshadow); }
.h1 { font-size: calc(32px * var(--hs)); }
.h2 { font-size: calc(18px * var(--hs)); margin-bottom: 10px; }
.big { font-family: var(--head); font-size: calc(32px * var(--hs)); margin-top: 8px; text-shadow: var(--hshadow); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.kicker { font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--acc2); }
.label { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.good { color: var(--good); } .bad { color: var(--bad); } .acc { color: var(--acc); } .acc2 { color: var(--acc2); }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid-wide { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-fill { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.row { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.row > .grow2 { flex: 2 1 420px; min-width: 0; }
.row > .grow1 { flex: 1 1 280px; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.between { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }

.btn, .go {
  min-height: 42px; padding: 0 16px; border-radius: var(--r); font-size: 14px; font-weight: 600; clip-path: var(--clip);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  transition: transform .15s, filter .15s, border-color .15s;
}
.btn { border: 1px solid var(--line); background: var(--raised); color: var(--text); }
.btn:hover { border-color: var(--acc); transform: translateY(-1px); }
.go { border: 0; background: var(--acc); color: var(--onacc); box-shadow: var(--glow); font-weight: 700; }
.go:hover { transform: translateY(-2px); filter: brightness(1.12); }
.btn:disabled, .go:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 999px; font-size: 13px; font-weight: 600; border: 1px solid var(--line); background: var(--raised); color: var(--text); }
.pill[aria-pressed="true"] { border-color: transparent; background: var(--acc); color: var(--onacc); box-shadow: var(--glow); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--raised); border: 1px solid var(--line); font-size: 12px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.bar { height: 8px; background: var(--raised); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--acc2); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .label { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: none; letter-spacing: 0; }
.input, select.input {
  min-height: 44px; border-radius: var(--r); border: 1px solid var(--line); background: var(--bg); color: var(--text); padding: 0 12px; font-size: 14px; width: 100%;
}
.check { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--r); background: var(--raised); border: 1px solid var(--line); }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--acc); flex: none; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; text-transform: uppercase; letter-spacing: 0.04em; }
td { padding: 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th button { all: unset; cursor: pointer; }
th button:focus-visible { outline: 3px solid var(--acc2); }

.list-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.list-row:first-of-type { border-top: 0; }
.date-box { width: 52px; flex: none; text-align: center; border-radius: var(--r); background: var(--raised); border: 1px solid var(--line); padding: 6px 0; }
.date-box .d { font-family: var(--head); font-size: calc(18px * var(--hs)); }

.ev-btn { text-align: left; width: 100%; display: flex; gap: 14px; align-items: center; padding: 14px; border-radius: var(--r); background: var(--panel); border: var(--border); clip-path: var(--clip); }
.ev-btn[aria-pressed="true"] { border: 2px solid var(--acc); box-shadow: var(--glow); }

/* Banner */
.banner { position: relative; overflow: hidden; border-radius: var(--r); clip-path: var(--clip); border: var(--border); background: var(--banner); box-shadow: var(--shadow); }
.banner.has-image { background: var(--bg) center / cover no-repeat; }
.banner .inner { position: relative; display: flex; flex-wrap: wrap; gap: 20px; align-items: center; justify-content: space-between; padding: 24px 28px; min-height: 120px; }
.banner.has-image .inner { background: linear-gradient(90deg, rgba(0,0,0,0.65), rgba(0,0,0,0.15)); color: #FFFFFF; }
.banner.has-image .inner .muted { color: rgba(255,255,255,0.85); }
.crest { position: relative; width: 80px; height: 80px; flex: none; }
.crest .glow { position: absolute; inset: -16px; border-radius: 50%; background: radial-gradient(circle, var(--acc-glow), transparent 65%); animation: kPulse 3.2s ease-in-out infinite; }
.crest img, .crest svg { position: relative; width: 80px; height: 80px; border-radius: 50%; object-fit: cover; display: block; }

.swatch { width: 40px; height: 40px; border-radius: 50%; padding: 0; border: 2px solid var(--line); }
.swatch[aria-pressed="true"] { border: 3px solid var(--text); box-shadow: 0 0 0 2px var(--bg); }
.theme-card { text-align: left; padding: 14px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--line); color: var(--text); display: flex; flex-direction: column; gap: 10px; min-height: 110px; }
.theme-card[aria-pressed="true"] { border: 2px solid var(--acc); box-shadow: var(--glow); }
.theme-card .preview { height: 44px; border-radius: 6px; box-shadow: inset 0 0 0 1px var(--line); }

.toggle { flex: none; width: 56px; height: 32px; border-radius: 99px; border: 0; padding: 4px; display: flex; background: var(--line); }
.toggle span { width: 24px; height: 24px; border-radius: 50%; background: #fff; display: block; }
.toggle[aria-checked="true"] { justify-content: flex-end; background: var(--acc); }

.notice { padding: 12px 14px; border-radius: var(--r); background: var(--raised); border: 1px solid var(--line); font-size: 14px; }
.notice.ok { border-color: var(--good); }
.notice.warn { border-color: var(--bad); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 10; background: var(--raised); border: 1px solid var(--acc); color: var(--text); padding: 12px 18px; border-radius: var(--r); box-shadow: var(--shadow); max-width: calc(100vw - 32px); }

.center-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { max-width: 460px; width: 100%; text-align: center; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.server-tile { display: flex; align-items: center; gap: 14px; text-align: left; width: 100%; }
.avatar { width: 44px; height: 44px; border-radius: var(--r); background: var(--acc2); color: var(--bg); display: grid; place-items: center; font-weight: 800; flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.demo-flag { font-size: 12px; padding: 6px 10px; border-radius: var(--r); border: 1px dashed var(--acc2); color: var(--acc2); }

/* Phones: compact header and a swipeable menu bar. Kept last so it wins over the rules above. */
@media (max-width: 840px) {
  .side { border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; gap: 10px; flex-basis: 100%; min-width: 0; max-width: 100%; }
  .side .logout { display: none; }
  .side .server-switch { min-height: 48px !important; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .nav a { white-space: nowrap; min-height: 40px; padding: 9px 12px; }
  .nav a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--acc); }
  .demo-flag { padding: 4px 8px; }
  .main { padding: 16px 12px 48px; }
  .banner .inner { padding: 18px; }
  .crest, .crest img, .crest svg { width: 56px; height: 56px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid .card { padding: 14px; }
}
