:root {
  --ink: #172023;
  --muted: #647174;
  --paper: #f5f7f6;
  --surface: #ffffff;
  --line: #dfe7e4;
  --navy: #13292d;
  --green: #176f5b;
  --green-deep: #0e5646;
  --green-soft: #dff2ea;
  --lime: #c5e95b;
  --amber: #a76607;
  --amber-soft: #fff1d6;
  --red: #a33a3a;
  --red-soft: #fbe4e4;
  --blue: #2c5c8e;
  --blue-soft: #e3effa;
  --shadow: 0 20px 55px rgba(18, 45, 47, .11);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
code { font-family: "SFMono-Regular", Consolas, monospace; font-size: .9em; }

.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; color: #102526; background: var(--lime); font-weight: 900; letter-spacing: -.06em; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: .08em; font-size: 1rem; }
.brand small { color: var(--muted); font-size: .72rem; margin-top: 2px; }
.private-pill { border: 1px solid rgba(23,111,91,.22); color: var(--green-deep); background: var(--green-soft); padding: 7px 11px; border-radius: 999px; font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.eyebrow { color: var(--green); font-size: .72rem; font-weight: 900; letter-spacing: .14em; margin: 0 0 8px; }
.lead { color: var(--muted); font-size: 1.08rem; line-height: 1.65; }
.optional { color: var(--muted); font-weight: 500; font-size: .82rem; }
.muted-text, .fine-print { color: var(--muted); }
.is-hidden { display: none !important; }

.button { appearance: none; display: inline-flex; justify-content: center; align-items: center; gap: 8px; border: 0; border-radius: 12px; padding: 11px 16px; text-decoration: none; font-weight: 800; cursor: pointer; transition: transform .15s ease, background .15s ease, box-shadow .15s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--green); color: white; box-shadow: 0 9px 24px rgba(23,111,91,.19); }
.button.primary:hover { background: var(--green-deep); }
.button.secondary { background: #edf2f0; color: var(--ink); border: 1px solid var(--line); }
.button.danger { color: white; background: var(--red); }
.button.large { min-height: 52px; padding: 14px 21px; font-size: 1rem; }
.button.disabled, .button:disabled { background: #d8dedc; color: #7e8987; cursor: not-allowed; box-shadow: none; transform: none; }
.mini-button { width: 100%; border: 1px solid var(--line); background: white; border-radius: 8px; padding: 7px 9px; color: var(--ink); font-weight: 700; cursor: pointer; text-align: left; }
.mini-button:hover { border-color: #9bb6ae; background: #f5faf8; }
.mini-button.danger { color: var(--red); }
.link-button { border: 0; background: none; color: #a9c4bd; padding: 0; cursor: pointer; font-weight: 700; }
.text-link { color: var(--green); font-weight: 800; text-decoration: none; }

.notice { border-radius: 12px; padding: 13px 15px; margin: 16px 0; line-height: 1.45; }
.notice.error { background: var(--red-soft); color: #782b2b; border: 1px solid #efc5c5; }
.notice.info { background: var(--blue-soft); color: #264f78; border: 1px solid #c4dbef; }
.callout { background: var(--green-soft); border: 1px solid #bddfd2; padding: 15px; border-radius: 13px; }
.callout p { color: #41665d; margin: 5px 0 0; }

/* Customer portal */
.portal-shell { background: radial-gradient(circle at top right, rgba(197,233,91,.22), transparent 32rem), linear-gradient(180deg, #f8faf8 0, #eef4f1 100%); }
.portal-header { max-width: 1160px; margin: 0 auto; padding: 25px 28px; display: flex; justify-content: space-between; align-items: center; }
.portal-main { max-width: 1120px; margin: 0 auto; padding: 50px 28px 80px; }
.portal-footer { max-width: 1120px; margin: 0 auto; border-top: 1px solid var(--line); padding: 26px 28px 44px; color: var(--muted); display: flex; justify-content: space-between; gap: 24px; font-size: .83rem; }
.portal-footer p { margin: 0; }
.access-card { width: min(100%, 520px); margin: 2vh auto 0; background: rgba(255,255,255,.93); border: 1px solid rgba(213,226,221,.9); box-shadow: var(--shadow); border-radius: 26px; padding: 44px; }
.access-card h1 { margin: 5px 0 10px; font-size: clamp(2rem, 6vw, 3rem); letter-spacing: -.055em; line-height: 1; }
.hero-icon { display: grid; place-items: center; width: 56px; height: 56px; background: var(--navy); color: var(--lime); border-radius: 18px; font-size: 1.5rem; font-weight: 900; margin-bottom: 25px; }
.hero-icon.muted { background: var(--red-soft); color: var(--red); }
.access-form { display: grid; gap: 18px; margin-top: 26px; }
.access-form label, .admin-form label { display: grid; gap: 8px; font-weight: 800; font-size: .9rem; }
input, select, textarea { width: 100%; border: 1px solid #cbd8d4; background: white; border-radius: 11px; padding: 12px 13px; color: var(--ink); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,111,91,.12); }
.access-form input[name="invitation_code"] { font-family: "SFMono-Regular", Consolas, monospace; text-transform: uppercase; letter-spacing: .08em; font-size: 1rem; }
.fine-print { font-size: .8rem; line-height: 1.55; margin: 20px 0 0; }
.admin-login { margin-top: 0; }

.product-hero { display: grid; grid-template-columns: 1.45fr .8fr; gap: 60px; align-items: center; padding: 60px 0 45px; }
.product-hero h1 { font-size: clamp(3rem, 8vw, 6.7rem); letter-spacing: -.075em; line-height: .88; margin: 0 0 24px; }
.product-hero .lead { max-width: 670px; font-size: 1.2rem; }
.personality-stack { display: grid; gap: 14px; transform: rotate(2deg); }
.personality { border-radius: 22px; padding: 25px; min-height: 126px; font-size: 2rem; font-weight: 900; display: flex; flex-direction: column; justify-content: end; box-shadow: var(--shadow); }
.personality span { font-size: .85rem; font-weight: 700; opacity: .72; margin-top: 4px; }
.personality.little { background: var(--lime); color: var(--navy); transform: rotate(-4deg); }
.personality.nasty { background: var(--navy); color: white; }
.release-card, .release-empty { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); padding: 32px; display: grid; grid-template-columns: 1fr auto; gap: 25px; align-items: center; }
.release-card h2, .release-empty h2 { font-size: 2rem; margin: 0 0 16px; }
.release-card details { grid-column: 1/-1; border-top: 1px solid var(--line); padding-top: 16px; }
.release-card summary { font-weight: 800; cursor: pointer; }
.metadata-grid { display: flex; flex-wrap: wrap; gap: 22px 38px; }
.metadata-grid span { font-weight: 800; }
.metadata-grid small { display: block; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.download-button { min-width: 210px; }
.release-empty { display: block; }
.info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin-top: 22px; }
.info-grid article { background: rgba(255,255,255,.78); border: 1px solid var(--line); border-radius: 18px; padding: 24px; }
.info-grid h3 { margin-top: 0; }
.info-grid p, .info-grid li { color: var(--muted); line-height: 1.6; }
.warning-card { border-color: #efd7af !important; background: var(--amber-soft) !important; }
.info-grid dl, .release-summary { margin: 0; }
.info-grid dl div, .release-summary div { display: flex; justify-content: space-between; gap: 20px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.info-grid dt, .release-summary dt { color: var(--muted); }
.info-grid dd, .release-summary dd { margin: 0; font-weight: 800; text-align: right; }
.attribution { color: var(--muted); text-align: center; font-size: .8rem; margin-top: 28px; }

/* Owner admin */
.admin-shell { display: grid; grid-template-columns: 246px minmax(0, 1fr); background: var(--paper); }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--navy); color: white; padding: 25px 18px; display: flex; flex-direction: column; }
.brand-admin { padding: 0 9px 24px; }
.brand-admin small { color: #9db8b1; }
.sidebar nav { display: grid; gap: 5px; }
.nav-link { text-decoration: none; color: #b7ccc7; padding: 11px 13px; border-radius: 10px; font-weight: 750; font-size: .9rem; }
.nav-link:hover { background: rgba(255,255,255,.06); color: white; }
.nav-link.is-active { background: var(--green); color: white; }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding: 18px 10px 0; display: grid; gap: 9px; }
.operator { color: #809c95; font-size: .75rem; }
.admin-main { min-width: 0; padding: 28px 34px 60px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 27px; }
.topbar h1 { margin: 0; font-size: 2rem; letter-spacing: -.04em; }
.status-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 35px rgba(18,45,47,.06); margin-bottom: 20px; }
.status-strip > div { padding: 18px; border-right: 1px solid var(--line); min-width: 0; }
.status-strip > div:last-child { border-right: 0; }
.status-strip strong, .status-strip small { display: block; }
.status-strip strong { overflow: hidden; text-overflow: ellipsis; }
.status-strip small { color: var(--muted); margin-top: 4px; font-size: .76rem; }
.status-dot { width: 9px; height: 9px; display: inline-block; border-radius: 999px; margin-right: 7px; }
.status-dot.ok { background: #24a57e; box-shadow: 0 0 0 5px rgba(36,165,126,.12); }
.status-dot.bad { background: var(--red); box-shadow: 0 0 0 5px rgba(163,58,58,.12); }
.card-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.metric-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 21px; box-shadow: 0 12px 35px rgba(18,45,47,.05); }
.metric-card.accent { background: var(--green); color: white; border-color: var(--green); }
.metric-card small, .metric-card strong, .metric-card a { display: block; }
.metric-card small { color: var(--muted); font-weight: 700; }
.metric-card.accent small { color: #c7e5dc; }
.metric-card strong { font-size: 2.2rem; letter-spacing: -.05em; margin: 8px 0; }
.metric-card a { color: inherit; font-size: .78rem; font-weight: 800; }
.two-column { display: grid; grid-template-columns: 1.4fr .7fr; gap: 20px; margin-bottom: 20px; }
.panel, .issued-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 23px; box-shadow: 0 12px 35px rgba(18,45,47,.05); margin-bottom: 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: start; gap: 20px; margin-bottom: 18px; }
.panel-head h2, .panel h2 { margin: 0; letter-spacing: -.025em; }
.panel-head > span { color: var(--muted); font-size: .78rem; }
.action-panel { background: linear-gradient(145deg, #eff8f4, #fafffd); }
.action-panel p { color: var(--muted); line-height: 1.55; }
.release-summary div:last-child { border-bottom: 0; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-bottom: 18px; }
.filter-form { display: flex; gap: 10px; width: min(100%, 680px); }
.filter-form input { flex: 1; }
.wide-panel { padding: 0; overflow: hidden; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th { color: var(--muted); font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; text-align: left; background: #f8faf9; white-space: nowrap; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover { background: #fbfdfc; }
td strong, td small { display: block; }
td small { color: var(--muted); margin-top: 4px; line-height: 1.35; }
.dense-table { min-width: 1680px; }
.empty-cell { color: var(--muted); text-align: center; padding: 35px; }
.badge { display: inline-flex; border-radius: 999px; padding: 5px 8px; font-size: .65rem; font-weight: 900; letter-spacing: .055em; white-space: nowrap; }
.badge-active, .badge-approved, .badge-verified, .badge-pass-6-of-6-and-100-of-100 { color: var(--green-deep); background: var(--green-soft); }
.badge-pending, .badge-staged, .badge-verified-staged, .badge-tested { color: var(--amber); background: var(--amber-soft); }
.badge-expired, .badge-retired { color: #586260; background: #e5e9e8; }
.badge-revoked { color: var(--red); background: var(--red-soft); }
.actions { min-width: 160px; }
.actions summary { color: var(--green); font-weight: 800; cursor: pointer; }
.actions[open] { position: relative; z-index: 3; }
.actions form { display: grid; gap: 5px; padding: 5px 0; }
.actions label { display: grid; gap: 5px; color: var(--muted); font-size: .72rem; }
.actions input, .actions select { padding: 7px; font-size: .76rem; }
.form-panel { max-width: 820px; }
.admin-form { display: grid; gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; }
.checkbox-row { grid-template-columns: auto 1fr !important; align-items: center; }
.checkbox-row input { width: auto; }
.issued-card { max-width: 760px; padding: 35px; }
.issued-card h2 { font-size: 2rem; margin: 0 0 8px; }
.issued-card > p { color: var(--muted); }
.code-display { display: flex; align-items: center; justify-content: space-between; gap: 14px; background: var(--navy); color: var(--lime); border-radius: 15px; padding: 17px; margin: 25px 0; }
.code-display code { font-size: 1.25rem; font-weight: 900; letter-spacing: .07em; overflow-wrap: anywhere; }
.issued-card dl { display: grid; gap: 8px; }
.issued-card dl div { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 9px 0; }
.issued-card dd { font-weight: 800; }
.confirm-dialog { border: 0; border-radius: 18px; padding: 26px; box-shadow: var(--shadow); max-width: 430px; }
.confirm-dialog::backdrop { background: rgba(7,27,29,.58); backdrop-filter: blur(2px); }
.confirm-dialog h2 { margin-top: 0; }
.confirm-dialog p { color: var(--muted); line-height: 1.55; }
.dialog-actions { display: flex; justify-content: end; gap: 10px; margin-top: 20px; }

@media (max-width: 1100px) {
  .admin-shell { grid-template-columns: 205px minmax(0,1fr); }
  .status-strip { grid-template-columns: repeat(3, 1fr); }
  .status-strip > div { border-bottom: 1px solid var(--line); }
  .card-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .portal-header, .portal-main, .portal-footer { padding-left: 18px; padding-right: 18px; }
  .portal-main { padding-top: 28px; }
  .portal-footer { display: grid; }
  .access-card { padding: 28px 22px; }
  .product-hero { grid-template-columns: 1fr; gap: 25px; padding-top: 30px; }
  .personality-stack { grid-template-columns: repeat(2, 1fr); transform: none; }
  .personality { min-height: 105px; font-size: 1.45rem; padding: 18px; }
  .release-card { grid-template-columns: 1fr; }
  .download-button { width: 100%; }
  .info-grid { grid-template-columns: 1fr; }
  .admin-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 15px; }
  .sidebar nav { grid-template-columns: repeat(2, 1fr); }
  .sidebar-foot { display: none; }
  .brand-admin { padding-bottom: 14px; }
  .admin-main { padding: 20px 15px 40px; }
  .topbar { align-items: start; }
  .status-strip { grid-template-columns: 1fr 1fr; }
  .card-grid, .two-column, .form-grid { grid-template-columns: 1fr; }
  .toolbar, .filter-form { align-items: stretch; flex-direction: column; width: 100%; }
  .private-pill { font-size: .6rem; }
}
