.button {
    align-items: center;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius-control);
    color: var(--on-accent);
    cursor: pointer;
    display: inline-flex;
    font-size: 0.875rem;
    font-weight: 600;
    gap: var(--space-2);
    justify-content: center;
    line-height: 1;
    min-height: 40px;
    padding: 0 var(--space-4);
    text-decoration: none;
    transition:
        background 140ms ease,
        border-color 140ms ease,
        box-shadow 140ms ease,
        transform 140ms var(--ease-out);
    white-space: nowrap;
}

.button:hover {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
    color: var(--on-accent);
}

.button:active {
    transform: translateY(1px);
}

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

.button--quiet {
    background: var(--panel);
    border-color: var(--line-strong);
    color: var(--ink);
}

.button--quiet:hover {
    background: var(--hover);
    border-color: var(--line-strong);
    color: var(--ink);
}

.button--danger {
    background: var(--panel);
    border-color: var(--line-strong);
    color: var(--bad);
}

.button--danger:hover {
    background: var(--bad-soft);
    border-color: var(--bad);
    color: var(--bad);
}

.button--small {
    font-size: 0.8125rem;
    min-height: 32px;
    padding: 0 var(--space-3);
}

.icon-button {
    align-items: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-control);
    color: var(--ink-2);
    cursor: pointer;
    display: inline-flex;
    height: 36px;
    justify-content: center;
    transition:
        background 140ms ease,
        color 140ms ease;
    width: 36px;
}

.icon-button:hover {
    background: var(--hover);
    color: var(--ink);
}

.icon-button--danger:hover {
    background: var(--bad-soft);
    color: var(--bad);
}

.field {
    align-content: start;
    display: grid;
    gap: 6px;
}

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

.field label {
    color: var(--ink);
    font-size: 0.8125rem;
    font-weight: 600;
}

.field input,
.field select,
.field textarea,
.search input {
    background: var(--panel);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-control);
    color: var(--ink);
    min-height: 42px;
    padding: 0 var(--space-3);
    transition:
        border-color 140ms ease,
        box-shadow 140ms ease;
    width: 100%;
}

.field textarea {
    line-height: 1.5;
    padding: var(--space-3);
    resize: vertical;
}

.field input[type='number'] {
    font-variant-numeric: tabular-nums;
}

.field select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a90a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-position: right 12px center;
    background-repeat: no-repeat;
    padding-right: 36px;
}

.field input:hover,
.field select:hover,
.field textarea:hover {
    border-color: var(--ink-3);
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible,
.search input:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    outline: 2px solid transparent;
}

.field input::placeholder {
    color: var(--ink-3);
}

.field input:disabled,
.field select:disabled,
.field textarea:disabled {
    background: var(--sunken);
    color: var(--ink-3);
}

.field--invalid input,
.field--invalid select,
.field--invalid textarea {
    border-color: var(--bad);
}

.field__hint {
    color: var(--ink-3);
    font-size: 0.8125rem;
}

.field__error {
    align-items: center;
    color: var(--bad);
    display: flex;
    font-size: 0.8125rem;
    font-weight: 500;
    gap: 6px;
}

.fields {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
}

.form {
    display: grid;
}

.form-section {
    border-top: 1px solid var(--line);
    display: grid;
    gap: var(--space-3) var(--space-6);
    grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
    padding: var(--space-5) 0;
}

.form-section:first-child {
    border-top: 0;
    padding-top: 0;
}

.form-section__intro p {
    color: var(--ink-3);
    font-size: 0.8125rem;
    margin-top: var(--space-1);
}

.form-section--plain {
    border: 0;
    margin: 0;
    min-width: 0;
    padding: 0;
}

.form-actions {
    align-items: center;
    border-top: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    padding-top: var(--space-5);
}

.switch {
    align-items: flex-start;
    cursor: pointer;
    display: inline-flex;
    gap: var(--space-3);
    min-height: 44px;
    position: relative;
}

.switch input {
    height: 100%;
    inset: 0;
    margin: 0;
    opacity: 0;
    position: absolute;
    width: 100%;
}

.switch__track {
    background: var(--line-strong);
    border-radius: 999px;
    flex: none;
    height: 24px;
    margin-top: 10px;
    position: relative;
    transition: background 180ms ease;
    width: 42px;
}

.switch__track::after {
    background: var(--white);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgb(0 0 0 / 30%);
    content: '';
    height: 18px;
    left: 3px;
    position: absolute;
    top: 3px;
    transition: transform 180ms var(--ease-out);
    width: 18px;
}

.switch input:checked + .switch__track {
    background: var(--accent);
}

.switch input:checked + .switch__track::after {
    transform: translateX(18px);
}

.switch input:focus-visible + .switch__track {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.switch__text {
    display: grid;
    font-size: 0.9375rem;
    font-weight: 600;
    padding-top: 10px;
}

.switch__text small {
    color: var(--ink-3);
    font-size: 0.8125rem;
    font-weight: 400;
}

.segmented {
    border: 0;
    margin: 0;
    min-width: 0;
    padding: 0;
}

.segmented legend {
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 6px;
    padding: 0;
}

.segmented__track {
    background: var(--sunken);
    border: 1px solid var(--line);
    border-radius: 12px;
    display: inline-flex;
    max-width: 100%;
    padding: 4px;
}

.segmented__option {
    position: relative;
}

.segmented__option input {
    height: 100%;
    inset: 0;
    margin: 0;
    opacity: 0;
    position: absolute;
    width: 100%;
}

.segmented__option span {
    align-items: center;
    border-radius: 9px;
    color: var(--ink-2);
    cursor: pointer;
    display: flex;
    font-size: 0.875rem;
    font-weight: 600;
    min-height: 36px;
    padding: 0 var(--space-4);
    transition:
        background 160ms ease,
        color 160ms ease;
}

.segmented__option input:checked + span {
    background: var(--panel);
    box-shadow:
        0 1px 2px rgb(18 22 43 / 14%),
        0 0 0 1px var(--line);
    color: var(--ink);
}

.segmented__option input:focus-visible + span {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.segmented__option input:disabled + span {
    cursor: not-allowed;
    opacity: 0.5;
}

.pill {
    align-items: center;
    background: var(--neutral-soft);
    border-radius: 999px;
    color: var(--ink-2);
    display: inline-flex;
    font-size: 0.75rem;
    font-weight: 650;
    gap: 6px;
    line-height: 1;
    padding: 6px 10px;
    text-transform: capitalize;
    white-space: nowrap;
}

.pill::before {
    background: currentcolor;
    border-radius: 50%;
    content: '';
    height: 6px;
    width: 6px;
}

.pill--active,
.pill--confirmed,
.pill--paid {
    background: var(--ok-soft);
    color: var(--ok);
}

.pill--pending {
    background: var(--warn-soft);
    color: var(--warn);
}

.pill--banned,
.pill--cancelled,
.pill--overdue {
    background: var(--bad-soft);
    color: var(--bad);
}

.pill--plain::before {
    display: none;
}

.pill--accent {
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.avatar {
    align-items: center;
    background: var(--accent-soft);
    border-radius: 50%;
    color: var(--accent-ink);
    display: inline-flex;
    flex: none;
    font-size: 0.8125rem;
    font-weight: 700;
    height: 40px;
    justify-content: center;
    letter-spacing: 0.02em;
    width: 40px;
}

.avatar--sm {
    font-size: 0.6875rem;
    height: 32px;
    width: 32px;
}

.avatar--lg {
    font-size: 1.25rem;
    height: 72px;
    width: 72px;
}

.page-section {
    display: grid;
    gap: var(--space-3);
    margin-top: var(--space-6);
}

.page-section:first-child {
    margin-top: 0;
}

.section-head {
    align-items: baseline;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    justify-content: space-between;
}

.section-head p {
    color: var(--ink-3);
    font-size: 0.8125rem;
}

.toolbar {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.search {
    flex: 1 1 240px;
    max-width: 380px;
    position: relative;
}

.search .icon {
    color: var(--ink-3);
    left: 12px;
    pointer-events: none;
    position: absolute;
    top: 11px;
}

.search input {
    padding-left: 38px;
}

.search-form {
    align-items: center;
    display: flex;
    flex: 1 1 280px;
    gap: var(--space-2);
    max-width: 460px;
}

.search-form .search {
    flex: 1;
    max-width: none;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.chip {
    background: var(--panel);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    color: var(--ink-2);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 600;
    min-height: 36px;
    padding: 0 var(--space-3);
    transition:
        background 140ms ease,
        border-color 140ms ease,
        color 140ms ease;
}

.chip:hover {
    background: var(--hover);
}

.chip[aria-pressed='true'] {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-ink);
}

.chip small {
    color: var(--ink-3);
    font-size: 0.75rem;
    margin-left: 4px;
}

.table-wrap {
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
}

.data {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}

.data th {
    background: var(--sunken);
    border-bottom: 1px solid var(--line);
    color: var(--ink-2);
    font-size: 0.75rem;
    font-weight: 650;
    letter-spacing: 0.02em;
    padding: var(--space-3) var(--space-4);
    position: sticky;
    text-align: left;
    top: var(--header-h);
    white-space: nowrap;
    z-index: 2;
}

.data th:first-child {
    border-top-left-radius: calc(var(--radius-card) - 1px);
}

.data th:last-child {
    border-top-right-radius: calc(var(--radius-card) - 1px);
}

.data td {
    border-bottom: 1px solid var(--line);
    padding: var(--space-3) var(--space-4);
    vertical-align: middle;
}

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

.data tbody tr:hover td {
    background: var(--hover);
}

.data .num {
    text-align: right;
}

.data__actions {
    align-items: center;
    display: flex;
    gap: 2px;
    justify-content: flex-end;
}

.data__actions form {
    margin: 0;
}

.empty {
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-card);
    display: grid;
    gap: var(--space-2);
    padding: var(--space-7) var(--space-5);
    place-items: center center;
    text-align: center;
}

.empty__art {
    align-items: center;
    background: var(--accent-soft);
    border-radius: 50%;
    color: var(--accent-ink);
    display: flex;
    height: 64px;
    justify-content: center;
    margin-bottom: var(--space-2);
    outline: 1px dashed var(--accent);
    outline-offset: 6px;
    width: 64px;
}

.empty p {
    color: var(--ink-3);
    max-width: 38ch;
}

.empty .button {
    margin-top: var(--space-3);
}

.facts {
    display: grid;
    gap: 0;
    margin: 0;
}

.facts div {
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: var(--space-3);
    grid-template-columns: minmax(0, 130px) minmax(0, 1fr);
    padding: var(--space-3) 0;
}

.facts div:last-child {
    border-bottom: 0;
}

.facts dt {
    color: var(--ink-3);
    font-size: 0.8125rem;
}

.facts dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.summary {
    background: var(--bad-soft);
    border: 1px solid var(--bad);
    border-radius: var(--radius-card);
    color: var(--ink);
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
    padding: var(--space-4);
}

.summary .icon {
    color: var(--bad);
    margin-top: 2px;
}

.summary ul {
    margin: var(--space-1) 0 0;
    padding-left: var(--space-4);
}

.toasts {
    display: grid;
    gap: var(--space-2);
    max-width: calc(100vw - 32px);
    position: fixed;
    right: var(--space-4);
    top: var(--space-4);
    width: 380px;
    z-index: 80;
}

.toast {
    align-items: flex-start;
    animation: toast-in 320ms var(--ease-out);
    background: var(--toast-bg);
    border-radius: 14px;
    box-shadow: var(--shadow-pop);
    color: var(--toast-ink);
    display: flex;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
}

.toast .icon {
    color: var(--on-dark-good);
    margin-top: 2px;
}

.toast--bad .icon {
    color: var(--on-dark-bad);
}

.toast p {
    flex: 1;
    padding-top: 2px;
}

.toast button {
    background: transparent;
    border: 0;
    border-radius: 8px;
    color: inherit;
    cursor: pointer;
    height: 32px;
    opacity: 0.75;
    width: 32px;
}

.toast button:hover {
    background: rgb(255 255 255 / 12%);
    opacity: 1;
}

.toast[data-leaving] {
    opacity: 0;
    transform: translateY(-8px);
    transition:
        opacity 200ms ease,
        transform 200ms ease;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.98);
    }
}

.dialog {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow-pop);
    color: var(--ink);
    max-width: min(440px, calc(100vw - 32px));
    padding: var(--space-5);
}

.dialog::backdrop {
    backdrop-filter: blur(3px);
    background: rgb(13 17 48 / 55%);
}

.dialog[open] {
    animation: dialog-in 240ms var(--ease-out);
}

.dialog h2 {
    font-family: var(--font-display);
    font-size: 1.25rem;
}

.dialog p {
    color: var(--ink-2);
    margin-top: var(--space-2);
}

.dialog__actions {
    display: flex;
    gap: var(--space-2);
    justify-content: flex-end;
    margin-top: var(--space-5);
}

@keyframes dialog-in {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
}

.rows {
    display: grid;
    list-style: none;
    margin: 0;
    padding: 0;
}

.row {
    align-items: center;
    border-bottom: 1px solid var(--line);
    color: inherit;
    display: grid;
    gap: var(--space-4);
    margin-inline: calc(var(--space-3) * -1);
    padding: var(--space-3);
    text-decoration: none;
    transition: background 140ms ease;
}

.rows > li:last-child .row {
    border-bottom: 0;
}

a.row:hover {
    background: var(--hover);
    border-radius: var(--radius-control);
    color: inherit;
}

.row__title {
    display: block;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row__sub {
    color: var(--ink-3);
    display: block;
    font-size: 0.8125rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row__chevron {
    color: var(--ink-3);
    transition: transform 160ms var(--ease-out);
}

a.row:hover .row__chevron {
    color: var(--accent);
    transform: translateX(2px);
}

.pips {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 3px;
    max-width: 140px;
}

.pip {
    background: var(--line-strong);
    border-radius: 3px 3px 2px 2px;
    height: 12px;
    width: 10px;
}

.pip--filled {
    background: var(--accent);
}

.sparkline {
    display: block;
    max-width: 100%;
    overflow: visible;
}

.sparkline__line {
    fill: none;
    stroke: var(--accent);
    stroke-linejoin: round;
    stroke-width: 2;
}

.sparkline__area {
    fill: var(--accent-soft);
    opacity: 0.7;
}

@media (width <= 760px) {
    .button,
    .chip,
    .field input,
    .field select,
    .search input {
        min-height: 44px;
    }

    .button--small {
        min-height: 40px;
    }

    .icon-button {
        height: 44px;
        width: 44px;
    }

    .form-section {
        grid-template-columns: minmax(0, 1fr);
    }

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

    .data th {
        position: static;
    }

    .facts div {
        gap: 2px;
        grid-template-columns: minmax(0, 1fr);
    }

    .toasts {
        left: var(--space-4);
        width: auto;
    }
}
