:root {
  color-scheme: light;
  --ink: #14233a;
  --muted: #53637b;
  --surface: #fff;
  --page: #f3f6fb;
  --nav: #10243f;
  --line: #dfe6f0;
  --primary: #204ebd;
  --primary-hover: #173c95;
  --focus: #176dcd;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 100%;
  line-height: 1.45;
  color: var(--ink);
  background: var(--page);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: default; opacity: .52; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
a { color: var(--primary); text-underline-offset: .2em; }

.topbar { background: var(--nav); color: #f5f8ff; }
.topbar-inner { max-width: 1540px; min-height: 68px; margin: auto; padding: .7rem clamp(1rem, 3vw, 3rem); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand, .account, .toolbar { display: flex; align-items: center; gap: .75rem; }
.brand-mark { display: grid; place-items: center; width: 2.45rem; height: 2.45rem; border-radius: .75rem; background: #b8d6ff; color: #193a74; font-size: 1.24rem; font-weight: 800; }
.brand strong, .brand div span { display: block; }
.brand strong { line-height: 1.15; letter-spacing: .01em; }
.brand div span { margin-top: .2rem; color: #bfcde2; font-size: .78rem; }
.account { min-width: 0; }
.account-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #dbe6f7; font-size: .875rem; }
.top-button { min-height: 2.4rem; padding: .35rem .75rem; border: 1px solid #526988; border-radius: .5rem; color: #fff; background: transparent; }
.top-button:hover { background: #28415f; }
.top-button:focus-visible { outline-color: #b8d6ff; }

.workspace { max-width: 1540px; margin: auto; padding: 2.65rem clamp(1rem, 3vw, 3rem) 3.2rem; }
.heading { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1.4rem; }
.heading-actions { flex-wrap: wrap; }
.section-label { color: #405779; font-size: .84rem; letter-spacing: .055em; font-weight: 700; margin-bottom: .4rem; }
h1 { font-size: clamp(1.8rem, 3.5vw, 2.65rem); line-height: 1.1; letter-spacing: -.045em; }
h2 { font-size: 1.3rem; line-height: 1.22; letter-spacing: -.023em; }
.muted { color: var(--muted); font-size: .875rem; }
.workspace-nav { display: flex; gap: .38rem; flex-wrap: wrap; margin-bottom: 1.2rem; border-bottom: 1px solid #cbd8eb; }
.workspace-nav button { min-height: 2.5rem; padding: .35rem .65rem; border: 0; border-bottom: 3px solid transparent; background: transparent; border-radius: .35rem .35rem 0 0; color: var(--muted); font-weight: 650; }
.workspace-nav button[aria-pressed="true"] { border-bottom-color: var(--primary); color: var(--primary); }
.workspace-nav button:hover { background: #e8effb; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 2.65rem; border: 1px solid #c8d3e3; padding: .45rem .9rem; border-radius: .52rem; font-size: .9rem; font-weight: 650; color: var(--ink); text-decoration: none; background: var(--surface); white-space: nowrap; }
.button:hover:not(:disabled) { background: #eaf0fa; border-color: #a9bad0; }
.button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.button.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.button.compact { min-height: 2.2rem; padding: .3rem .65rem; }
.button.quiet { border-color: transparent; background: transparent; color: var(--primary); }

.cards { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1.08fr; gap: .85rem; margin-bottom: 1.4rem; }
.stat-card { min-width: 0; min-height: 8.65rem; padding: .9rem 1rem; border: 1px solid var(--line); background: var(--surface); border-radius: .8rem; }
.stat-label { display: block; color: #3f5371; font-size: .9rem; line-height: 1.25; font-weight: 650; }
.stat-card strong { display: block; margin-top: .43rem; font-size: clamp(1.75rem, 3vw, 2.35rem); line-height: 1.15; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.stat-note { margin-top: .45rem; color: var(--muted); font-size: .82rem; }
.snapshot-card { background: #ebf2ff; border-color: #d5e3fa; }
.snapshot-card select { margin-top: .55rem; }

input:not([type="checkbox"]), select, textarea { display: block; width: 100%; min-height: 2.6rem; border: 1px solid #bbc9dc; border-radius: .48rem; padding: .45rem .65rem; background: #fff; color: var(--ink); }
input::placeholder, textarea::placeholder { color: #65768f; }
select { appearance: none; padding-right: 1.7rem; text-overflow: ellipsis; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='9' viewBox='0 0 12 9'%3E%3Cpath fill='none' stroke='%23465b78' stroke-width='1.5' stroke-linejoin='round' d='m1 2 5 5 5-5'/%3E%3C/svg%3E") no-repeat right .65rem center; }
textarea { resize: vertical; }
input, select, textarea { min-width: 0; }

.registry { border: 1px solid var(--line); background: var(--surface); border-radius: .9rem; overflow: hidden; }
.registry-head { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: 1.1rem 1.15rem .9rem; }
.registry-head h2 + p { margin-top: .3rem; }
.filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .78rem .85rem; border-top: 1px solid var(--line); padding: .95rem 1.15rem 1.05rem; background: #f9fbfe; }
.filter-search { grid-column: span 2; }
.filter label, .dialog-body > label, .stack label, .import-grid label { display: block; margin-bottom: .25rem; font-size: .875rem; color: #3d516e; font-weight: 650; }
.filter input, .filter select, .snapshot-card select { font-size: .875rem; }
.filter-actions { display: flex; justify-content: start; align-items: end; }
.filter-actions .button { margin-left: -.5rem; }
.table-wrap { border-top: 1px solid var(--line); overflow-x: auto; }
.table-wrap:focus-visible { outline-offset: -3px; }
table { min-width: 1030px; width: 100%; border-spacing: 0; text-align: left; font-size: .925rem; }
#tandem-table table { min-width: 880px; }
th { padding: .72rem .7rem; font-size: .875rem; color: #405774; background: #f2f6fc; font-weight: 680; }
th:first-child, td:first-child { padding-left: 1.15rem; }
th:last-child, td:last-child { padding-right: 1.15rem; }
th button { background: none; border: 0; font-weight: inherit; padding: 0; color: inherit; text-align: inherit; }
th button:hover { color: var(--primary); }
th button span { display: inline-block; margin-left: .12rem; color: var(--primary); }
td { border-top: 1px solid #edf1f7; padding: .62rem .7rem; max-width: 17rem; overflow-wrap: anywhere; vertical-align: top; }
tbody tr:not(.group-row):hover td { background: #f8faff; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.chat-cell { min-width: 9.2rem; }
.chat-name { font-weight: 690; }
.cell-note { display: block; font-size: .82rem; color: var(--muted); margin-top: .18rem; }
.comment-cell { min-width: 10rem; }
.comment-preview { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.group-row th { background: #e7eefb; color: #294d80; text-align: left; border-top: 1px solid #d6e1f3; }
.pill { display: inline-block; max-width: 100%; padding: .22rem .48rem; background: #edf1f6; border-radius: .35rem; color: #3d516a; font-size: .8rem; line-height: 1.25; }
.pill.good { background: #e0f1e9; color: #206045; }
.pill.warn { background: #fff1da; color: #754910; }
.row-details { border: 1px solid #cbd8eb; background: #fff; min-height: 2rem; border-radius: .4rem; padding: .2rem .5rem; color: var(--primary); font-size: .83rem; }
.row-details:hover { background: #e9f1ff; }
.pagination { border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; justify-content: space-between; gap: .65rem; align-items: center; padding: .75rem 1.15rem; font-size: .875rem; color: var(--muted); }
.pagination select { min-height: 2.2rem; width: auto; }
.pagination .toolbar { flex-wrap: wrap; gap: .42rem; }
.empty { padding: 2.1rem 1.1rem; text-align: center; color: var(--muted); }

.loader { margin: 3rem auto; text-align: center; color: var(--muted); padding: 0 1rem; }
.login { padding: clamp(2rem, 9vh, 6.25rem) 1rem; }
.login-card { width: min(100%, 28rem); margin: auto; padding: clamp(1.3rem, 5vw, 2.15rem); border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); box-shadow: 0 12px 40px #13335e19; }
.login-card .muted { margin-top: .65rem; }
.stack { margin-top: 1.3rem; }
.stack input + label { margin-top: .85rem; }
.stack .button { margin-top: 1rem; width: 100%; }
.form-error { margin-top: .7rem; color: #9d1b31; font-size: .9rem; }
.workspace-error { padding: .8rem 1rem; border-radius: .6rem; background: #ffedf0; color: #80213a; margin-bottom: 1rem; display: flex; gap: .6rem; align-items: center; justify-content: space-between; }

dialog { border: 1px solid var(--line); padding: 0; width: min(calc(100% - 1.5rem), 41rem); max-height: calc(100% - 1.5rem); border-radius: .9rem; box-shadow: 0 20px 55px #132b5166; color: var(--ink); }
dialog::backdrop { background: #10243f80; }
.dialog-body { padding: 1.1rem 1.3rem 1.3rem; }
.dialog-head { display: flex; align-items: start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.close { width: 2rem; height: 2rem; border: 0; border-radius: .4rem; background: #edf2fa; color: var(--ink); font-size: 1.35rem; line-height: 1; }
.dialog-body > select, .dialog-body > input { margin-bottom: .8rem; }
.dialog-body textarea + p { margin-top: .35rem; }
.dialog-body fieldset { border: 1px solid var(--line); min-width: 0; margin: .9rem 0 0; border-radius: .55rem; padding: .65rem .77rem .85rem; }
.dialog-body legend { padding: 0 .3rem; color: #3d516e; font-size: .875rem; font-weight: 650; }
.import-grid { display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: .6rem; margin-top: .55rem; }
.import-grid label input { margin-top: .25rem; font-size: .9rem; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: .6rem; margin-top: 1rem; }
.group-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem .85rem; margin: 0 0 1rem; padding: .75rem; background: #f4f7fc; border-radius: .5rem; }
.group-details dt { font-size: .83rem; font-weight: 650; color: var(--muted); }
.group-details dd { margin: .1rem 0 0; overflow-wrap: anywhere; }
.toast { position: fixed; bottom: 1rem; right: 1rem; z-index: 3; max-width: calc(100% - 2rem); padding: .7rem 1rem; border-radius: .55rem; background: var(--nav); color: #fff; box-shadow: 0 6px 24px #132b5155; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 850px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .heading { display: block; }
  .heading-actions { margin-top: .9rem; }
  .workspace { padding-top: 1.7rem; }
  .cards, .filters { gap: .6rem; }
  .stat-card { min-height: 7.6rem; padding: .7rem; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .registry-head, .filters, .pagination { padding-left: .7rem; padding-right: .7rem; }
  .registry-head { align-items: start; }
  .import-grid { grid-template-columns: 1fr; }
}
@media (max-width: 370px) {
  .cards { grid-template-columns: 1fr; }
  .registry-head { flex-wrap: wrap; }
  .group-details { grid-template-columns: 1fr; }
}
