:root {
  color-scheme: light;
  --background: #f6f3f8;
  --surface: #fff;
  --border: #ded5e3;
  --text: #281c2d;
  --muted: #64566c;
  --purple: #722167;
  --sidebar: #27122d;
  --yellow: #fecb09;
  --sidebar-width: 222px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--text); font: 14px/1.5 system-ui, sans-serif; }
a { color: var(--purple); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid #a24496; outline-offset: 3px; }

.app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow: auto; background: var(--sidebar); color: #fff; }
.sidebar-header { min-height: 70px; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; border-bottom: 1px solid #54335a; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: #fff; font-weight: 700; text-decoration: none; }
.brand img { display: block; object-fit: contain; }
.brand span { color: var(--yellow); border-left: 1px solid #856587; padding-left: 12px; }
.sidebar nav { padding: 12px; display: grid; gap: 3px; }
.nav-group { padding: 12px 12px 3px; color: #d2bdd4; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.sidebar nav a { display: block; padding: 9px 12px; border-radius: 6px; text-decoration: none; color: #f7edf7; }
.sidebar nav a:hover { background: #49234d; }
.sidebar nav a[aria-current] { background: var(--yellow); color: #291526; font-weight: 750; }
.sidebar :focus-visible, .auth-brand :focus-visible { outline-color: var(--yellow); }
.nav-toggle { display: none; }
.workspace { min-width: 0; }
.topbar { min-height: 57px; padding: 0 clamp(14px, 2vw, 32px); display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface); border-bottom: 1px solid var(--border); font-weight: 650; }
.topbar > a { text-decoration: none; }
.account { display: flex; align-items: center; gap: 12px; }
.account span { color: var(--muted); overflow-wrap: anywhere; }
.account a { padding: 5px 10px; border: 1px solid var(--border); border-radius: 6px; text-decoration: none; }
.account a:hover { background: #f4e8f3; }

main { max-width: 1720px; margin: auto; padding: 24px clamp(14px, 2vw, 32px) 40px; }
h1 { font-size: clamp(23px, 3vw, 32px); margin: 0 0 20px; line-height: 1.2; letter-spacing: -.025em; }
h2 { font-size: 16px; margin: 0 0 12px; line-height: 1.35; }
p { margin: 0 0 12px; }
.muted, small { color: var(--muted); }
.filters, .actions, .withdraw { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }
.filters { margin-bottom: 16px; }
.card > .filters:last-child { margin-bottom: 0; }
main > #filters { background: var(--surface); padding: 13px; border: 1px solid var(--border); border-radius: 8px; }
label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; font-weight: 600; min-width: 0; }
input, select, button { font: inherit; padding: 7px 9px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); color: var(--text); max-width: 100%; }
input[type="checkbox"] { accent-color: var(--purple); }
button { background: var(--purple); border-color: var(--purple); color: #fff; font-weight: 700; cursor: pointer; }
button:hover { background: #591852; }
button.danger { background: #fbebed; color: #8d1933; border-color: #e9c0c9; }
button.danger:hover { background: #f4d9df; }
.subtle, .actions a { padding: 7px; }
.dashboard, .summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.summary { grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); margin-bottom: 16px; }
.summary article, .card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 14px; min-width: 0; box-shadow: 0 1px 2px #2f183014; }
.summary article { border-left: 3px solid var(--purple); }
.summary strong, .summary span { display: block; overflow-wrap: anywhere; }
.summary strong { font-size: 19px; }
.summary span { color: var(--muted); }
main > .card + .card { margin-top: 14px; }
.panel h2 { padding-bottom: 9px; border-bottom: 1px solid var(--border); }
.panel[data-kind="table"] { grid-column: 1 / -1; }
.table { max-height: 360px; overflow: auto; }
table { border-collapse: collapse; width: 100%; white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { background: #f2ecf5; color: #4d3752; position: sticky; top: 0; }
tbody tr:hover { background: #faf6fb; }
canvas { width: 100%; height: auto; display: block; }
details { margin-top: 8px; }
summary { cursor: pointer; color: var(--purple); }
.notice { border-left: 3px solid var(--purple); padding: 10px; background: #f2e6f2; overflow-wrap: anywhere; }
.withdraw label { display: flex; align-items: center; }
.withdraw input[type="checkbox"] { width: auto; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(145deg, var(--sidebar), var(--purple)); }
.auth-shell main { width: min(100%, 424px); padding: 28px 16px; }
.auth-brand { display: flex; justify-content: center; margin-bottom: 19px; }
.auth-shell .card { border-top: 4px solid var(--yellow); padding: clamp(20px, 5vw, 30px); box-shadow: 0 12px 36px #180b2440; }
.auth-shell .filters { display: grid; align-items: stretch; gap: 14px; }
.auth-shell .filters input:not([type="hidden"]) { width: 100%; }
.auth-shell .filters button { margin-top: 4px; }

@media (max-width: 1050px) {
  .dashboard { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; }
  .sidebar-header { min-height: 56px; }
  .nav-toggle:not([hidden]) { display: block; }
  .sidebar:has(.nav-toggle:not([hidden])[aria-expanded="false"]) nav { display: none; }
  .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-group { grid-column: 1 / -1; }
  .filters label { max-width: 100%; }
}
