:root {
  --bg: #f4f0e8;
  --surface: #fffdf8;
  --surface-2: #f8f4ec;
  --text: #201a1c;
  --muted: #6d6664;
  --primary: #4b2e47;
  --primary-2: #3a2238;
  --accent: #c9a052;
  --border: rgba(32, 26, 28, .12);
  --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: 6px; 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: 8px; 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: 8px; 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: 8px; 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, .28); 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: 8px; 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: 8px; 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: 8px; 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: 8px; 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: 8px; background: var(--surface-2); padding: 14px; }
.module-list a:hover { border-color: rgba(75, 46, 71, .32); }
.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: 8px; 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: 8px; 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: 8px; 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: 8px; 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: 8px; }
.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: 999px; 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: 999px; 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: 8px; 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, .28); background: rgba(70, 130, 92, .1); color: #346c4b; }
.edit-panel { display: grid; gap: 14px; border: 1px solid var(--border); border-radius: 8px; 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: 8px; background: var(--surface-2); padding: 14px; }
.portrait-preview img, .portrait-preview > span { width: 84px; height: 84px; border-radius: 8px; 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: 8px; 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: 8px; 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, .18); border-radius: 8px; 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, .22); 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: 8px; 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, .11);
  --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: 8px; 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, .14); border-radius: 7px; 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: 7px; background: var(--primary); box-shadow: none; font-weight: 500; }
.authors-panel .quiet-link { min-height: 38px; border-radius: 7px; 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, .1); }
.authors-panel .admin-table td { height: 62px; padding: 9px 12px; border-bottom: 1px solid rgba(36, 35, 38, .08); 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: 7px; border-color: rgba(36, 35, 38, .12); 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, .1); border-radius: 999px; background: #f7f7f6; color: #6d6971; padding: 2px 8px; font-size: .74rem; font-weight: 400; }
.status-pill.is-on { border-color: rgba(55, 128, 91, .18); background: #f1f7f3; color: #3e7456; }
.status-pill.is-off { border-color: rgba(164, 60, 52, .18); background: #fbf2f1; color: #95433c; }

.pager { padding: 12px 14px; border-top: 1px solid var(--border); background: #fbfbfa; }
.pager a { min-height: 34px; border-radius: 7px; 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, .08);
  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, .12);
  border-radius: 7px;
  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: 7px;
  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, .08);
  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, .11);
  border-radius: 7px;
  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; }
