:root {
    --bg: #f5f4fa;
    --surface: #ffffff;
    --text: #1c1a2e;
    --muted: #5f5c78;
    --border: #dedbed;
    --brand: #382888;
    --brand-contrast: #ffffff;
    --brand-soft: #ebe8f8;
    --accent: #ff8334;
    --accent-2: #12908b;
    --logo-indigo: #382888;
    --logo-teal: #2abdb7;
    --logo-orange: #ff8334;
    --danger: #b3261e;
    --ok: #1f7a4d;
    --shadow: 0 1px 2px rgba(30, 20, 70, .08), 0 4px 14px rgba(30, 20, 70, .06);
    --radius: 8px;
    --topbar-h: 56px;
    --sidebar-w: 260px;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #0f0e1a;
    --surface: #181629;
    --text: #e8e6f5;
    --muted: #a29fbd;
    --border: #2c2a46;
    --brand: #a99bf0;
    --brand-contrast: #14102e;
    --brand-soft: #25224a;
    --accent-2: #2abdb7;
    --logo-indigo: #b2a6f5;
    --danger: #ff8a80;
    --ok: #6fd6a0;
    --shadow: none;
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root[data-theme="auto"] {
        --bg: #0f0e1a;
        --surface: #181629;
        --text: #e8e6f5;
        --muted: #a29fbd;
        --border: #2c2a46;
        --brand: #a99bf0;
        --brand-contrast: #14102e;
        --brand-soft: #25224a;
        --accent-2: #2abdb7;
        --logo-indigo: #b2a6f5;
        --danger: #ff8a80;
        --ok: #6fd6a0;
        --shadow: none;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--brand); }

h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 0 0 .5rem; }

.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.inline { display: inline; margin: 0; }
ul.plain { list-style: none; margin: 0; padding: 0; }

.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: .5rem;
    height: var(--topbar-h); padding: 0 1rem;
    background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar .spacer { flex: 1; }
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.user-link { color: var(--text); text-decoration: none; padding: .25rem .5rem; border-radius: var(--radius); }
.user-link:hover { background: var(--brand-soft); }

.shell { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.menu {
    width: var(--sidebar-w); flex: none;
    background: var(--surface); border-right: 1px solid var(--border);
    padding: .6rem; overflow-y: auto;
    position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h));
    transition: width .15s;
    z-index: 10;
}
.menu details { margin: .15rem 0; }
.menu summary { cursor: pointer; padding: .4rem .5rem; border-radius: var(--radius); font-weight: 600; list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover { background: var(--brand-soft); }
.menu summary i, .nav-link i { width: 1.25rem; text-align: center; margin-right: .35rem; color: var(--accent-2); }
.nav-link { display: block; padding: .35rem .5rem; border-radius: var(--radius); color: var(--text); text-decoration: none; }
.nav-link.sub { padding-left: 2.1rem; font-size: .93rem; }
.nav-link:hover { background: var(--brand-soft); }
.nav-link.active { background: var(--brand); color: var(--brand-contrast); }
.nav-link.active i { color: inherit; }

.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-node { position: relative; }
.menu-item {
    display: flex; align-items: center; gap: .4rem; width: 100%;
    padding: .38rem .5rem; border: 0; border-radius: var(--radius);
    background: transparent; color: var(--text); font: inherit; text-align: left;
    cursor: pointer; text-decoration: none; position: relative;
}
.menu-item:hover { background: var(--brand-soft); }
.menu-item.active { background: var(--brand); color: var(--brand-contrast); }
.menu-item.has-active { font-weight: 600; }
.menu-item .mi { width: 1.25rem; text-align: center; color: var(--accent-2); flex: none; }
.menu-item.active .mi { color: inherit; }
.menu-item .ml { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item .caret { font-size: .65rem; opacity: .6; transition: transform .15s; flex: none; }
.menu-node.open > .menu-item .caret { transform: rotate(90deg); }
.menu-list.level-0 > .menu-node > .menu-item { font-weight: 600; }
.menu-node:not(.open) > .menu-list { display: none; }
.menu-list.level-1 > .menu-node > .menu-item { padding-left: 1.6rem; }
.menu-list.level-2 > .menu-node > .menu-item { padding-left: 2.6rem; }
.menu-list.level-3 > .menu-node > .menu-item { padding-left: 3.6rem; }
.menu-list.level-4 > .menu-node > .menu-item { padding-left: 4.6rem; }
.menu-list.level-5 > .menu-node > .menu-item { padding-left: 5.6rem; }

@media (min-width: 861px) {
    html[data-menu="vertical"][data-collapsed="1"] .menu { width: 58px; padding: .6rem .35rem; overflow: visible; }
    html[data-menu="vertical"][data-collapsed="1"] .menu-list.level-0 > .menu-node > .menu-item { justify-content: center; padding-left: 0; padding-right: 0; }
    html[data-menu="vertical"][data-collapsed="1"] .menu-list.level-0 > .menu-node > .menu-item > .ml,
    html[data-menu="vertical"][data-collapsed="1"] .menu-list.level-0 > .menu-node > .menu-item > .caret { display: none; }
    html[data-menu="vertical"][data-collapsed="1"] .menu-list.level-0 > .menu-node > .menu-item .mi { margin: 0; font-size: 1.05rem; }

    html[data-menu="horizontal"] .shell { flex-direction: column; }
    html[data-menu="horizontal"] .menu {
        width: 100%; height: auto; position: sticky; top: var(--topbar-h);
        border-right: 0; border-bottom: 1px solid var(--border); padding: 0 .6rem; overflow: visible;
    }
    html[data-menu="horizontal"] .menu-list.level-0 { display: flex; flex-wrap: wrap; gap: .1rem; }
    html[data-menu="horizontal"] .menu-list.level-0 > .menu-node > .menu-item { width: auto; padding: .6rem .65rem; border-radius: 0; }
    html[data-menu="horizontal"] .menu-list.level-0 > .menu-node > .menu-item .caret { transform: rotate(90deg); }
    html[data-menu="horizontal"] [data-toggle-nav] { display: none; }

    :is(html[data-menu="horizontal"], html[data-menu="vertical"][data-collapsed="1"]) .menu-node:not(.open) > .menu-list,
    :is(html[data-menu="horizontal"], html[data-menu="vertical"][data-collapsed="1"]) .menu-node.open > .menu-list { display: none; }
    :is(html[data-menu="horizontal"], html[data-menu="vertical"][data-collapsed="1"]) .menu-node:hover > .menu-list,
    :is(html[data-menu="horizontal"], html[data-menu="vertical"][data-collapsed="1"]) .menu-node.fly > .menu-list { display: block; }
    :is(html[data-menu="horizontal"], html[data-menu="vertical"][data-collapsed="1"]) .menu-list:not(.level-0) {
        position: absolute; left: 100%; top: 0; min-width: 230px;
        background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
        box-shadow: var(--shadow); padding: .3rem; z-index: 40;
        max-height: calc(100vh - var(--topbar-h) - 4rem); overflow-y: auto;
    }
    html[data-menu="horizontal"] .menu .menu-list.level-0 > .menu-node > .menu-list.level-1 { left: 0; top: 100%; }
    :is(html[data-menu="horizontal"], html[data-menu="vertical"][data-collapsed="1"]) .menu-list:not(.level-0) > .menu-node > .menu-item { padding-left: .6rem; }
    :is(html[data-menu="horizontal"], html[data-menu="vertical"][data-collapsed="1"]) .menu-list:not(.level-0) .caret { transform: none; }
    :is(html[data-menu="horizontal"], html[data-menu="vertical"][data-collapsed="1"]) .menu .menu-list:not(.level-0).flip { left: auto; right: 100%; }
    html[data-menu="horizontal"] .menu .menu-list.level-0 > .menu-node > .menu-list.level-1.flip { left: auto; right: 0; }
    html[data-menu="vertical"][data-collapsed="1"] .menu-list.level-1::before {
        content: attr(data-title); display: block; padding: .3rem .6rem .4rem; font-weight: 700; color: var(--muted);
        border-bottom: 1px solid var(--border); margin-bottom: .25rem;
    }
    html[data-menu="vertical"][data-collapsed="1"] .menu-list.level-0 > .menu-node:not(.has-sub) > .menu-item:hover::after {
        content: attr(data-tip); position: absolute; left: calc(100% + 8px); top: 50%; transform: translateY(-50%);
        background: var(--text); color: var(--bg); padding: .3rem .55rem; border-radius: 6px; font-size: .85rem;
        white-space: nowrap; z-index: 50; pointer-events: none;
    }
}

.content { flex: 1; min-width: 0; padding: 1.25rem; max-width: 1280px; }

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border: 0; border-radius: var(--radius);
    background: transparent; color: var(--text); cursor: pointer; text-decoration: none; font-size: 1rem;
}
.icon-btn:hover { background: var(--brand-soft); }
.icon-btn.danger:hover { color: var(--danger); }

.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .5rem .9rem; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); color: var(--text); font: inherit; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--brand-soft); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-contrast); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.block { width: 100%; justify-content: center; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.flash { padding: .65rem .9rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid var(--border); background: var(--surface); }
.flash.ok { border-color: var(--ok); color: var(--ok); }
.flash.error { border-color: var(--danger); color: var(--danger); }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.tools { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.search { display: flex; gap: .35rem; }

input[type="text"], input[type="password"], input[type="search"], input[type="date"], input[type="datetime-local"], select, textarea {
    width: 100%; padding: .5rem .65rem; font: inherit; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.search input { width: 220px; }
.select-filter { margin-bottom: .35rem; }

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data th { font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
table.data th a { color: inherit; text-decoration: none; }
table.data tbody tr:hover { background: var(--brand-soft); }
table.data td.t-integer, table.data td.t-float { text-align: right; font-variant-numeric: tabular-nums; }
.actions-col { width: 1%; white-space: nowrap; text-align: right !important; }
.empty { padding: 2rem; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1rem; }

.form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.form.narrow { max-width: 460px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem 1.25rem; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field.wide { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: .9rem; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.err { color: var(--danger); margin: 0; font-size: .85rem; }
.actions { display: flex; gap: .5rem; margin-top: 1.25rem; flex-wrap: wrap; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.card li { padding: .15rem 0; }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 2rem; box-shadow: var(--shadow); text-align: center; }
.login-card form { text-align: left; margin-top: 1rem; display: grid; gap: 1rem; }

@media (max-width: 860px) {
    .menu { position: fixed; z-index: 15; top: var(--topbar-h); left: 0; bottom: 0; height: auto; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
    body.nav-open .menu { transform: none; }
    .content { padding: .9rem; }
    .search input { width: 100%; }
    .tools { width: 100%; }
    .search { flex: 1; }

    table.data thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
    table.data tr { border-bottom: 1px solid var(--border); padding: .5rem 0; }
    table.data td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .25rem .8rem; text-align: right !important; }
    table.data td::before { content: attr(data-label); font-weight: 600; color: var(--muted); text-align: left; }
    table.data td.actions-col { justify-content: flex-end; width: auto; }
    table.data td.actions-col::before { content: none; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

.incident { margin: 1rem 0; padding: .75rem 1rem; border: 1px solid var(--border, #cbd5e1); border-radius: 8px; }
.empty-state { text-align: center; padding: 3rem 1rem; }
.muted { opacity: .7; }
.card-sub { font-weight: 600; color: var(--muted); margin-top: .35rem; }
.card h2 i { color: var(--accent-2); margin-right: .3rem; }

.logo { display: block; width: auto; }
.logo .lg-i { fill: var(--logo-indigo); }
.logo .lg-t { fill: var(--logo-teal); }
.logo .lg-o { fill: var(--logo-orange); }
.login-logo { margin: 0 0 1rem; display: flex; justify-content: center; }

.shell.no-nav .content { margin: 0 auto; width: 100%; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.project-card { display: block; text-decoration: none; color: var(--text); transition: border-color .15s, transform .15s; }
.project-card:hover { border-color: var(--brand); transform: translateY(-1px); }
.project-card h2 { margin: 0 0 .15rem; font-size: 1.1rem; }
.project-card p { margin: .35rem 0 0; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; margin: .15rem 0 0; }
.small { font-size: .85rem; }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; background: var(--brand); color: var(--brand-contrast); font-size: .78rem; font-weight: 600; }
.badge.soft { background: var(--brand-soft); color: var(--brand); }
.badge.bad { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.section { margin: 1.5rem 0; }
.section h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
.section h2 i { color: var(--accent-2); margin-right: .3rem; }
.section h3 { font-size: .95rem; margin: 1.1rem 0 .4rem; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.5rem; }
.search.wide { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.search.wide input[type=search] { flex: 1 1 220px; }
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .75rem; }
.crumbs { margin: 0 0 .5rem; color: var(--muted); font-size: .9rem; }
.chips { line-height: 1.9; }
.chip { display: inline-block; padding: 0 .5rem; border: 1px solid var(--border); border-radius: 6px; background: var(--brand-soft); font-size: .78rem; margin-right: .2rem; white-space: nowrap; }
.chip b { color: var(--brand); }
.chip i { color: var(--muted); font-style: normal; }
.chip.off { opacity: .6; text-decoration: line-through; }
table.data td.t-fk, table.data td.t-sino { text-align: left; }
.search.wide input[type=search] { flex: 1 1 220px; width: auto; min-width: 0; }
.search.wide select { flex: 0 1 240px; width: auto; }
.inline-form input[type=text], .inline-form select { width: auto; flex: 0 1 220px; }
.inline-form input[type=file] { width: auto; flex: 1 1 260px; }

.busy-overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: rgba(15, 14, 26, .55); backdrop-filter: blur(2px); }
.busy-overlay[hidden] { display: none; }
.busy-box { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem 2rem; max-width: 380px; text-align: center; box-shadow: var(--shadow); }
.busy-text { margin: 1rem 0 0; }
.busy-spin { width: 42px; height: 42px; margin: 0 auto; border-radius: 50%; border: 4px solid var(--brand-soft); border-top-color: var(--brand); animation: busy-rot .8s linear infinite; }
@keyframes busy-rot { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .busy-spin { animation-duration: 2.4s; } }

.btn.small { padding: .15rem .55rem; font-size: .8rem; margin-left: .5rem; vertical-align: middle; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.chip-btn { background: none; border: 0; padding: 0 .25rem; cursor: pointer; color: var(--muted); font: inherit; line-height: 1; list-style: none; }
.chip-btn:hover { color: var(--brand); }
summary.chip-btn::-webkit-details-marker { display: none; }
.tag-add { display: inline-block; vertical-align: middle; }
.tag-add[open] { display: block; margin-top: .4rem; }
.tag-form { display: flex; gap: .4rem; flex-wrap: wrap; align-items: flex-start; margin-top: .5rem; }
.tag-form select, .tag-form input, .tag-form textarea { font: inherit; padding: .25rem .5rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: inherit; }
.tag-form textarea { resize: vertical; min-height: 2rem; }
form.inline { display: inline; }
.tag-form select, .tag-form input, .tag-form textarea { width: auto; flex: 1 1 9rem; min-width: 8rem; max-width: 100%; }
.tag-form .btn { flex: 0 0 auto; }

.form.wide-form { max-width: 720px; }
.field-warn { margin: .3rem 0 0; padding: .45rem .7rem; border: 1px solid var(--danger); border-radius: 6px; color: var(--danger); font-size: .88rem; }
.field-warn .btn { margin-left: .4rem; }
.field-block { margin-top: 1rem; padding-top: .5rem; border-top: 1px solid var(--border); }
h2.sub, h3.sub { font-size: 1rem; margin: .5rem 0 .25rem; }
.check-group { margin: .9rem 0 .3rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.check-row { display: flex; align-items: baseline; gap: .5rem; padding: .15rem 0; cursor: pointer; }
.check-row input { margin: 0; flex: none; }
.type-badge { display: inline-block; padding: 0 .5rem; border: 1px solid var(--border); border-radius: 6px; font-size: .78rem; background: var(--brand-soft); }
.badge-warn { display: inline-block; padding: 0 .45rem; border: 1px solid var(--danger); border-radius: 6px; font-size: .75rem; color: var(--danger); margin-left: .3rem; white-space: nowrap; }
details.std-fields > summary { cursor: pointer; font-weight: 600; margin-bottom: .5rem; }

.flash.warn { border-color: var(--accent); color: var(--text); background: var(--surface); }
.flash.warn i { color: var(--accent); }

.class-layout { display: block; }
.class-layout.with-panel { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; }
.panel { position: sticky; top: calc(var(--topbar-h) + 1rem); max-height: calc(100vh - var(--topbar-h) - 2rem); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem 1rem; }
.panel-head h2 { font-size: 1rem; margin: 0 0 .25rem; }
.panel-head p { margin: 0 0 .5rem; }
.panel-all { padding-bottom: .4rem; border-bottom: 1px solid var(--border); margin-bottom: .25rem; }
.panel .actions { position: sticky; bottom: -.9rem; background: var(--surface); padding: .6rem 0 .2rem; }
.field-item { display: flex; flex-direction: column; gap: .25rem; padding: .3rem .4rem; border-radius: 6px; cursor: grab; border: 1px solid transparent; }
.field-item:hover { background: var(--brand-soft); }
.field-item.dragging { opacity: .45; border-color: var(--brand); }
.field-item .check-row { cursor: grab; }
.field-param { font: inherit; margin-left: 1.5rem; max-width: 100%; }

.drag-col { width: 1.6rem; padding-right: 0; }
.drag-handle { color: var(--muted); cursor: grab; display: inline-block; padding: .2rem .3rem; }
.drag-handle:hover { color: var(--brand); }
.attrs-table tr.dragging { opacity: .4; }
.attrs-table tr.drop-before > td { box-shadow: inset 0 3px 0 var(--accent-2); }
.attrs-table tr.drop-after > td { box-shadow: inset 0 -3px 0 var(--accent-2); }
.attrs-table .empty-row td { padding: 1.2rem; text-align: center; }

.fk-badge { display: inline-block; margin-left: .35rem; padding: 0 .4rem; font-size: .75rem; border-radius: 999px; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.check-inline { display: inline-flex; gap: .35rem; align-items: center; font-weight: 400; margin-top: .25rem; }

dialog.modal { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); padding: 0; width: min(560px, 94vw); max-height: 90vh; box-shadow: 0 12px 40px rgba(20, 10, 60, .35); }
dialog.modal::backdrop { background: rgba(15, 10, 40, .5); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: .8rem 1.1rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h2 { margin: 0; font-size: 1.1rem; }
.modal-body { padding: 1rem 1.1rem 1.2rem; overflow: auto; }
.modal-body .form { max-width: none; }
.modal-body .select-filter { margin-bottom: .3rem; }

.toast-box { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 50; }
.toast { padding: .6rem .9rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); max-width: 360px; }
.toast.ok { border-color: var(--ok); }
.toast.error { border-color: var(--danger); color: var(--danger); }

@media (max-width: 1100px) {
    .class-layout.with-panel { grid-template-columns: minmax(0, 1fr); }
    .panel { position: static; max-height: none; }
}

[hidden] { display: none !important; }
.modal-body .form { border: 0; box-shadow: none; padding: 0; background: none; }

.sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
.sort-link i { color: var(--muted); font-size: .75rem; }
.sort-link.active, .sort-link.active i { color: var(--brand); }
.sort-link:hover { text-decoration: underline; }
kbd { font: inherit; font-size: .72rem; padding: 0 .3rem; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); }
dialog.palette { top: 12vh; margin: 0 auto; padding: .6rem; }
dialog.palette input { width: 100%; font: inherit; padding: .6rem .8rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text); box-sizing: border-box; }
.palette-list { list-style: none; margin: .5rem 0 0; padding: 0; max-height: 50vh; overflow: auto; }
.palette-list li { border-radius: 6px; }
.palette-list li a { display: block; padding: .45rem .6rem; color: inherit; text-decoration: none; }
.palette-list li.active, .palette-list li:hover { background: var(--brand-soft); }

.view-switch { display: inline-flex; gap: .25rem; margin-left: .5rem; }
.view-switch .btn[aria-current] { cursor: default; }
.content:has(.dg-wrap) { max-width: none; padding-bottom: 0; }
.dg-wrap { display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h) - 2.5rem); min-height: 420px; }
.dg-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.dg-title { display: flex; align-items: center; gap: .5rem; font-weight: 600; }
.dg-tools { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.dg-tools select { font: inherit; padding: .25rem .4rem; max-width: 14rem; }
.dg-legend { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .5rem; }
.dg-chip { display: inline-flex; align-items: center; gap: .25rem; font: inherit; font-size: .78rem; padding: .1rem .55rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); cursor: pointer; }
.dg-chip small { color: var(--muted); }
.dg-chip.off { opacity: .45; text-decoration: line-through; }
.dg-dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--tc); display: inline-block; }
.dg-body { flex: 1; display: flex; min-height: 0; gap: .75rem; }
.dg-view { position: relative; flex: 1; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); cursor: grab; touch-action: none; user-select: none; outline: none; }
.dg-view:focus-visible { border-color: var(--brand); }
.dg-view.panning { cursor: grabbing; }
.dg-canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.dg-edges { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; z-index: 3; }
.dg-edges path { fill: none; stroke-width: 2.5; stroke-opacity: .8; }
.dg-edges .edge-out { stroke: var(--brand); }
.dg-edges .edge-in { stroke: var(--accent); stroke-dasharray: 8 5; }
.dg-hint { position: absolute; left: .6rem; bottom: .4rem; margin: 0; pointer-events: none; background: color-mix(in srgb, var(--surface) 85%, transparent); padding: .1rem .5rem; border-radius: 6px; z-index: 5; }
.dg-loading { position: absolute; inset: 0; display: grid; place-items: center; }
.dg-mod { position: absolute; border: 2px solid var(--border); border-radius: 14px; background: color-mix(in srgb, var(--surface) 70%, transparent); }
.dg-mod-title { padding: 6px 16px; font-size: var(--tfs, 26px); font-weight: 700; color: var(--brand); white-space: nowrap; line-height: 1.1; }
.dg-mod-title small { color: var(--muted); font-weight: 400; font-size: .55em; }
.dg-card { position: absolute; width: 190px; height: 150px; box-sizing: border-box; background: var(--surface); border: 1px solid var(--border); border-top: 5px solid var(--tc); border-radius: 8px; padding: 6px 8px; overflow: hidden; cursor: pointer; box-shadow: var(--shadow); }
.dg-card:hover { border-color: var(--tc); }
.dg-card.sel { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand); z-index: 4; }
.dg-card.rel { box-shadow: 0 0 0 2px var(--accent); }
.dg-card.dim { opacity: .22; }
.dg-card-head { display: flex; flex-direction: column; line-height: 1.2; margin-bottom: 4px; }
.dg-card-head strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dg-card-table { font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dg-attrs { list-style: none; margin: 0; padding: 0; font-size: 11px; }
.dg-attrs li { display: flex; gap: 3px; align-items: baseline; white-space: nowrap; overflow: hidden; line-height: 1.45; }
.dg-attrs li span { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.dg-attrs li em { font-style: normal; color: var(--muted); font-size: 10px; }
.dg-attrs li i { font-size: 9px; width: 10px; }
.dg-attrs li.pk i { color: var(--accent); }
.dg-attrs li.fk i { color: var(--brand); }
.dg-attrs li.more { color: var(--muted); }
.dg-view.lod-0 .dg-card { border-top-width: 14px; }
.dg-view.lod-0 .dg-card-head, .dg-view.lod-0 .dg-attrs, .dg-view.lod-1 .dg-attrs { display: none; }
.dg-view.lod-1 .dg-card-head strong { font-size: 18px; white-space: normal; }
.dg-view.lod-1 .dg-card-table { font-size: 14px; }
.dg-inspector { width: 320px; flex: none; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; }
.dg-insp-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.dg-insp-head h2 { font-size: 1.1rem; margin: 0; overflow-wrap: anywhere; }
.dg-insp-actions { display: flex; flex-wrap: wrap; gap: .3rem; margin: .5rem 0; }
.dg-inspector h3.sub { font-size: .85rem; margin: .8rem 0 .25rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.dg-links, .dg-insp-attrs { list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.dg-links li { padding: .05rem 0; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); text-decoration: underline; cursor: pointer; }
.dg-insp-attrs li { display: flex; gap: .3rem; padding: .1rem 0; border-bottom: 1px dotted var(--border); }
.dg-insp-attrs li span { flex: 1; overflow-wrap: anywhere; }
.dg-insp-attrs li em { font-style: normal; color: var(--muted); font-size: .78rem; }
.dg-insp-attrs li i { font-size: .7rem; color: var(--brand); }
@media (max-width: 900px) { .dg-body { flex-direction: column; } .dg-inspector { width: auto; max-height: 40%; } }

.dg-card.msel { outline: 3px solid var(--accent-2); outline-offset: 1px; }
.dg-sug { position: absolute; right: 6px; bottom: 6px; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--tc); color: #fff; max-width: calc(100% - 12px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dg-sug[data-c="media"] { opacity: .85; }
.dg-sug[data-c="baja"] { opacity: .65; outline: 1px dashed #fff; }
.dg-view.lod-0 .dg-sug { display: none; }
.dg-bulk { position: absolute; left: 50%; bottom: .6rem; transform: translateX(-50%); z-index: 6; display: flex; gap: .5rem; align-items: center; padding: .4rem .7rem; background: var(--surface); border: 1px solid var(--brand); border-radius: 999px; box-shadow: var(--shadow); }
.dg-bulk select { font: inherit; padding: .15rem .3rem; }
.dg-select-tools { position: absolute; right: .6rem; bottom: .5rem; z-index: 5; display: flex; gap: .3rem; }
.dg-sug-filters { display: flex; flex-wrap: wrap; gap: .6rem; margin: .4rem 0; }
.dg-sug-items { list-style: none; margin: 0 0 .5rem; padding: 0; font-size: .85rem; }
.dg-sug-items li { display: flex; flex-wrap: wrap; gap: .3rem; align-items: baseline; padding: .2rem 0; border-bottom: 1px dotted var(--border); }
.dg-why { flex-basis: 100%; padding-left: 1.4rem; }
.dg-lvl { font-size: .7rem; padding: 0 .4rem; border-radius: 999px; border: 1px solid var(--border); }
.dg-lvl.alta { color: var(--ok); border-color: var(--ok); }
.dg-lvl.media { color: var(--accent); border-color: var(--accent); }

.dg-mod-add { font: inherit; font-size: .55em; margin-left: .6em; padding: 0 .5em; border: 1px dashed var(--brand); border-radius: 6px; background: transparent; color: var(--brand); cursor: pointer; vertical-align: middle; }
.dg-mod-add:hover { background: var(--brand); color: #fff; }
.dg-view.can-edit .dg-card { cursor: move; }
.dg-card.dragging { opacity: .85; z-index: 7; box-shadow: 0 8px 22px rgba(0,0,0,.28); }
.dg-view.moving { cursor: move; }
.dg-port { position: absolute; right: -1px; top: 50%; width: 22px; height: 22px; margin-top: -11px; display: none; align-items: center; justify-content: center; border-radius: 50% 0 0 50%; background: var(--brand); color: #fff; font-size: 11px; cursor: crosshair; }
.dg-view.can-edit .dg-card:hover .dg-port, .dg-view.can-edit .dg-card.sel .dg-port { display: flex; }
.dg-view.lod-0 .dg-port { display: none !important; }
.dg-view.linking, .dg-view.linking .dg-card { cursor: crosshair; }
.dg-edges .edge-new { stroke: var(--accent-2, var(--brand)); stroke-dasharray: 12 7; stroke-width: 4; stroke-opacity: 1; }
.dg-hint { max-width: calc(100% - 22rem); }
.dg-card.link-target { box-shadow: 0 0 0 4px var(--ok); }

.undo-box { display: inline-flex; gap: .25rem; align-items: center; }
.undo-box .btn[disabled] { opacity: .4; cursor: default; }
.pager { display: flex; gap: .75rem; align-items: center; margin: 1rem 0; }

.sub-block { margin-top: 1.5rem; }
.rel-block { border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem 1rem 1rem; margin: 1rem 0; }
.rel-block legend { font-weight: 600; padding: 0 .4rem; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .25rem .75rem; max-height: 18rem; overflow: auto; }
.sub-note { margin-top: 1rem; }

tr.row-dup td { background: color-mix(in srgb, var(--warn, #e0a100) 14%, transparent); }
.field-item.field-dup { outline: 1px dashed var(--warn, #e0a100); outline-offset: 2px; }
.field-item .field-warn { margin: .25rem 0 0; }

.estado-block .inline-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .5rem 0 1rem; }
.estado-block .inline-form input[type="text"] { flex: 1 1 14rem; min-width: 10rem; }
.estado-block .badge { display: inline-block; margin-left: .5rem; padding: .1rem .6rem; border-radius: 999px; background: var(--accent-soft, rgba(37, 99, 235, .12)); color: var(--accent, #2563eb); font-size: .85rem; font-weight: 600; }
.estado-block .row-actual td { font-weight: 600; }
.check-row.with-cols { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.check-row.with-cols label { flex: 1 1 12rem; }
.set-col { flex: 0 1 9rem; min-width: 6rem; }

dialog.ficha-modal { width: min(760px, 96vw); }
.ficha .tabs { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.ficha .tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: .5rem .8rem; cursor: pointer; color: var(--muted, inherit); font: inherit; }
.ficha .tab.active { border-bottom-color: var(--accent, #2563eb); color: var(--text); font-weight: 600; }
.tab-count { display: inline-block; min-width: 1.3rem; padding: 0 .35rem; border-radius: 999px; background: var(--surface-2, rgba(127, 127, 127, .15)); font-size: .75rem; text-align: center; }
.ficha-datos { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .75rem 1.25rem; margin: 0; }
.ficha-fila.wide { grid-column: 1 / -1; }
.ficha-fila dt { font-size: .78rem; color: var(--muted, inherit); opacity: .8; }
.ficha-fila dd { margin: 0; overflow-wrap: anywhere; }
.ficha-lista { margin: 0; padding-left: 1.2rem; }
.ficha-lista small { margin-left: .5rem; }
.ficha .actions { margin-top: 1rem; }
.search select { max-width: 12rem; }

.media-upload { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .5rem 0; }
.media-upload input[type="text"] { flex: 1 1 14rem; min-width: 10rem; }
.media-grid { list-style: none; margin: .75rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .75rem; }
.media-item { position: relative; border: 1px solid var(--border); border-radius: 10px; padding: .5rem; background: var(--surface); display: flex; flex-direction: column; gap: .4rem; }
.media-item img, .media-item video { width: 100%; height: 8rem; object-fit: cover; border-radius: 6px; background: var(--surface-2, rgba(127, 127, 127, .12)); }
.media-item .media-file { display: flex; align-items: center; justify-content: center; height: 8rem; font-size: 2.2rem; border-radius: 6px; background: var(--surface-2, rgba(127, 127, 127, .12)); }
.media-meta { display: flex; flex-direction: column; min-width: 0; }
.media-meta a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-item form.inline { position: absolute; top: .6rem; right: .6rem; }
.tree, .tree-root { list-style: none; margin: 0; padding-left: 1.4rem; }
.tree-root { padding-left: 0; }
.tree-node { margin: .15rem 0; }
.tree-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .25rem .4rem; border-radius: 6px; }
.tree-row:hover { background: var(--surface-2, rgba(127, 127, 127, .1)); }
.tree-actions { display: flex; align-items: center; gap: .15rem; }
.tree-move summary { list-style: none; cursor: pointer; }
.tree-move[open] { position: relative; }
.tree-move .inline-form { position: absolute; right: 0; z-index: 3; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .5rem; display: flex; gap: .4rem; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); }

.token-value { display: block; padding: .6rem .8rem; border-radius: 8px; background: var(--surface-2, rgba(127, 127, 127, .15)); word-break: break-all; user-select: all; }
tr.row-off td { opacity: .55; }

.preview-box .tools { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: .75rem 0; }
.preview-ok { color: var(--ok); font-weight: 600; }
.preview-bad { color: var(--danger); font-weight: 600; }
.preview-fails { margin: .5rem 0 0; padding-left: 1.1rem; }
.preview-fails li { margin: .25rem 0; font-size: .9rem; }

.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-right: 2.6rem; }
.pw-toggle { position: absolute; top: 0; right: 0; bottom: 0; width: 2.6rem; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 0 var(--radius) var(--radius) 0; }
.pw-toggle:hover, .pw-toggle:focus-visible { color: var(--text); }
.dropzone { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; padding: .75rem 1rem; border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface); transition: border-color .15s, background .15s; }
.dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone.has-file { border-style: solid; border-color: var(--ok); }
.dropzone .drop-text { flex: 1 1 220px; color: var(--muted); }
.dropzone.has-file .drop-text { color: var(--text); font-weight: 600; }
.dropzone input[type=file] { width: auto; flex: 0 1 280px; }
.cred-card { border: 1px solid var(--ok); border-radius: var(--radius); background: var(--surface); padding: 1rem 1.1rem; margin-bottom: 1.25rem; }
.cred-card h2 { margin: 0 0 .25rem; font-size: 1.05rem; color: var(--ok); }
.cred-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .75rem; margin: .75rem 0; }
.cred-field { display: flex; flex-direction: column; gap: .25rem; }
.cred-field label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.cred-line { display: flex; gap: .4rem; }
.cred-line input { flex: 1 1 auto; font-family: ui-monospace, monospace; }
.cred-card .tools { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.preview-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .5rem 1.25rem; margin: .5rem 0 .75rem; font-size: .9rem; }
.preview-meta dt { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.preview-meta dd { margin: 0; }
.preview-stale { color: var(--danger); font-weight: 600; }
.pager.numbered { flex-wrap: wrap; gap: .35rem; justify-content: space-between; }
.pager .pages { display: flex; gap: .25rem; flex-wrap: wrap; align-items: center; }
.pager .pages a, .pager .pages span.current, .pager .pages span.gap { min-width: 2rem; text-align: center; padding: .25rem .5rem; border-radius: var(--radius); border: 1px solid var(--border); }
.pager .pages span.current { background: var(--brand); color: var(--brand-contrast); border-color: var(--brand); font-weight: 700; }
.pager .pages span.gap { border-color: transparent; color: var(--muted); }
.pager .per { display: flex; align-items: center; gap: .4rem; font-size: .9rem; }
.pager.top { margin: 0 0 .75rem; }

.struct-tools { border: 1px solid var(--border); border-radius: .6rem; padding: .75rem 1rem; margin-bottom: 1rem; background: var(--surface); }
.struct-row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.struct-row .field { min-width: 11rem; flex: 1 1 11rem; margin: 0; }
.struct-module { border: 1px solid var(--border); border-radius: .6rem; margin-bottom: .75rem; background: var(--surface); }
.struct-module > summary { cursor: pointer; padding: .65rem 1rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.struct-module > summary i { color: var(--accent, #2abdb7); }
.struct-sub { padding: .25rem 1rem .75rem; }
.struct-sub h3.sub { margin: .5rem 0 .25rem; display: flex; flex-wrap: wrap; gap: .4rem; align-items: baseline; }
.struct-edit { margin: .25rem 1rem .5rem; }
.struct-edit > summary { display: inline-flex; cursor: pointer; list-style: none; }
.struct-edit[open] > summary { margin-bottom: .5rem; }
.struct-classes { list-style: none; margin: 0; padding: 0; columns: 18rem; column-gap: 1.5rem; }
.struct-classes li { break-inside: avoid; padding: .1rem 0; display: flex; gap: .4rem; align-items: baseline; }

.preview-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 .9rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; padding: .2rem .6rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.chip.ok { color: var(--ok); border-color: var(--ok); }
.chip.bad { color: var(--danger); border-color: var(--danger); }
.chip.warn { color: var(--warn, #b26a00); border-color: var(--warn, #b26a00); }
.chip.mono { font-family: ui-monospace, monospace; }
.preview-timeline { list-style: none; margin: 0 0 .9rem; padding: 0 0 0 .25rem; display: grid; gap: .65rem; position: relative; }
.preview-timeline::before { content: ""; position: absolute; left: 1.05rem; top: .9rem; bottom: .9rem; width: 2px; background: var(--border); }
.preview-timeline li { display: flex; gap: .75rem; align-items: flex-start; position: relative; font-size: .9rem; }
.preview-timeline small { color: var(--muted); }
.tl-dot { flex: 0 0 1.6rem; height: 1.6rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: .7rem; background: var(--surface); border: 2px solid var(--border); color: var(--muted); z-index: 1; }
.tl-dot.warn { border-color: var(--warn, #b26a00); color: var(--warn, #b26a00); }
.tl-dot.bad { border-color: var(--danger); color: var(--danger); }

.preview-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: .3rem 1rem; background: #12908b; color: #fff; font-size: .82rem; position: relative; z-index: 60; }
.preview-bar .spacer { flex: 1 1 auto; }
.preview-bar .pb-tag { font-weight: 700; letter-spacing: .02em; text-transform: uppercase; font-size: .72rem; background: rgba(0, 0, 0, .22); padding: .15rem .55rem; border-radius: 999px; }
.preview-bar .pb-info.warn { color: #ffe3a3; font-weight: 600; }
.preview-bar .pb-btn { display: inline-flex; align-items: center; gap: .35rem; color: #fff; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .35); border-radius: .4rem; padding: .15rem .6rem; font: inherit; text-decoration: none; cursor: pointer; }
.preview-bar .pb-btn:hover { background: rgba(255, 255, 255, .28); }
.brand-name { font-weight: 700; font-size: 1.15rem; color: var(--text); letter-spacing: .01em; }
.brand-name.big { font-size: 1.8rem; }
@media (max-width: 640px) { .preview-bar .pb-btn span { display: none; } }
.inline-select{width:auto;display:inline-block;margin-right:.4rem}

.card-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.count { flex: none; min-width: 1.9rem; text-align: center; font-size: .75rem; font-weight: 600; padding: .05rem .5rem; border-radius: 999px; background: color-mix(in srgb, var(--accent-2, var(--brand)) 18%, transparent); color: var(--accent-2, var(--brand)); font-variant-numeric: tabular-nums; }
.count-zero { background: transparent; color: var(--muted); font-weight: 400; border: 1px dashed var(--border); }
.count-total { float: right; font-size: .8rem; font-weight: 600; padding: .1rem .6rem; border-radius: 999px; background: var(--surface-2, rgba(127,127,127,.15)); color: var(--muted); font-variant-numeric: tabular-nums; }

.brand-logo { height: 28px; width: auto; max-width: 120px; object-fit: contain; vertical-align: middle; margin-right: .5rem; border-radius: 4px; }
.brand-logo.big { height: 56px; max-width: 220px; display: block; margin: 0 auto .5rem; }
.project-logo { height: 26px; width: auto; max-width: 90px; object-fit: contain; vertical-align: middle; border-radius: 4px; }
.project-logo.big { height: 64px; max-width: 160px; }
.project-title { display: flex; align-items: center; gap: 1rem; }
.logo-edit { margin-top: .3rem; }
.logo-form { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .4rem 0; }

.doc-text { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem; line-height: 1.5; min-height: 60vh; resize: vertical; }
.doc-new { margin-bottom: 1rem; align-items: flex-end; }

.chat-fab { position: fixed; right: 1rem; bottom: 1rem; z-index: 70; display: inline-flex; align-items: center; gap: .45rem; padding: .6rem 1rem; border-radius: 999px; border: 0; cursor: pointer; font: inherit; font-weight: 600; background: var(--brand); color: #fff; box-shadow: 0 4px 14px rgba(0, 0, 0, .3); }
.chat-fab:hover { filter: brightness(1.1); }
body.chat-on .chat-fab { display: none; }
.chat-panel { --chat-w: 430px; position: fixed; top: 0; right: 0; bottom: 0; width: min(var(--chat-w), 100vw); z-index: 80; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--border); box-shadow: -6px 0 24px rgba(0, 0, 0, .25); }
.chat-panel[hidden] { display: none; }
.chat-head { display: flex; align-items: center; gap: .5rem; padding: .6rem .8rem; border-bottom: 1px solid var(--border); }
.chat-head .spacer { flex: 1 1 auto; }
.chat-meta { font-size: .72rem; }
.chat-log { flex: 1 1 auto; overflow-y: auto; padding: .8rem; display: flex; flex-direction: column; gap: .6rem; }
.chat-msg { max-width: 92%; padding: .5rem .7rem; border-radius: .7rem; font-size: .9rem; line-height: 1.4; white-space: pre-wrap; word-wrap: break-word; }
.chat-msg.usuario { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: .2rem; }
.chat-msg.asistente { align-self: flex-start; background: var(--surface-2, rgba(127, 127, 127, .15)); border-bottom-left-radius: .2rem; }
.chat-msg.sistema { align-self: center; max-width: 100%; font-size: .8rem; color: var(--muted); background: transparent; border: 1px dashed var(--border); }
.chat-msg .time { display: block; font-size: .65rem; opacity: .6; margin-top: .2rem; }
.chat-ops { margin: .5rem 0 0; padding-left: 1.1rem; white-space: normal; font-size: .83rem; }
.chat-ops li { margin: .15rem 0; }
.chat-ops li.danger { color: var(--danger); font-weight: 600; }
.chat-actions { margin-top: .5rem; display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; white-space: normal; }
.chat-state { font-size: .72rem; color: var(--muted); }
.chat-form { display: flex; gap: .5rem; padding: .6rem .8rem 0; align-items: flex-end; }
.chat-form textarea { flex: 1 1 auto; resize: none; max-height: 8rem; font: inherit; }
.chat-hint { font-size: .72rem; padding: .3rem .8rem .6rem; margin: 0; }
.chat-typing { font-style: italic; color: var(--muted); font-size: .85rem; }
@media (max-width: 640px) { .chat-fab span { display: none; } }

.chat-resize { position: absolute; left: -4px; top: 0; bottom: 0; width: 9px; cursor: ew-resize; z-index: 2; }
.chat-resize:hover, .chat-panel.resizing .chat-resize { background: color-mix(in srgb, var(--brand) 45%, transparent); }
.chat-panel.resizing { user-select: none; }
.chat-msg.asistente, .chat-msg.sistema { white-space: normal; }
.chat-msg.usuario { white-space: pre-wrap; }
.chat-msg p { margin: 0 0 .45rem; }
.chat-msg p:last-of-type { margin-bottom: 0; }
.chat-msg ul.chat-list { margin: .3rem 0 .5rem; padding-left: 1.2rem; }
.chat-msg ul.chat-list li { margin: .15rem 0; }
.chat-msg code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; padding: .05rem .3rem; border-radius: .25rem; background: rgba(127, 127, 127, .22); }
.chat-msg.sistema { display: flex; gap: .5rem; align-items: flex-start; text-align: left; }
.chat-msg.sistema .chat-ico { flex: none; font-size: 1.1rem; line-height: 1.3; }
.chat-msg.sistema .chat-body { flex: 1 1 auto; min-width: 0; }
.chat-msg.sistema.ok { color: #0f5132; background: #d1e7dd; border: 1px solid #7bc6a0; font-size: .88rem; font-weight: 600; }
.chat-msg.sistema.ok .chat-ico { color: #198754; font-size: 1.5rem; }
.chat-msg.sistema.bad { color: #842029; background: #f8d7da; border: 1px solid #e29aa1; }
.chat-msg.sistema.warn { color: #664d03; background: #fff3cd; border: 1px solid #e6c768; }
.chat-msg.sistema.neutral .chat-ico { color: var(--muted); }
:root[data-theme="dark"] .chat-msg.sistema.ok, html[data-theme="dark"] .chat-msg.sistema.ok { color: #9be3bb; background: #12301f; border-color: #1f7a47; }
:root[data-theme="dark"] .chat-msg.sistema.bad, html[data-theme="dark"] .chat-msg.sistema.bad { color: #f1aeb5; background: #3a1519; border-color: #842029; }
:root[data-theme="dark"] .chat-msg.sistema.warn, html[data-theme="dark"] .chat-msg.sistema.warn { color: #ffda6a; background: #33290a; border-color: #8a6d1a; }
@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] .chat-msg.sistema.ok { color: #9be3bb; background: #12301f; border-color: #1f7a47; }
  html[data-theme="auto"] .chat-msg.sistema.bad { color: #f1aeb5; background: #3a1519; border-color: #842029; }
  html[data-theme="auto"] .chat-msg.sistema.warn { color: #ffda6a; background: #33290a; border-color: #8a6d1a; }
}
.chat-msg.asistente.st-aplicada { border-left: 4px solid #198754; }
.chat-msg.asistente.st-vencida, .chat-msg.asistente.st-fallida { border-left: 4px solid #d19a00; }
.chat-msg.asistente.st-descartada, .chat-msg.asistente.st-reemplazada { opacity: .7; }
.chat-badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; font-weight: 700; padding: .1rem .55rem; border-radius: 999px; }
.chat-badge.aplicada { background: #198754; color: #fff; }
.chat-badge.vencida, .chat-badge.fallida { background: #d19a00; color: #1b1400; }
.chat-badge.descartada, .chat-badge.reemplazada { background: rgba(127, 127, 127, .3); color: var(--text); }
