:root {
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #181f35;
  background: #f5f6fa;
  --ink: #181f35;
  --muted: #525d74;
  --line: #dfe4ef;
  --accent: #4438c5;
  --accent-dark: #362ba7;
  --accent-soft: #eeecff;
  --white: #fff;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; line-height: 1.5; }
h1,h2,p { margin: 0; }
h1 { font-size: clamp(1.75rem, 3vw, 2.4rem); line-height: 1.18; letter-spacing: -.045em; }
h2 { font-size: 1.15rem; line-height: 1.25; letter-spacing: -.015em; }
small { display: block; font-size: .875rem; color: var(--muted); font-weight: 400; }
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.skip { position: fixed; top: .5rem; left: .5rem; z-index: 5; background: white; padding: .75rem; transform: translateY(-180%); }
.skip:focus { transform: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

button,.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 2.625rem;
  padding: .52rem .9rem; border: 1px solid var(--line); border-radius: .55rem; background: var(--white);
  color: var(--ink); font: inherit; font-size: .875rem; font-weight: 650; text-decoration: none; cursor: pointer; gap: .38rem;
}
button:hover,.button:hover { background: #f2f4f9; }
button:disabled { cursor: default; opacity: .6; }
.primary { background: var(--accent); border-color: var(--accent); color: white; }
.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.quiet { background: transparent; }
.row-action { min-height: 2.1rem; padding: .28rem .65rem; border-color: transparent; color: var(--accent); }
input:not([type="checkbox"]),select,textarea {
  display: block; width: 100%; min-width: 0; min-height: 2.65rem; padding: .52rem .62rem;
  border: 1px solid #cbd2e2; border-radius: .5rem; color: var(--ink); background: var(--white); font: inherit;
}
input:not([type="checkbox"]):focus,select:focus,textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 5rem; }
input[type="checkbox"] { width: 1.125rem; height: 1.125rem; accent-color: var(--accent); flex: 0 0 auto; }
input::placeholder { color: #59647a; }
label { display: grid; gap: .28rem; font-size: .875rem; font-weight: 650; min-width: 0; }
.fields { display: grid; gap: .9rem; }
.check { display: flex; align-items: center; gap: .5rem; }
.status { color: #365751; font-size: .9rem; }
.status:empty { display: none; }
.status[data-state="error"] { color: #a1172d; }
.content > .status { margin-bottom: 1.1rem; padding: .7rem .9rem; background: #edf8f3; border: 1px solid #bfded1; border-radius: .55rem; }
.content > .status[data-state="error"] { background: #fff0f2; border-color: #f1c0cb; }

.signin { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; background: radial-gradient(ellipse at top right, #e7e4ff, transparent 55%), #f5f6fa; }
.signin-card { width: min(100%, 25rem); padding: clamp(1.4rem, 5vw, 2.1rem); background: var(--white); border: 1px solid var(--line); border-radius: 1.1rem; box-shadow: 0 18px 44px #22205713; }
.signin-card h1 { margin: 1.65rem 0 1.2rem; }
.signin-card .status { margin-top: 1rem; }
.brand { display: flex; gap: .65rem; align-items: center; font-size: .98rem; line-height: 1.22; font-weight: 750; text-decoration: none; color: inherit; }
.brand small { margin-top: .15rem; font-size: .8rem; }
.brand-mark { display: grid; place-items: center; min-width: 2.35rem; height: 2.35rem; color: white; background: var(--accent); border-radius: .65rem; letter-spacing: -.04em; }
.workspace { display: grid; grid-template-columns: 14.3rem minmax(0, 1fr); min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 2.1rem; padding: 1.3rem .8rem; border-right: 1px solid var(--line); background: var(--white); overflow-y: auto; }
.sidebar .brand { padding: 0 .45rem; }
nav { display: grid; gap: .35rem; }
nav a { display: flex; align-items: center; gap: .68rem; padding: .62rem .65rem; min-height: 2.65rem; border-radius: .55rem; font-size: .91rem; font-weight: 650; color: #404a65; text-decoration: none; }
nav a span { width: 1.1rem; text-align: center; font-size: 1.14rem; line-height: 1; }
nav a:hover { background: #f2f3f8; }
nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-dark); }
.sidebar-footer { margin-top: auto; padding: .9rem .42rem 0; border-top: 1px solid var(--line); display: grid; gap: .7rem; }
.profile { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.profile strong { overflow-wrap: anywhere; font-size: .89rem; }
.avatar { width: 2rem; height: 2rem; flex: 0 0 auto; display: grid; place-items: center; color: var(--accent-dark); font-weight: 750; background: var(--accent-soft); border-radius: 50%; }
.shell { min-width: 0; }
.topbar { min-height: 4.15rem; padding: .6rem clamp(1rem, 3vw, 2.25rem); display: flex; align-items: center; justify-content: space-between; gap: .65rem; background: var(--white); border-bottom: 1px solid var(--line); }
.topbar-heading { display: flex; align-items: center; gap: .65rem; color: var(--muted); font-weight: 650; font-size: .92rem; }
.mobile-menu { display: none; }
.content { width: min(100%, 100rem); margin: 0 auto; padding: clamp(1rem, 3vw, 2.25rem); }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: .8rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.page-heading p { margin-top: .3rem; color: var(--muted); }
.card,.metric { background: white; border: 1px solid var(--line); border-radius: .8rem; box-shadow: 0 2px 5px #1d264605; min-width: 0; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .85rem; margin-bottom: 1.2rem; }
.metric { display: grid; gap: .4rem; padding: 1.1rem; }
.metric span { color: var(--muted); font-size: .875rem; font-weight: 650; }
.metric strong { font-size: clamp(1.65rem, 3vw, 2.25rem); letter-spacing: -.04em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.card-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .65rem; padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); }
.card-heading a { font-size: .875rem; font-weight: 650; }
.filters { display: flex; align-items: end; flex-wrap: wrap; gap: .75rem; padding: 1rem 1.1rem .65rem; }
.filters label { flex: 1 1 10rem; max-width: 20rem; }
.filters label.search { flex: 2 1 14rem; max-width: 31rem; }
.result,.hint { padding: .25rem 1.1rem .85rem; font-size: .875rem; color: var(--muted); }
.hint { padding-top: .75rem; border-top: 1px solid var(--line); }
.table-scroll { overflow: auto; }
table { border-collapse: collapse; width: 100%; text-align: left; font-size: .875rem; }
th,td { padding: .7rem .9rem; vertical-align: middle; border-bottom: 1px solid #ecedf4; }
th { background: #f5f6fb; font-weight: 650; color: #48536e; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover, tbody tr.selected { background: #f8f8ff; }
td:first-child { font-weight: 650; }
td.actions { text-align: right; }
.nowrap { white-space: nowrap; font-variant-numeric: tabular-nums; }
.empty { padding: 1.5rem 1.1rem; color: var(--muted); text-align: center; }
.badge { display: inline-flex; align-items: center; padding: .12rem .46rem; margin: .1rem .2rem .1rem 0; color: #3b4682; background: #edf0ff; border: 1px solid #dfe4ff; border-radius: .38rem; font-size: .82rem; font-weight: 650; white-space: nowrap; }
.good { background: #e9f6ef; border-color: #cae7d9; color: #1f5b43; }
.bad { background: #fff0f2; border-color: #f3cbd3; color: #a2223b; }
.neutral { background: #edf0f4; border-color: #dce2ea; color: #4d576a; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.checks { display: grid; gap: .45rem; margin: 0; padding: .55rem 0; border: 0; min-width: 0; }
.checks label { display: flex; align-items: flex-start; gap: .55rem; }
.checks input { margin: .12rem 0 0; }
.checks:disabled { opacity: .65; }
.tabs { display: flex; gap: .4rem; padding: .75rem 1rem 0; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: .4rem .4rem 0 0; color: var(--muted); }
.tabs button[aria-pressed="true"] { color: var(--accent-dark); border-bottom-color: var(--accent); background: var(--accent-soft); }
.audit-list { padding: 0 1.1rem .8rem; }
.audit-list details { margin-bottom: .55rem; }
summary { cursor: pointer; }
.audit-list details,form details { border: 1px solid var(--line); border-radius: .5rem; background: #fbfcff; }
.audit-list summary,form summary { padding: .65rem .8rem; font-size: .9rem; font-weight: 650; }
.audit-list summary small { margin-left: .9rem; }
.audit-list pre { margin: 0; padding: .65rem .8rem; border-top: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; font-size: .82rem; }
dialog { width: min(40rem, calc(100% - 1.5rem)); max-height: calc(100dvh - 1.5rem); border: 1px solid var(--line); border-radius: .85rem; padding: 0; color: var(--ink); box-shadow: 0 20px 60px #1a164128; }
dialog::backdrop { background: #15183276; }
.dialog-heading { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .75rem 1rem; background: white; border-bottom: 1px solid var(--line); z-index: 1; }
.form-pad { padding: 1rem 1.1rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .75rem; }
.detail-body { padding: .7rem .8rem; border-top: 1px solid var(--line); }
.form-actions { display: flex; justify-content: flex-end; }

@media (max-width: 960px) {
  .workspace { grid-template-columns: 12.4rem minmax(0, 1fr); }
  .metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 670px) {
  .workspace { display: block; }
  .sidebar { position: fixed; z-index: 3; top: 4.1rem; bottom: 0; left: 0; width: min(16rem, 85vw); height: auto; box-shadow: 6px 0 20px #17162f28; display: none; }
  .sidebar.open { display: flex; }
  .topbar { position: sticky; top: 0; z-index: 3; }
  .mobile-menu { display: inline-flex; }
  .metrics { gap: .6rem; }
  .metric { padding: .8rem; }
  .form-grid { grid-template-columns: 1fr; }
}

.topbar-actions,.view-switch { display: flex; align-items: center; gap: .5rem; }
.signin-theme { margin-top: .75rem; }
.view-switch { padding: 0 1.1rem .75rem; }
.view-switch button { min-height: 2.05rem; }
.view-switch button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-dark); }
.catalog-tree { padding: .25rem 1.1rem 1rem; }
.catalog-tree details { padding-left: .75rem; border-left: 1px solid var(--line); }
.catalog-tree summary,.tree-host { padding: .4rem .5rem; }
.catalog-tree summary { font-weight: 650; }
.tree-host { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); gap: .4rem; }
.transfer-dialog { width: min(64rem, calc(100% - 1.5rem)); }
.transfer-dialog .hint { padding-top: .8rem; border-top: 0; }
.transfer-path { overflow-wrap: anywhere; min-width: 9rem; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e7eaf5;
  --muted: #b5bfd5;
  --line: #38415a;
  --accent: #b1a7ff;
  --accent-dark: #d4ccff;
  --accent-soft: #352861;
  --white: #20263a;
  color: var(--ink);
  background: #161a28;
}
[data-theme="dark"] :is(.skip,.card,.metric,.dialog-heading,dialog) { background: var(--white); }
[data-theme="dark"] .signin { background: radial-gradient(ellipse at top right, #312650, transparent 55%), #161a28; }
[data-theme="dark"] :is(th,nav a, input::placeholder) { color: var(--muted); }
[data-theme="dark"] th { background: #262e44; }
[data-theme="dark"] :is(th,td,input:not([type="checkbox"]),select,textarea) { border-color: var(--line); }
[data-theme="dark"] :is(button,.button,nav a):hover, [data-theme="dark"] tbody tr:is(:hover,.selected) { background: #303752; }
[data-theme="dark"] :is(.primary,.brand-mark) { background: #614fe4; border-color: #614fe4; }
[data-theme="dark"] .primary:hover { background: #5844d7; }
[data-theme="dark"] :is(.audit-list details,form details) { background: #252b40; }
[data-theme="dark"] .badge { color: #ced6ff; background: #313b61; border-color: #46517f; }
[data-theme="dark"] .good { color: #adf0cc; background: #193d34; border-color: #2b5a4b; }
[data-theme="dark"] .bad { color: #ffbbcb; background: #492638; border-color: #6a384d; }
[data-theme="dark"] .neutral { color: #d3d9ed; background: #303752; border-color: #424c6b; }
[data-theme="dark"] .status { color: #b7efda; }
[data-theme="dark"] .status[data-state="error"] { color: #ffbbcb; }
[data-theme="dark"] .content > .status { background: #193d34; border-color: #2b5a4b; }
[data-theme="dark"] .content > .status[data-state="error"] { background: #492638; border-color: #6a384d; }
