:root {
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-2: #f6f9f7;
  --text: #13201a;
  --muted: #5f7068;
  --border: #dfe7e2;
  --accent: #00a862;
  --accent-strong: #008a50;
  --accent-soft: #e3f7ec;
  --on-accent: #ffffff;
  --danger: #d93a4a;
  --danger-soft: #fdecee;
  --warn: #b7791f;
  --warn-soft: #fdf3e1;
  --shadow: 0 1px 2px rgba(16, 32, 24, .06), 0 12px 32px rgba(16, 32, 24, .08);
  --radius: 16px;
  --mono: "JetBrains Mono", ui-monospace, "Courier New", monospace;
  --sans: "Heebo", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #07110c;
    --surface: #0e1a14;
    --surface-2: #13221a;
    --text: #e3f4ea;
    --muted: #8ca79a;
    --border: #1f3329;
    --accent: #1fd184;
    --accent-strong: #5de3a6;
    --accent-soft: #10311f;
    --on-accent: #04130b;
    --danger: #ff6b78;
    --danger-soft: #36161b;
    --warn: #f1b24a;
    --warn-soft: #33260f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #07110c;
  --surface: #0e1a14;
  --surface-2: #13221a;
  --text: #e3f4ea;
  --muted: #8ca79a;
  --border: #1f3329;
  --accent: #1fd184;
  --accent-strong: #5de3a6;
  --accent-soft: #10311f;
  --on-accent: #04130b;
  --danger: #ff6b78;
  --danger-soft: #36161b;
  --warn: #f1b24a;
  --warn-soft: #33260f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}
[hidden] { display: none !important; }
a { color: var(--accent-strong); }

.brand {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 20px;
  color: var(--text);
  text-decoration: none;
  direction: ltr;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.brand .dot { color: var(--muted); }
.brand .mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: #04120a; color: #00ff88;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
}

/* ---------- portal layout ---------- */
.portal {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 16px 32px;
}
.portal > .brand { margin-bottom: 24px; }
.card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
}
.card.wide { max-width: 560px; }
.card h1 { font-size: 22px; margin: 0 0 6px; font-weight: 800; }
.card .lead { color: var(--muted); margin: 0 0 22px; font-size: 15px; }
.site-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-soft); color: var(--accent-strong);
  padding: 2px 10px; border-radius: 999px; font-weight: 700;
}
.portal-footer { margin-top: 20px; font-size: 12.5px; color: var(--muted); text-align: center; }
.portal-footer a { color: var(--muted); }

/* ---------- forms ---------- */
label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin: 14px 0 6px; }
input, select, textarea {
  width: 100%;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="email"], input[dir="ltr"] { direction: ltr; text-align: right; }
textarea { min-height: 80px; resize: vertical; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

.btn {
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  border: 1.5px solid transparent;
  border-radius: 10px;
  padding: 11px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: background .15s, border-color .15s, transform .1s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-outline:hover:not(:disabled) { border-color: var(--muted); }
.btn-ghost { background: transparent; color: var(--muted); padding: 8px 10px; }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-sm { font-size: 13px; padding: 6px 10px; border-radius: 8px; }
.btn-block { width: 100%; }
.link-btn { background: none; border: none; color: var(--accent-strong); font: inherit; font-size: 13.5px; cursor: pointer; padding: 0; text-decoration: underline; }

.stack > * + * { margin-top: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }

.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 20px 0 6px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }


.btn-lg { padding: 13px 16px; font-size: 16px; margin-top: 18px; }
.label-row { display: flex; align-items: baseline; justify-content: space-between; margin: 14px 0 6px; }
.label-row label { margin: 0; }
.label-row .link-btn { font-size: 13px; text-decoration: none; font-weight: 700; }
.pw-field { position: relative; }
.pw-field input { padding-left: 44px; }
.pw-toggle {
  position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 16px; padding: 6px; border-radius: 8px;
  opacity: .55; line-height: 1;
}
.pw-toggle:hover, .pw-toggle[aria-pressed="true"] { opacity: 1; }
.switch {
  margin: 22px -24px -28px; padding: 16px 24px; text-align: center; font-size: 14.5px; color: var(--muted);
  background: var(--surface-2); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
}
.switch .link-btn { font-size: 14.5px; font-weight: 700; text-decoration: none; }
.info-box { display: flex; gap: 12px; align-items: flex-start; background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; }
.info-box p { margin: 0; font-size: 14px; color: var(--text); }
.big-icon.sm { width: 36px; height: 36px; font-size: 18px; border-radius: 10px; margin: 0; flex-shrink: 0; background: var(--surface); }

.alert { border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-top: 14px; }
.alert.err { background: var(--danger-soft); color: var(--danger); }
.alert.ok { background: var(--accent-soft); color: var(--accent-strong); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert a { color: inherit; }

.big-icon {
  width: 56px; height: 56px; border-radius: 16px;
  background: var(--accent-soft); color: var(--accent-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; margin-bottom: 14px;
}

.account-chip {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 12px; padding: 12px;
}
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; flex-shrink: 0; overflow: hidden; text-transform: uppercase;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 30px; height: 30px; font-size: 13px; }
.account-chip .who { min-width: 0; }
.account-chip .who b { display: block; }
.account-chip .who span { color: var(--muted); font-size: 13.5px; direction: ltr; display: block; text-align: right; overflow: hidden; text-overflow: ellipsis; }

.list { list-style: none; padding: 0; margin: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.list li { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 12px 14px; }
.list li + li { border-top: 1px solid var(--border); }
.list .meta { color: var(--muted); font-size: 13px; }

.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.green { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }
.badge.red { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.section-title { font-size: 15px; font-weight: 800; margin: 26px 0 10px; }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid currentColor; border-top-color: transparent;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.center { text-align: center; }
.loading { display: flex; justify-content: center; padding: 30px; color: var(--muted); }

@media (max-width: 480px) {
  .portal { padding-top: 24px; }
  .card { padding: 22px 16px; }
  .switch { margin: 22px -16px -22px; padding: 14px 16px; }
}
