:root {
  --bg0: #0e1114;
  --bg1: #151a1f;
  --bg2: #1b2229;
  --sidebar: #0a0d10;
  --ink: #e6ebe8;
  --muted: #8b9690;
  --line: rgba(230, 235, 232, 0.1);
  --accent: #3dd68c;
  --accent-dim: rgba(61, 214, 140, 0.14);
  --danger: #e85d4c;
  --warn: #d4a84b;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sidebar-w: 220px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg0);
}

.hidden {
  display: none !important;
}

/* ——— Admin shell ——— */
body.admin {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.85rem;
  gap: 1.5rem;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.5rem;
}

.sidebar-brand strong {
  display: block;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.sidebar-brand span {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.brand-mark {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--warn), var(--accent));
  box-shadow: 0 0 0 4px rgba(212, 168, 75, 0.15);
  flex-shrink: 0;
}

.sidebar-nav {
  display: grid;
  gap: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  font-size: 0.92rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
}

.nav-item.is-active {
  color: var(--ink);
  background: var(--accent-dim);
}

.nav-icon {
  font-size: 0.7rem;
  opacity: 0.7;
}

.sidebar-foot {
  margin-top: auto;
  padding: 0.5rem;
}

.sidebar-hint {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.4;
}

.admin-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 70% 40% at 100% 0%, rgba(61, 214, 140, 0.07), transparent 55%),
    var(--bg0);
}

.admin-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.5rem 2rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 17, 20, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-top h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.page-sub {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-right: 0.35rem;
  font-family: var(--mono);
}

.admin-content {
  padding: 1.25rem 2rem 3rem;
  display: grid;
  gap: 1.25rem;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}

.view[hidden] {
  display: none !important;
}

.panel {
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.15rem 1.25rem 1.25rem;
}

.panel-head {
  margin-bottom: 1rem;
}

.panel-head h2,
h2 {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.85rem 1rem;
}

.section-head-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.count {
  font-size: 0.72rem;
  color: var(--bg0);
  background: var(--muted);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-weight: 700;
  font-family: var(--mono);
}

/* Forms */
.token-form,
.add-form {
  display: grid;
  grid-template-columns: 1.4fr 0.55fr 0.9fr auto;
  gap: 0.85rem;
  align-items: end;
  max-width: 960px;
}

.token-form:has(#token-days-wrap:not(.hidden)) {
  grid-template-columns: 1.2fr 0.5fr 0.85fr 0.7fr auto;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
}

input,
select {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg2);
  color: var(--ink);
  font: inherit;
  outline: none;
  transition: border-color 0.2s;
  color-scheme: dark;
}

input:focus,
select:focus {
  border-color: rgba(61, 214, 140, 0.55);
}

select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238b9690' d='M1.4 0.6L6 5.2 10.6 0.6 12 2 6 8 0 2z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

select option {
  background: var(--bg1);
  color: var(--ink);
}

.form-hint {
  margin: 0.85rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

/* Buttons */
.btn {
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s, opacity 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #062015;
}

.btn-primary:hover:not(:disabled) {
  background: #58e5a0;
}

.btn-start {
  background: var(--accent);
  color: #062015;
}

.btn-stop {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(232, 93, 76, 0.45);
}

.btn-stop:hover:not(:disabled) {
  background: rgba(232, 93, 76, 0.12);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-ghost:hover:not(:disabled) {
  border-color: rgba(230, 235, 232, 0.25);
}

.btn-danger-soft {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 0.4rem 0.55rem;
  font-size: 0.78rem;
}

.btn-danger-soft:hover {
  color: var(--danger);
}

.btn-sm {
  padding: 0.4rem 0.7rem;
  font-size: 0.78rem;
}

/* Token cards */
.token-list {
  display: grid;
  gap: 0.75rem;
}

.token-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg2);
  padding: 1rem 1.1rem;
  display: grid;
  gap: 0.75rem;
  animation: fadeUp 0.3s ease both;
}

.token-card.is-revoked {
  opacity: 0.55;
}

.token-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.token-card-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.token-card-meta {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  font-family: var(--mono);
}

.seat-meter {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-family: var(--mono);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
}

.seat-meter.full {
  border-color: rgba(232, 93, 76, 0.4);
  color: var(--danger);
}

.seat-meter.open {
  border-color: rgba(61, 214, 140, 0.35);
  color: var(--accent);
}

.plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-family: var(--mono);
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.plan-badge.trial {
  color: var(--warn);
  border-color: rgba(212, 168, 75, 0.4);
}

.plan-badge.paid {
  color: var(--accent);
  border-color: rgba(61, 214, 140, 0.35);
}

.plan-badge.lifetime {
  color: var(--ink);
}

.plan-badge.expired {
  color: var(--danger);
  border-color: rgba(232, 93, 76, 0.45);
}

.token-card.is-expired {
  border-color: rgba(232, 93, 76, 0.35);
}

.token-expiry {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  font-family: var(--mono);
}

.token-expiry.expired {
  color: var(--danger);
}

.token-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* Schedule */
fieldset {
  border: none;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.schedule-form {
  display: grid;
  gap: 1.25rem;
  margin-top: 0.5rem;
  max-width: 720px;
}

.sched-fieldset {
  margin: 0;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg2);
  display: grid;
  gap: 0.85rem;
}

.sched-fieldset legend {
  padding: 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.check-row {
  display: flex !important;
  align-items: center;
  gap: 0.55rem;
  grid-template-columns: none !important;
  font-size: 0.9rem;
  color: var(--ink);
}

.check-row input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}

.time-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.impact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
}

.hm {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.hm input {
  width: 4.5rem;
}

.hm span {
  color: var(--muted);
}

.schedule-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.token-secret {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  border: 1px solid var(--line);
}

.token-secret code {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--accent);
  word-break: break-all;
}

.seat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.seat-chip {
  font-size: 0.75rem;
  font-family: var(--mono);
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.seat-chip.online {
  color: var(--accent);
  border-color: rgba(61, 214, 140, 0.35);
  background: var(--accent-dim);
}

/* Accounts */
.account-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.account-filter {
  display: grid;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.account-filter-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.account-filter select,
.account-filter input[type="search"] {
  min-width: 140px;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--ink);
  font-size: 0.88rem;
}

.account-filter-search {
  flex: 1 1 200px;
  min-width: min(100%, 220px);
}

.account-filter-search input[type="search"] {
  width: 100%;
  min-width: 0;
}

.account-filter-clear {
  margin-left: auto;
}

.account-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.summary-chip {
  display: grid;
  gap: 0.15rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg2);
}

.summary-chip-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.summary-chip strong {
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.summary-chip-sub {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: var(--mono);
}

.summary-chip .pos {
  color: var(--accent);
}

.summary-chip .neg {
  color: var(--danger);
}

.account-list {
  display: grid;
  gap: 0.85rem;
}

.account-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg2);
  padding: 1rem 1.1rem 0.9rem;
  display: grid;
  gap: 0.9rem;
  transition: border-color 0.15s;
}

.account-card:hover {
  border-color: rgba(61, 214, 140, 0.22);
}

.account-card.is-new {
  animation: fadeUp 0.35s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.account-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.account-identity {
  min-width: 0;
  flex: 1 1 220px;
}

.acc-name {
  margin: 0 0 0.25rem;
  font-size: 1.08rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.acc-broker {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
  font-family: var(--mono);
}

.acc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.55rem;
}

.account-wallet {
  display: flex;
  align-items: flex-end;
  gap: 1.25rem;
  flex-shrink: 0;
  text-align: right;
}

.wallet-today {
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  min-width: 7.5rem;
}

.wallet-today.pos {
  border-color: rgba(61, 214, 140, 0.35);
  background: rgba(61, 214, 140, 0.08);
}

.wallet-today.neg {
  border-color: rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.08);
}

.wallet-today-value {
  display: block;
  margin-top: 0.1rem;
  font-size: 1.2rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.wallet-today.pos .wallet-today-value {
  color: var(--accent);
}

.wallet-today.neg .wallet-today-value {
  color: var(--danger);
}

.wallet-balance-block {
  min-width: 0;
}

.wallet-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.wallet-value {
  display: block;
  margin-top: 0.15rem;
  font-size: 1.35rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.wallet-cur {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}

.wallet-sub {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.wallet-sub strong {
  color: var(--ink);
  font-weight: 600;
}

.account-metrics {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metric {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

.metric-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-value {
  font-size: 0.92rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.metric-value.metric-mono {
  font-family: var(--mono);
  font-size: 0.82rem;
}

.metric-value.pos {
  color: var(--accent);
}

.metric-value.neg {
  color: var(--danger);
}

.account-card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
}

.account-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
  font-family: var(--mono);
}

.meta-sep {
  opacity: 0.5;
}

.status-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  font-size: 0.8rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.dot.on { background: var(--accent); }
.dot.off { background: var(--danger); }
.dot.idle { background: var(--warn); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
  margin-left: auto;
}

.token-row {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.token-snip {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  word-break: break-all;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.btn-icon:hover {
  color: var(--ink);
  border-color: rgba(61, 214, 140, 0.45);
}

.btn-icon.copied {
  color: var(--accent);
  border-color: rgba(61, 214, 140, 0.55);
}

.empty {
  color: var(--muted);
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
}

/* Dialogs */
dialog {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg1);
  color: var(--ink);
  padding: 0;
  max-width: 480px;
  width: calc(100% - 2rem);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.dialog-body {
  padding: 1.35rem;
  display: grid;
  gap: 0.85rem;
}

.dialog-body h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.dialog-body p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.token-box {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 8px;
  border: 1px solid var(--line);
}

.token-box code {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.75rem;
  word-break: break-all;
  color: var(--accent);
}

.hint {
  font-size: 0.82rem !important;
}

code {
  font-family: var(--mono);
  font-size: 0.85em;
  color: var(--accent);
}

.login-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.password-ok {
  margin: 0;
  color: var(--accent);
  font-size: 0.9rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

#limits-clear-lock {
  margin-right: auto;
}

#password-dialog .dialog-body label {
  display: grid;
  gap: 0.35rem;
}

/* Login */
.login-page {
  background:
    radial-gradient(ellipse 55% 45% at 50% -5%, rgba(212, 168, 75, 0.12), transparent 50%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(61, 214, 140, 0.08), transparent 55%),
    var(--bg0);
}

.login-page .login-wrap {
  min-height: 100vh;
  display: grid;
  place-content: center;
  gap: 1.5rem;
  padding: 1.5rem;
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.login-brand {
  text-align: left;
}

.login-brand-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.login-brand .brand-mark {
  display: block;
  margin: 0;
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.login-product {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--warn);
}

.login-brand h1 {
  margin: 0.15rem 0 0;
  font-weight: 600;
  font-size: clamp(1.55rem, 4vw, 1.85rem);
  letter-spacing: -0.02em;
}

.login-tagline {
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.login-foot {
  margin: 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.login-form {
  display: grid;
  gap: 0.85rem;
  padding: 1.35rem 1.25rem;
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.login-submit {
  width: 100%;
  margin-top: 0.35rem;
}

/* Summary page (kept compatible) */
.bg-grid {
  display: none;
}

.top {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 1.5rem 2rem 1rem;
  box-sizing: border-box;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.summary-product {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--warn);
}

.brand h1 {
  margin: 0.1rem 0 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.brand-sub {
  margin: 0.5rem 0 0;
  color: var(--muted);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.summary-page {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0 2rem 3rem;
  box-sizing: border-box;
}

.back-link {
  color: var(--ink);
  text-decoration: none;
}

.back-link:hover {
  color: var(--accent);
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.stat-card {
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg1);
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.stat-card strong {
  font-size: 1.15rem;
}

.summary-meta {
  margin: 0 0 1rem;
}

.summary-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.summary-filter {
  display: grid;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.summary-filter select {
  min-width: 160px;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--ink);
}

.summary-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.summary-tab {
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}

.summary-tab.is-active {
  color: var(--ink);
  border-color: rgba(61, 214, 140, 0.45);
  background: var(--accent-dim);
}

.summary-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg1);
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.summary-table th,
.summary-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.summary-table th {
  color: var(--muted);
  font-weight: 500;
}

.summary-table tr:last-child td {
  border-bottom: none;
}

.summary-table .pos {
  color: var(--accent);
}

.summary-table .neg {
  color: var(--danger);
}

.empty-inline {
  padding: 1rem;
  color: var(--muted);
  margin: 0;
}

.symbol-totals {
  margin-top: 2rem;
}

.symbol-totals h2 {
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
}

@media (max-width: 900px) {
  body.admin {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
  }

  .sidebar-nav {
    display: flex;
    flex: 1;
  }

  .sidebar-foot {
    display: none;
  }

  .token-form,
  .add-form {
    grid-template-columns: 1fr;
  }

  .account-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .account-metrics {
    grid-template-columns: repeat(3, 1fr);
  }

  .account-card-head {
    flex-direction: column;
  }

  .account-wallet {
    text-align: left;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .wallet-today {
    min-width: 0;
  }

  .account-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .account-filter-clear {
    margin-left: 0;
  }

  .account-card-foot {
    flex-direction: column;
    align-items: stretch;
  }

  .actions {
    justify-content: flex-start;
    margin-left: 0;
  }

  .summary-stats {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 520px) {
  .account-summary {
    grid-template-columns: 1fr;
  }

  .account-metrics {
    grid-template-columns: repeat(2, 1fr);
  }

  .summary-stats {
    grid-template-columns: 1fr;
  }
}

/* Users admin */
.users-intro {
  margin: 0 0 1rem;
}

.user-form {
  margin-top: 0;
}

.user-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  max-width: 900px;
}

.user-form-grid > .user-token-fieldset,
.user-form-grid > .login-error,
.user-form-grid > .user-form-actions {
  grid-column: 1 / -1;
}

.user-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.15rem;
}

.token-pick-hint {
  margin: 0 0 0.65rem !important;
}

.user-token-fieldset {
  border-radius: 10px;
}

.token-pick-fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin: 0;
  background: var(--bg2);
}

.token-pick-fieldset legend {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 0.25rem;
}

.token-pick-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.55rem;
  max-height: 240px;
  overflow: auto;
  margin-top: 0.25rem;
}

.token-pick {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-size: 0.88rem;
  cursor: pointer;
  padding: 0.65rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.15);
  transition: border-color 0.15s, background 0.15s;
}

.token-pick:hover {
  border-color: rgba(61, 214, 140, 0.25);
  background: rgba(255, 255, 255, 0.03);
}

.token-pick.is-selected {
  border-color: rgba(61, 214, 140, 0.45);
  background: rgba(61, 214, 140, 0.08);
}

.token-pick input[type="checkbox"] {
  width: auto;
  margin: 0.15rem 0 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.token-pick-body {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

.token-pick-name {
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.token-pick-meta {
  font-size: 0.72rem;
  font-family: var(--mono);
  color: var(--muted);
  line-height: 1.35;
}

.user-list {
  display: grid;
  gap: 0.85rem;
}

.user-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg2);
  padding: 1rem 1.1rem 0.9rem;
  display: grid;
  gap: 0.85rem;
  transition: border-color 0.15s;
}

.user-card:hover {
  border-color: rgba(61, 214, 140, 0.22);
}

.user-card.is-admin {
  border-color: rgba(61, 214, 140, 0.28);
  background: linear-gradient(135deg, rgba(61, 214, 140, 0.06), var(--bg2) 45%);
}

.user-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.user-identity {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 10px;
  background: rgba(61, 214, 140, 0.12);
  border: 1px solid rgba(61, 214, 140, 0.28);
  color: var(--accent);
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.user-card.is-admin .user-avatar {
  background: rgba(61, 214, 140, 0.18);
}

.user-identity-text {
  min-width: 0;
}

.user-card-name {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.user-card-meta {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-family: var(--mono);
}

.role-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-family: var(--mono);
  font-weight: 600;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.role-badge--admin {
  color: var(--accent);
  border-color: rgba(61, 214, 140, 0.4);
  background: rgba(61, 214, 140, 0.1);
}

.role-badge--sub-admin {
  color: var(--warn);
  border-color: rgba(212, 168, 75, 0.4);
  background: rgba(212, 168, 75, 0.08);
}

.role-badge--readonly {
  color: var(--muted);
  border-color: rgba(230, 235, 232, 0.2);
  background: rgba(255, 255, 255, 0.04);
}

.role-badge--write {
  color: var(--accent);
  border-color: rgba(61, 214, 140, 0.35);
  background: rgba(61, 214, 140, 0.08);
}

.user-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

.user-readonly-row {
  grid-column: 1 / -1;
}

.readonly-banner {
  margin: 0 1.75rem 0.75rem;
  padding: 0.65rem 0.9rem;
  border: 1px solid rgba(212, 168, 75, 0.35);
  border-radius: 8px;
  background: rgba(212, 168, 75, 0.1);
  color: var(--warn);
  font-size: 0.85rem;
}

.readonly-hint {
  font-size: 0.75rem;
  color: var(--muted);
  align-self: center;
}

body.is-readonly .bulk-actions {
  display: none !important;
}

.user-card-metrics {
  display: grid;
  grid-template-columns: minmax(7rem, 0.35fr) 1fr;
  gap: 0.75rem 1rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.user-metric {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.user-metric--wide {
  min-width: 0;
}

.user-metric-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.user-metric-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.user-token-chips {
  margin-top: 0.15rem;
}

.seat-chip--all {
  border-color: rgba(61, 214, 140, 0.35);
  color: var(--accent);
}

.seat-chip--empty {
  opacity: 0.75;
  font-style: italic;
}

.user-card-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 2rem;
}

.user-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
  width: 100%;
}

.user-protected {
  font-size: 0.78rem;
  color: var(--muted);
  font-family: var(--mono);
  width: 100%;
  text-align: right;
}

.user-dialog {
  max-width: 520px;
}

.dialog-sub {
  margin: -0.35rem 0 0 !important;
  font-size: 0.85rem !important;
  color: var(--muted) !important;
}

@media (max-width: 720px) {
  .user-form-grid {
    grid-template-columns: 1fr;
  }

  .user-card-metrics {
    grid-template-columns: 1fr;
  }

  .user-card-foot {
    justify-content: flex-start;
  }

  .user-protected {
    text-align: left;
  }

  .token-pick-list {
    grid-template-columns: 1fr;
  }
}

.account-limits {
  display: grid;
  gap: 0.45rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.12);
}

.account-limits.is-locked {
  border-color: rgba(212, 168, 75, 0.45);
  background: rgba(212, 168, 75, 0.08);
}

.account-limits-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.account-limits-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.account-limits-values {
  font-size: 0.82rem;
  font-family: var(--mono);
  color: var(--ink);
}

.limit-lock-badge,
.pill-warn {
  font-size: 0.72rem;
  color: var(--warn);
  font-family: var(--mono);
}

.limit-progress {
  display: grid;
  gap: 0.25rem;
}

.limit-progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--mono);
}

.limit-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.limit-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.2s ease;
}

.limit-bar-fill.is-hit {
  background: var(--warn);
}

.limits-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.limits-dialog {
  max-width: 460px;
}

.limits-status-line {
  margin: 0 !important;
}

@media (max-width: 520px) {
  .limits-form-grid {
    grid-template-columns: 1fr;
  }
}

/* Dashboard */
.dash-panel {
  margin-bottom: 0;
}

.dash-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.dash-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
}

.dash-kpi {
  display: grid;
  gap: 0.2rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg2);
}

.dash-kpi-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.dash-kpi-value {
  font-size: 1.25rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.dash-kpi-value.pos { color: var(--accent); }
.dash-kpi-value.neg { color: var(--danger); }

.dash-kpi-sub {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: var(--mono);
}

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.15rem;
  margin: 1rem 0;
}

.dash-alerts,
.dash-leaders {
  display: grid;
  gap: 0.55rem;
}

.dash-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.15);
}

.dash-alert--ok {
  border-color: rgba(61, 214, 140, 0.3);
  background: rgba(61, 214, 140, 0.06);
}

.dash-alert--warn {
  border-color: rgba(212, 168, 75, 0.4);
  background: rgba(212, 168, 75, 0.08);
}

.dash-alert--info {
  border-color: rgba(120, 160, 220, 0.35);
  background: rgba(120, 160, 220, 0.06);
}

.dash-alert-text {
  font-size: 0.88rem;
  line-height: 1.35;
}

.dash-leaders-split {
  margin: 0.35rem 0 0;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.dash-leader-row {
  display: grid;
  grid-template-columns: 2.2rem 1fr auto auto;
  gap: 0.5rem 0.75rem;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.12);
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s;
}

.dash-leader-row:hover {
  border-color: rgba(61, 214, 140, 0.3);
}

.dash-leader-rank {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.dash-leader-name {
  font-weight: 600;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-leader-meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.dash-leader-pnl {
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  justify-self: end;
}

.dash-leader-pnl.pos { color: var(--accent); }
.dash-leader-pnl.neg { color: var(--danger); }

.dash-fleet {
  display: grid;
  gap: 0.55rem;
}

.dash-fleet-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.2fr) auto;
  gap: 0.75rem 1.25rem;
  align-items: center;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg2);
}

.dash-fleet-row.is-locked {
  border-color: rgba(212, 168, 75, 0.4);
}

.dash-fleet-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.65rem;
  min-width: 0;
}

.dash-fleet-name {
  font-size: 0.95rem;
}

.dash-fleet-meta {
  width: 100%;
  font-size: 0.75rem;
  font-family: var(--mono);
  color: var(--muted);
}

.dash-fleet-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-family: var(--mono);
}

.dash-fleet-stats .pos strong { color: var(--accent); }
.dash-fleet-stats .neg strong { color: var(--danger); }

.dash-fleet-stats strong {
  color: var(--ink);
  font-weight: 600;
}

.dash-fleet-actions {
  justify-self: end;
}

.empty-inline {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .dash-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 800px) {
  .dash-grid {
    grid-template-columns: 1fr;
  }

  .dash-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dash-fleet-row {
    grid-template-columns: 1fr;
  }

  .dash-fleet-actions {
    justify-self: start;
  }

  .dash-leader-row {
    grid-template-columns: 2rem 1fr auto;
  }

  .dash-leader-meta {
    display: none;
  }
}

@media (max-width: 520px) {
  .dash-kpis {
    grid-template-columns: 1fr;
  }
}

.nav-admin-only.hidden {
  display: none;
}

/* Activity + Telegram alerts */
.activity-toolbar {
  margin-bottom: 0.85rem;
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: min(52vh, 560px);
  overflow: auto;
  padding-right: 0.15rem;
}

.activity-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.65rem 1.25rem;
  align-items: baseline;
  padding: 0.7rem 0.15rem;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
}

.activity-row:last-child {
  border-bottom: none;
}

.activity-row-main {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: baseline;
  min-width: 0;
}

.activity-action {
  font-weight: 600;
  color: var(--text);
}

.activity-entity {
  color: var(--muted);
  font-size: 0.92rem;
}

.activity-detail {
  width: 100%;
  font-size: 0.82rem;
  color: var(--muted);
  opacity: 0.9;
}

.activity-row-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.activity-actor {
  font-weight: 500;
  color: var(--text);
  opacity: 0.85;
}

#view-settings.is-active:not([hidden]) {
  display: block;
}

.settings-tabs {
  display: flex;
  gap: 0.45rem;
  margin: 0 0 1.1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--line);
}

.settings-tab {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: 500;
}

.settings-tab:hover {
  color: var(--ink);
  background: var(--bg2);
}

.settings-tab.is-active {
  color: var(--ink);
  border-color: rgba(61, 214, 140, 0.45);
  background: var(--accent-dim);
}

.settings-pane[hidden] {
  display: none !important;
}

.settings-pane.is-active {
  display: block;
}

.settings-pane-intro {
  margin: 0 0 0.35rem;
  max-width: 42rem;
  line-height: 1.45;
}

/* Fleet profits */
.profits-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.profits-stats .stat-card {
  padding: 0.85rem 0.95rem;
}

.profits-stats .stat-card strong {
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.account-units {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--line);
}

.units-dialog {
  width: min(720px, 96vw);
  max-height: 90vh;
  overflow: auto;
}

.units-dialog-list {
  padding: 0 1.25rem 1.25rem;
}

.units-list-heading {
  margin: 0 0 0.65rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.units-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

.units-table {
  font-size: 0.85rem;
}


.profits-table-wrap {
  max-height: min(48vh, 520px);
  overflow: auto;
}

.profits-table-wrap .metric-mono {
  font-family: var(--mono);
  font-size: 0.85rem;
}

@media (max-width: 1100px) {
  .profits-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .profits-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.alerts-form {
  display: grid;
  gap: 1.25rem;
  margin-top: 0.5rem;
  max-width: 720px;
}

.alerts-form .sched-fieldset {
  gap: 1rem;
}

.alerts-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem 1rem;
}

.alerts-form-grid label {
  display: grid;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.alerts-form #alert-token-hint {
  margin: 0;
}

.alerts-notify-row {
  gap: 0.85rem 1.5rem;
}

.alerts-form .schedule-actions {
  margin-top: 0.15rem;
}

.alerts-form .login-error,
.alerts-form .password-ok {
  margin: 0;
}

@media (max-width: 700px) {
  .activity-row {
    grid-template-columns: 1fr;
  }

  .activity-row-meta {
    align-items: flex-start;
    flex-direction: row;
    gap: 0.75rem;
  }

  .alerts-form-grid {
    grid-template-columns: 1fr;
  }
}
