:root {
  color-scheme: light;
  --ink: #0f172a;
  --muted: #475569;
  --line: #e2e8f0;
  --panel: #ffffff;
  --canvas: #f1f5f9;
  --sidebar: #0f172a;
  --sidebar-text: #e2e8f0;
  --sidebar-muted: #94a3b8;
  --accent: #1d4ed8;
  --accent-soft: #dbeafe;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --ok: #047857;
  --ok-soft: #d1fae5;
  --warn: #b45309;
  --warn-soft: #ffedd5;
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.06);
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
}

body[data-page]:not([data-page="sign-in"]) {
  background: var(--canvas);
}

button, input, select, textarea { font: inherit; color: inherit; }

a { color: var(--accent); }

.sign-in {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
}

.brand-panel {
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
}

.brand-product .brand-icon {
  width: 88px;
  height: 88px;
  border-radius: 20px;
  display: block;
  margin: 0 0 14px;
}

.brand-mark {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  margin: 0;
}

.brand-site {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.brand-panel h1 {
  margin: 0 0 12px;
  font-size: 1.35rem;
  line-height: 1.25;
  font-weight: 600;
  color: var(--sidebar-text);
}

.brand-site > p {
  color: var(--sidebar-muted);
}

.brand-panel p { margin: 0; line-height: 1.5; color: var(--sidebar-text); }

.brand-panel ul {
  margin: 20px 0 0;
  padding-left: 18px;
  color: var(--sidebar-muted);
  line-height: 1.6;
}

.sign-in-main {
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.sign-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.sign-card h2 { margin: 0 0 8px; font-size: 1.35rem; }
.sign-card .lede { margin: 0 0 20px; color: var(--muted); line-height: 1.5; }

label {
  display: grid;
  gap: 6px;
  font-weight: 650;
  margin: 14px 0 0;
}

input, select, textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 10px;
  padding: 11px 12px;
}

textarea { min-height: 72px; resize: vertical; }

input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}

button.secondary, a.button.secondary {
  background: #fff;
  color: var(--ink);
  border-color: #cbd5e1;
}

button.danger { background: var(--danger); }
button.quiet {
  background: transparent;
  color: var(--accent);
  border-color: transparent;
  padding-inline: 8px;
}
button:disabled { opacity: 0.55; cursor: not-allowed; }

.sign-card button[type="submit"] { width: 100%; margin-top: 18px; }

.error { color: var(--danger); margin: 12px 0 0; }
.muted { color: var(--muted); }
.alert-list { margin: 0; padding-left: 1.2rem; }
.alert-list li { margin: 8px 0; }
.hint { margin-top: 18px; color: var(--muted); font-size: 0.92rem; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
}

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sidebar a.nav {
  display: block;
  color: var(--sidebar-text);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
}

.sidebar a.nav[aria-current="page"], .sidebar a.nav:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar a.product {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  color: var(--sidebar-text);
  text-decoration: none;
}

.sidebar .product img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex: none;
}

.sidebar .product strong { display: block; font-size: 1rem; color: #fff; }
.sidebar .product-copy > span { display: block; color: var(--sidebar-muted); font-size: 0.82rem; }

.brand-name-ink {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 700;
}

.sidebar nav { display: grid; gap: 4px; }
.sidebar-foot { margin-top: auto; padding: 0 8px; }
.sidebar-foot p { margin: 0 0 8px; color: var(--sidebar-muted); font-size: 0.85rem; word-break: break-word; }
.sidebar-foot button {
  width: 100%;
  background: transparent;
  color: var(--sidebar-text);
  border-color: rgba(255, 255, 255, 0.18);
}

.workspace { min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 28px 0;
}
.topbar h1 { margin: 0; font-size: 1.45rem; }
.crumb { margin: 0; color: var(--muted); font-size: 0.9rem; }

#orgbar { padding: 16px 28px 0; }
.org-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.org-switch a {
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 650;
  font-size: 0.92rem;
}
.org-switch a[aria-current="page"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

main#main { padding: 20px 28px 40px; }

.stack { display: grid; gap: 16px; }
.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 6px; font-size: 1.05rem; }
.panel p { margin: 0; line-height: 1.5; }
.stat { font-size: 1.7rem; font-weight: 700; margin: 8px 0 0; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--accent-soft);
  color: #1e3a8a;
}
.badge.trial, .badge.external { background: #e0e7ff; color: #3730a3; }
.badge.active, .badge.member { background: var(--ok-soft); color: #065f46; }
.badge.lapsed, .badge.trial_expired, .badge.excluded { background: var(--warn-soft); color: #9a3412; }
.badge.suspended { background: var(--danger-soft); color: #991b1b; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th { font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
tr:last-child td { border-bottom: none; }

.toolbar, .row-actions, .pager, .form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}
.toolbar { margin-bottom: 14px; }
.toolbar label { margin: 0 0 6px; }
.grow { flex: 1 1 220px; }
.facts { display: grid; gap: 8px; margin: 12px 0 0; }
.facts div { display: grid; grid-template-columns: 160px 1fr; gap: 8px; }
.facts dt { color: var(--muted); font-weight: 650; }
.facts dd { margin: 0; }
.code {
  font-family: ui-monospace, monospace;
  font-size: 1.6rem;
  letter-spacing: 0.14em;
  margin: 8px 0;
}
#flash {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100% - 32px));
  background: var(--ink);
  color: #fff;
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}
#flash[hidden] { display: none; }
dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(440px, calc(100% - 32px));
  box-shadow: var(--shadow);
}
dialog form { padding: 22px; }
dialog h2 { margin: 0 0 8px; }
dialog p { margin: 0 0 16px; line-height: 1.5; }
dialog::backdrop { background: rgba(15, 23, 42, 0.45); }

@media (max-width: 860px) {
  .sign-in, .app { grid-template-columns: 1fr; }
  .brand-panel { padding: 28px 22px; }
  .facts div { grid-template-columns: 1fr; }
  .topbar, #orgbar, main#main { padding-left: 16px; padding-right: 16px; }
}

.fact-card-panel .fact-card-head h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.near-quote-block dd p {
  margin: 0.35rem 0 0;
  line-height: 1.45;
  font-size: 0.92rem;
}

.near-quote-block dd p:first-child {
  margin-top: 0;
  color: var(--warn);
  font-weight: 600;
}
