:root {
  color: #17211b;
  background: #f4f6f4;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
  --ink: #17211b;
  --muted: #66716a;
  --line: #dce2dd;
  --panel: #ffffff;
  --green: #176447;
  --green-dark: #104a36;
  --green-soft: #e9f4ee;
  --lime: #c8ed65;
  --red: #a23a35;
  --red-soft: #faecea;
  --amber: #8a5a0a;
  --amber-soft: #fff5dc;
  --shadow: 0 12px 32px rgba(28, 42, 33, .08);
}
.legal-document { width: min(720px, calc(100% - 40px)); margin: 64px auto; color: var(--ink); line-height: 1.65; }
.legal-document h1 { margin-bottom: 24px; font-size: 32px; }
.legal-document code { border-radius: 3px; padding: 2px 5px; background: #e9eeea; }

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; min-height: 100vh; }
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 24px; line-height: 1.25; }
h2 { margin-bottom: 4px; font-size: 18px; line-height: 1.3; }
h3 { margin-bottom: 0; font-size: 15px; }
code { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }

.button { min-height: 40px; border: 1px solid transparent; border-radius: 5px; padding: 9px 16px; font-weight: 700; transition: background .15s, border-color .15s, transform .15s; }
.button:active:not(:disabled) { transform: translateY(1px); }
.button.primary { background: var(--green); color: #fff; }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { border-color: #cbd4cd; background: #fff; color: var(--ink); }
.button.secondary:hover { border-color: #99aa9d; background: #f9fbf9; }
.button.danger { background: var(--red); color: #fff; }
.button.compact { min-height: 36px; padding: 7px 12px; }
.full-button { width: 100%; margin-top: 22px; }
.icon-button { display: inline-grid; width: 36px; height: 36px; place-items: center; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: 20px; }
.icon-button:hover { background: #edf1ee; color: var(--ink); }
.text-button { border: 0; background: transparent; color: var(--green); padding: 6px 0; font-weight: 700; }

.auth-view { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: linear-gradient(115deg, #15251d 0 44%, #eef2ee 44% 100%); }
.auth-panel { width: min(100%, 440px); margin-left: 18%; padding: 42px; border: 1px solid var(--line); border-radius: 7px; background: #fff; box-shadow: var(--shadow); }
.product-mark, .brand-mark { display: grid; place-items: center; background: var(--lime); color: #15251d; font-weight: 900; }
.product-mark { width: 48px; height: 48px; margin-bottom: 28px; font-size: 21px; }
.auth-panel h1 { font-size: 28px; }
.kicker { margin-bottom: 6px; color: var(--green); font-size: 10px; font-weight: 900; letter-spacing: 0; }
.auth-copy, .dialog-copy { margin: 10px 0 26px; color: var(--muted); line-height: 1.55; }
.auth-form { display: grid; gap: 16px; }
.auth-form .full-button { margin-top: 4px; }
.auth-switch { justify-self: start; padding: 0; font-size: 13px; }
.inline-loading { display: flex; align-items: center; gap: 9px; margin-top: 18px; color: var(--muted); font-size: 13px; }
.message { margin: 14px 0 0; font-size: 13px; line-height: 1.45; }
.error-message { color: var(--red); }
label { display: grid; gap: 7px; color: #344039; font-size: 13px; font-weight: 700; }
input { width: 100%; height: 43px; border: 1px solid #cbd3cd; border-radius: 4px; background: #fff; color: var(--ink); padding: 9px 11px; outline: none; }
input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 100, 71, .12); }
select { width: 100%; height: 43px; border: 1px solid #cbd3cd; border-radius: 4px; background: #fff; color: var(--ink); padding: 8px 30px 8px 11px; outline: none; }
select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 100, 71, .12); }
.legal-links { display: flex; gap: 16px; margin: 22px 0 0; font-size: 12px; }
.legal-links a, .consent-label a { color: var(--green); }
.consent-label { display: flex; grid-template-columns: none; align-items: flex-start; gap: 9px; margin-top: 18px; font-weight: 500; line-height: 1.5; }
.consent-label input { flex: 0 0 auto; width: 16px; height: 16px; margin-top: 2px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 228px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; z-index: 20; height: 100vh; display: flex; flex-direction: column; padding: 20px 13px; background: #18251e; color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 9px 28px; font-weight: 800; }
.brand-mark { width: 30px; height: 30px; }
.sidebar nav { display: grid; gap: 3px; }
.nav-item { width: 100%; min-height: 42px; display: flex; align-items: center; gap: 11px; border: 0; border-left: 3px solid transparent; border-radius: 2px; padding: 9px 11px; background: transparent; color: #b8c2bb; text-align: left; font-weight: 600; }
.nav-item:hover { background: #23332a; color: #fff; }
.nav-item.active { border-left-color: var(--lime); background: #293a30; color: #fff; }
.nav-icon { width: 17px; font-size: 17px; text-align: center; }
.sidebar-account { min-width: 0; display: grid; grid-template-columns: 34px minmax(0, 1fr) 36px; align-items: center; gap: 9px; margin-top: auto; padding: 17px 4px 0; border-top: 1px solid #36433b; }
.sidebar-account > div { min-width: 0; }
.sidebar-account strong, .sidebar-account span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-account strong { font-size: 13px; }
.sidebar-account div span { margin-top: 3px; color: #98a59d; font-size: 11px; }
.sidebar-account .icon-button { color: #aeb9b2; }
.avatar { width: 34px; height: 34px; display: grid !important; place-items: center; border-radius: 50%; background: #e9f2ec; color: #173a29; font-weight: 800; }

.workspace { min-width: 0; padding: 0 30px 46px; }
.topbar { height: 90px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.menu-button { display: none; }
.view { padding-top: 26px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric-card { min-height: 142px; display: flex; flex-direction: column; padding: 20px; border: 1px solid var(--line); border-top: 3px solid #91a198; border-radius: 6px; background: var(--panel); }
.metric-card:first-child { border-top-color: var(--green); }
.metric-label, .metric-note { color: var(--muted); font-size: 12px; }
.metric-value { margin: 17px 0 7px; font-size: 28px; line-height: 1; overflow-wrap: anywhere; }
.metric-note { margin-top: auto; }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); gap: 14px; margin-top: 14px; }
.surface { min-width: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.section-heading { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.section-heading p { margin-bottom: 0; color: var(--muted); font-size: 12px; }
.page-section-heading { min-height: auto; padding: 0 0 18px; border: 0; }
.page-section-heading h2 { font-size: 20px; }
.table-surface { overflow: hidden; }
.filter-bar { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: #eef2ee; }
.filter-bar label { min-width: 135px; flex: 1 1 150px; }
.filter-bar input, .filter-bar select { height: 38px; background: #fff; }
.filter-actions { display: flex; gap: 8px; margin-left: auto; }
.compact-list { padding: 2px 18px; }
.compact-row, .activity-row { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid #edf0ed; }
.compact-row:last-child, .activity-row:last-child { border-bottom: 0; }
.compact-row > div, .activity-row > div { min-width: 0; display: grid; gap: 4px; }
.compact-row strong, .activity-row strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.compact-row span, .activity-row span { color: var(--muted); font-size: 11px; }
.activity-row { justify-content: flex-start; }
.activity-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.numeric { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { height: 43px; padding: 9px 16px; background: #f8faf8; color: var(--muted); text-align: left; font-size: 11px; text-transform: uppercase; }
td { height: 62px; padding: 11px 16px; border-top: 1px solid #e8ece9; color: #354039; }
td.numeric, th.numeric { text-align: right; }
.primary-cell { min-width: 180px; display: grid; gap: 5px; }
.primary-cell strong { color: var(--ink); }
.primary-cell code { color: var(--muted); font-size: 11px; }
.action-cell { width: 54px; text-align: right; }
.revoke-button { color: var(--red); }
.status { display: inline-flex; align-items: center; min-height: 24px; border-radius: 999px; padding: 3px 8px; background: #eef1ef; color: #526058; font-size: 11px; font-weight: 800; text-transform: capitalize; white-space: nowrap; }
.status-active, .status-success, .status-succeeded, .status-completed { background: var(--green-soft); color: var(--green-dark); }
.status-pending, .status-processing { background: var(--amber-soft); color: var(--amber); }
.status-revoked, .status-failed, .status-error { background: var(--red-soft); color: var(--red); }
.status-expired { background: var(--amber-soft); color: var(--amber); }
.pagination { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.pagination-actions { display: flex; gap: 8px; }
.standalone-pagination { margin-top: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }

.model-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.model-card { min-height: 155px; display: flex; flex-direction: column; padding: 18px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.model-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.model-heading code { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 22px; }
.chip { border: 1px solid #d5ddd7; border-radius: 3px; padding: 4px 7px; color: #4d5a52; background: #fafbfa; font-size: 10px; text-transform: capitalize; }
.muted, .model-meta { color: var(--muted); font-size: 11px; }
.model-meta { margin: auto 0 0; padding-top: 14px; }
.loading-state, .empty-state { min-height: 210px; display: flex; align-items: center; justify-content: center; gap: 9px; color: var(--muted); font-size: 13px; }
.empty-state { flex-direction: column; text-align: center; padding: 28px; }
.empty-state strong { color: #3b4740; font-size: 14px; }
.empty-state p { max-width: 330px; margin-bottom: 0; line-height: 1.5; }
.spinner { width: 16px; height: 16px; display: inline-block; border: 2px solid #d6ddd8; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { position: relative; overflow: hidden; }
.skeleton::after { position: absolute; inset: 0; content: ""; background: linear-gradient(100deg, transparent 20%, rgba(236, 241, 237, .9) 45%, transparent 70%); transform: translateX(-100%); animation: shimmer 1.25s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

.banner { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 18px; border: 1px solid #ebc4c0; border-radius: 5px; padding: 8px 10px 8px 15px; background: var(--red-soft); color: var(--red); font-size: 13px; }
.notice-banner { border-color: #e3ce98; background: var(--amber-soft); color: #664407; }
.banner-actions { display: flex; flex: 0 0 auto; gap: 8px; }
.button:is(a) { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.settings-section { padding: 20px; }
.settings-section h3 { margin-bottom: 20px; font-size: 16px; }
.inline-form { display: flex; align-items: stretch; gap: 9px; }
.inline-form input { min-width: 0; }
.details-list { margin: 0; }
.details-list > div { display: flex; justify-content: space-between; gap: 20px; padding: 11px 0; border-bottom: 1px solid #edf0ed; }
.details-list dt { color: var(--muted); font-size: 12px; }
.details-list dd { margin: 0; font-size: 13px; font-weight: 700; text-align: right; overflow-wrap: anywhere; }
.settings-link { margin-top: 18px; }
.settings-legal { margin-top: 18px; }
.dialog-field { margin-top: 18px; }
dialog { width: min(calc(100% - 28px), 480px); border: 1px solid var(--line); border-radius: 7px; padding: 0; color: var(--ink); box-shadow: 0 24px 70px rgba(15, 25, 19, .22); }
dialog::backdrop { background: rgba(20, 31, 24, .48); }
dialog form, .dialog-body { padding: 24px; }
dialog header { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
dialog header h2 { font-size: 20px; }
.scope-fieldset { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 18px 0 0; border: 1px solid var(--line); border-radius: 5px; padding: 14px; }
.scope-fieldset legend { padding: 0 5px; color: var(--muted); font-size: 12px; }
.scope-fieldset label { display: flex; align-items: center; gap: 7px; color: #3b4740; font-size: 12px; font-weight: 500; }
.scope-fieldset input { width: auto; min-height: 0; }
dialog footer { display: flex; justify-content: flex-end; gap: 9px; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }
.secret-dialog { width: min(calc(100% - 28px), 590px); }
.secret-field { display: flex; align-items: stretch; gap: 8px; }
.secret-field code { min-width: 0; flex: 1; display: flex; align-items: center; overflow-x: auto; border: 1px solid #cad4cc; border-radius: 4px; padding: 10px 12px; background: #f5f8f5; color: #153b29; font-size: 12px; white-space: nowrap; user-select: all; }
.copy-status { min-height: 18px; margin: 7px 0 0; color: var(--green); font-size: 12px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 100; max-width: min(360px, calc(100vw - 32px)); border-radius: 5px; padding: 12px 16px; background: #17251d; color: #fff; box-shadow: var(--shadow); font-size: 13px; opacity: 0; pointer-events: none; transform: translateY(10px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.toast-error { background: var(--red); }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-grid { grid-template-columns: 1fr; }
  .model-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .auth-view { padding: 18px; background: #eef2ee; }
  .auth-panel { margin-left: 0; padding: 30px 24px; }
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); width: min(84vw, 270px); box-shadow: 18px 0 45px rgba(15, 25, 19, .2); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .workspace { padding: 0 16px 36px; }
  .topbar { height: 76px; justify-content: flex-start; }
  .topbar > div { min-width: 0; flex: 1; }
  .topbar h1 { font-size: 20px; }
  .menu-button { display: inline-grid; flex: 0 0 auto; }
  .topbar .button { font-size: 0; }
  .topbar .button span { font-size: 18px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric-card { min-height: 125px; padding: 15px; }
  .metric-value { font-size: 22px; }
  .view { padding-top: 20px; }
  .section-heading { padding: 14px; }
  .page-section-heading { align-items: flex-end; padding: 0 0 15px; }
  .model-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .banner { align-items: flex-start; flex-direction: column; }
  .banner-actions { width: 100%; flex-wrap: wrap; }
  th, td { padding-left: 13px; padding-right: 13px; }
}

@media (max-width: 430px) {
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 116px; }
  .compact-row { align-items: flex-start; flex-direction: column; gap: 7px; padding: 13px 0; }
  .compact-row .numeric { text-align: left; }
  .secret-field { align-items: stretch; flex-direction: column; }
  .filter-bar { display: grid; grid-template-columns: 1fr; }
  .filter-bar label { min-width: 0; }
  .filter-actions { margin-left: 0; }
  .filter-actions .button { flex: 1; }
  .inline-form { align-items: stretch; flex-direction: column; }
  dialog form, .dialog-body { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
