:root {
    --brand: #ed123f;
    --brand-dark: #c70f35;
    --brand-soft: #fff0f4;
    --ink: #201a1c;
    --muted: #74696d;
    --line: #ece4e6;
    --surface: #ffffff;
    --canvas: #f7f3f4;
    --danger: #be123c;
    --shadow: 0 18px 50px rgba(71, 28, 40, 0.08);
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    background: var(--canvas);
}

body {
    margin: 0;
    min-width: 320px;
    color: var(--ink);
    background: var(--canvas);
}

button,
input,
select {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

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

.brand-panel {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    background: var(--brand);
}

.brand-panel img {
    width: 100%;
    height: auto;
    display: block;
}

.brand-panel::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 32%;
    background: linear-gradient(transparent, rgba(94, 1, 27, 0.56));
    pointer-events: none;
}

.brand-panel__caption {
    position: absolute;
    z-index: 1;
    left: 32px;
    right: 32px;
    bottom: 34px;
    display: grid;
    gap: 4px;
    color: #fff;
}

.brand-panel__caption span {
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.78;
}

.brand-panel__caption strong {
    font-size: 1.45rem;
    line-height: 1.1;
}

.content {
    width: 100%;
    max-width: 1480px;
    margin: 0 auto;
    padding: 44px clamp(24px, 4vw, 64px) 64px;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--brand);
    font-size: 0.73rem;
    font-weight: 900;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

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

h1 {
    margin-bottom: 8px;
    font-size: clamp(2rem, 4vw, 3.25rem);
    line-height: 1;
    letter-spacing: -0.045em;
}

h2 {
    margin-bottom: 0;
    font-size: 1.4rem;
    letter-spacing: -0.02em;
}

.subtitle {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 1rem;
}

.button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 12px;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.button:hover:not(:disabled) {
    transform: translateY(-1px);
}

.button:focus-visible,
.icon-button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid rgba(237, 18, 63, 0.22);
    outline-offset: 2px;
}

.button:disabled {
    opacity: 0.48;
    cursor: not-allowed;
}

.button--primary,
.button--danger {
    color: #fff;
    background: var(--brand);
    box-shadow: 0 10px 24px rgba(237, 18, 63, 0.2);
}

.button--danger {
    background: var(--danger);
}

.button--secondary,
.button--ghost {
    color: var(--ink);
    background: #fff;
    border-color: var(--line);
}

.button--ghost {
    background: transparent;
}

.button--danger-soft {
    color: var(--danger);
    background: #fff1f4;
    border-color: #ffd6df;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.stat-card {
    min-height: 132px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: 0 10px 30px rgba(71, 28, 40, 0.035);
}

.stat-card span {
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 750;
}

.stat-card strong {
    font-size: 2rem;
    letter-spacing: -0.04em;
}

.stat-card--primary {
    color: #fff;
    border-color: var(--brand);
    background: linear-gradient(135deg, #f21b49, #d80d38);
}

.stat-card--primary span {
    color: rgba(255, 255, 255, 0.78);
}

.stat-card__date {
    font-size: 1.1rem !important;
    letter-spacing: -0.02em !important;
}

.records-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px;
    border-bottom: 1px solid var(--line);
}

.search-box {
    width: min(480px, 100%);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #faf8f8;
}

.search-box:focus-within {
    border-color: rgba(237, 18, 63, 0.44);
    box-shadow: 0 0 0 3px rgba(237, 18, 63, 0.08);
}

.search-box__icon {
    color: var(--brand);
    font-size: 1.3rem;
    font-weight: 900;
}

.search-box input {
    width: 100%;
    min-height: 44px;
    padding: 0;
    border: 0;
    outline: 0;
    color: var(--ink);
    background: transparent;
}

.toolbar__actions {
    display: flex;
    gap: 10px;
}

.table-wrap {
    position: relative;
    min-height: 260px;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

th,
td {
    padding: 15px 16px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

th {
    color: var(--muted);
    background: #fcfafa;
    font-size: 0.71rem;
    font-weight: 900;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

td {
    font-size: 0.88rem;
}

tbody tr:hover {
    background: #fffafb;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.person-cell {
    max-width: 250px;
    white-space: normal;
}

.person-cell strong,
.stacked-cell strong {
    display: block;
    margin-bottom: 3px;
}

.person-cell span,
.stacked-cell span,
.muted {
    color: var(--muted);
    font-size: 0.78rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 8px;
    border-radius: 999px;
    color: var(--brand-dark);
    background: var(--brand-soft);
    font-size: 0.7rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.actions-column {
    text-align: right;
}

.row-actions {
    display: flex;
    justify-content: flex-end;
    gap: 7px;
}

.row-button,
.icon-button {
    min-width: 38px;
    min-height: 38px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--ink);
    background: #fff;
    cursor: pointer;
}

.row-button {
    padding: 0 10px;
    font-size: 0.76rem;
    font-weight: 800;
}

.row-button--danger {
    color: var(--danger);
}

.loading-state,
.empty-state {
    position: absolute;
    inset: 48px 0 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.9);
}

.empty-state[hidden],
.loading-state[hidden] {
    display: none;
}

.empty-state > span {
    color: var(--brand);
    font-size: 2rem;
}

.empty-state strong {
    color: var(--ink);
    font-size: 1.05rem;
}

.empty-state p {
    margin-bottom: 0;
    font-size: 0.86rem;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #f5cbd5;
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px 20px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.82rem;
}

.pagination p {
    margin: 0;
}

.pagination > div {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal {
    width: min(720px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    padding: 0;
    overflow: auto;
    border: 0;
    border-radius: 22px;
    color: var(--ink);
    background: #fff;
    box-shadow: 0 28px 90px rgba(55, 16, 27, 0.28);
}

.modal::backdrop {
    background: rgba(36, 12, 19, 0.58);
    backdrop-filter: blur(4px);
}

.modal--small {
    width: min(500px, calc(100vw - 32px));
}

.modal__header,
.modal__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 24px;
}

.modal__header {
    border-bottom: 1px solid var(--line);
}

.modal__footer {
    justify-content: flex-end;
    border-top: 1px solid var(--line);
}

.modal__body {
    padding: 24px;
}

.modal__body > p:last-child {
    margin-bottom: 0;
}

.modal__close {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    border: 0;
    border-radius: 50%;
    color: var(--muted);
    background: #f7f2f3;
    font-size: 1.5rem;
    cursor: pointer;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.field {
    display: grid;
    gap: 7px;
}

.field--wide {
    grid-column: 1 / -1;
}

.field > span {
    color: #4f4649;
    font-size: 0.78rem;
    font-weight: 850;
}

.field input,
.field select {
    width: 100%;
    min-height: 46px;
    padding: 0 13px;
    border: 1px solid var(--line);
    border-radius: 11px;
    color: var(--ink);
    background: #fff;
}

.field input[readonly] {
    color: var(--muted);
    background: #f8f5f6;
}

.field--confirmation {
    margin-top: 20px;
}

.toast {
    position: fixed;
    z-index: 20;
    right: 24px;
    bottom: 24px;
    max-width: min(420px, calc(100vw - 48px));
    padding: 14px 18px;
    border-radius: 12px;
    color: #fff;
    background: #251b1e;
    box-shadow: 0 18px 50px rgba(34, 12, 18, 0.3);
    font-size: 0.88rem;
    font-weight: 750;
    opacity: 0;
    transform: translateY(16px);
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
}

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

.toast.is-error {
    background: var(--danger);
}

@media (max-width: 1100px) {
    .app-shell {
        grid-template-columns: 210px minmax(0, 1fr);
    }

    .brand-panel__caption {
        left: 22px;
        right: 22px;
    }

    .toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .search-box {
        width: 100%;
    }
}

@media (max-width: 760px) {
    .app-shell {
        display: block;
    }

    .brand-panel {
        position: relative;
        height: 190px;
    }

    .brand-panel img {
        width: min(100%, 430px);
        height: auto;
        margin: 0 auto;
    }

    .brand-panel::after {
        height: 65%;
    }

    .brand-panel__caption {
        bottom: 18px;
    }

    .brand-panel__caption strong {
        font-size: 1.15rem;
    }

    .content {
        padding: 28px 16px 40px;
    }

    .page-header {
        align-items: stretch;
        flex-direction: column;
    }

    .page-header .button {
        align-self: flex-start;
    }

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

    .stat-card:last-child {
        grid-column: 1 / -1;
    }

    .toolbar__actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .pagination {
        align-items: flex-start;
        flex-direction: column;
    }

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

    .field--wide {
        grid-column: auto;
    }

    .modal__footer {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 430px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card:last-child {
        grid-column: auto;
    }

    .toolbar__actions,
    .modal__footer {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
