:root {
  --bg-grad-1: #f1f5f3;
  --bg-grad-2: #e7efeb;
  --surface: #fff;
  --surface-alt: #f7faf8;
  --surface-soft: #f6f8f7;
  --ink: #153d32;
  --ink-dim: #687a72;
  --ink-faint: #718078;
  --border: #e2ebe6;
  --border-strong: #cbd8d2;
  --brand: #17483b;
  --brand-hover: #0f392d;
  --brand-ink: #fff;
  --link: #216651;
  --eyebrow: #3d7364;
  --label: #214c3f;
  --input-bg: #fff;
  --input-ink: #173f34;
  --focus-ring: #2d77641c;
  --focus-border: #2d7764;
  --flash-err-bg: #ffe5df;
  --flash-err-ink: #812a20;
  --flash-ok-bg: #def3e7;
  --flash-ok-ink: #16633d;
  --shadow-card: 0 22px 55px #17372c18;
  --shadow-logo: 0 8px 16px #17483b28;
  --tile-bg: #fff;
  --tile-border: #e1e8e4;
  --tile-shadow: 0 3px 12px #17372c0a;
  --avatar-bg: #e2eee9;
  --active-badge-bg: #ddf3e6; --active-badge-ink: #17633d;
  --inactive-badge-bg: #edf0ee; --inactive-badge-ink: #68746e;
  --admin-badge-bg: #e7e6fa; --admin-badge-ink: #454083;
  --manage-ink: #245c4d;
  --fieldset-border: #d9dfdb;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-grad-1: #0c1210;
    --bg-grad-2: #0a0e0c;
    --surface: #141c19;
    --surface-alt: #1a2420;
    --surface-soft: #182420;
    --ink: #eaf3ef;
    --ink-dim: #a3b6ae;
    --ink-faint: #899289;
    --border: #263b34;
    --border-strong: #32493f;
    --brand: #34d399;
    --brand-hover: #2bb583;
    --brand-ink: #06231b;
    --link: #6ee7bf;
    --eyebrow: #6ee7bf;
    --label: #d4ede4;
    --input-bg: #101d18;
    --input-ink: #eaf3ef;
    --focus-ring: rgba(52,211,153,.18);
    --focus-border: #34d399;
    --flash-err-bg: #3a1a17;
    --flash-err-ink: #ffb4a4;
    --flash-ok-bg: #12301f;
    --flash-ok-ink: #7ee8ae;
    --shadow-card: 0 22px 55px rgba(0,0,0,.5);
    --shadow-logo: 0 8px 16px rgba(0,0,0,.4);
    --tile-bg: #141c19;
    --tile-border: #263b34;
    --tile-shadow: 0 3px 12px rgba(0,0,0,.3);
    --avatar-bg: #1e3129;
    --active-badge-bg: #12301f; --active-badge-ink: #7ee8ae;
    --inactive-badge-bg: #202a26; --inactive-badge-ink: #93a49c;
    --admin-badge-bg: #241f42; --admin-badge-ink: #b7b0f7;
    --manage-ink: #6ee7bf;
    --fieldset-border: #2b3d36;
  }
}
:root[data-theme="dark"] {
  --bg-grad-1: #0c1210;
  --bg-grad-2: #0a0e0c;
  --surface: #141c19;
  --surface-alt: #1a2420;
  --surface-soft: #182420;
  --ink: #eaf3ef;
  --ink-dim: #a3b6ae;
  --ink-faint: #899289;
  --border: #263b34;
  --border-strong: #32493f;
  --brand: #34d399;
  --brand-hover: #2bb583;
  --brand-ink: #06231b;
  --link: #6ee7bf;
  --eyebrow: #6ee7bf;
  --label: #d4ede4;
  --input-bg: #101d18;
  --input-ink: #eaf3ef;
  --focus-ring: rgba(52,211,153,.18);
  --focus-border: #34d399;
  --flash-err-bg: #3a1a17;
  --flash-err-ink: #ffb4a4;
  --flash-ok-bg: #12301f;
  --flash-ok-ink: #7ee8ae;
  --shadow-card: 0 22px 55px rgba(0,0,0,.5);
  --shadow-logo: 0 8px 16px rgba(0,0,0,.4);
  --tile-bg: #141c19;
  --tile-border: #263b34;
  --tile-shadow: 0 3px 12px rgba(0,0,0,.3);
  --avatar-bg: #1e3129;
  --active-badge-bg: #12301f; --active-badge-ink: #7ee8ae;
  --inactive-badge-bg: #202a26; --inactive-badge-ink: #93a49c;
  --admin-badge-bg: #241f42; --admin-badge-ink: #b7b0f7;
  --manage-ink: #6ee7bf;
  --fieldset-border: #2b3d36;
}

:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="dark"] *::-webkit-scrollbar { width: 12px; height: 12px; }
:root[data-theme="dark"] *::-webkit-scrollbar-track { background: var(--bg-grad-1); }
:root[data-theme="dark"] *::-webkit-scrollbar-thumb { background-color: var(--border-strong); border-radius: 999px; border: 2px solid var(--bg-grad-1); }
:root[data-theme="dark"] * { scrollbar-color: var(--border-strong) var(--bg-grad-1); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
  :root:not([data-theme="light"]) *::-webkit-scrollbar { width: 12px; height: 12px; }
  :root:not([data-theme="light"]) *::-webkit-scrollbar-track { background: var(--bg-grad-1); }
  :root:not([data-theme="light"]) *::-webkit-scrollbar-thumb { background-color: var(--border-strong); border-radius: 999px; border: 2px solid var(--bg-grad-1); }
  :root:not([data-theme="light"]) * { scrollbar-color: var(--border-strong) var(--bg-grad-1); }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: linear-gradient(135deg, var(--bg-grad-1) 0%, var(--bg-grad-2) 100%);
  color: var(--ink);
  font: 15px "Segoe UI", sans-serif;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
  transition: background-color .2s ease, color .2s ease;
}
.card { width: min(500px, 100%); background: var(--surface); padding: 38px; border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-card); }
.auth-card { max-width: 500px; position: relative; }
.theme-toggle {
  position: absolute; top: 20px; right: 20px;
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface-alt);
  color: var(--ink); font-size: 15px; cursor: pointer;
}
.theme-toggle:hover { border-color: var(--brand); }
.logo { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; background: var(--brand); color: var(--brand-ink); font-size: 23px; font-weight: 800; box-shadow: var(--shadow-logo); }
.auth-card .logo { margin: 0 auto; }
.auth-heading { margin: 19px 0 26px; text-align: center; }
.eyebrow { display: block; margin-bottom: 8px; color: var(--eyebrow); font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.auth-heading h1 { margin: 0 0 8px; font-family: Georgia, serif; font-size: 34px; line-height: 1.1; }
.auth-heading p { margin: 0; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-family: Georgia, serif; }
p, small { color: var(--ink-dim); }
label { display: block; margin: 17px 0; font-weight: 650; color: var(--label); }
input, select {
  width: 100%; height: 46px; padding: 10px 12px; margin-top: 7px;
  border: 1px solid var(--border-strong); border-radius: 9px;
  background: var(--input-bg); color: var(--input-ink); font: inherit;
  transition: border-color .15s, box-shadow .15s, background-color .2s;
}
input:focus, select:focus { outline: 0; border-color: var(--focus-border); box-shadow: 0 0 0 3px var(--focus-ring); }
.login-type { padding: 13px 14px; margin: 0 0 19px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-alt); }
.login-type select { height: 42px; margin-top: 6px; background: var(--input-bg); }
button { border: 0; background: var(--brand); color: var(--brand-ink); padding: 12px 18px; border-radius: 9px; font-weight: 750; cursor: pointer; font: inherit; transition: background .15s, transform .15s; }
button:hover { background: var(--brand-hover); }
button:active { transform: translateY(1px); }
form button { margin: 12px 0 0; }
.primary-button { width: 100%; height: 48px; }
.flash { padding: 12px 14px; background: var(--flash-err-bg); color: var(--flash-err-ink); border-radius: 9px; margin: 14px 0; }
.flash.success { background: var(--flash-ok-bg); color: var(--flash-ok-ink); }
.auth-links { display: flex; justify-content: space-between; gap: 16px; margin: 19px 0 0; }
.auth-links a { font-weight: 650; text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }
a { color: var(--link); }
.admin { display: block; padding: 0; }
.admin header { display: flex; align-items: center; justify-content: space-between; padding: 22px max(4%, 24px); background: var(--brand); color: var(--brand-ink); }
.admin header h1 { margin: 0; font-size: 25px; }
.admin header p { margin: 3px 0 0; color: var(--brand-ink); opacity: .82; }
.admin header nav { display: flex; gap: 22px; }
.admin header nav a { color: var(--brand-ink); }
.admin main { max-width: 1200px; margin: auto; padding: 28px 24px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 16px; }
.stats div, .panel { background: var(--tile-bg); border: 1px solid var(--tile-border); border-radius: 12px; box-shadow: var(--tile-shadow); }
.stats div { padding: 18px 20px; }
.stats strong { display: block; font-size: 26px; }
.stats span { color: var(--ink-faint); }
.panel { margin: 16px 0; }
.add-user > summary { padding: 20px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; list-style: none; }
.add-user > summary::-webkit-details-marker, .user-row > summary::-webkit-details-marker { display: none; }
.add-user summary small, .identity small { display: block; margin-top: 3px; }
.summary-action, .clear { font-weight: 700; }
.new { padding: 0 20px 20px; border-top: 1px solid var(--border); }
.new-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.new h3, .user-editor h3 { font-size: 15px; margin: 18px 0 5px; }
.new button { min-width: 180px; }
.users-panel { padding: 20px; }
.section-heading { display: flex; justify-content: space-between; }
.section-heading h2 { margin-bottom: 4px; }
.filters { display: flex; align-items: end; gap: 10px; padding: 15px; background: var(--surface-soft); border-radius: 10px; }
.filters label { margin: 0; }
.filters .search { flex: 1; }
.filters input, .filters select { margin: 0; }
.filters button { margin: 0; }
.clear { padding: 11px; }
.user-list { margin-top: 16px; border: 1px solid var(--tile-border); border-radius: 10px; overflow: hidden; }
.user-row { border-bottom: 1px solid var(--tile-border); }
.user-row:last-child { border: 0; }
.user-row > summary { display: grid; grid-template-columns: 42px minmax(180px, 1fr) auto 90px; gap: 12px; align-items: center; padding: 14px 16px; cursor: pointer; list-style: none; }
.user-row[open] > summary { background: var(--surface-soft); }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--avatar-bg); color: var(--brand); font-weight: 800; }
.badge { border-radius: 99px; padding: 5px 9px; font-size: 12px; font-weight: 700; }
.active-badge { background: var(--active-badge-bg); color: var(--active-badge-ink); }
.inactive-badge { background: var(--inactive-badge-bg); color: var(--inactive-badge-ink); }
.admin-badge { background: var(--admin-badge-bg); color: var(--admin-badge-ink); }
.manage { text-align: right; color: var(--manage-ink); font-weight: 700; }
.user-editor, .admin-note { padding: 18px 20px; border-top: 1px solid var(--tile-border); }
.admin-note { color: var(--ink-faint); }
.account-state { display: flex; justify-content: space-between; align-items: center; }
.account-state small { display: block; }
.switch-label { margin: 0; }
.switch-label input { width: auto; margin: 0 6px; }
.permissions { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; margin: 10px 0; }
.permissions fieldset { border: 1px solid var(--fieldset-border); border-radius: 8px; padding: 10px; }
.permissions legend { font-weight: 700; padding: 0 4px; }
.permissions label { display: inline-block; margin: 5px 9px 5px 0; }
.permissions input { width: auto; margin: 0 4px 0 0; }
.editor-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; color: var(--ink-faint); }
.editor-actions button { margin: 0; min-width: 150px; }
.empty { display: grid; place-items: center; padding: 45px; color: var(--ink-faint); }
.empty b { color: var(--ink); margin-bottom: 5px; }
.pagination { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-top: 18px; }
.pagination a:last-child { text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
@media (max-width: 700px) {
  body { padding: 18px 12px; place-items: start center; }
  .card { padding: 28px 22px; border-radius: 16px; }
  .auth-heading h1 { font-size: 29px; }
  .auth-links { align-items: flex-start; flex-direction: column; gap: 11px; }
  .admin header { display: block; }
  .admin header nav { margin-top: 14px; flex-wrap: wrap; }
  .admin main { padding: 18px 12px; }
  .stats { gap: 7px; }
  .stats div { padding: 13px; }
  .new-fields { grid-template-columns: 1fr; gap: 0; }
  .filters { align-items: stretch; flex-wrap: wrap; }
  .filters .search { flex-basis: 100%; }
  .user-row > summary { grid-template-columns: 42px 1fr auto; }
  .manage { display: none; }
  .badge { grid-column: 3; }
  .editor-actions { align-items: stretch; flex-direction: column; gap: 10px; }
  .editor-actions button { width: 100%; }
}

/* Theme controls must not inherit padding from ordinary form buttons. */
#themeToggle {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  line-height: 1;
  flex: 0 0 44px;
}
#themeToggleIcon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin: 0;
  padding: 0;
  line-height: 1;
  pointer-events: none;
}
/* End theme-control layout. */
