:root {
    --ink: #1f2933;
    --paper: #fbfbf2;
    --blue: #4c6fff;
    --orange: #f9703e;
    --mint: #2fbf9f;
    --line: rgba(31, 41, 51, 0.14);
    --muted: #64707d;
    --danger: #f9703e;
    --warn: #d7a323;
    --ok: #2fbf9f;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--ink);
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        linear-gradient(90deg, rgba(76, 111, 255, 0.09) 1px, transparent 1px),
        linear-gradient(rgba(76, 111, 255, 0.07) 1px, transparent 1px),
        var(--paper);
    background-size: 38px 38px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    display: grid;
    grid-template-columns: 244px minmax(0, 1fr);
    min-height: 100vh;
}

.rail {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 28px;
    height: 100vh;
    padding: 22px 18px;
    color: var(--paper);
    background:
        radial-gradient(circle at 72% 12%, rgba(249, 112, 62, 0.18), transparent 24%),
        linear-gradient(160deg, #17202a, #1f2933 62%, #111820);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
    font-weight: 800;
    letter-spacing: 0;
}

.brand img {
    flex: 0 0 auto;
}

.nav {
    display: grid;
    gap: 8px;
}

.nav__item {
    width: 100%;
    min-height: 44px;
    border: 1px solid rgba(251, 251, 242, 0.12);
    border-radius: 8px;
    color: rgba(251, 251, 242, 0.78);
    background: transparent;
    text-align: left;
    padding: 0 14px;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav__item:hover,
.nav__item.is-active {
    color: var(--paper);
    background: rgba(76, 111, 255, 0.22);
    transform: translateX(2px);
}

.rail__status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: auto;
    color: rgba(251, 251, 242, 0.68);
    font-size: 13px;
}

.pulse {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: var(--mint);
    box-shadow: 0 0 0 0 rgba(47, 191, 159, 0.54);
    animation: pulse 1.8s infinite;
}

.workspace {
    min-width: 0;
    padding: 28px clamp(16px, 3vw, 42px) 42px;
}

.topline {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 580px);
    gap: 22px;
    align-items: end;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--blue);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    max-width: 760px;
    margin-bottom: 0;
    font-size: clamp(30px, 4vw, 56px);
    line-height: 0.98;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 10px;
    font-size: clamp(24px, 3vw, 38px);
    line-height: 1.05;
    letter-spacing: 0;
}

h3 {
    margin-bottom: 10px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.searchbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 138px 92px;
    gap: 8px;
}

.searchbar input,
.searchbar select,
.editor-form input,
.editor-form select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: rgba(251, 251, 242, 0.92);
    padding: 0 12px;
    outline: none;
}

.searchbar button,
.editor-form button,
.action-row button {
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    color: #fff;
    background: var(--blue);
    padding: 0 16px;
    font-weight: 800;
}

.summary-strip {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(4, minmax(120px, 1fr)) minmax(240px, 1.2fr);
    gap: 1px;
    margin: 24px 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: var(--line);
    box-shadow: 0 20px 60px rgba(31, 41, 51, 0.12);
}

.metric,
.heatline {
    min-height: 82px;
    background: rgba(251, 251, 242, 0.96);
    padding: 14px;
}

.metric span,
.finance-grid span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.metric strong,
.finance-grid strong {
    display: block;
    margin-top: 4px;
    font-size: clamp(27px, 3vw, 42px);
    line-height: 1;
    letter-spacing: 0;
}

.heatline {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.heat {
    display: grid;
    align-content: center;
    min-width: 0;
    border-radius: 6px;
    padding: 8px;
    color: #fff;
}

.heat b {
    font-size: 22px;
    line-height: 1;
}

.heat em {
    overflow-wrap: anywhere;
    font-size: 12px;
    font-style: normal;
}

.heat--low {
    background: var(--ok);
}

.heat--medium {
    background: var(--warn);
}

.heat--high {
    background: var(--danger);
}

.screen {
    display: none;
    animation: rise 240ms ease both;
}

.screen.is-active {
    display: block;
}

.registry-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 390px);
    gap: 18px;
    align-items: start;
}

.registry-table,
.inspector,
.work-panel,
.split-board {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(251, 251, 242, 0.95);
}

.registry-table {
    overflow: hidden;
}

.table-head,
.table-row {
    display: grid;
    grid-template-columns: minmax(180px, 1.4fr) minmax(180px, 1.2fr) minmax(92px, 0.7fr) minmax(92px, 0.6fr) minmax(110px, 0.7fr);
    gap: 14px;
    align-items: center;
    min-width: 780px;
}

.table-head {
    padding: 12px 16px;
    color: var(--muted);
    background: #eef0e9;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.table-body {
    overflow-x: auto;
}

.table-row {
    width: 100%;
    border: 0;
    border-top: 1px solid var(--line);
    color: var(--ink);
    background: transparent;
    padding: 14px 16px;
    text-align: left;
    transition: background 150ms ease, box-shadow 150ms ease;
}

.table-row:hover,
.table-row.is-selected {
    background: rgba(76, 111, 255, 0.08);
    box-shadow: inset 4px 0 0 var(--blue);
}

.table-row span {
    min-width: 0;
}

.table-row b,
.mini-block b,
.action-row b {
    display: block;
    overflow-wrap: anywhere;
}

.table-row small,
.mini-block small,
.action-row small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.risk-dot {
    display: inline-block;
    width: 11px;
    height: 11px;
    margin-right: 8px;
    border-radius: 2px;
    vertical-align: -1px;
}

.risk-dot--high,
.severity--high {
    background: var(--danger);
}

.risk-dot--medium,
.severity--medium {
    background: var(--warn);
}

.risk-dot--low,
.severity--low {
    background: var(--ok);
}

.inspector {
    position: sticky;
    top: 130px;
    padding: 18px;
}

.inspector__empty {
    min-height: 360px;
    display: grid;
    align-content: center;
    color: var(--muted);
}

.clamp-mark {
    width: 54px;
    height: 54px;
    border: 8px solid var(--blue);
    border-right-color: var(--orange);
    border-radius: 8px;
    transform: rotate(45deg);
}

.inspector__header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
}

.severity {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    color: #fff;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 800;
}

.pet-facts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 14px 0;
}

.pet-facts div {
    border-top: 1px solid var(--line);
    padding-top: 10px;
}

.pet-facts dt {
    color: var(--muted);
    font-size: 12px;
}

.pet-facts dd {
    margin: 2px 0 0;
    font-weight: 800;
}

.mini-block {
    border-top: 1px solid var(--line);
    padding-top: 14px;
    margin-top: 14px;
}

.mini-block p {
    margin-bottom: 10px;
}

.muted,
.form-note {
    color: var(--muted);
}

.work-panel,
.split-board {
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) minmax(280px, 1.2fr);
    gap: clamp(18px, 4vw, 54px);
    padding: clamp(18px, 4vw, 42px);
}

.panel-copy p:not(.eyebrow),
.split-board > div:first-child p:not(.eyebrow) {
    color: var(--muted);
    max-width: 480px;
}

.editor-form {
    display: grid;
    gap: 14px;
}

.editor-form label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.action-list {
    display: grid;
    gap: 10px;
}

.action-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.45);
}

.finance-grid {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: var(--line);
}

.finance-grid div {
    min-height: 112px;
    background: #fffdf4;
    padding: 18px;
}

.split-board .action-list {
    grid-column: 1 / -1;
}

.empty-row {
    padding: 18px;
    color: var(--muted);
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 20;
    max-width: min(360px, calc(100vw - 36px));
    border-radius: 8px;
    color: #fff;
    background: var(--ink);
    padding: 12px 14px;
    box-shadow: 0 16px 44px rgba(31, 41, 51, 0.28);
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

@keyframes pulse {
    70% {
        box-shadow: 0 0 0 10px rgba(47, 191, 159, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(47, 191, 159, 0);
    }
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1080px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .rail {
        position: relative;
        height: auto;
        flex-direction: row;
        align-items: center;
        gap: 16px;
        padding: 14px 16px;
    }

    .nav {
        grid-auto-flow: column;
        grid-auto-columns: max-content;
        overflow-x: auto;
    }

    .nav__item {
        text-align: center;
        white-space: nowrap;
    }

    .rail__status {
        display: none;
    }

    .topline,
    .registry-layout,
    .work-panel,
    .split-board {
        grid-template-columns: 1fr;
    }

    .summary-strip {
        position: static;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .heatline {
        grid-column: 1 / -1;
    }

    .inspector {
        position: static;
    }
}

@media (max-width: 680px) {
    .workspace {
        padding: 18px 12px 28px;
    }

    .rail {
        display: grid;
    }

    .brand span {
        font-size: 15px;
    }

    .searchbar {
        grid-template-columns: 1fr;
    }

    .summary-strip,
    .finance-grid {
        grid-template-columns: 1fr;
    }

    .pet-facts,
    .action-row {
        grid-template-columns: 1fr;
    }

    .action-row button {
        width: 100%;
    }
}

