@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@600;700&display=swap');

:root {
  --canvas: #f6f4ee;
  --surface: #fffefa;
  --surface-strong: #ffffff;
  --ink: #1f2923;
  --muted: #6f776f;
  --faint: #a3aaa2;
  --line: #e2e1d9;
  --line-strong: #cbcfc5;
  --green: #146b48;
  --green-text: #146b48;
  --green-hover: #0f573b;
  --green-soft: #e6f0e9;
  --amber-soft: #f5efe3;
  --amber: #986224;
  --red-soft: #f8e9e7;
  --red: #98463e;
  --shadow: 0 18px 55px rgba(31,41,35,.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { color: var(--ink); background: var(--canvas); font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
a, button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.admin-topbar { height: 70px; padding: 0 24px; position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(255,254,250,.92); backdrop-filter: blur(14px); }
.admin-brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.admin-brand img { display: block; width: auto; height: 30px; }
.admin-brand span { padding: 5px 8px; border-radius: 6px; background: var(--green-soft); color: var(--green-text); font-size: .8rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.admin-top-actions { display: flex; align-items: center; gap: 8px; }
.quiet-button, .primary-button, .icon-button { border: 0; cursor: pointer; text-decoration: none; font-weight: 700; transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease; }
.quiet-button { min-height: 40px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink); font-size: 12px; }
.quiet-button:hover, .icon-button:hover { border-color: var(--green-text); color: var(--green-text); transform: translateY(-1px); }
.primary-button { min-height: 42px; padding: 0 17px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; background: var(--green); color: #fff; font-size: 12px; }
.primary-button:hover { background: var(--green-hover); }
.icon-button { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 10px; background: transparent; color: var(--muted); }
.quiet-button:focus-visible, .primary-button:focus-visible, .icon-button:focus-visible, .admin-search:focus-within { outline: 3px solid color-mix(in srgb, var(--green-text) 28%, transparent); outline-offset: 2px; }

main { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 52px 0 72px; }
.eyebrow { margin: 0 0 8px; color: var(--green-text); font-size: .8rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.access-state { min-height: calc(100vh - 194px); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.access-state h1 { margin: 0; font: 700 34px/1.1 Manrope, sans-serif; letter-spacing: -.035em; }
.access-state > p:not(.eyebrow) { max-width: 410px; margin: 13px 0 22px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.access-spinner { width: 31px; height: 31px; margin-bottom: 22px; border: 2px solid var(--green-soft); border-top-color: var(--green); border-radius: 50%; animation: spin .75s linear infinite; }
.access-state.is-denied .access-spinner { display: none; }

.admin-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.admin-heading h1 { margin: 0; font: 700 clamp(34px, 4vw, 48px)/1.08 Manrope, sans-serif; letter-spacing: -.045em; }
.admin-heading > div > p:last-child { max-width: 570px; margin: 12px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.metric-strip { margin: 38px 0 26px; display: grid; grid-template-columns: repeat(6, 1fr); border: 1px solid var(--line); border-radius: 15px; background: var(--surface); overflow: hidden; box-shadow: var(--shadow); }
.metric-strip div { min-width: 0; padding: 20px 18px; border-right: 1px solid var(--line); }
.metric-strip div:last-child { border-right: 0; }
.metric-strip span, .metric-strip strong { display: block; }
.metric-strip span { color: var(--muted); font-size: .8rem; font-weight: 700; letter-spacing: .035em; text-transform: uppercase; }
.metric-strip strong { margin-top: 10px; font: 700 27px/1 Manrope, sans-serif; }

.admin-section { margin-top: 18px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.section-heading { min-height: 82px; padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.section-heading h2 { margin: 0; font: 700 18px/1.2 Manrope, sans-serif; letter-spacing: -.025em; }
.section-heading p { margin: 5px 0 0; color: var(--muted); font-size: .8rem; }
.admin-search { width: min(310px, 40vw); height: 42px; padding: 0 10px 0 12px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-strong); color: var(--muted); }
.admin-search input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 12px; }
.admin-search kbd { padding: 2px 6px; border: 1px solid var(--line); border-radius: 5px; color: var(--faint); font-size: .8rem; }
.user-table-wrap { overflow-x: auto; }
.user-table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 1120px; }
.user-table th { padding: 12px 16px; color: var(--muted); background: var(--canvas); font-size: .8rem; font-weight: 700; letter-spacing: .055em; text-align: left; text-transform: uppercase; }
.user-table td { padding: 15px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; white-space: nowrap; }
.user-table tbody tr:first-child td { border-top: 0; }
.user-table tbody tr:hover { background: color-mix(in srgb, var(--green-soft) 38%, transparent); }
.user-table th:first-child, .user-table td:first-child { position: sticky; left: 0; min-width: 250px; z-index: 2; background: var(--surface); box-shadow: 1px 0 0 var(--line); }
.user-table th:last-child, .user-table td:last-child { position: sticky; right: 0; min-width: 132px; z-index: 2; background: var(--surface); box-shadow: -1px 0 0 var(--line); }
.user-table thead th:first-child, .user-table thead th:last-child { z-index: 4; background: var(--canvas); }
.user-table tbody tr:hover td:first-child, .user-table tbody tr:hover td:last-child { background: color-mix(in srgb, var(--surface) 62%, var(--green-soft)); }
.admin-role-select { min-height: 32px; padding: 0 38px 0 11px; appearance: none; -webkit-appearance: none; border: 1px solid var(--line-strong); border-radius: 8px; background-color: var(--surface); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236f776f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 14px; color: var(--ink); font: inherit; }
.user-actions { display: flex; gap: 7px; }
.compact { min-height: 32px; padding: 0 10px; font-size: 11px; }
.danger-button { min-height: 38px; padding: 0 14px; border: 1px solid rgba(196, 92, 82, .45); border-radius: 9px; background: transparent; color: #c45c52; font: 700 12px/1 inherit; cursor: pointer; }
.danger-button:hover { background: rgba(196, 92, 82, .1); }
.admin-role-select:disabled, .user-actions button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 32px; height: 32px; flex: 0 0 32px; display: grid; place-items: center; border-radius: 50%; background: var(--green-soft); color: var(--green-text); font-size: .8rem; font-weight: 700; }
.user-cell strong { display: block; max-width: 235px; overflow: hidden; color: var(--ink); text-overflow: ellipsis; }
.status-pill { display: inline-flex; min-height: 24px; padding: 0 9px; align-items: center; border-radius: 999px; background: var(--green-soft); color: var(--green-text); font-size: .8rem; font-weight: 700; }
.status-pill.pending { background: var(--amber-soft); color: var(--amber); }
.status-pill.suspended { background: var(--red-soft); color: var(--red); }
.table-empty { padding: 30px 20px; color: var(--muted); font-size: 12px; text-align: center; }

.audit-section { margin-top: 18px; }
.audit-list { display: grid; }
.audit-item { min-height: 58px; padding: 13px 20px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; border-top: 1px solid var(--line); }
.audit-item:first-child { border-top: 0; }
.audit-item strong, .audit-item small { display: block; }
.audit-item strong { font-size: .8rem; }
.audit-item small, .audit-item time { margin-top: 3px; color: var(--muted); font-size: .8rem; }
.admin-toast { position: fixed; left: 50%; bottom: 24px; z-index: 100; padding: 10px 15px; border-radius: 9px; background: var(--ink); color: #fff; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: opacity .2s, transform .2s; font-size: .8rem; font-weight: 700; }
.admin-toast.show { opacity: 1; transform: translate(-50%, 0); }

html[data-theme="dark"] {
  --canvas: #12171c; --surface: #20262d; --surface-strong: #293039; --ink: #e7e3d9;
  --muted: #a9b3bf; --faint: #98a4b1; --line: #303943; --line-strong: #43505e;
  --green: #23724f; --green-text: #67c59a; --green-hover: #1c5d40; --green-soft: #253a32;
  --amber-soft: #282721; --amber: #d8b678; --red-soft: #3a2928; --red: #d87c72;
  --shadow: 0 18px 55px rgba(5,8,11,.3); color-scheme: dark;
}
html[data-theme="dark"] .admin-topbar { background: rgba(24,29,35,.94); }
html[data-theme="dark"] .primary-button { color: #e7e3d9; }
html[data-theme="dark"] .admin-toast { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); }
html[data-theme="dark"] .admin-role-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23a9b3bf' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E"); }

@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 960px) { .metric-strip { grid-template-columns: repeat(3, 1fr); } .metric-strip div:nth-child(3) { border-right: 0; } .metric-strip div:nth-child(-n+3) { border-bottom: 1px solid var(--line); } }
@media (max-width: 680px) { main { width: min(100% - 28px, 1180px); padding-top: 32px; } .admin-topbar { padding: 0 14px; } .admin-top-actions .quiet-button { display: none; } .admin-heading, .section-heading { align-items: flex-start; flex-direction: column; } .admin-search { width: 100%; } .metric-strip { grid-template-columns: repeat(2, 1fr); } .metric-strip div { border-bottom: 1px solid var(--line); } .metric-strip div:nth-child(2n) { border-right: 0; } .metric-strip div:nth-last-child(-n+2) { border-bottom: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
