:root {
  color-scheme: light;
  --ink: #f1f7ef;
  --ink-2: #fbfefa;
  --ink-3: #e7f1e3;
  --paper: #173126;
  --paper-muted: #607269;
  --line: rgba(37, 82, 56, 0.15);
  --line-strong: rgba(37, 82, 56, 0.28);
  --brass: #557f51;
  --brass-soft: #477b49;
  --green: #4f8d5d;
  --amber: #a06f32;
  --red: #aa4f48;
  --blue: #4d7689;
  --shadow: 0 28px 70px rgba(28, 68, 49, 0.17);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-size: 16px;
  line-height: 1.55;
}

button, input, select { font: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

button { color: inherit; }

a { color: inherit; }

[hidden] { display: none !important; }

.ambient-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  border: 48px solid transparent;
  outline: 1px solid rgba(255,255,255,0.025);
  outline-offset: -48px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brass);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.auth-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  min-height: 100vh;
}

.auth-manifesto {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  justify-content: space-between;
  padding: 42px clamp(36px, 6vw, 92px) 52px;
  border-right: 1px solid var(--line);
  background-color: #15140f;
}

.back-link {
  width: fit-content;
  color: var(--paper-muted);
  font-size: 15px;
  text-decoration: none;
  transition: color 160ms ease;
}

.back-link:hover { color: var(--paper); }

.manifesto-copy { max-width: 680px; }

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 50px;
}

.brand-mark span {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--brass);
  color: var(--brass-soft);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
}

.brand-mark strong {
  font-size: 13px;
  letter-spacing: 0.28em;
}

.manifesto-copy h1 {
  margin: 0 0 26px;
  max-width: 700px;
  color: #f4efe4;
  font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
  font-size: clamp(54px, 6.6vw, 102px);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 0.94;
}

.manifesto-copy > p:last-child {
  max-width: 610px;
  margin: 0;
  color: var(--paper-muted);
  font-size: 16px;
}

.auth-principles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.auth-principles article {
  min-width: 0;
  padding: 18px 18px 20px 0;
}

.auth-principles article + article {
  padding-left: 18px;
  border-left: 1px solid var(--line);
}

.auth-principles span,
.auth-principles small,
.auth-principles strong { display: block; }

.auth-principles span {
  color: var(--brass);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

.auth-principles strong {
  margin: 7px 0 4px;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-principles small { color: #827c72; }

.auth-card {
  align-self: center;
  width: min(460px, calc(100% - 54px));
  margin: 40px auto;
  padding: 0 34px 22px;
  border: 1px solid var(--line-strong);
  background: #1a1915;
  box-shadow: var(--shadow);
}

.auth-card > header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 -34px 0;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

.auth-card > header div { display: grid; gap: 2px; }
.auth-card > header small { color: #777167; font-size: 11px; font-weight: 800; letter-spacing: 0.18em; }
.auth-card > header strong { font-size: 15px; }

.status-dot, .live-indicator {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(103, 197, 162, 0.1);
}

.auth-loading {
  display: grid;
  grid-template-columns: repeat(3, 8px);
  justify-content: center;
  gap: 7px;
  padding: 100px 0 80px;
}

.auth-loading span {
  width: 8px;
  height: 8px;
  background: var(--brass);
  animation: pulse 900ms ease-in-out infinite alternate;
}

.auth-loading span:nth-child(2) { animation-delay: 180ms; }
.auth-loading span:nth-child(3) { animation-delay: 360ms; }
.auth-loading p { grid-column: 1 / -1; width: 250px; margin: 22px -110px 0; color: var(--paper-muted); text-align: center; }

@keyframes pulse { to { opacity: 0.25; transform: translateY(-5px); } }

.form-intro { padding: 34px 0 24px; }
.form-intro span { color: var(--brass); font: 700 11px/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: 0.2em; }
.form-intro h2 { margin: 8px 0 8px; font-family: Georgia, "Noto Serif SC", "Songti SC", serif; font-size: 28px; font-weight: 500; }
.form-intro p { margin: 0; color: var(--paper-muted); font-size: 15px; }

.auth-card form label,
.admin-dialog label,
.settings-form label {
  display: grid;
  gap: 7px;
  margin-bottom: 15px;
  color: #b8b0a4;
  font-size: 14px;
  font-weight: 650;
}

input, select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  outline: none;
  background: #12110e;
  color: var(--paper);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input::placeholder { color: #5f5a52; }
input:focus, select:focus { border-color: var(--brass); box-shadow: 0 0 0 3px rgba(201, 165, 104, 0.1); }
input:disabled, select:disabled { cursor: not-allowed; opacity: 0.55; }

button {
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: transparent;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease;
}

button:hover { border-color: var(--brass); color: var(--brass-soft); }
button:disabled { cursor: wait; opacity: 0.5; }

.primary-action {
  width: 100%;
  min-height: 46px;
  border-color: var(--brass);
  background: var(--brass);
  color: #17140f;
  font-weight: 850;
  letter-spacing: 0.04em;
}

.primary-action:hover { background: var(--brass-soft); color: #17140f; }
.primary-action.compact { width: auto; min-height: 38px; }

.auth-message {
  margin: 16px 0 0;
  padding: 10px 12px;
  border-left: 2px solid var(--red);
  background: rgba(224, 124, 112, 0.08);
  color: #efb1a9;
  font-size: 14px;
}

.auth-message.success { border-color: var(--green); background: rgba(103, 197, 162, 0.08); color: #a8dac7; }

.auth-card > footer {
  display: flex;
  justify-content: space-between;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: #696359;
  font: 700 11px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.13em;
}

.admin-app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-height: 100vh;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #14130f;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 92px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.admin-monogram {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--brass);
  color: var(--brass-soft);
  font-family: Georgia, serif;
}

.admin-brand div { display: grid; gap: 2px; }
.admin-brand strong { font-size: 14px; letter-spacing: 0.12em; }
.admin-brand small { color: #716b62; font-size: 10px; letter-spacing: 0.18em; }

.system-context {
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 24px 18px 18px;
  padding: 12px;
  border: 1px solid var(--line);
}

.system-context div { display: grid; }
.system-context small { color: #777168; font-size: 11px; }
.system-context strong { font: 700 12px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: 0.08em; }

#adminNav { display: grid; gap: 4px; padding: 4px 12px; }

.admin-nav-button {
  position: relative;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  color: #9f988d;
  text-align: left;
}

.admin-nav-button span {
  color: #665f56;
  font: 700 11px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.admin-nav-button strong { font-size: 15px; font-weight: 650; }
.admin-nav-button:hover { background: #1b1a15; color: var(--paper); }
.admin-nav-button.active { background: #201d17; color: var(--paper); }
.admin-nav-button.active::before { position: absolute; inset: 8px auto 8px 0; width: 2px; background: var(--brass); content: ""; }
.admin-nav-button.active span { color: var(--brass); }

.sidebar-foot {
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding: 20px 18px 26px;
  border-top: 1px solid var(--line);
}

.sidebar-foot a, .sidebar-foot button {
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  color: #8d867c;
  font-size: 14px;
  text-align: center;
  text-decoration: none;
}

.sidebar-foot a:hover, .sidebar-foot button:hover { border-color: var(--line-strong); color: var(--paper); }

.admin-stage { min-width: 0; background: #11100d; }

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 92px;
  padding: 18px clamp(24px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(17, 16, 13, 0.93);
}

.admin-topbar h1 {
  margin: 0;
  font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
  font-size: 29px;
  font-weight: 500;
}

.admin-identity {
  display: flex;
  align-items: center;
  gap: 11px;
}

.admin-identity > span {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line-strong);
  color: var(--brass-soft);
  font-size: 13px;
  font-weight: 800;
}

.admin-identity div { display: grid; text-align: right; }
.admin-identity strong { font-size: 15px; }
.admin-identity small { color: var(--paper-muted); font-size: 12px; }

.admin-content { padding: 34px clamp(24px, 4vw, 56px) 70px; }

.content-loading, .content-error, .empty-panel {
  display: grid;
  min-height: 340px;
  place-items: center;
  border: 1px dashed var(--line-strong);
  color: var(--paper-muted);
  text-align: center;
}

.content-error strong { display: block; margin-bottom: 8px; color: var(--red); }

.view-lead {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.view-lead h2 { margin: 0 0 5px; font-family: Georgia, "Noto Serif SC", "Songti SC", serif; font-size: 23px; font-weight: 500; }
.view-lead p { max-width: 720px; margin: 0; color: var(--paper-muted); }
.view-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 24px;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}

.metric-card {
  min-width: 0;
  padding: 20px 18px;
}

.metric-card + .metric-card { border-left: 1px solid var(--line); }
.metric-card span, .metric-card strong, .metric-card small { display: block; }
.metric-card span { color: var(--brass); font: 700 11px/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: 0.13em; }
.metric-card strong { margin: 13px 0 7px; overflow: hidden; color: #f1eadf; font-family: Georgia, serif; font-size: clamp(26px, 3vw, 40px); font-weight: 500; line-height: 1; text-overflow: ellipsis; white-space: nowrap; }
.metric-card small { color: #777066; }

.admin-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
}

.control-panel {
  grid-column: span 6;
  border: 1px solid var(--line);
  background: #171612;
}

.control-panel.wide { grid-column: 1 / -1; }
.control-panel.narrow { grid-column: span 4; }

.control-panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.control-panel > header h3 { margin: 0; font-size: 15px; }
.control-panel > header span { color: #6d675f; font: 700 11px/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: 0.12em; }
.panel-body { padding: 18px; }

.status-list { display: grid; gap: 0; }
.status-row { display: grid; grid-template-columns: minmax(150px, 1fr) auto; gap: 20px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.status-row:last-child { border-bottom: 0; }
.status-row span { color: var(--paper-muted); }
.status-row strong { font-size: 14px; text-align: right; }

.state-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid var(--line-strong);
  color: var(--paper-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.state-pill.ok { border-color: rgba(103, 197, 162, 0.4); background: rgba(103, 197, 162, 0.07); color: #9fd5c0; }
.state-pill.warn { border-color: rgba(224, 180, 88, 0.45); background: rgba(224, 180, 88, 0.07); color: #e5c57e; }
.state-pill.error { border-color: rgba(224, 124, 112, 0.45); background: rgba(224, 124, 112, 0.07); color: #eaa69e; }
.state-pill.info { border-color: rgba(120, 169, 207, 0.42); background: rgba(120, 169, 207, 0.07); color: #a9cae2; }

.table-wrap { overflow-x: auto; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-strong);
  color: #756f65;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.admin-table td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tbody tr:hover { background: rgba(255,255,255,0.018); }
.admin-table strong, .admin-table small { display: block; }
.admin-table small { margin-top: 2px; color: #756f65; }
.admin-table select { min-width: 138px; min-height: 34px; padding: 5px 8px; font-size: 13px; }
.admin-table input[type="number"] { min-width: 110px; width: 100%; max-width: 150px; min-height: 34px; padding: 5px 8px; font-size: 13px; }
.fob-customized-tag { color: var(--brass); font-weight: 700; }
.table-actions { display: flex; gap: 6px; white-space: nowrap; }
.table-actions button, .table-actions a { min-height: 31px; padding: 5px 8px; border: 1px solid var(--line); color: var(--paper-muted); font-size: 12px; text-decoration: none; }
.table-actions button:hover, .table-actions a:hover { border-color: var(--brass); color: var(--brass-soft); }

.user-cell { display: flex; align-items: center; gap: 10px; }
.user-avatar { display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; border: 1px solid var(--line); color: var(--brass-soft); font-size: 11px; font-weight: 800; }

.role-card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
.role-card { min-height: 150px; padding: 18px; border: 1px solid var(--line); background: #171612; }
.role-card span { color: var(--brass); font: 700 11px/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: 0.1em; }
.role-card h3 { margin: 13px 0 7px; font-family: Georgia, "Noto Serif SC", serif; font-size: 19px; font-weight: 500; }
.role-card p { margin: 0; color: var(--paper-muted); font-size: 14px; }
.role-card small { display: block; margin-top: 13px; color: #777168; }

.permission-matrix th:first-child, .permission-matrix td:first-child { position: sticky; left: 0; min-width: 180px; background: #171612; }
.permission-check { color: var(--green); font-size: 17px; text-align: center; }
.user-permission-group-title { grid-column: 1 / -1; padding-top: 12px; color: var(--green); font-size: 14px; }
.permission-dash { color: #49453f; text-align: center; }

.settings-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(290px, 0.75fr); gap: 16px; }
.settings-form { padding: 20px; border: 1px solid var(--line); background: #171612; }
.settings-form h3 { margin: 0 0 5px; font-family: Georgia, "Noto Serif SC", serif; font-size: 21px; font-weight: 500; }
.settings-form > p { margin: 0 0 22px; color: var(--paper-muted); }
.settings-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.settings-form .full { grid-column: 1 / -1; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.settings-actions .primary-action { width: auto; min-height: 38px; }

.notice-panel { padding: 18px; border: 1px solid var(--line); background: #171612; }
.notice-panel + .notice-panel { margin-top: 16px; }
.notice-panel span { color: var(--brass); font: 700 11px/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: 0.13em; }
.notice-panel h3 { margin: 10px 0 8px; font-family: Georgia, "Noto Serif SC", serif; font-size: 18px; font-weight: 500; }
.notice-panel p { margin: 0; color: var(--paper-muted); font-size: 14px; }
.notice-panel code { display: block; margin-top: 12px; padding: 10px; overflow-wrap: anywhere; border: 1px solid var(--line); background: #11100d; color: #bfb7ab; font: 13px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; }

.test-result { margin-top: 16px; padding: 12px; border-left: 2px solid var(--line-strong); background: #12110e; }
.test-result.ok { border-color: var(--green); }
.test-result.error { border-color: var(--red); }
.test-result strong { display: block; margin-bottom: 4px; }
.test-result p { margin: 0; color: var(--paper-muted); font-size: 14px; overflow-wrap: anywhere; }

.switch-label { display: flex !important; align-items: center; justify-content: space-between; min-height: 44px; padding: 8px 0; }
.switch-label input { width: 42px; min-height: 22px; accent-color: var(--brass); }

.audit-event { display: inline-flex; padding: 4px 7px; border: 1px solid var(--line); color: var(--brass-soft); font: 700 11px/1.25 ui-monospace, SFMono-Regular, Consolas, monospace; }
.audit-meta { max-width: 440px; color: #817a70; font: 12px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }

.admin-dialog {
  width: min(680px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: #191814;
  color: var(--paper);
  box-shadow: var(--shadow);
}

#userDialog { width: min(920px, calc(100vw - 32px)); max-height: calc(100vh - 36px); }
#userDialog form { max-height: calc(100vh - 40px); overflow-y: auto; }
.user-permission-editor { grid-column: 1 / -1; min-width: 0; margin: 4px 0 6px; border: 1px solid var(--line); background: #12110e; padding: 14px; }
.user-permission-editor legend { color: var(--brass); padding: 0 7px; font-size: 12px; font-weight: 800; letter-spacing: .08em; }
.permission-editor-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.permission-editor-head div { display: grid; gap: 2px; }
.permission-editor-head strong { color: var(--paper); font-size: 14px; }
.permission-editor-head small { color: #756f65; font-size: 11px; }
.permission-editor-head button { min-height: 30px; padding: 5px 8px; border: 1px solid var(--line); color: var(--paper-muted); font-size: 12px; }
.user-permission-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; }
.user-permission-grid label { display: flex; align-items: flex-start; gap: 7px; min-height: 46px; margin: 0; border: 1px solid #302d27; background: #191814; padding: 8px; cursor: pointer; }
.user-permission-grid input { width: 15px; min-height: 15px; margin: 1px 0 0; accent-color: var(--brass); }
.user-permission-grid span { display: grid; gap: 2px; color: var(--paper); font-size: 12px; }
.user-permission-grid small { color: #756f65; font: 10px/1.35 ui-monospace,SFMono-Regular,Consolas,monospace; }
.user-permission-editor.is-locked { opacity: .62; }

.admin-dialog.narrow { width: min(500px, calc(100vw - 32px)); }
.admin-dialog::backdrop { background: rgba(5, 5, 4, 0.78); backdrop-filter: blur(3px); }
.admin-dialog form { padding: 0 22px 20px; }
.admin-dialog header { display: flex; align-items: center; justify-content: space-between; margin: 0 -22px 22px; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.admin-dialog header small { color: var(--brass); font-size: 10px; font-weight: 800; letter-spacing: 0.15em; }
.admin-dialog header h2 { margin: 3px 0 0; font-family: Georgia, "Noto Serif SC", serif; font-size: 22px; font-weight: 500; }
.admin-dialog header button { width: 34px; min-height: 34px; padding: 0; border: 0; font-size: 24px; }
.dialog-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.admin-dialog footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.dialog-note { margin: 2px 0 0; padding: 10px; border-left: 2px solid var(--brass); background: rgba(201,165,104,0.06); color: var(--paper-muted); font-size: 13px; }
.password-target { padding: 10px 12px; border: 1px solid var(--line); background: #12110e; color: var(--paper-muted); }
.password-target strong { color: var(--paper); }

.admin-toast-region { position: fixed; z-index: 50; right: 22px; bottom: 22px; display: grid; width: min(380px, calc(100vw - 44px)); gap: 8px; }
.admin-toast { padding: 12px 14px; border: 1px solid var(--line-strong); border-left: 3px solid var(--green); background: #211f19; box-shadow: 0 14px 36px rgba(0,0,0,.35); color: var(--paper); font-size: 14px; animation: toast-in 180ms ease-out; }
.admin-toast.error { border-left-color: var(--red); }
.admin-toast.warn { border-left-color: var(--amber); }
.danger-action {
  border-color: #b55a50;
  background: rgba(181, 90, 80, 0.1);
  color: #f0a39a;
}
.danger-action:hover,
.danger-action:focus-visible {
  border-color: #dc756a;
  background: rgba(181, 90, 80, 0.2);
  color: #ffd0ca;
  outline: none;
}
.danger-panel { border-color: rgba(181, 90, 80, 0.55); }
.danger-panel header span { color: #d97a70; }
.danger-panel-body { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 20px; }
.danger-panel-body strong { color: var(--paper); }
.danger-panel-body p { max-width: 820px; margin: 6px 0 0; color: var(--paper-muted); }
.danger-note { border-left-color: #b55a50; background: rgba(181, 90, 80, 0.08); }
.danger-dialog header small { color: #d97a70; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1100px) {
  .auth-shell { grid-template-columns: 1fr 420px; }
  .manifesto-copy h1 { font-size: 62px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-card:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .metric-card:nth-child(4) { border-top: 1px solid var(--line); }
  .control-panel.narrow { grid-column: span 6; }
  .role-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .danger-panel-body { align-items: stretch; flex-direction: column; }
  .auth-shell { display: block; padding: 24px 0; }
  .auth-manifesto { min-height: auto; padding: 26px 26px 42px; border-right: 0; }
  .manifesto-copy { margin: 70px 0; }
  .manifesto-copy h1 { font-size: clamp(48px, 14vw, 72px); }
  .auth-principles { grid-template-columns: 1fr; }
  .auth-principles article + article { padding-left: 0; border-top: 1px solid var(--line); border-left: 0; }
  .auth-card { width: calc(100% - 32px); }
  .admin-app { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; height: auto; }
  .admin-brand, .system-context { display: none; }
  #adminNav { display: flex; padding: 8px; overflow-x: auto; border-bottom: 1px solid var(--line); }
  .admin-nav-button { grid-template-columns: 20px auto; min-width: max-content; }
  .sidebar-foot { grid-template-columns: 1fr 1fr; margin: 0; padding: 8px; border-top: 0; border-bottom: 1px solid var(--line); }
  .admin-topbar { min-height: 78px; padding: 14px 18px; }
  .admin-topbar h1 { font-size: 23px; }
  .admin-identity div { display: none; }
  .admin-content { padding: 24px 16px 50px; }
  .view-lead { align-items: start; flex-direction: column; }
  .control-panel, .control-panel.narrow { grid-column: 1 / -1; }
  .settings-layout { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .auth-principles { display: none; }
  .manifesto-copy { margin: 55px 0 10px; }
  .manifesto-copy > p:last-child { font-size: 16px; }
  .auth-card { padding-right: 20px; padding-left: 20px; }
  .auth-card > header { margin-right: -20px; margin-left: -20px; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card + .metric-card { border-top: 1px solid var(--line); border-left: 0; }
  .role-card-grid { grid-template-columns: 1fr; }
  .settings-columns, .dialog-grid, .user-permission-grid { grid-template-columns: 1fr; }
  .admin-topbar { align-items: start; }
  .admin-identity > span { width: 34px; height: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ========================================================================== 
   Mobile administration system
   ========================================================================== */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

button,
a,
input,
select,
summary {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@media (max-width: 820px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }

  body {
    min-width: 0;
  }

  .admin-app {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    grid-template-columns: minmax(0, 1fr);
  }

  .auth-shell {
    min-height: 100dvh;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  }

  .auth-manifesto {
    padding-top: calc(22px + env(safe-area-inset-top));
  }

  .auth-card {
    max-width: 560px;
  }

  input,
  select {
    min-height: 44px;
    font-size: 16px;
  }

  button,
  a,
  summary {
    min-height: 44px;
  }

  .admin-sidebar {
    position: sticky;
    top: 0;
    z-index: 60;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding-top: env(safe-area-inset-top);
    overflow: hidden;
    box-shadow: 0 8px 22px rgba(0, 0, 0, .28);
  }

  #adminNav {
    flex-wrap: nowrap;
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  #adminNav::-webkit-scrollbar {
    display: none;
  }

  .admin-nav-button {
    min-height: 44px;
    scroll-snap-align: start;
  }

  .sidebar-foot {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  .admin-topbar {
    gap: 10px;
  }

  .admin-topbar h1 {
    min-width: 0;
    font-size: clamp(21px, 6.5vw, 26px);
    overflow-wrap: anywhere;
  }

  .admin-content {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding-bottom: calc(48px + env(safe-area-inset-bottom));
  }

  .admin-stage,
  .view-lead,
  .view-lead > div,
  .view-lead p,
  .admin-grid,
  .view-actions,
  .control-panel,
  .settings-layout,
  .settings-columns,
  .role-card-grid,
  .metric-grid {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .view-lead p {
    overflow-wrap: anywhere;
  }

  .admin-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .control-panel,
  .control-panel.narrow,
  .control-panel.wide {
    grid-column: 1;
  }

  .view-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .view-actions > * {
    width: 100%;
  }

  .control-panel > header {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 6px 12px;
  }

  .status-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .status-row strong {
    text-align: left;
    overflow-wrap: anywhere;
  }

  .table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  .admin-table {
    min-width: 720px;
  }

  .table-actions button,
  .table-actions a {
    min-height: 38px;
  }

  .admin-toast-region {
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    left: 12px;
    width: auto;
  }
}

@media (max-width: 560px) {
  .auth-manifesto {
    padding: calc(18px + env(safe-area-inset-top)) 18px 26px;
  }

  .back-link {
    display: inline-flex;
    align-items: center;
  }

  .brand-mark {
    margin-bottom: 28px;
  }

  .manifesto-copy {
    margin: 38px 0 0;
  }

  .manifesto-copy h1 {
    font-size: clamp(42px, 15vw, 62px);
  }

  .auth-card {
    width: calc(100% - 20px);
    margin: 10px auto 24px;
  }

  .admin-content {
    padding: 20px 10px calc(40px + env(safe-area-inset-bottom));
  }

  .admin-topbar {
    min-height: 70px;
    padding: 12px 10px;
  }

  .metric-card {
    min-height: 116px;
    padding: 18px;
  }

  .view-actions {
    grid-template-columns: 1fr;
  }

  .control-panel > header,
  .panel-body {
    padding-right: 12px;
    padding-left: 12px;
  }

  .permission-editor-head {
    align-items: stretch;
    flex-direction: column;
  }

  .permission-editor-head button {
    width: 100%;
    min-height: 44px;
  }

  .user-permission-grid label {
    min-height: 52px;
  }

  .admin-dialog {
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  #userDialog,
  .admin-dialog.narrow {
    width: 100%;
    max-width: none;
    max-height: 100dvh;
  }

  #userDialog form,
  .admin-dialog form {
    height: 100%;
    max-height: 100dvh;
    overflow-y: auto;
    padding: 0 16px calc(18px + env(safe-area-inset-bottom));
  }

  .admin-dialog header {
    position: sticky;
    top: 0;
    z-index: 2;
    margin: 0 -16px 18px;
    padding: calc(14px + env(safe-area-inset-top)) 14px 14px;
    background: #191814;
  }

  .admin-dialog header button {
    width: 44px;
    min-height: 44px;
  }

  .admin-dialog footer {
    position: sticky;
    bottom: calc((18px + env(safe-area-inset-bottom)) * -1);
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr;
    margin: 18px -16px 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: #191814;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, .24);
  }

  .admin-dialog footer button {
    width: 100%;
  }
}

/* ========================================================================== 
   Sage green administration system
   ========================================================================== */
body {
  background:
    radial-gradient(circle at 84% 0, rgba(120, 163, 108, .13), transparent 30%),
    #f1f7ef;
  color: #173126;
}

.ambient-grid {
  opacity: .32;
  outline-color: rgba(50, 99, 68, .08);
  background-image:
    linear-gradient(rgba(69, 116, 78, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(69, 116, 78, .035) 1px, transparent 1px);
  background-size: 36px 36px;
}

.auth-manifesto {
  border-right-color: #315b47;
  background:
    radial-gradient(circle at 18% 8%, rgba(152, 192, 135, .16), transparent 30%),
    #173d2e;
  color: #edf7ee;
}

.back-link,
.manifesto-copy > p:last-child,
.auth-principles small {
  color: #b8cdbd;
}

.brand-mark span {
  border-color: #91b87f;
  color: #d9edd2;
}

.auth-principles {
  border-color: rgba(210, 232, 205, .2);
}

.auth-principles article + article {
  border-color: rgba(210, 232, 205, .16);
}

.auth-principles span,
.eyebrow,
.form-intro span {
  color: #65975a;
}

.auth-manifesto .eyebrow,
.auth-principles span {
  color: #a9ca99;
}

.auth-card {
  border-color: #b8cdb3;
  background: #fbfefa;
  color: #173126;
}

.auth-card > header {
  border-bottom-color: #c5d7c0;
  background: #e7f1e3;
}

.auth-card > header small,
.auth-card > footer,
.form-intro p {
  color: #607269;
}

.auth-card form label,
.admin-dialog label,
.settings-form label {
  color: #496156;
}

input,
select {
  border-color: #afc5aa;
  background: #fbfefa;
  color: #173126;
}

input::placeholder {
  color: #87988e;
}

input:focus,
select:focus {
  border-color: #6f9d67;
  box-shadow: 0 0 0 3px rgba(105, 151, 96, .17);
}

button {
  border-color: #a9c0a4;
  color: #304b3e;
}

button:hover {
  border-color: #557f51;
  background: #e3eee0;
  color: #356346;
}

.primary-action,
.primary-action:hover {
  border-color: #557f51;
  background: #557f51;
  color: #fff;
}

.primary-action:hover {
  background: #4d7b49;
}

.status-dot,
.live-indicator {
  box-shadow: 0 0 0 5px rgba(79, 141, 93, .12);
}

.admin-sidebar {
  border-right-color: #315b47;
  background:
    radial-gradient(circle at 22% 0, rgba(151, 194, 133, .13), transparent 28%),
    #173d2e;
  color: #e6f2e8;
}

.admin-monogram {
  border-color: #91b87f;
  color: #d9edd2;
}

.admin-brand small,
.system-context small,
.admin-nav-button,
.sidebar-foot a,
.sidebar-foot button {
  color: #adc4b3;
}

.system-context,
.sidebar-foot,
.sidebar-foot a,
.sidebar-foot button {
  border-color: rgba(205, 228, 200, .18);
}

.admin-nav-button span {
  color: #7f9e88;
}

.admin-nav-button:hover,
.admin-nav-button.active {
  background: rgba(139, 182, 122, .15);
  color: #f2faf1;
}

.admin-nav-button.active span,
.admin-nav-button.active::before {
  color: #a8cb96;
  background: #a8cb96;
}

.sidebar-foot a:hover,
.sidebar-foot button:hover {
  border-color: #88ad78;
  background: rgba(139, 182, 122, .12);
  color: #fff;
}

.admin-stage {
  background: #f1f7ef;
  color: #173126;
}

.admin-topbar {
  border-bottom-color: #c5d7c0;
  background: rgba(247, 251, 245, .94);
  box-shadow: 0 8px 28px rgba(36, 79, 52, .07);
}

.admin-identity > span,
.user-avatar {
  border-color: #abc3a6;
  background: #e7f1e3;
  color: #477b49;
}

.metric-grid {
  border-color: #b7ccb2;
  background: #e7f1e3;
}

.metric-card {
  background: #f7fbf5;
}

.metric-card + .metric-card {
  border-color: #c5d7c0;
}

.metric-card strong {
  color: #214b36;
}

.metric-card small,
.control-panel > header span,
.admin-table th,
.admin-table small,
.role-card small {
  color: #667970;
}

.control-panel,
.role-card,
.settings-form,
.notice-panel {
  border-color: #c5d7c0;
  background: #fbfefa;
  box-shadow: 0 12px 28px rgba(31, 76, 48, .06);
}

.control-panel > header {
  border-bottom-color: #c5d7c0;
  background: #eaf3e7;
}

.status-row,
.admin-table th,
.admin-table td,
.settings-actions {
  border-color: #d0dfcc;
}

.admin-table tbody tr:hover {
  background: #edf5ea;
}

.permission-matrix th:first-child,
.permission-matrix td:first-child {
  background: #fbfefa;
}

.table-actions button,
.table-actions a {
  border-color: #b8cdb3;
  color: #4d6559;
}

.table-actions .danger-action {
  border-color: #d7aaa4;
  background: #fff8f7;
  color: #9c3a32;
}

.table-actions .danger-action:hover,
.table-actions .danger-action:focus-visible {
  border-color: #952f27;
  background: #f9e7e4;
  color: #7f241d;
  outline: none;
}

.notice-panel code,
.test-result {
  border-color: #c5d7c0;
  background: #eaf3e7;
  color: #365143;
}

.admin-dialog {
  border-color: #9fb99a;
  background: #fbfefa;
  color: #173126;
}

.admin-dialog header,
.admin-dialog footer {
  border-color: #c5d7c0;
  background: #e7f1e3;
}

.admin-dialog header small,
.user-permission-editor legend,
.permission-editor-head strong {
  color: #477b49;
}

.user-permission-editor,
.user-permission-grid label,
.password-target {
  border-color: #c5d7c0;
  background: #f1f7ef;
}

.permission-editor-head small,
.user-permission-grid small,
.dialog-note,
.password-target {
  color: #607269;
}

.user-permission-grid span {
  color: #173126;
}

.permission-editor-head button {
  border-color: #aac2a5;
  color: #496156;
}

.dialog-note {
  border-left-color: #6f9d67;
  background: rgba(111, 157, 103, .1);
}

.admin-toast {
  border-color: #8eab88;
  border-left-color: #4f8d5d;
  background: #214b36;
  color: #edf7ee;
}

.state-pill.ok {
  border-color: rgba(79,141,93,.42);
  background: rgba(79,141,93,.1);
  color: #397048;
}

.state-pill.warn {
  color: #8b5d22;
}

.state-pill.error {
  color: #98443e;
}

.state-pill.info {
  color: #3f687a;
}

@media (max-width: 820px) {
  .admin-sidebar {
    background: #173d2e;
  }
}

@media (max-width: 560px) {
  .admin-dialog header,
  .admin-dialog footer {
    background: #e7f1e3;
  }
}

/* Personnel credentials */
.staff-metric-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.staff-person-form {
  margin-bottom: 24px;
}

.staff-person-form > header h3,
.staff-person-form > header p,
.staff-certificate-upload h4 {
  margin: 0;
}

.staff-person-form > header p {
  margin-top: 6px;
  color: #667970;
  font-size: 12px;
}

.staff-role-field {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
  border: 1px solid #c5d7c0;
  border-radius: 8px;
  padding: 14px;
}

.staff-role-field legend {
  padding: 0 6px;
  color: #667970;
  font-size: 12px;
}

.staff-role-field label {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  border: 1px solid #c5d7c0;
  border-radius: 999px;
  background: #f1f7ef;
  padding: 7px 12px;
}

.staff-role-field input {
  width: 16px;
  height: 16px;
}

.staff-person-list {
  display: grid;
  gap: 22px;
}

.staff-person-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.staff-person-card > header h3 {
  margin: 5px 0 8px;
}

.staff-role-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.staff-role-badge {
  border: 1px solid #aac2a5;
  border-radius: 999px;
  background: #edf5ea;
  padding: 4px 8px;
  color: #477b49;
  font-size: 11px;
}

.staff-aliases {
  margin: 0;
  border-bottom: 1px solid #d0dfcc;
  padding: 12px 18px;
  color: #667970;
  font-size: 12px;
}

.staff-person-certificates {
  padding: 18px;
}

.staff-certificate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}

.staff-certificate-card {
  display: grid;
  grid-template-columns: minmax(120px, .7fr) minmax(0, 1.3fr);
  overflow: hidden;
  border: 1px solid #c5d7c0;
  border-radius: 8px;
  background: #f7fbf5;
}

.staff-certificate-image {
  display: grid;
  min-height: 170px;
  place-items: center;
  border-right: 1px solid #c5d7c0;
  background: #e7f1e3;
}

.staff-certificate-image img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 220px;
  object-fit: contain;
}

.staff-certificate-copy {
  min-width: 0;
  padding: 15px;
}

.staff-certificate-copy > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.staff-certificate-copy h4 {
  margin: 13px 0 8px;
  overflow-wrap: anywhere;
}

.staff-certificate-copy p {
  margin: 5px 0;
  color: #607269;
  font-size: 12px;
  line-height: 1.55;
}

.staff-certificate-copy button {
  margin-top: 12px;
}

.staff-certificate-empty {
  border: 1px dashed #b8cdb3;
  border-radius: 8px;
  padding: 24px;
  color: #667970;
  text-align: center;
}

.staff-certificate-upload {
  border-top: 1px solid #d0dfcc;
  background: #f1f7ef;
  padding: 18px;
}

.staff-certificate-upload h4 {
  margin-bottom: 14px;
}

.staff-certificate-upload label small {
  margin-top: 5px;
  color: #667970;
  font-size: 11px;
}

.staff-upload-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  border: 1px solid #c5d7c0;
  border-radius: 8px;
  background: #fbfefa;
  padding: 10px;
  color: #607269;
  font-size: 12px;
}

.staff-upload-preview[hidden] {
  display: none;
}

.staff-upload-preview img {
  width: 120px;
  height: 82px;
  object-fit: contain;
  background: #e7f1e3;
}

@media (max-width: 720px) {
  .staff-metric-grid,
  .staff-certificate-grid {
    grid-template-columns: 1fr;
  }

  .staff-person-card > header,
  .staff-certificate-card {
    grid-template-columns: 1fr;
  }

  .staff-person-card > header {
    align-items: flex-start;
    flex-direction: column;
  }

  .staff-certificate-image {
    border-right: 0;
    border-bottom: 1px solid #c5d7c0;
  }
}

/* Database data-integrity diagnostic */
.diagnostic-panel {
  margin-top: 22px;
}

.diag-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  border-bottom: 1px solid var(--line);
  background: var(--line);
}

.diag-summary .metric-card {
  border: 0;
  background: #171612;
}

.diag-section {
  padding: 18px 16px;
  border-bottom: 1px solid var(--line);
}

.diag-section:last-child {
  border-bottom: 0;
}

.diag-section h4 {
  margin: 0 0 12px;
  color: var(--brass);
  font: 700 11px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.diag-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.diag-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid #3a352d;
  border-radius: 999px;
  background: #1e1b16;
  padding: 4px 12px;
  color: #d8c8a8;
  font: 700 11px ui-monospace, SFMono-Regular, Consolas, monospace;
}

.diag-chip.muted {
  border-color: #2c2822;
  color: #6d675f;
}

.diag-count-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.diag-count-item {
  display: grid;
  gap: 3px;
  border: 1px solid #2c2822;
  border-radius: 6px;
  background: #131210;
  padding: 11px 12px;
}

.diag-count-item span {
  color: #d8c8a8;
  font-size: 12px;
}

.diag-count-item strong {
  color: #f1eadf;
  font: 700 20px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.diag-count-item small {
  color: #6d675f;
  font: 600 10px ui-monospace, SFMono-Regular, Consolas, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diag-count-item.missing strong {
  color: #d97a70;
}

.diag-issues {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.diag-issue {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  border: 1px solid #2c2822;
  border-radius: 6px;
  background: #131210;
  padding: 11px 13px;
}

.diag-issue strong {
  margin-top: 1px;
  border-radius: 4px;
  padding: 2px 7px;
  font: 700 10px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.diag-issue span {
  color: #c9bda8;
  font-size: 12px;
  line-height: 1.6;
}

.diag-issue.diag-ok strong {
  background: rgba(79, 141, 93, 0.16);
  color: #7fbf8a;
}

.diag-issue.diag-warning strong {
  background: rgba(181, 135, 79, 0.16);
  color: #d8b077;
}

.diag-issue.diag-error strong {
  background: rgba(181, 90, 80, 0.18);
  color: #e09180;
}

.diag-note {
  margin: 10px 0 0;
  color: #6d675f;
  font-size: 11px;
  line-height: 1.6;
}

@media (max-width: 560px) {
  .diag-summary {
    grid-template-columns: 1fr;
  }

  .diag-count-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .diag-issue {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}
