:root {
  color-scheme: light;
  --ink: #15251e;
  --secondary: #42554b;
  --muted: #51655a;
  --line: #d6e0d8;
  --paper: #f5f7f3;
  --white: #fff;
  --forest: #132b22;
  --forest-deep: #102219;
  --mint: #cdeca2;
  --green: #1f5338;
  --accent: #1b5834;
  --good-bg: #edf5e5;
  --warn-bg: #fff2d9;
  --danger: #982e2a;
  --danger-bg: #fbebe8;
  --radius: 9px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); }
a:hover { color: var(--forest); }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 3px solid #498951; outline-offset: 3px; }
[hidden] { display: none !important; }

.skip-link { position: absolute; left: 1rem; top: -6rem; z-index: 3; padding: .7rem; background: var(--white); }
.skip-link:focus { top: 1rem; }
.shell { display: grid; grid-template-columns: 226px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  min-width: 0;
  padding: 28px 20px;
  background: var(--forest);
  color: #d6e7d9;
}
.brand { display: flex; align-items: center; gap: .7rem; margin-bottom: 2.7rem; }
.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 6px;
  background: var(--mint);
  color: var(--forest-deep);
  font-weight: 800;
  font-size: 17px;
}
.brand-name { color: var(--white); font-weight: 740; font-size: 19px; letter-spacing: -.035em; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a {
  position: relative;
  display: block;
  padding: .68rem .8rem;
  border-radius: 6px;
  color: #d6e7d9;
  text-decoration: none;
  font-weight: 600;
}
.sidebar nav a:hover { background: #223e30; color: var(--white); }
.sidebar nav a[aria-current="page"] { background: #2a4536; color: #ebf6e8; }
.sidebar nav a[aria-current="page"]::before {
  position: absolute;
  inset: .65rem auto .65rem 0;
  width: 3px;
  background: var(--mint);
  content: "";
}
.sidebar a:focus-visible { outline-color: var(--mint); }
.identity { margin: 2rem .8rem 0; color: #bdd2c1; font-size: .85rem; overflow-wrap: anywhere; }

.workspace { min-width: 0; width: 100%; max-width: 1510px; padding: 39px clamp(18px, 4vw, 58px) 70px; }
.page-header, .section-head, .detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}
.page-header { margin-bottom: 1.5rem; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2rem, 4vw, 3.13rem); line-height: 1.08; font-weight: 750; letter-spacing: -.055em; }
h2 { font-size: 1.23rem; font-weight: 735; line-height: 1.22; letter-spacing: -.025em; }
h3 { font-size: 1rem; line-height: 1.3; }
.subtitle { margin-top: .55rem; color: var(--muted); }
.section-head { margin-bottom: .95rem; }
.section-head a { font-weight: 620; }
.card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  padding: clamp(16px, 2vw, 24px);
}
.card + .card, .page-section + .page-section, .card + .page-section, .page-section + .card { margin-top: 1.4rem; }
.heading-text { color: var(--muted); font-size: .91rem; }
.card h2 + .heading-text, .card h3 + .heading-text { margin-top: .3rem; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .85rem; margin: 0 0 1.4rem; }
.metric { margin: 0; min-width: 0; }
.metric dt { color: var(--secondary); font-size: .91rem; font-weight: 620; }
.metric dd { margin: .3rem 0 0; font-size: 1.85rem; font-weight: 745; line-height: 1.15; letter-spacing: -.045em; }

.search-form { display: flex; flex-wrap: wrap; align-items: end; gap: .55rem; margin: 0 0 1.4rem; }
.search-form label { flex: 1; min-width: min(100%, 20rem); }
.search-reset { padding: .54rem .46rem; font-weight: 620; }
.form-columns { display: flex; flex-wrap: wrap; align-items: end; gap: .7rem; margin-top: .85rem; }
.form-columns > label { flex: 1 1 10rem; min-width: 0; }
.form-columns > .grow { flex-basis: 13rem; }
.form-columns button { flex: 0 0 auto; }
label { display: grid; gap: .36rem; color: var(--secondary); font-size: .87rem; font-weight: 630; }
input:not([type="checkbox"]), select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 2.61rem;
  padding: .54rem .63rem;
  border: 1px solid #abbdb0;
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  font-size: .94rem;
}
input::placeholder, textarea::placeholder { color: #62736a; opacity: 1; }
textarea { resize: vertical; }
.checkbox { display: flex; align-items: start; gap: .55rem; padding: .25rem 0; }
.checkbox input { width: 1rem; height: 1rem; flex: 0 0 auto; margin: .13rem 0 0; accent-color: var(--accent); }
.button, button {
  display: inline-block;
  min-height: 2.61rem;
  padding: .55rem .85rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-weight: 690;
  white-space: normal;
  text-decoration: none;
  cursor: pointer;
}
.button:hover, button:hover { background: #104526; color: white; }
.button.secondary, button.secondary { background: var(--white); border-color: #abc1af; color: var(--green); }
.button.secondary:hover, button.secondary:hover { background: #eef5ee; color: var(--green); }
.button.danger, button.danger { background: var(--danger); color: var(--white); }
.button.danger:hover, button.danger:hover { background: #752423; }

.notice {
  padding: .78rem .95rem;
  margin-bottom: 1rem;
  border: 1px solid #bad2b2;
  border-radius: var(--radius);
  background: var(--good-bg);
  color: #25442d;
}
.notice.error { border-color: #e8a8a2; background: var(--danger-bg); color: #742322; }
.key-notice { margin-bottom: 1.4rem; }
.key-notice p { margin: .3rem 0 .75rem; }
.key-value { max-width: 47rem; }
.key-value input { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.key-value input::selection { background: var(--mint); color: var(--forest); }

.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: .72rem .85rem; vertical-align: top; }
th {
  background: #f1f5ef;
  color: var(--secondary);
  font-size: .82rem;
  font-weight: 710;
  white-space: nowrap;
}
td { border-top: 1px solid var(--line); overflow-wrap: anywhere; }
td:first-child, th:first-child { padding-left: 1rem; }
td:last-child, th:last-child { padding-right: 1rem; }
td small, .detail-note { display: block; margin-top: .3rem; color: var(--muted); }
.num, time, .nowrap { white-space: nowrap; }
.id-text {
  color: var(--secondary);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: .83rem;
  overflow-wrap: anywhere;
}
.table-scroll table { min-width: 575px; }
.table-scroll.audit-table table { min-width: 720px; }
.table-actions { min-width: 13rem; }
.empty { padding: 1.35rem; color: var(--muted); }
.badge {
  display: inline-block;
  padding: .12rem .52rem;
  border: 1px solid #d7e0d6;
  border-radius: 4px;
  background: #f2f5f0;
  color: #3c5546;
  font-size: .82rem;
  font-weight: 660;
  white-space: nowrap;
}
.badge.active, .badge.paid, .badge.applied { background: var(--good-bg); border-color: #c7ddbc; color: #24532e; }
.badge.pending, .badge.awaiting_payment { background: var(--warn-bg); border-color: #e8d5a8; color: #765119; }
.badge.revoked, .badge.cancelled, .badge.refunded { background: var(--danger-bg); border-color: #ecc5ba; color: #862b28; }

details > summary { color: var(--accent); font-weight: 660; cursor: pointer; }
details > summary:hover { color: var(--forest); }
.details-body { padding: .55rem 0 0; }
.details-body form, .action-form { display: grid; gap: .65rem; justify-items: stretch; }
.details-body button, .action-form button { justify-self: start; }
.subscription-list { display: grid; gap: .8rem; }
.subscription-list > .card { margin: 0; }
.detail-head { align-items: start; }
.detail-head h2 { margin-top: .05rem; overflow-wrap: anywhere; }
.detail-head > div { flex: 1 1 15rem; min-width: 0; }
.detail-id { display: block; margin-top: .3rem; color: var(--muted); }
.detail-data {
  margin: .95rem 0;
  padding-bottom: .95rem;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
  gap: .8rem;
}
.detail-data dt { color: var(--muted); font-size: .83rem; }
.detail-data dd { margin: .21rem 0 0; overflow-wrap: anywhere; }
.operations { display: grid; gap: .55rem; }
.operations > details {
  padding: .55rem .72rem;
  border: 1px solid #e2eae1;
  border-radius: 6px;
  background: #fcfdfb;
}
.operations .danger-text { color: var(--danger); }
.operation-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.full-width { grid-column: 1 / -1; }

@media (max-width: 920px) {
  .shell { grid-template-columns: 172px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  .brand { padding-inline: .25rem; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 690px) {
  .shell { display: block; }
  .sidebar { padding: .8rem 1rem .6rem; }
  .brand { margin: 0 0 .65rem; padding: 0; }
  .brand-mark { width: 27px; height: 27px; font-size: .9rem; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: .22rem .4rem; }
  .sidebar nav a { padding: .45rem .55rem; font-size: .87rem; }
  .sidebar nav a[aria-current="page"]::before { inset: auto .5rem 0; width: auto; height: 2px; }
  .identity { margin: .65rem 0 0; }
  .workspace { padding-top: 24px; }
  .operation-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 380px) {
  .metrics { grid-template-columns: 1fr; }
  .search-form button, .form-columns button { width: 100%; }
}

.identity p { margin: 0 0 .3rem; }
.signout {
  min-height: auto;
  margin: 0;
  padding: .28rem 0;
  border: 0;
  background: transparent;
  color: #bdd2c1;
  font-size: .86rem;
}
.signout:hover { background: transparent; color: white; text-decoration: underline; }
.signout:focus-visible { outline-color: var(--mint); }
button:disabled { cursor: default; opacity: .58; }
.operation-grid { align-items: end; }

.login {
  display: grid;
  min-height: 100vh;
  padding: 1rem;
  place-items: center;
  background: #e5ede4;
}
.login-card { width: min(100%, 30rem); padding: clamp(20px, 5vw, 35px); }
.login-card .brand { margin: 0 0 1.2rem; padding: 0; }
.login-card .brand-name { color: var(--forest); }
.login-card h1 { margin-bottom: 1.2rem; font-size: clamp(1.75rem, 5vw, 2.35rem); }
.login-card .action-form > button { justify-self: stretch; margin-top: .2rem; }
