:root {
  --bg: #212121;
  --card: #2f2f2f;
  --border: #424242;
  --text: #ececec;
  --muted: #a1a1a1;
  --accent: #10a37f;
  --accent-hover: #0d8c6d;
  --admin: #5436da;
  --admin-hover: #4628c4;
  --error: #ef4444;
}

:root[data-theme="light"] {
  --bg: #f7f7f8;
  --card: #ffffff;
  --border: #d7d7db;
  --text: #1f1f1f;
  --muted: #6b6b6b;
}
:root[data-theme="light"] .login-page {
  background: radial-gradient(ellipse at top, #d8ece4 0%, var(--bg) 60%);
}
:root[data-theme="light"] .role-tabs,
:root[data-theme="light"] form input,
:root[data-theme="light"] .consent-details,
:root[data-theme="light"] .consent-details-body {
  background: #f0f0f2;
}
:root[data-theme="light"] form input { background: #ffffff; }
:root[data-theme="light"] .role-tab.active { background: #ffffff; }
:root[data-theme="light"] .btn-consent-secondary:hover { background: #ececec; }

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at top, #2a3a35 0%, var(--bg) 60%);
}

.login-home { flex-direction: column; gap: 16px; }

.icp-footer {
  width: 100%; padding: 2px 12px; color: var(--muted);
  text-align: center; font-size: 12px; line-height: 1.5;
}
.icp-footer a { color: inherit; text-decoration: none; }
.icp-footer a:hover { color: var(--text); text-decoration: underline; }

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px 32px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.logo {
  text-align: center;
  margin-bottom: 24px;
}

.logo-icon {
  width: 56px;
  height: 56px;
  background: var(--accent);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  margin: 0 auto 16px;
}

.logo h1 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 6px;
}

.logo p {
  font-size: 14px;
  color: var(--muted);
}

.role-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  background: #212121;
  border-radius: 10px;
  padding: 4px;
}

.role-tab {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.role-tab:hover {
  color: var(--text);
}

.role-tab.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.login-form {
  display: none;
}

.login-form.active {
  display: block;
}

form label {
  display: block;
  margin-bottom: 16px;
}

form label span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

form input {
  width: 100%;
  padding: 12px 14px;
  background: #212121;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}

form input:focus {
  border-color: var(--accent);
}

#adminForm input:focus {
  border-color: var(--admin);
}

.field-hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-muted, #8e8ea0);
}

.field-hint-ok {
  color: #10a37f;
}

.field-hint-bad {
  color: #ef4444;
}

.error {
  color: var(--error);
  font-size: 13px;
  min-height: 20px;
  margin-bottom: 8px;
}

button[type="submit"] {
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

button[type="submit"]:hover { background: var(--accent-hover); }
button[type="submit"]:disabled { opacity: 0.6; cursor: default; }

button.btn-admin {
  background: var(--admin);
}

button.btn-admin:hover {
  background: var(--admin-hover);
}

.hint {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin-top: 16px;
}

.admin-hint {
  font-size: 12px;
}

.hint .link {
  color: var(--accent);
  text-decoration: none;
}

.hint .link:hover {
  text-decoration: underline;
}

.consent-hint {
  margin: 0 0 14px;
  text-align: left;
  font-size: 13px;
  line-height: 1.5;
}

.consent-hint-action {
  display: block;
  margin-top: 6px;
}

.consent-hint-action .link {
  white-space: nowrap;
}

.pw-field {
  display: block;
  position: relative;
}
.pw-field input {
  padding-right: 56px;
}
.pw-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  padding: 4px 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  border-radius: 6px;
}
.pw-toggle:hover { color: var(--text); }

.remember-check {
  display: flex !important;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px !important;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  user-select: none;
}

.remember-check input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

.register-card {
  max-width: 440px;
}

.consent-details {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #212121;
  overflow: hidden;
}

.consent-details summary {
  padding: 12px 14px;
  cursor: pointer;
  color: var(--accent);
  font-size: 14px;
  line-height: 1.5;
  list-style: none;
  user-select: none;
}

.consent-details summary::-webkit-details-marker {
  display: none;
}

.consent-details summary::before {
  content: '▸ ';
  color: var(--muted);
}

.consent-details[open] summary::before {
  content: '▾ ';
}

.consent-details-body {
  padding: 0 14px 14px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  max-height: 240px;
  overflow-y: auto;
}

.consent-extra-link {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

.consent-page-card {
  max-width: 520px;
}

.consent-page-body {
  font-size: 14px;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
  text-align: left;
}

.consent-check {
  display: flex !important;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px !important;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.consent-check input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
  position: relative;
  z-index: 1;
}

a.link-btn {
  display: inline;
}

body.consent-modal-open {
  overflow: hidden;
}

.consent-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.72);
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.consent-modal.open {
  display: flex !important;
}

.consent-modal-box {
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.consent-modal-box h2 {
  font-size: 18px;
  padding: 20px 22px 12px;
  border-bottom: 1px solid var(--border);
}

.consent-modal-body {
  padding: 16px 22px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
}

.consent-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border);
}

.btn-consent-primary,
.btn-consent-secondary {
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid var(--border);
}

.btn-consent-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-consent-primary:hover {
  background: var(--accent-hover);
}

.btn-consent-secondary {
  background: transparent;
  color: var(--muted);
}

.btn-consent-secondary:hover {
  color: var(--text);
  background: #3a3a3a;
}

@media (max-width: 480px) {
  .login-page { min-height: 100dvh; padding: 16px; }
  .login-card { padding: 24px 20px; border-radius: 12px; }
  .logo { margin-bottom: 18px; }
  .logo-icon { width: 48px; height: 48px; margin-bottom: 12px; }
  .logo h1 { font-size: 20px; }
  .role-tabs { gap: 4px; margin-bottom: 18px; }
  .role-tab { min-height: 44px; padding: 10px 2px; font-size: 12px; white-space: nowrap; }
  form input, button[type="submit"] { min-height: 44px; }
  .consent-modal { padding: 12px; }
  .consent-modal-box { max-height: 92dvh; border-radius: 12px; }
  .consent-modal-box h2 { padding: 16px 18px 10px; }
  .consent-modal-body { padding: 14px 18px; }
  .consent-modal-actions { padding: 12px 18px 16px; }
}
