:root {
  --ink: #e8f2ff;
  --muted: #8296ae;
  --faint: #566b83;
  --canvas: #070d15;
  --surface: #0c1521;
  --raised: #101c2b;
  --line: #21344a;
  --line-soft: #172638;
  --blue: #59afff;
  --blue-soft: #143757;
  --teal: #35d4b2;
  --amber: #f2bd58;
  --danger: #ff6575;
  --font: "IBM Plex Sans", "Segoe UI", "Microsoft YaHei UI", sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--ink); background: var(--canvas); font-family: var(--font); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.ambient-grid { position: fixed; inset: 0; pointer-events: none; opacity: .22; background-image: linear-gradient(rgba(65,111,156,.08) 1px, transparent 1px), linear-gradient(90deg, rgba(65,111,156,.08) 1px, transparent 1px); background-size: 42px 42px; mask-image: linear-gradient(to bottom right, black, transparent 76%); }
.admin-shell { position: relative; display: grid; grid-template-columns: 238px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 28px 18px 20px; border-right: 1px solid var(--line); background: rgba(8, 16, 27, .94); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; padding: 0 9px 29px; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; color: var(--blue); font-size: 30px; transform: rotate(-16deg); }
.brand b { display: block; color: #76bdff; letter-spacing: .06em; font-size: 17px; }
.brand small { display: block; margin-top: 3px; color: var(--faint); font: 9px/1 var(--mono); letter-spacing: .16em; }
.admin-nav { display: grid; gap: 5px; }
.nav-item { position: relative; width: 100%; border: 0; border-radius: 7px; padding: 12px 11px; color: #a8b8ca; background: transparent; text-align: left; cursor: pointer; transition: background .16s ease, color .16s ease; }
.nav-item span { display: inline-block; width: 28px; color: var(--faint); font: 10px var(--mono); }
.nav-item em { float: right; min-width: 20px; padding: 2px 6px; border-radius: 20px; color: #111923; background: var(--amber); font-style: normal; font-weight: 800; text-align: center; }
.nav-item::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; background: transparent; }
.nav-item:hover { color: var(--ink); background: rgba(38, 72, 108, .3); }
.nav-item.is-active { color: #83c5ff; background: var(--blue-soft); }
.nav-item.is-active::before { background: var(--blue); box-shadow: 0 0 14px var(--blue); }
.operator { margin-top: auto; padding: 15px 10px 2px; border-top: 1px solid var(--line); }
.operator span, .operator strong, .operator a { display: block; }
.operator span { color: var(--faint); font-size: 11px; }
.operator strong { overflow: hidden; margin: 7px 0 11px; font: 11px var(--mono); text-overflow: ellipsis; }
.operator a { color: #77bfff; font-size: 12px; text-decoration: none; }

.workspace { min-width: 0; padding: 42px clamp(24px, 4vw, 64px) 70px; }
.mobile-header, .mobile-nav { display: none; }
.live-status { position: fixed; z-index: 20; right: 28px; bottom: 24px; max-width: min(420px, calc(100vw - 40px)); border: 1px solid var(--line); border-radius: 8px; padding: 11px 14px; color: var(--ink); background: #101d2c; box-shadow: 0 15px 50px rgba(0,0,0,.34); opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .18s, transform .18s; }
.live-status.is-visible { opacity: 1; transform: none; }
.live-status.is-error { border-color: #854250; color: #ffbdc5; }
.view { max-width: 1500px; margin: 0 auto; animation: reveal .28s ease both; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 24px; }
.page-head h1 { margin: 4px 0 5px; font-size: clamp(28px, 3vw, 40px); letter-spacing: -.045em; }
.page-head p:last-child { margin: 0; color: var(--muted); }
.eyebrow { margin: 0; color: var(--blue); font: 10px/1.2 var(--mono); letter-spacing: .17em; }

.button, .text-button, .icon-button { cursor: pointer; }
.button { min-height: 40px; border: 1px solid #4389c8; border-radius: 6px; padding: 8px 16px; color: #eff8ff; background: #17639f; font-weight: 700; text-decoration: none; transition: transform .15s, background .15s, border-color .15s; }
.button:hover { transform: translateY(-1px); background: #2478b9; }
.button:disabled { cursor: not-allowed; opacity: .38; transform: none; }
.button.secondary { border-color: #405873; color: #c2d1e2; background: #111d2c; }
.button.danger { border-color: #70404a; color: #ffb3bd; background: #28151b; }
.text-button { border: 0; padding: 6px; color: var(--blue); background: transparent; }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); background: transparent; font-size: 23px; }
:focus-visible { outline: 2px solid #8acaff; outline-offset: 3px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { position: relative; overflow: hidden; min-height: 150px; border: 1px solid var(--line); border-radius: 9px; padding: 19px; background: linear-gradient(145deg, var(--raised), #0b1420); }
.metric::after { content: ""; position: absolute; right: -32px; bottom: -50px; width: 130px; height: 130px; border: 1px solid rgba(89,175,255,.13); border-radius: 50%; }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { display: block; margin: 19px 0 10px; font: 700 34px/1 var(--mono); }
.metric small { color: var(--faint); }
.metric.urgent { border-top-color: var(--amber); }
.metric.urgent strong, .metric.urgent small { color: var(--amber); }
.panel, .lookup-card, .member-card { border: 1px solid var(--line); border-radius: 9px; background: rgba(13, 23, 36, .94); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 17px 19px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 4px 0 0; font-size: 18px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 14px 18px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: #101b2a; font-size: 11px; font-weight: 650; letter-spacing: .04em; }
td { color: #cbd8e7; font-size: 13px; }
td code { color: #9fc5e9; font: 11px var(--mono); }
.empty { padding: 44px 18px; color: var(--faint); text-align: center; }
.status { display: inline-flex; border: 1px solid var(--line); border-radius: 20px; padding: 4px 8px; font: 10px var(--mono); }
.status-review { color: var(--amber); border-color: #725d32; }
.status-approved { color: var(--teal); border-color: #276c60; }
.status-rejected { color: #ff9ba7; border-color: #713844; }
.panel-foot { display: flex; justify-content: center; padding: 14px; }

.toolbar { display: grid; grid-template-columns: 190px minmax(280px, 1fr) auto; gap: 12px; align-items: end; margin-bottom: 14px; }
label > span, .toolbar label > span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; }
input, select, textarea { width: 100%; border: 1px solid #354c66; border-radius: 6px; color: var(--ink); background: #0d1826; }
input, select { min-height: 42px; padding: 9px 12px; }
textarea { resize: vertical; padding: 11px 12px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #526980; }
.lookup-card { padding: 20px; }
.lookup-card > label { display: block; margin-bottom: 9px; color: var(--muted); font-size: 12px; }
.lookup-card > div { display: grid; grid-template-columns: minmax(240px, 1fr) auto; gap: 10px; }
.member-card { display: grid; grid-template-columns: minmax(220px, .8fr) minmax(180px, .6fr) minmax(360px, 1.6fr); gap: 0; margin-top: 14px; overflow: hidden; }
.member-identity, .membership-current { padding: 24px; border-right: 1px solid var(--line); }
.member-identity span, .membership-current span { display: block; color: var(--muted); font-size: 11px; }
.member-identity strong, .membership-current strong { display: block; margin: 12px 0 7px; }
.member-identity strong { overflow-wrap: anywhere; font: 12px/1.6 var(--mono); }
.member-identity small, .membership-current small { color: var(--faint); overflow-wrap: anywhere; }
.membership-current strong { color: var(--blue); font: 700 28px var(--mono); }
.grant-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 24px; }
.grant-form label { color: var(--muted); font-size: 11px; }
.reason-field { grid-column: 1 / -1; color: var(--muted); font-size: 11px; }
.reason-field textarea { margin-top: 7px; }
.form-note { grid-column: 1 / -1; margin: 0; color: var(--faint); font-size: 11px; }
.grant-form .button { justify-self: start; }

.review-drawer { width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 24px); margin: 12px 12px 12px auto; border: 1px solid #35516f; border-radius: 11px; padding: 0; color: var(--ink); background: #0b1522; box-shadow: -24px 0 80px rgba(0,0,0,.5); }
.review-drawer::backdrop { background: rgba(2,7,13,.7); backdrop-filter: blur(3px); }
.drawer-head { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; padding: 22px; border-bottom: 1px solid var(--line); background: #0b1522; }
.drawer-head h2 { margin: 5px 0 0; }
.order-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: 0; padding: 8px 22px 18px; }
.order-detail div { padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.order-detail dt { color: var(--muted); font-size: 10px; }
.order-detail dd { margin: 6px 0 0; overflow-wrap: anywhere; font: 12px/1.5 var(--mono); }
#reviewForm { padding: 0 22px 24px; }
.checklist { display: grid; gap: 4px; margin: 0 0 18px; border: 1px solid var(--line); border-radius: 7px; padding: 13px; }
.checklist legend { padding: 0 6px; color: var(--muted); font-size: 11px; }
.checklist label { display: flex; align-items: center; gap: 10px; min-height: 38px; color: #c8d6e5; font-size: 13px; }
.checklist input { width: 17px; min-height: 17px; accent-color: var(--blue); }
.drawer-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }

.access-state { position: relative; z-index: 2; min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.access-card { width: min(520px, 100%); border: 1px solid var(--line); border-radius: 12px; padding: 42px; background: rgba(12,21,33,.96); box-shadow: 0 24px 90px rgba(0,0,0,.35); text-align: center; }
.access-mark { color: var(--blue); font-size: 48px; }
.access-card h1 { margin: 12px 0 10px; font-size: 25px; }
.access-card > p:not(.eyebrow) { margin: 0 0 24px; color: var(--muted); line-height: 1.7; }

@keyframes reveal { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@media (max-width: 1060px) {
  .admin-shell { grid-template-columns: 205px minmax(0, 1fr); }
  .workspace { padding-inline: 24px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .member-card { grid-template-columns: 1fr 1fr; }
  .grant-form { grid-column: 1 / -1; border-top: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .admin-shell { display: block; }
  .sidebar { display: none; }
  .workspace { padding: 0 14px 72px; }
  .mobile-header { display: flex; align-items: center; justify-content: space-between; min-height: 62px; border-bottom: 1px solid var(--line); }
  .mobile-header a { color: var(--muted); text-decoration: none; font-size: 12px; }
  .mobile-brand { color: var(--blue) !important; font-weight: 800; letter-spacing: .06em; }
  .mobile-nav { position: sticky; z-index: 8; top: 0; display: grid; grid-template-columns: repeat(4, 1fr); margin: 0 -14px 28px; border-bottom: 1px solid var(--line); background: rgba(7,13,21,.95); backdrop-filter: blur(12px); }
  .mobile-nav button { border: 0; border-bottom: 2px solid transparent; padding: 13px 2px; color: var(--muted); background: transparent; }
  .mobile-nav button.is-active { color: var(--blue); border-bottom-color: var(--blue); }
  .page-head { align-items: flex-start; }
  .page-head h1 { font-size: 30px; }
  .metric-grid { gap: 9px; }
  .metric { min-height: 125px; padding: 15px; }
  .metric strong { margin-top: 16px; font-size: 27px; }
  .toolbar { grid-template-columns: 1fr; }
  .lookup-card > div { grid-template-columns: 1fr; }
  .member-card { grid-template-columns: 1fr; }
  .member-identity, .membership-current { border-right: 0; border-bottom: 1px solid var(--line); }
  .grant-form { grid-template-columns: 1fr; }
  .reason-field, .form-note { grid-column: auto; }
  .review-drawer { margin: auto 0 0; width: 100%; max-width: none; max-height: 92vh; border-radius: 14px 14px 0 0; }
}
@media (max-width: 460px) {
  .metric-grid { grid-template-columns: 1fr; }
  .metric { min-height: 112px; }
  .order-detail { grid-template-columns: 1fr; }
  .access-card { padding: 30px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
