:root {
  --bg: #0b0d12; --surface: #151922; --surface-2: #1b2030; --border: #272e40;
  --text: #eef1f8; --muted: #98a1b6; --accent: #5865f2; --accent-2: #8b94f7;
  --success: #3dd68c; --danger: #f2545b; --warn: #f0b232;
  --radius: 14px; --shadow: 0 10px 30px rgba(0,0,0,.28);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(1000px 420px at 0% -10%, rgba(88,101,242,.16), transparent 60%), var(--bg);
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--surface-2); padding: .1em .4em; border-radius: 6px; font-size: .9em; }
h1 { font-size: clamp(1.4rem, 3.5vw, 1.9rem); margin: .1rem 0; letter-spacing: -.02em; }
h2 { font-size: 1.1rem; margin: 0 0 .8rem; }
.muted { color: var(--muted); }
.fine { color: var(--muted); font-size: .85rem; margin-top: .8rem; }
small { color: var(--muted); }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .75rem clamp(1rem, 3vw, 1.6rem); background: rgba(11,13,18,.85);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: .55rem; color: var(--text); font-weight: 700; font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.topbar-right { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; }
.username { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.shell { width: min(1040px, calc(100% - 2rem)); margin: 1.6rem auto 3rem; flex: 1; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.2rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid transparent;
  border-radius: 10px; padding: .6rem 1.05rem; font: inherit; font-weight: 600; cursor: pointer; color: var(--text);
  background: var(--surface-2); transition: background .15s, border-color .15s; }
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn-primary { background: var(--accent); }
.btn-primary:hover { background: #4752c4; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; }
.btn-lg { padding: .85rem 1.4rem; font-size: 1.05rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem;
  margin-bottom: 1rem; box-shadow: var(--shadow); }
.banner { border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px; padding: .7rem 1rem; margin: 0 0 1rem; }
.banner.success { border-color: rgba(61,214,140,.45); background: rgba(61,214,140,.1); }
.banner.error { border-color: rgba(242,84,91,.5); background: rgba(242,84,91,.1); }

.hero { display: grid; place-items: center; min-height: 60vh; }
.login-card { max-width: 520px; text-align: center; padding: 2rem 1.6rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; color: var(--accent-2); font-size: .75rem; font-weight: 700; margin: 0; }
.lede { color: var(--muted); margin: .6rem 0 1.4rem; }

.page-head { margin-bottom: 1.2rem; }
.page-head.row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: .8rem; }
.page-head p { margin: .2rem 0 0; }
.section-title { margin: 2rem 0 .8rem; font-size: 1rem; color: var(--muted); }
.status-chip { display: inline-flex; align-items: center; gap: .45rem; padding: .35rem .8rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); font-size: .85rem; }
.status-line { display: flex; align-items: center; justify-content: center; gap: .45rem; color: var(--muted); font-size: .9rem; }
.card .status-line { justify-content: flex-start; color: var(--text); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.on { background: var(--success); box-shadow: 0 0 0 3px rgba(61,214,140,.18); }
.dot.off { background: var(--danger); }

.server-grid { list-style: none; padding: 0; margin: 0; display: grid; gap: .8rem;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.server-grid.compact { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.server-card { display: flex; flex-direction: column; align-items: center; gap: .45rem; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem .8rem;
  color: var(--text); height: 100%; transition: transform .15s, border-color .15s; }
.server-card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); }
.server-card.dim { opacity: .75; }
.server-card img { width: 56px; height: 56px; border-radius: 50%; }
.server-grid.compact img { width: 40px; height: 40px; }
.server-name { font-weight: 600; word-break: break-word; }
.server-fallback { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent); font-weight: 700; font-size: 1.3rem; color: #fff; }
.server-fallback.sm { width: 40px; height: 40px; font-size: 1rem; }

.guild-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.guild-head p { margin: 0; }
.guild-icon { width: 56px; height: 56px; border-radius: 50%; }
.back { font-size: .85rem; color: var(--muted); }
.tabs { display: flex; gap: .3rem; overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: 1.2rem;
  scrollbar-width: none; }
.tabs a { padding: .65rem .95rem; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; font-weight: 600; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.jump { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.jump a { font-size: .82rem; padding: .3rem .7rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.jump a:hover { color: var(--text); text-decoration: none; border-color: var(--accent); }

.stats-grid { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem;
  display: flex; flex-direction: column; color: var(--text); }
a.stat:hover { border-color: var(--accent); text-decoration: none; }
.stat b { font-size: 1.6rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .85rem; }
.two-col { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.two-col .card { margin-bottom: 0; }
.two-col + .card { margin-top: 1rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; margin: .8rem 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
details summary { cursor: pointer; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; padding: 0; margin: .6rem 0; }
.chip { display: inline-flex; align-items: center; gap: .3rem; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: .2rem .65rem; font-size: .82rem; }
.chip form { display: inline; margin: 0; }
.chip-x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 .1rem; }
.chip-x:hover { color: var(--danger); }
.leader { margin: 0; padding-left: 1.2rem; }
.leader li { display: flex; justify-content: space-between; gap: .5rem; padding: .3rem 0; border-bottom: 1px solid var(--border); }
.leader li:last-child { border: 0; }

.module-list { list-style: none; margin: 0; padding: 0; }
.module-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem 0; border-top: 1px solid var(--border); }
.module-list li div { display: flex; flex-direction: column; }
.module-list form { margin: 0; }
.pill { min-width: 64px; border-radius: 999px; padding: .35rem .9rem; font: inherit; font-weight: 700; cursor: pointer; border: 1px solid var(--border); }
.pill.on { background: rgba(61,214,140,.15); color: var(--success); border-color: rgba(61,214,140,.5); }
.pill.off { background: var(--surface-2); color: var(--muted); }

.settings .card { scroll-margin-top: 80px; }
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; font-weight: 600; font-size: .9rem; }
.field small { font-weight: 400; }
input[type=text], input[type=number], select, textarea {
  width: 100%; font: inherit; font-weight: 400; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: .6rem .75rem; min-height: 42px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 0 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

.switch { display: flex; align-items: flex-start; gap: .7rem; margin-bottom: .9rem; cursor: pointer; }
.switch input[type=checkbox] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.slider { flex: none; width: 40px; height: 22px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border);
  position: relative; transition: background .15s; margin-top: 1px; }
.slider::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.switch-text { display: flex; flex-direction: column; }
.save-bar { position: sticky; bottom: 0; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .8rem 1rem; margin-top: 1rem; background: rgba(21,25,34,.95); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: var(--radius); }

.inline-form { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; margin: .6rem 0 1rem; }
.inline-form input[type=text] { flex: 1; min-width: 180px; }
.inline-form .grow { flex: 1; min-width: 220px; margin: 0; }
.stack-form { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--border); }

.table-wrap { overflow-x: auto; margin: 0 -.2rem; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
td form { margin: 0; }
.wrap { word-break: break-word; min-width: 180px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.badge { padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--surface-2); text-transform: capitalize; }
.badge.approved { color: var(--success); background: rgba(61,214,140,.12); }
.badge.denied { color: var(--danger); background: rgba(242,84,91,.12); }
.badge.pending { color: var(--warn); background: rgba(240,178,50,.12); }

.poll-list { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.poll { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: .9rem; }
.poll header { display: flex; flex-direction: column; margin-bottom: .6rem; }
.bar-row { display: grid; grid-template-columns: minmax(70px, 1fr) 2fr auto; gap: .5rem; align-items: center; font-size: .85rem; margin: .3rem 0; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar-num { color: var(--muted); white-space: nowrap; }
.small-link { font-size: .82rem; display: inline-block; margin-top: .4rem; }
.bday-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.bday-list li { display: flex; gap: .6rem; align-items: center; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: .45rem .7rem; }
.bday-list .date { font-weight: 700; min-width: 54px; }
.empty { text-align: center; padding: 2rem 1.2rem; }

@media (max-width: 600px) {
  body { font-size: 14.5px; }
  .shell { width: calc(100% - 1.2rem); margin-top: 1rem; }
  .card { padding: 1rem; }
  .username { display: none; }
  .server-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .save-bar .muted { display: none; }
  .save-bar .btn { width: 100%; }
  .guild-head h1 { font-size: 1.3rem; }
}
