:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  color: #17211b;
  background: #f1f4ef;
  --ink: #17211b;
  --muted: #68736c;
  --line: #d9dfd9;
  --paper: #fffef9;
  --accent: #176b4d;
  --accent-soft: #dcece4;
  --danger: #a53b32;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
button, select, input, textarea { font: inherit; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 1.25rem 2rem; background: var(--ink); color: white; }
.topbar h1 { margin: 0; font-family: Georgia, serif; font-size: 2rem; font-weight: 500; }
.topbar-brand { display: flex; align-items: center; gap: 1rem; }
.settings-button { width: 2.5rem; height: 2.5rem; border: 1px solid #92c9af; border-radius: 50%; background: transparent; color: white; font-size: 1.35rem; line-height: 1; cursor: pointer; }
.settings-button:hover { background: #ffffff18; }
.topbar-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: .75rem; }
.topbar-actions > span:not(.health) { color: #dcece4; font-size: .9rem; }
.topbar-actions button { padding: .45rem .8rem; border: 1px solid #92c9af; border-radius: 6px; background: transparent; color: white; cursor: pointer; }
.topbar-actions button:hover { background: #ffffff18; }
.eyebrow { margin: 0 0 .25rem; color: #92c9af; font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.health { padding: .45rem .8rem; border: 1px solid #516059; border-radius: 999px; font-size: .82rem; }
.health.ok { color: #b9f1d5; border-color: #4c9471; }
.health.error { color: #ffc2ba; border-color: #a85b51; }
.workspace { display: grid; grid-template-columns: minmax(220px, 290px) 1fr; min-height: calc(100vh - 90px); }
.sidebar { padding: 1.5rem; border-right: 1px solid var(--line); background: #e8ede7; }
.sidebar label { display: block; margin-bottom: .5rem; color: var(--muted); font-size: .8rem; font-weight: 700; text-transform: uppercase; }
.sidebar select { width: 100%; padding: .75rem; border: 1px solid #bcc7bf; border-radius: 7px; background: var(--paper); }
#content-kind { margin-bottom: 1.25rem; }
.catalog-list { display: grid; gap: .45rem; margin-top: 1.25rem; }
.catalog-row { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: stretch; gap: .35rem; }
.catalog-item { width: 100%; padding: .8rem; border: 0; border-radius: 7px; background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.catalog-item:hover, .catalog-item.active { background: var(--paper); box-shadow: 0 1px 8px #23382b12; }
.catalog-item-name, .catalog-item-description { display: block; }
.catalog-item-description { display: -webkit-box; margin-top: .25rem; overflow: hidden; color: var(--muted); font-size: .75rem; line-height: 1.3; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.catalog-edit { align-self: center; width: 2rem; height: 2rem; padding: 0; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.catalog-edit:hover { border-color: #9db4a5; background: var(--paper); color: var(--accent); }
.catalog-broken-toggle { width: 100%; margin-top: .55rem; padding: .7rem .8rem; border: 1px dashed #9da7a0; border-radius: 7px; background: transparent; color: var(--muted); text-align: left; cursor: pointer; }
.catalog-broken-toggle:hover { border-color: var(--danger); color: var(--danger); background: #fff8f6; }
.content { display: grid; grid-template-rows: minmax(300px, 48vh) 1fr; min-width: 0; }
.panel { padding: 1.5rem 2rem; overflow: auto; }
.list-panel { display: flex; flex-direction: column; min-height: 0; overflow: hidden; border-bottom: 1px solid var(--line); background: var(--paper); }
.detail-panel { background: #f8faf6; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.panel-heading h2 { margin: 0; font-family: Georgia, serif; font-size: 1.45rem; font-weight: 500; }
.list-heading { display: flex; align-items: center; gap: 1rem; }
.inline-filter { display: flex; align-items: center; gap: .45rem; color: var(--muted); font-size: .78rem; font-weight: 700; text-transform: uppercase; }
.inline-filter select { padding: .4rem .55rem; border: 1px solid #bcc7bf; border-radius: 6px; background: var(--paper); color: var(--ink); text-transform: none; }
.heading-actions { display: flex; align-items: center; gap: .75rem; }
.heading-actions button { padding: .5rem .9rem; border: 0; border-radius: 6px; background: var(--accent); color: white; font-weight: 700; cursor: pointer; }
.selection-label, .meta { color: var(--muted); font-size: .9rem; }
.table-scroll { flex: 1; min-height: 0; max-height: 40vh; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: .25rem .7rem; color: var(--muted); font-size: .72rem; letter-spacing: .05em; text-align: left; text-transform: uppercase; }
thead th { position: sticky; top: 0; z-index: 2; background: var(--paper); }
th button { width: 100%; padding: .45rem 0; border: 0; background: transparent; color: inherit; font: inherit; font-weight: 700; letter-spacing: inherit; text-align: left; text-transform: inherit; cursor: pointer; }
th button:hover { color: var(--accent); }
td { padding: .8rem .7rem; border-top: 1px solid #e4e8e3; }
tbody tr { cursor: pointer; }
tbody tr:hover, tbody tr.active { background: var(--accent-soft); }
.badge { display: inline-block; padding: .25rem .45rem; border-radius: 4px; background: #e6ebe7; font-size: .72rem; font-weight: 800; }
.empty { color: var(--muted); text-align: center; padding: 2rem; }
.meta { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin-bottom: 1rem; }
.detail-content { max-width: 1100px; line-height: 1.65; white-space: pre-wrap; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.actions button, .dialog-actions button { padding: .55rem .9rem; border: 0; border-radius: 6px; background: var(--accent); color: white; cursor: pointer; }
.actions button:disabled { opacity: .4; cursor: not-allowed; }
.actions button.reject, .dialog-actions button.reject { background: var(--danger); }
.actions button.explained { background: #71312b; }
.go-link { display: inline-block; padding: .35rem .65rem; border-radius: 5px; background: var(--accent); color: white; font-weight: 700; text-decoration: none; }
.go-link.indirect { background: #d87516; }
.table-action { padding: .35rem .65rem; border: 1px solid #9db4a5; border-radius: 5px; background: #eef5f0; color: var(--accent); font-weight: 700; cursor: pointer; white-space: nowrap; }
.table-action:disabled { opacity: .4; cursor: not-allowed; }
.row-actions { display: flex; align-items: center; gap: .3rem; white-space: nowrap; }
.row-actions button { width: 2.2rem; padding: .35rem 0; border: 0; border-radius: 5px; background: var(--accent); color: white; font-size: .72rem; font-weight: 800; cursor: pointer; }
.row-actions button.reject { background: var(--danger); }
.row-actions button.explained { background: #71312b; }
.row-actions button:disabled { opacity: .35; cursor: not-allowed; }
.delete-row { padding: .35rem .55rem; border: 0; border-radius: 5px; background: #f5dedb; color: var(--danger); cursor: pointer; }
.query-url, .path-cell { max-width: 300px; overflow-wrap: anywhere; }
.metrics-table { max-width: 620px; }
.user-data-form { display: grid; grid-template-columns: repeat(2, minmax(180px, 1fr)); gap: 1rem; max-width: 900px; }
.user-data-form label { display: grid; gap: .35rem; color: var(--muted); font-size: .82rem; font-weight: 700; }
.user-data-form label:has(textarea), .user-data-form .form-error { grid-column: 1 / -1; }
.user-data-form input, .user-data-form select, .user-data-form textarea { width: 100%; padding: .7rem; border: 1px solid #bcc7bf; border-radius: 7px; background: var(--paper); color: var(--ink); }
.user-data-form textarea { min-height: 180px; resize: vertical; }
dialog { width: min(560px, calc(100% - 2rem)); border: 0; border-radius: 10px; background: var(--paper); box-shadow: 0 20px 70px #17211b55; }
dialog::backdrop { background: #17211b80; }
dialog h2 { margin-top: 0; font-family: Georgia, serif; font-weight: 500; }
dialog label { display: block; margin-bottom: .5rem; font-weight: 700; }
dialog input, dialog textarea { width: 100%; padding: .75rem; border: 1px solid #bcc7bf; border-radius: 7px; }
dialog textarea { min-height: 130px; resize: vertical; }
.settings-fields { display: grid; gap: 1rem; }
.settings-fields label { display: grid; gap: .45rem; }
.settings-fields input { width: 100%; padding: .7rem; border: 1px solid #bcc7bf; border-radius: 7px; background: white; }
#collection-settings-dialog { width: min(1000px, calc(100% - 2rem)); max-height: 90vh; overflow: auto; }
.endpoints-settings { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.endpoints-settings h3 { margin: 0; font-family: Georgia, serif; font-size: 1.25rem; font-weight: 500; }
.endpoints-settings > p { margin: .35rem 0 1rem; color: var(--muted); }
.endpoints-list { display: grid; gap: .6rem; }
.endpoint-card { border: 1px solid var(--line); border-radius: 7px; background: white; }
.endpoint-card > summary { display: flex; align-items: center; gap: .7rem; padding: .75rem; cursor: pointer; }
.endpoint-method { min-width: 4.2rem; color: var(--accent); font-size: .75rem; font-weight: 900; }
.endpoint-path { overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; }
.endpoint-contract { padding: 0 .85rem .85rem; }
.endpoint-contract h4 { margin: .9rem 0 .35rem; }
.endpoint-contract p { margin: .35rem 0; }
.endpoint-contract pre { margin: .35rem 0; padding: .7rem; overflow: auto; border-radius: 6px; background: #f1f4ef; font-size: .78rem; white-space: pre-wrap; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.dialog-actions button.secondary { background: #e5e9e5; color: var(--ink); }
.form-error { min-height: 1.2em; margin: .35rem 0 0; color: var(--danger); font-size: .85rem; }
#preview-dialog { width: min(1000px, calc(100% - 3rem)); height: min(90vh, 900px); padding: 0; }
.preview-shell { display: flex; flex-direction: column; height: 100%; padding: 1rem; }
.preview-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.preview-heading h2 { margin: 0; }
.preview-heading button { padding: .5rem .8rem; border: 0; border-radius: 6px; background: #e5e9e5; cursor: pointer; }
.preview-content { flex: 1; min-height: 0; margin-top: 1rem; overflow: auto; }
.preview-content iframe { width: 100%; height: 100%; min-height: 70vh; border: 1px solid var(--line); }
.mail-preview { max-width: 760px; margin: 0 auto; padding: 1.5rem; border: 1px solid var(--line); border-radius: 8px; background: white; }
.mail-preview h3 { margin-top: 0; }
.mail-preview pre { margin: 1.5rem 0 0; font: inherit; line-height: 1.6; white-space: pre-wrap; }
@media (max-width: 760px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .content { grid-template-rows: auto auto; }
  .panel { padding: 1.2rem; }
  .user-data-form { grid-template-columns: 1fr; }
}

[hidden] { display: none !important; }
.auth-panel { max-width: 30rem; margin: 3rem auto; padding: 2rem; }
.auth-panel form { display: grid; gap: .8rem; }
.auth-panel input { width: 100%; padding: .65rem; box-sizing: border-box; }
.auth-actions { display: flex; gap: .7rem; margin-top: .5rem; }
#auth-error { color: var(--danger); }
