:root {
  --ink: #14211c;
  --muted: #66736d;
  --paper: #f4f6f1;
  --panel: #fff;
  --line: #dce3dc;
  --brand: #096b4b;
  --brand-dark: #064b36;
  --accent: #d7f05a;
  --danger: #a52b2b;
  --shadow: 0 18px 50px rgba(23, 43, 34, .09);
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { min-height: 100vh; margin: 0; }
button, input, select, textarea { font: inherit; }
button { padding: .72rem 1rem; border: 0; border-radius: 10px; background: var(--brand); color: #fff; font-weight: 700; cursor: pointer; }
button:hover { background: var(--brand-dark); }
button:disabled { cursor: not-allowed; opacity: .55; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(9, 107, 75, .25); outline-offset: 2px; }
.secondary, .quiet { background: #edf2ed; color: var(--ink); }
.secondary:hover, .quiet:hover { background: #dde7df; }
.danger-button { border: 1px solid #efcaca; background: #fff0f0; color: var(--danger); }
.danger-button:hover { background: #fbdede; }

.auth-page { display: grid; place-items: center; padding: 2rem; background: radial-gradient(circle at 20% 10%, #e6f4bd 0, transparent 34%), linear-gradient(135deg, #eef2e8, #f8faf6); }
.auth-card { width: min(440px, 100%); padding: 2.5rem; border: 1px solid rgba(255, 255, 255, .7); border-radius: 24px; background: rgba(255, 255, 255, .92); box-shadow: var(--shadow); }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--brand); color: var(--accent); font-size: 1.25rem; font-weight: 900; }
.auth-card .brand-mark { width: 54px; height: 54px; border-radius: 16px; font-size: 1.6rem; }
.eyebrow { margin: 1.2rem 0 .35rem; color: var(--brand); font-size: .72rem; font-weight: 900; letter-spacing: .14em; }
.auth-card h1 { margin: .3rem 0; font-size: 2rem; line-height: 1.05; }
.muted { color: var(--muted); line-height: 1.55; }
.stack { display: grid; gap: 1rem; margin-top: 1.5rem; }
label { display: grid; gap: .42rem; color: #34423c; font-size: .88rem; font-weight: 700; }
input, select, textarea { width: 100%; padding: .72rem .8rem; border: 1px solid #cdd7cf; border-radius: 10px; background: #fff; color: var(--ink); }
textarea { min-height: 110px; resize: vertical; }
.error { margin: 0; color: var(--danger); font-weight: 700; }
.field-help { color: var(--muted); font-size: .76rem; font-weight: 500; line-height: 1.4; }
.field-label { display: flex; align-items: center; gap: .4rem; }
.help-tip { position: relative; display: inline-grid; place-items: center; width: 1.2rem; height: 1.2rem; border: 1px solid #9eaca3; border-radius: 50%; color: var(--brand-dark); font-size: .74rem; font-weight: 900; line-height: 1; cursor: help; }
.help-tip::after { position: absolute; z-index: 20; bottom: calc(100% + .55rem); left: 0; display: none; width: min(29rem, calc(100vw - 4rem)); padding: .8rem .9rem; border-radius: 10px; background: #14211c; box-shadow: 0 12px 35px rgba(0, 0, 0, .2); color: #fff; content: attr(data-tooltip); font-size: .78rem; font-weight: 500; line-height: 1.45; white-space: pre-line; }
.help-tip:hover::after, .help-tip:focus::after { display: block; }
.help-tip:focus-visible { outline: 3px solid rgba(9, 107, 75, .25); outline-offset: 2px; }

.topbar { display: flex; align-items: center; justify-content: space-between; height: 72px; padding: 0 1.5rem; border-bottom: 1px solid var(--line); background: #fff; }
.brand, .session { display: flex; align-items: center; gap: .8rem; }
.brand strong, .brand small { display: block; }
.brand small { margin-top: .14rem; color: var(--muted); }
.shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: calc(100vh - 72px); }
.side-nav { display: grid; align-content: start; gap: .35rem; padding: 1rem; border-right: 1px solid var(--line); background: #f8faf7; }
.side-nav button { background: transparent; color: #405049; text-align: left; }
.side-nav button:hover, .side-nav button.active { background: #e3eee5; color: var(--brand-dark); }
#workspace { overflow: hidden; padding: 2rem; }
.page-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 1.5rem; }
.page-heading h1 { margin: 0; font-size: 2rem; }
.page-heading .eyebrow { margin: 0 0 .35rem; }
.notice { margin-bottom: 1rem; padding: 1rem; border-radius: 12px; background: #e5f4e9; color: #164e34; }
.notice.bad { background: #fde7e7; color: #7f1d1d; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.stat { padding: 1.2rem; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.stat strong { display: block; font-size: 2rem; }
.stat span { color: var(--muted); }
.panel { overflow: hidden; margin-top: 1.25rem; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0; font-size: 1.05rem; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .75rem 1rem; border-bottom: 1px solid #edf0ed; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .8em; }
.badge { display: inline-flex; padding: .25rem .5rem; border-radius: 999px; background: #eaf0eb; color: #425048; font-size: .74rem; font-weight: 800; }
.badge.active, .badge.succeeded { background: #dcf5e6; color: #13643b; }
.badge.pending_local, .badge.awaiting_approval, .badge.queued { background: #fff2c7; color: #765b00; }
.badge.failed, .badge.revoked, .badge.denied, .badge.disabled { background: #fde2e2; color: #8c2222; }
.action-row { display: flex; align-items: center; gap: .45rem; }
.action-row button { padding: .42rem .62rem; font-size: .78rem; }
.icon-action { display: inline-grid; place-items: center; width: 2rem; height: 2rem; padding: 0; border: 1px solid #cfd9d1; background: #f3f6f3; color: var(--brand-dark); font-size: 1rem; }
.icon-action:hover { background: #dfe9e1; }
.icon-action.danger { border-color: #efcaca; background: #fff0f0; color: var(--danger); }
.icon-action.danger:hover { background: #fbdede; }

dialog { width: min(620px, calc(100% - 2rem)); padding: 0; border: 0; border-radius: 18px; box-shadow: 0 30px 90px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(10, 25, 18, .52); }
dialog form { padding: 1.3rem; }
dialog header, dialog footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
dialog h2 { margin: 0; }
.icon-button { padding: .3rem .65rem; background: transparent; color: var(--ink); font-size: 1.6rem; }
.error-box { margin-top: 1rem; padding: .8rem 1rem; border-radius: 10px; background: #fde7e7; color: #7f1d1d; font-weight: 700; }
.recovery-codes { overflow: auto; padding: 1rem; border-radius: 10px; background: #f3f5f2; }
dialog footer { justify-content: flex-end; margin-top: 1.5rem; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.check-grid label { display: flex; align-items: center; gap: .5rem; }
.check-grid input { width: auto; }
.empty { padding: 2rem; color: var(--muted); text-align: center; }

@media (max-width: 850px) {
  .shell { grid-template-columns: 1fr; }
  .side-nav { display: flex; overflow: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .side-nav button { white-space: nowrap; }
  #workspace { padding: 1rem; }
  .session span { display: none; }
}
