:root {
  --bg: #f4f0e8;
  --surface: #fffdf8;
  --surface-2: #f8f4ec;
  --text: #201a1c;
  --muted: #6d6664;
  --primary: #4b2e47;
  --primary-2: #3a2238;
  --accent: #c9a052;
  --border: rgba(32, 26, 28, .07);
  --shadow: 0 16px 40px rgba(32, 26, 28, .08);
}

* { box-sizing: border-box; }
body { min-height: 100vh; margin: 0; background: var(--bg); color: var(--text); font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.5; }
button, input { font: inherit; }
a { color: inherit; text-decoration: none; }
code { border-radius: 5px; padding: 2px 6px; background: rgba(75, 46, 71, .09); color: var(--primary); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; background: radial-gradient(circle at 18% 18%, rgba(201, 160, 82, .18), transparent 28%), radial-gradient(circle at 86% 28%, rgba(126, 74, 116, .3), transparent 30%), linear-gradient(135deg, #160f17, #2b1b2a 56%, #4b2e47); }
.login-panel { width: min(100%, 520px); border: 1px solid rgba(255, 255, 255, .22); border-radius: 5px; background: linear-gradient(180deg, var(--surface-2), var(--surface)); box-shadow: 0 22px 70px rgba(0, 0, 0, .28); padding: clamp(22px, 4vw, 38px); }
.admin-brand { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.admin-mark { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 5px; background: var(--primary); color: #fffdf8; font-weight: 600; letter-spacing: .04em; box-shadow: 0 10px 24px rgba(75, 46, 71, .25); flex: 0 0 auto; }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: clamp(1.85rem, 4vw, 2.65rem); line-height: 1.05; }
h2 { margin-bottom: 8px; font-size: 1.1rem; }
p { margin-bottom: 0; color: var(--muted); }

.admin-alert { display: grid; gap: 6px; border: 1px solid var(--border); border-radius: 5px; background: rgba(255, 253, 248, .72); padding: 16px; color: var(--muted); }
.alert-title { color: var(--text); font-weight: 500; }
.admin-alert-error { margin-bottom: 14px; border-color: rgba(164, 60, 52, .12); background: rgba(164, 60, 52, .09); color: #7a2f2a; }
.admin-login { display: grid; gap: 14px; }
.admin-login label { display: grid; gap: 7px; color: var(--muted); font-size: .92rem; }
.admin-login input { width: 100%; min-height: 42px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); color: var(--text); padding: 10px 12px; outline: 0; }
.admin-login input:focus { border-color: rgba(75, 46, 71, .42); box-shadow: 0 0 0 3px rgba(75, 46, 71, .12); }
.admin-login button { min-height: 42px; border: 0; border-radius: 5px; background: var(--primary); color: #fffdf8; font-weight: 600; cursor: pointer; }
.admin-login button:hover { background: var(--primary-2); }

.admin-layout { min-height: 100vh; display: grid; grid-template-columns: 220px minmax(0, 1fr); }

.admin-main { min-width: 0; padding: 18px 22px 24px; }
.page-title { margin: 0 0 14px; font-size: clamp(1.65rem, 2.4vw, 2.2rem); line-height: 1.1; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card { display: grid; gap: 8px; min-height: 118px; align-content: center; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); box-shadow: var(--shadow); padding: 18px; }
.stat-card span { color: var(--muted); font-size: .9rem; }

.work-panel { display: grid; gap: 18px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); box-shadow: var(--shadow); padding: 20px; }
.module-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.module-list a { display: grid; gap: 5px; min-height: 96px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface-2); padding: 14px; }
.module-list a:hover { border-color: rgba(75, 46, 71, .18); }
.module-list span { color: var(--muted); font-size: .92rem; }
.plan-list { display: grid; gap: 9px; margin: 0; padding-left: 20px; color: var(--muted); }
.plan-list li::marker { color: var(--primary); }

@media (max-width: 640px) {
  .admin-brand { align-items: flex-start; }
  .stat-grid, .module-list { grid-template-columns: 1fr; }
}


.table-panel { display: grid; gap: 14px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); box-shadow: var(--shadow); padding: 16px; }
.admin-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.admin-filters label { display: grid; gap: 6px; min-width: min(100%, 260px); color: var(--muted); font-size: .88rem; }
.admin-filters input, .admin-filters select { min-height: 40px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); color: var(--text); padding: 9px 11px; outline: 0; }
.admin-filters input:focus, .admin-filters select:focus { border-color: rgba(75, 46, 71, .42); box-shadow: 0 0 0 3px rgba(75, 46, 71, .12); }
.admin-filters button { min-height: 40px; border: 0; border-radius: 5px; background: var(--primary); color: #fffdf8; padding: 9px 14px; font-weight: 600; cursor: pointer; }
.quiet-link { min-height: 40px; display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 5px; padding: 8px 12px; color: var(--muted); }
.table-meta { color: var(--muted); font-size: .92rem; }
.table-meta .meta-value { color: var(--text); font-weight: 500; }
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 5px; }
.admin-table { width: 100%; min-width: 980px; border-collapse: collapse; background: var(--surface); font-size: .92rem; }
.admin-table th, .admin-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.admin-table th { background: var(--surface-2); color: var(--muted); font-size: .78rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table .name-link span { color: inherit; }
.subtext { display: block; margin-top: 2px; color: var(--muted); font-size: .82rem; }
.quote-cell { max-width: 520px; color: var(--text); line-height: 1.45; }
.status-pill { display: inline-flex; align-items: center; min-height: 24px; border-radius: 5px; padding: 3px 8px; background: rgba(109, 102, 100, .12); color: var(--muted); font-size: .78rem; font-weight: 500; white-space: nowrap; }
.status-pill.is-on { background: rgba(70, 130, 92, .14); color: #346c4b; }
.status-pill.is-off { background: rgba(164, 60, 52, .12); color: #8a3731; }
.row-action { display: inline-flex; min-height: 30px; align-items: center; border: 1px solid var(--border); border-radius: 5px; padding: 5px 10px; color: var(--primary); font-weight: 500; }
.row-action[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.empty-cell { padding: 24px !important; color: var(--muted); text-align: center !important; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; color: var(--muted); }
.pager a { min-height: 36px; display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 5px; padding: 7px 11px; color: var(--primary); font-weight: 500; }
.pager a[aria-disabled="true"] { color: var(--muted); opacity: .45; pointer-events: none; }

@media (max-width: 640px) {
  .admin-filters { display: grid; }
  .admin-filters label, .admin-filters button, .quiet-link { width: 100%; }
  .pager { justify-content: stretch; }
  .pager a, .pager span { flex: 1; justify-content: center; text-align: center; }
}


.admin-alert-success { margin-bottom: 14px; border-color: rgba(70, 130, 92, .18); background: rgba(70, 130, 92, .1); color: #346c4b; }
.edit-panel { display: grid; gap: 14px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); box-shadow: var(--shadow); padding: 16px; }
.edit-toolbar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; }
.edit-form { display: grid; gap: 18px; }
.portrait-preview { display: flex; align-items: center; gap: 14px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface-2); padding: 14px; }
.portrait-preview img, .portrait-preview > span { width: 84px; height: 84px; border-radius: 5px; object-fit: cover; background: rgba(75, 46, 71, .08); }
.portrait-preview > span { display: grid; place-items: center; color: var(--muted); font-size: .82rem; text-align: center; }
.portrait-preview .preview-title { display: block; font-size: 1.1rem; }
.portrait-preview small { display: block; color: var(--muted); margin-top: 3px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 7px; color: var(--muted); font-size: .88rem; }
.field-wide { grid-column: 1 / -1; }
.field input, .field textarea, .field select { width: 100%; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); color: var(--text); padding: 10px 12px; outline: 0; }
.field input, .field select { min-height: 42px; }
.field textarea { resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: rgba(75, 46, 71, .42); box-shadow: 0 0 0 3px rgba(75, 46, 71, .12); }
.field input[readonly] { background: var(--surface-2); color: var(--muted); }
.edit-actions { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 92%, transparent); padding-top: 14px; }
.edit-actions button { min-height: 42px; border: 0; border-radius: 5px; background: var(--primary); color: #fffdf8; padding: 9px 15px; font-weight: 600; cursor: pointer; }
.edit-actions button:hover { background: var(--primary-2); }

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .portrait-preview { align-items: flex-start; }
}

.filter-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid rgba(75, 46, 71, .10); border-radius: 5px; background: rgba(75, 46, 71, .07); padding: 12px 14px; color: var(--muted); }
.filter-banner .inline-emphasis { color: var(--text); }
.filter-banner a { color: var(--primary); font-weight: 500; }
.filter-banner.is-warning { border-color: rgba(164, 60, 52, .14); background: rgba(164, 60, 52, .08); }

.count-link { color: var(--primary); font-weight: 500; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.count-link:hover { color: var(--primary-2); }

.name-link { color: var(--text); }
.name-link span { display: inline; color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.name-link:hover { color: var(--primary); }

.quote-edit-link { color: var(--text); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.quote-edit-link:hover { color: var(--primary); }
.quote-preview { display: grid; gap: 10px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface-2); padding: 14px; }
.quote-preview blockquote { margin: 0; color: var(--text); font-size: 1.05rem; line-height: 1.55; }
.quote-preview .preview-title { display: block; }
.quote-preview small { display: block; color: var(--muted); margin-top: 3px; }
.stat-value { color: var(--primary); font-size: clamp(1.75rem, 3vw, 2.45rem); line-height: 1; font-weight: 500; }
.module-title { color: var(--text); font-weight: 500; }
.meta-value, .inline-emphasis, .preview-title { color: var(--text); font-weight: 500; }

/* Investor-ready admin grid refinement */
:root {
  --bg: #f6f7f6;
  --surface: #ffffff;
  --surface-2: #f8f8f7;
  --text: #242326;
  --muted: #737178;
  --primary: #514253;
  --primary-2: #3f3341;
  --accent: #b9964b;
  --border: rgba(36, 35, 38, .07);
  --shadow: 0 1px 2px rgba(36, 35, 38, .05), 0 12px 28px rgba(36, 35, 38, .06);
}

body { background: var(--bg); }
.admin-main { padding: 20px 24px 28px; }
.page-title { margin: 0 0 12px; font-size: 1.72rem; line-height: 1.16; letter-spacing: 0; font-weight: 500; }

.table-panel { border-radius: 5px; background: var(--surface); box-shadow: var(--shadow); }
.authors-panel { gap: 0; padding: 0; overflow: hidden; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
.authors-panel .admin-filters { display: grid; grid-template-columns: minmax(280px, 1fr) 180px auto auto; gap: 10px; align-items: end; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: #fbfbfa; padding: 14px; }
.authors-panel .admin-filters label { min-width: 0; gap: 5px; color: var(--muted); font-size: .75rem; font-weight: 400; letter-spacing: .02em; }
.authors-panel .admin-filters label:first-child { flex: initial; }
.authors-panel .admin-filters input, .authors-panel .admin-filters select { min-height: 38px; border-color: rgba(36, 35, 38, .09); border-radius: 5px; background: #fff; box-shadow: none; color: var(--text); }
.authors-panel .admin-filters input::placeholder { color: #9b99a0; }
.authors-panel .admin-filters button { min-height: 38px; border-radius: 5px; background: var(--primary); box-shadow: none; font-weight: 500; }
.authors-panel .quiet-link { min-height: 38px; border-radius: 5px; background: transparent; color: var(--muted); }
.authors-meta { min-height: 0; justify-self: stretch; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: #fff; padding: 9px 14px; color: var(--muted); font-size: .84rem; }
.authors-meta span { color: var(--text); font-weight: 500; }
.authors-panel .table-scroll { border: 0; border-radius: 0; background: #fff; box-shadow: none; }
.authors-panel .admin-table { min-width: 1040px; font-size: .9rem; }
.authors-panel .admin-table th { height: 38px; background: #fbfbfa; color: #76737b; font-size: .72rem; font-weight: 500; letter-spacing: .04em; border-bottom: 1px solid rgba(36, 35, 38, .06); }
.authors-panel .admin-table td { height: 62px; padding: 9px 12px; border-bottom: 1px solid rgba(36, 35, 38, .05); vertical-align: middle; }
.authors-panel .admin-table tbody tr:hover { background: #faf9f7; }
.authors-panel .admin-table tbody tr:last-child td { border-bottom: 0; }

.author-cell { min-width: 310px; gap: 10px; }
.author-avatar { width: 38px; height: 38px; flex-basis: 38px; border-radius: 5px; border-color: rgba(36, 35, 38, .07); background: #f0efed; color: #6f6470; font-size: .88rem; font-weight: 500; }
.author-name-link { color: #242326; font-size: .94rem; font-weight: 500; line-height: 1.2; }
.author-name-link:hover { color: var(--primary); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.author-id, .subtext { color: #8a878e; font-size: .76rem; font-weight: 400; }

.metric-link, .metric-muted { display: inline; min-width: 0; border: 0; border-radius: 0; background: transparent; padding: 0; color: var(--primary); }
.metric-link span:not(.metric-value), .metric-muted span:not(.metric-value) { display: none; }
.metric-link .metric-value, .metric-muted .metric-value { display: inline; color: var(--primary); font-size: .92rem; font-weight: 500; }
.metric-link:hover .metric-value { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.rank-badge { min-height: 0; border-radius: 0; background: transparent; color: #6f6c73; padding: 0; font-weight: 400; }
.text-pill { display: inline; min-height: 0; max-width: 180px; border: 0; border-radius: 0; background: transparent; padding: 0; color: #454348; font-weight: 400; }
.occupation-text { max-width: 340px; color: #6f6c73; line-height: 1.35; }
.status-pill { min-height: 24px; border: 1px solid rgba(36, 35, 38, .06); border-radius: 5px; background: #f7f7f6; color: #6d6971; padding: 2px 8px; font-size: .74rem; font-weight: 400; }
.status-pill.is-on { border-color: rgba(55, 128, 91, .12); background: #f1f7f3; color: #3e7456; }
.status-pill.is-off { border-color: rgba(164, 60, 52, .12); background: #fbf2f1; color: #95433c; }

.pager { padding: 12px 14px; border-top: 1px solid var(--border); background: #fbfbfa; }
.pager a { min-height: 34px; border-radius: 5px; background: #fff; color: var(--primary); font-weight: 400; }
.pager span { color: var(--muted); }

@media (max-width: 900px) {
  .authors-panel .admin-filters { grid-template-columns: 1fr 160px; }
}
@media (max-width: 640px) {
  .admin-main { padding: 16px 14px 24px; }
  .authors-panel .admin-filters { grid-template-columns: 1fr; }
  .author-cell { min-width: 260px; }
}
/* Sidebar refinement */
.admin-layout { grid-template-columns: 220px minmax(0, 1fr); }
.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #ffffff;
  color: var(--text);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  box-shadow: none;
}
.sidebar-brand {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 6px 12px;
  border-bottom: 1px solid rgba(36, 35, 38, .05);
  color: var(--text);
  font-weight: 400;
}
.sidebar-logo {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border: 1px solid rgba(36, 35, 38, .07);
  border-radius: 5px;
  background: #f7f7f6;
  color: var(--primary);
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .02em;
}
.sidebar-brand-copy { display: grid; gap: 0; min-width: 0; }
.sidebar-brand-name { color: var(--text); font-size: .9rem; font-weight: 500; line-height: 1.15; letter-spacing: 0; }
.sidebar-brand-sub { color: var(--muted); font-size: .7rem; font-weight: 400; line-height: 1.2; }
.sidebar-nav {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  padding: 0;
}
.sidebar-nav a {
  position: relative;
  min-height: 34px;
  display: flex;
  align-items: center;
  border-radius: 5px;
  padding: 7px 9px 7px 13px;
  color: #69666d;
  font-size: .86rem;
  font-weight: 400;
}
.sidebar-nav a::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 9px;
  bottom: 9px;
  width: 2px;
  border-radius: 2px;
  background: transparent;
}
.sidebar-nav a:hover { background: #f7f7f5; color: var(--text); }
.sidebar-nav a[aria-current="page"] { background: #f4f2f0; color: var(--text); }
.sidebar-nav a[aria-current="page"]::before { background: var(--primary); }
.sidebar-link-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding: 12px 6px 0;
  border-top: 1px solid rgba(36, 35, 38, .05);
  color: var(--muted);
  font-size: .78rem;
}
.sidebar-account { display: grid; gap: 1px; }
.sidebar-account-label { color: #9a979e; font-size: .68rem; line-height: 1.2; }
.sidebar-user { color: var(--text); font-weight: 400; line-height: 1.25; }
.sidebar-foot form { margin: 0; }
.sidebar-foot button {
  width: 100%;
  min-height: 32px;
  border: 1px solid rgba(36, 35, 38, .07);
  border-radius: 5px;
  background: #fff;
  color: #69666d;
  padding: 6px 9px;
  font-weight: 400;
  text-align: left;
}
.sidebar-foot button:hover { background: #f7f7f5; color: var(--text); }

@media (max-width: 640px) {
  .admin-layout { grid-template-columns: 204px minmax(0, 1fr); }
  .admin-sidebar { padding: 12px 8px; }
  .sidebar-brand-name { font-size: .86rem; }
  .sidebar-nav a { font-size: .82rem; min-height: 32px; }
}


.quote-taxonomy { display: flex; flex-wrap: wrap; gap: 5px; align-items: baseline; margin-top: 4px; color: var(--muted); font-size: .78rem; line-height: 1.35; }
.quote-mood-label { color: var(--text); font-weight: 600; }
.quote-mood-label::after { content: "·"; margin-left: 5px; color: #aaa6ad; font-weight: 400; }
.quote-taxonomy .quote-mood-label:last-child::after { content: ""; margin: 0; }


.author-list-cell { min-width: 150px; }
.author-list-cell .subtext { display: block; margin-top: 3px; }
.missing-author {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid rgba(177, 92, 48, .14);
  border-radius: 5px;
  background: #fff7f1;
  color: #8a4a28;
  padding: 3px 9px;
  font-size: .76rem;
  font-weight: 500;
}


.legacy-author-name {
  display: inline-block;
  color: var(--text);
  font-size: .88rem;
  font-weight: 500;
  line-height: 1.3;
}

/* Admin system polish */
:root {
  color-scheme: light;
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f3f2ef;
  --surface-3: #ebe9e5;
  --text: #242326;
  --muted: #737078;
  --soft: #918d95;
  --primary: #59455a;
  --primary-2: #453647;
  --accent: #b68b39;
  --border: rgba(36, 35, 38, .07);
  --border-strong: rgba(36, 35, 38, .07);
  --focus: rgba(89, 69, 90, .18);
  --danger-bg: #fff4f0;
  --success-bg: #eff8f2;
  --shadow: none;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171519;
  --surface: #211e24;
  --surface-2: #2a262d;
  --surface-3: #35313a;
  --text: #f3f0f2;
  --muted: #b4adb8;
  --soft: #928a97;
  --primary: #d9bddc;
  --primary-2: #ead7ec;
  --accent: #d6af5b;
  --border: rgba(243, 240, 242, .08);
  --border-strong: rgba(243, 240, 242, .12);
  --focus: rgba(217, 189, 220, .24);
  --danger-bg: rgba(180, 86, 67, .16);
  --success-bg: rgba(72, 148, 101, .16);
}

body { background: var(--bg); color: var(--text); }
.icon { width: 17px; height: 17px; flex: 0 0 17px; }

.admin-main { padding: 18px 22px 28px; }
.page-title { color: var(--text); font-size: 1.58rem; font-weight: 500; margin-bottom: 12px; }

.table-panel,
.authors-panel,
.edit-panel,
.work-panel,
.stat-card,
.quote-preview,
.portrait-preview,
.login-panel {
  box-shadow: none !important;
  border: 1px solid var(--border);
  background: var(--surface);
}

.authors-panel .admin-filters,
.authors-meta,
.pager,
.admin-table th,
.authors-panel .admin-table th,
.filter-banner,
.quote-preview,
.portrait-preview,
.module-list a {
  background: var(--surface-2);
}

.table-scroll,
.authors-panel .table-scroll,
.admin-table,
.authors-panel .table-scroll,
.authors-panel .admin-table,
.admin-table td,
.authors-panel .admin-table td {
  background: var(--surface);
  border-color: var(--border);
}

.admin-table tbody tr:hover,
.authors-panel .admin-table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 72%, transparent); }

button,
.quiet-link,
.pager a,
.row-action,
.admin-filters button,
.edit-actions button,
.admin-login button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  box-shadow: none;
  font-weight: 500;
  line-height: 1.1;
  cursor: pointer;
}

.admin-filters button,
.edit-actions button,
.admin-login button {
  background: var(--primary);
  color: var(--surface);
  border-color: var(--primary);
  padding: 8px 13px;
}

.admin-filters button:hover,
.edit-actions button:hover,
.admin-login button:hover { background: var(--primary-2); border-color: var(--primary-2); }

.quiet-link,
.pager a,
.row-action {
  background: var(--surface);
  color: var(--text);
  padding: 8px 12px;
}

.quiet-link:hover,
.pager a:hover,
.row-action:hover { background: var(--surface-2); color: var(--text); }

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px var(--focus) !important;
  border-color: var(--primary) !important;
}

.admin-sidebar {
  width: 220px;
  background: var(--surface);
  border-right-color: var(--border);
  padding: 14px 10px;
}
.sidebar-brand { border-bottom-color: var(--border); padding-bottom: 13px; }
.sidebar-logo { background: var(--surface-2); border-color: var(--border-strong); color: var(--primary); }
.sidebar-brand-name,
.sidebar-user { color: var(--text); }
.sidebar-brand-sub,
.sidebar-account-label,
.sidebar-nav a { color: var(--muted); }
.sidebar-nav { gap: 3px; }
.sidebar-nav a {
  min-height: 36px;
  gap: 9px;
  padding: 8px 10px;
  border: 1px solid transparent;
}
.sidebar-nav a::before { content: none; }
.sidebar-nav a:hover { background: var(--surface-2); color: var(--text); }
.sidebar-nav a[aria-current="page"] {
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--primary) 20%, transparent);
  color: var(--text);
}
.sidebar-nav a[aria-current="page"] .icon { color: var(--primary); }
.sidebar-foot { border-top-color: var(--border); }
.sidebar-foot button {
  justify-content: flex-start;
  width: 100%;
  background: var(--surface);
  color: var(--muted);
  border-color: var(--border);
}
.sidebar-foot button:hover { background: var(--surface-2); color: var(--text); }

.theme-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-2);
}
.theme-switch button {
  min-height: 32px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  padding: 6px 8px;
  font-size: .76rem;
}
.theme-switch button[aria-pressed="true"] {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.admin-filters input,
.admin-filters select,
.field input,
.field textarea,
.field select,
.admin-login input {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
  box-shadow: none;
}
.admin-filters input::placeholder,
.field input::placeholder { color: var(--soft); }
.field input[readonly] { background: var(--surface-2); color: var(--muted); }

.edit-panel { padding: 14px; }
.edit-toolbar { justify-content: flex-start; gap: 8px; }
.edit-form { gap: 14px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.field,
.field-wide {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  grid-column: auto;
  min-height: 40px;
  color: var(--muted);
  font-size: .85rem;
}
.field > span {
  min-height: 38px;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: .8rem;
}
.field input,
.field select,
.field textarea {
  width: min(100%, var(--control-width, 420px));
  min-height: 38px;
  border-radius: 5px;
  padding: 8px 10px;
}
.field textarea {
  width: min(100%, var(--control-width, 760px));
  line-height: 1.45;
}
.field-kind-id,
.field-kind-rank,
.field-kind-rank2,
.field-kind-count,
.field-kind-flag,
.field-kind-number { --control-width: 138px; }
.field-kind-date { --control-width: 170px; }
.field-kind-short { --control-width: 260px; }
.field-kind-medium { --control-width: 420px; }
.field-kind-url { --control-width: 620px; }
.field-kind-long { --control-width: 820px; }
.field-kind-code { --control-width: 900px; }

.edit-actions {
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-top-color: var(--border);
  padding-top: 12px;
}

.stat-card { background: var(--surface); }
.stat-value { color: var(--primary); }
.status-pill { border-color: var(--border); background: var(--surface-2); color: var(--muted); }
.status-pill.is-on { background: var(--success-bg); color: color-mix(in srgb, #3e7456 80%, var(--text)); }
.status-pill.is-off,
.missing-author { background: var(--danger-bg); }

html[data-theme="dark"] .admin-filters button,
html[data-theme="dark"] .edit-actions button,
html[data-theme="dark"] .admin-login button { color: #171519; }
html[data-theme="dark"] code { background: rgba(217, 189, 220, .12); color: var(--primary); }
html[data-theme="dark"] .login-shell { background: linear-gradient(135deg, #121014, #211b24 58%, #35283a); }
html[data-theme="dark"] .admin-mark { color: #171519; background: var(--primary); }
html[data-theme="dark"] .authors-panel .admin-filters input,
html[data-theme="dark"] .authors-panel .admin-filters select,
html[data-theme="dark"] .authors-panel .admin-filters,
html[data-theme="dark"] .authors-meta,
html[data-theme="dark"] .pager,
html[data-theme="dark"] .authors-panel .admin-table th { background: var(--surface-2); }
html[data-theme="dark"] .author-name-link,
html[data-theme="dark"] .name-link,
html[data-theme="dark"] .quote-edit-link,
html[data-theme="dark"] .legacy-author-name,
html[data-theme="dark"] .text-pill { color: var(--text); }
html[data-theme="dark"] .author-avatar { background: var(--surface-3); color: var(--muted); border-color: var(--border-strong); }
html[data-theme="dark"] .occupation-text,
html[data-theme="dark"] .rank-badge { color: var(--muted); }

@media (max-width: 720px) {
  .field,
  .field-wide { grid-template-columns: 1fr; gap: 5px; }
  .field > span { min-height: 0; }
  .field input,
  .field select,
  .field textarea { width: 100%; }
}

/* Authors top repair and button typography */
button,
.quiet-link,
.pager a,
.row-action,
.admin-filters button,
.edit-actions button,
.admin-login button,
.sidebar-foot button,
.theme-switch button {
  font-size: .84rem;
  font-weight: 400;
  letter-spacing: 0;
}

.page-title {
  font-size: 1.42rem;
  font-weight: 500;
  line-height: 1.18;
  margin-bottom: 14px;
}

.authors-panel {
  border-color: var(--border);
}

.authors-panel .admin-filters {
  grid-template-columns: minmax(320px, 1fr) 170px max-content max-content;
  gap: 8px;
  align-items: end;
  padding: 12px;
  background: var(--surface);
}

.authors-panel .admin-filters label {
  gap: 5px;
  font-size: .74rem;
  font-weight: 400;
  letter-spacing: 0;
}

.authors-panel .admin-filters label > span {
  color: var(--muted);
  font-size: .74rem;
  font-weight: 400;
}

.authors-panel .admin-filters input,
.authors-panel .admin-filters select {
  min-height: 34px;
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 7px 10px;
  font-size: .84rem;
  font-weight: 400;
}

.authors-panel .admin-filters input::placeholder {
  color: var(--soft);
  font-weight: 400;
}

.authors-panel .admin-filters button,
.authors-panel .quiet-link {
  min-height: 34px;
  padding: 7px 12px;
  font-size: .84rem;
  font-weight: 400;
}

.authors-panel .admin-filters button {
  background: color-mix(in srgb, var(--primary) 86%, var(--surface));
  border-color: color-mix(in srgb, var(--primary) 72%, transparent);
  color: var(--surface);
}

.authors-panel .admin-filters button:hover {
  background: var(--primary);
  border-color: var(--primary);
}

.authors-panel .quiet-link {
  background: var(--surface);
  border-color: var(--border);
  color: var(--muted);
}

.authors-panel .quiet-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.authors-meta {
  padding: 8px 12px;
  background: var(--surface);
  font-size: .82rem;
}

.authors-meta span,
.table-meta .meta-value,
.metric-link .metric-value,
.metric-muted .metric-value,
.author-name-link,
.name-link span,
.legacy-author-name {
  font-weight: 400;
}

.authors-panel .admin-table th {
  height: 34px;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .035em;
}

.authors-panel .admin-table td {
  height: 58px;
}

.author-avatar {
  font-weight: 400;
}

@media (max-width: 900px) {
  .authors-panel .admin-filters {
    grid-template-columns: 1fr 150px;
  }
}

@media (max-width: 640px) {
  .authors-panel .admin-filters {
    grid-template-columns: 1fr;
  }
}

.taxonomy-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 24%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.taxonomy-link:hover {
  color: var(--primary);
  text-decoration-color: currentColor;
}

.occupation-list {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 7px;
  max-width: 340px;
  line-height: 1.35;
}
.occupation-list .occupation-text:not(:last-child)::after {
  content: ",";
  color: var(--muted);
  text-decoration: none;
}

/* Author identity cell refinement */
.authors-panel .admin-table td {
  height: 68px;
}
.author-cell {
  display: flex;
  align-items: center;
  min-width: 340px;
  gap: 12px;
}
.author-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .82rem;
  font-weight: 400;
}
.author-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.author-avatar img + span,
.author-avatar:has(img) > span {
  display: none;
}
.author-identity {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.author-name-link {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  font-size: .92rem;
  line-height: 1.22;
}
.author-id {
  display: block;
  margin-top: 1px;
  color: var(--soft);
  font-size: .74rem;
  line-height: 1.2;
}

@media (max-width: 640px) {
  .author-cell { min-width: 300px; }
  .author-avatar { width: 46px; height: 46px; flex-basis: 46px; }
}

/* Author management controls */
.authors-panel .admin-filters {
  grid-template-columns: minmax(280px, 1fr) 130px 160px max-content max-content;
}
.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.active-filters a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 4px 8px;
  font-size: .76rem;
  font-weight: 400;
}
.active-filters a:hover { color: var(--text); border-color: var(--border-strong); }
.active-filters span { color: var(--soft); font-size: .82rem; }
.sort-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  font-weight: inherit;
}
.sort-link:hover { color: var(--text); }
.sort-link.is-active { color: var(--text); }
.sort-marker {
  display: inline-block;
  min-width: 8px;
  color: var(--soft);
  font-size: .72rem;
  line-height: 1;
}
.quality-signals {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.quality-dot {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--soft);
  font-size: .66rem;
  font-weight: 400;
  line-height: 1;
}
.quality-dot.is-ok {
  background: color-mix(in srgb, #4b8f63 9%, var(--surface));
  border-color: color-mix(in srgb, #4b8f63 18%, transparent);
  color: #4b7b5c;
}
.quality-dot.is-missing {
  background: color-mix(in srgb, #b15c48 8%, var(--surface));
  border-color: color-mix(in srgb, #b15c48 16%, transparent);
  color: #9a5a49;
}

@media (max-width: 900px) {
  .authors-panel .admin-filters {
    grid-template-columns: 1fr 140px;
  }
}
@media (max-width: 640px) {
  .authors-panel .admin-filters {
    grid-template-columns: 1fr;
  }
}

/* Author image process */
.process-image-button {
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
}
.process-image-button:hover {
  background: var(--surface-2);
  color: var(--primary);
  border-color: var(--border-strong);
}
.process-image-button.is-loading {
  color: var(--soft);
  cursor: wait;
}
.process-image-button.is-loading .icon {
  animation: admin-spin .9s linear infinite;
}
@keyframes admin-spin {
  to { transform: rotate(360deg); }
}
.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 40;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
}
.admin-toast {
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  font-size: .84rem;
  box-shadow: none;
  opacity: 1;
  transform: translateY(0);
  transition: opacity .18s ease, transform .18s ease;
}
.admin-toast.is-success {
  background: color-mix(in srgb, #4b8f63 10%, var(--surface));
  border-color: color-mix(in srgb, #4b8f63 18%, transparent);
}
.admin-toast.is-error {
  background: color-mix(in srgb, #b15c48 10%, var(--surface));
  border-color: color-mix(in srgb, #b15c48 18%, transparent);
}
.admin-toast.is-hiding {
  opacity: 0;
  transform: translateY(4px);
}

.authors-panel .admin-table {
  min-width: 1140px;
}
.authors-panel .admin-table th:nth-child(2),
.authors-panel .admin-table td:nth-child(2) {
  width: 82px;
  text-align: center;
}
.authors-panel .admin-table td:nth-child(2) {
  vertical-align: middle;
}

/* Jobs */
.jobs-panel {
  gap: 12px;
}
.job-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  padding: 12px;
}
.job-card-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.job-title {
  color: var(--text);
  font-size: .92rem;
  font-weight: 400;
}
.job-subtext {
  color: var(--muted);
  font-size: .8rem;
}
.job-run-button {
  min-height: 34px;
  border-color: var(--primary);
  background: var(--primary);
  color: var(--surface);
  padding: 7px 12px;
}
.job-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: .82rem;
}
.job-summary span {
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-2);
  padding: 5px 8px;
}
.jobs-table {
  min-width: 760px;
}
.job-status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 3px 7px;
  font-size: .74rem;
  color: var(--muted);
  background: var(--surface-2);
}
.job-status.is-ok {
  background: color-mix(in srgb, #4b8f63 10%, var(--surface));
  border-color: color-mix(in srgb, #4b8f63 18%, transparent);
  color: #4b7b5c;
}
.job-status.is-failed {
  background: color-mix(in srgb, #b15c48 10%, var(--surface));
  border-color: color-mix(in srgb, #b15c48 18%, transparent);
  color: #9a5a49;
}
@media (max-width: 640px) {
  .job-card { align-items: stretch; flex-direction: column; }
  .job-run-button { width: 100%; }
}

.job-author-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
}
.job-author-avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .78rem;
}
.job-author-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.job-author-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.jobs-table {
  min-width: 680px;
}

.quality-dot.is-skipped {
  background: color-mix(in srgb, #b9964b 10%, var(--surface));
  border-color: color-mix(in srgb, #b9964b 18%, transparent);
  color: #80642b;
}

/* FAQ */
.faq-table {
  min-width: 980px;
}
.faq-copy-cell {
  max-width: 680px;
  line-height: 1.42;
}
.faq-answer {
  max-width: 760px;
  margin-top: 5px;
  color: var(--muted);
}
.faq-panel .admin-filters {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.faq-panel .pager {
  font-size: .8rem;
  padding: 9px 12px;
}
.faq-panel .pager a {
  min-height: 30px;
  padding: 5px 9px;
  font-size: .8rem;
}
.faq-panel .pager span {
  font-size: .8rem;
}



.portrait-preview-media {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  flex: 0 0 84px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .8rem;
  text-align: center;
}
.portrait-preview-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.portrait-preview-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.portrait-process-button {
  margin-left: auto;
  flex: 0 0 auto;
}
@media (max-width: 640px) {
  .portrait-process-button { margin-left: 0; }
}


/* Taxonomy lists */
.taxonomy-panel .admin-filters {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.taxonomy-table {
  min-width: 1040px;
}
.taxonomy-title-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 300px;
}
.taxonomy-thumb {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .78rem;
}
.taxonomy-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.taxonomy-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.taxonomy-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.taxonomy-flags span {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 2px 6px;
  font-size: .74rem;
}
.mood-thumb .icon {
  width: 18px;
  height: 18px;
  color: var(--primary);
}

/* Pagination standard */
.pager,
.faq-panel .pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-height: 46px;
  padding: 9px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.2;
}
.pager a,
.faq-panel .pager a {
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font-size: .8rem;
  font-weight: 400;
}
.pager span,
.faq-panel .pager span {
  color: var(--muted);
  font-size: .8rem;
  font-weight: 400;
}
