.page-head,
.head-actions,
.form-actions,
.filters,
.field-inline,
.card-row,
.page-links {
    display: flex;
    gap: 10px;
    align-items: center;
}

.page-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 16px;
    row-gap: 6px;
    margin-bottom: 22px;
}

.page-head > div {
    display: contents;
}

.page-head > .head-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    grid-column: 2;
    grid-row: 1;
}

.page-head .btn {
    grid-column: 2;
    grid-row: 1;
    width: auto;
    justify-self: end;
}

.page-head > .head-actions .btn {
    grid-column: auto;
    grid-row: auto;
    justify-self: auto;
}

.page-head .lede {
    grid-column: 1 / -1;
}

.lede,
.muted,
.help,
.card-meta,
.card-source,
.user-chip {
    color: var(--muted);
}

.lede {
    margin-top: 6px;
    max-width: 62ch;
}

.help,
.muted-block {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
}

.btn {
    font-weight: 500;
    border: 1px solid var(--line-strong);
    background: transparent;
    color: var(--text);
    border-radius: 999px;
    padding: 7px 13px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:hover {
    border-color: var(--accent);
    color: var(--text);
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-ink);
    border-color: transparent;
    font-weight: 500;
    font-size: 13px;
}

.btn-primary:hover {
    color: var(--accent-ink);
    filter: brightness(1.05);
}

.btn-ghost,
.btn-quiet {
    background: transparent;
    border-color: transparent;
    color: var(--muted);
}

.btn-quiet:hover {
    border-color: transparent;
    color: var(--text);
}

.btn-small {
    padding: 5px 10px;
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
}

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

.stat {
    background: transparent;
    border: 0;
    padding: 0;
    display: flex;
    flex-direction: column-reverse;
    gap: 2px;
}

.stat span,
.stat strong {
    display: block;
}

.stat span {
    color: var(--muted);
    font-size: 0.75rem;
}

.stat strong,
.count,
.card-amount {
    font-variant-numeric: tabular-nums;
}

.stat strong {
    font-size: 20px;
    font-weight: 500;
    letter-spacing: -0.03em;
}

a.stat:hover {
    color: inherit;
}

.panel,
.reveal,
.banner {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.table-wrap {
    background: transparent;
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
}

.panel {
    padding: 18px;
}

.learn-panel {
    display: grid;
    gap: 18px;
}

.learn-panel h2,
.learn-panel .help,
.learn-panel .alert,
.learn-panel form {
    margin: 0;
}

.banner {
    padding: 12px 14px;
    margin-bottom: 16px;
}

.reveal {
    padding: 16px 18px;
    margin-bottom: 16px;
    border-color: rgba(232, 160, 74, 0.45);
}

.reveal dl {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 12px 0 0;
}

.reveal dt {
    color: var(--muted);
    font-size: 0.78rem;
}

.reveal dd {
    margin: 2px 0 0;
}

.reveal code,
code,
.snippet {
    font-family: var(--mono);
    font-size: 0.82rem;
}

.filters {
    margin-bottom: 12px;
}

.client-filters {
    align-items: end;
    flex-wrap: wrap;
}

.client-filters .field:not(.grow) {
    flex: 0 0 auto;
}

.client-filters select,
.client-filters input[type="date"] {
    width: auto;
    min-width: 9.5rem;
    color-scheme: dark;
}

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

.filters .grow {
    flex: 1;
}

.field span,
.field legend {
    font-size: 0.82rem;
    color: var(--muted);
}

input,
select,
textarea {
    width: 100%;
    background: transparent;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    padding: 8px 10px;
}

.field select,
.client-filters select {
    appearance: none;
    padding-right: 34px;
    background-color: transparent;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%238d95a1' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px 8px;
}

textarea {
    resize: vertical;
}

.field-inline input {
    flex: 1;
}

.field-error {
    color: var(--danger);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 16px;
    align-items: start;
}

.span-2,
.form-actions,
.check-row {
    grid-column: span 2;
}

.form-actions {
    flex-wrap: wrap;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.check-row input {
    width: auto;
}

fieldset {
    border: 0;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
    align-content: start;
    min-inline-size: 0;
}

.form-grid fieldset.field {
    gap: 6px;
}

.limit-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
}

.limit-choices .check-row {
    grid-column: auto;
    width: auto;
}

.limit-panel[hidden],
.limit-panel [hidden] {
    display: none;
}

.form-grid legend {
    padding: 0;
    margin-bottom: 6px;
}

.stack {
    display: grid;
    gap: 12px;
    margin-top: 12px;
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
}

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

.data-table th {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 500;
}

.row-title {
    font-weight: 500;
}

.row-sub {
    display: none;
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lead-cell {
    white-space: nowrap;
}

.lead-extra {
    margin-left: 8px;
    color: var(--muted);
    font-weight: 500;
}

.lead-extra.is-up {
    color: var(--ok);
}

.cell-quiet {
    color: var(--muted);
    font-size: 0.86rem;
}

.row-actions {
    width: 1%;
    white-space: nowrap;
}

.empty {
    color: var(--muted);
    text-align: center;
    padding: 28px 14px;
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    color: var(--muted);
}

.page-links a,
.page-links .is-current {
    min-width: 32px;
    text-align: center;
    padding: 4px 8px;
    border-radius: 8px;
}

.page-links .is-current,
.tabs a.is-active {
    background: var(--accent-soft);
    color: #f3d7a8;
}

.tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.tabs a {
    padding: 6px 10px;
    border-radius: 999px;
    color: var(--muted);
    border: 1px solid transparent;
}

.tabs a:hover {
    color: var(--text);
}

.badge,
.pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 0.75rem;
    border: 1px solid var(--line);
    color: var(--muted);
}

.badge[data-stage="new_lead"] { color: var(--stage-new); }
.badge[data-stage="contacting"] { color: var(--stage-contacting); }
.badge[data-stage="meeting_booked"] { color: var(--stage-booked); }
.badge[data-stage="meeting_done"] { color: var(--stage-done); }
.badge[data-stage="proposal_sent"] { color: var(--stage-proposal); }
.badge[data-stage="won"] { color: var(--stage-won); }
.badge[data-stage="lost"] { color: var(--stage-lost); }

.pill-warn {
    color: var(--danger);
    border-color: transparent;
    background: var(--danger-soft);
}

.alert {
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 14px;
    background: var(--bg-elev-2);
    border: 1px solid var(--line);
}

.alert-success {
    background: var(--ok-soft);
    color: #d7f5e4;
}

.alert-error {
    background: var(--danger-soft);
    color: #ffd7da;
}

.split {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
    gap: 16px;
    margin-bottom: 16px;
}

.client-sheet {
    display: grid;
    gap: 16px;
    max-width: 820px;
}

.question-list {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: grid;
    gap: 14px;
}

.question-item {
    display: grid;
    gap: 8px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

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

.login-panel {
    display: grid;
    gap: 10px;
}

.login-identity {
    display: grid;
    gap: 4px;
}

.login-who .muted {
    margin-left: 8px;
}

.login-reset {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    margin-top: 6px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.login-reset .field {
    flex: 1 1 240px;
    min-width: 0;
}

.meta-actions,
.mail-choices,
.mail-notify {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.mail-notify {
    margin: 8px 0;
}

.guide-block + .guide-block {
    margin-top: 8px;
}

.guide-block p {
    margin-top: 8px;
}

.steps {
    margin: 10px 0 0;
    padding-left: 1.2rem;
    display: grid;
    gap: 8px;
}

.fold {
    margin-top: 16px;
    border-top: 1px solid var(--line);
    padding-top: 12px;
}

.fold summary {
    cursor: pointer;
    color: var(--muted);
    width: fit-content;
}

.fold[open] summary {
    margin-bottom: 12px;
}

.timeline {
    list-style: none;
    margin: 12px 0 16px;
    padding: 0;
    display: grid;
    gap: 12px;
}

.timeline li {
    display: grid;
    gap: 2px;
    border-top: 1px solid var(--line);
    padding-top: 10px;
}

.timeline span {
    color: var(--muted);
    font-size: 0.8rem;
}

.snippet {
    width: 100%;
    white-space: pre-wrap;
    background: #0f131a;
    border-radius: 10px;
    border: 1px solid var(--line);
    padding: 12px;
    color: var(--muted);
}

.webhook-box {
    margin-top: 16px;
    display: grid;
    gap: 6px;
}

.webhook-box code {
    display: block;
    padding: 8px 10px;
    background: #0f131a;
    border-radius: 8px;
    overflow-wrap: anywhere;
}

.narrow,
.plain-card {
    max-width: 460px;
    margin: 12vh auto;
    padding: 0 16px;
}

@media (max-width: 900px) {
    .form-grid,
    .split,
    .reveal dl {
        grid-template-columns: 1fr;
    }

    .stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px 20px;
    }

    .span-2,
    .check-row {
        grid-column: auto;
    }

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

@media (max-width: 720px) {
    .hide-sm {
        display: none;
    }

    .row-sub {
        display: block;
    }

    .data-table thead {
        display: none;
    }

    .data-table tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 2px 12px;
        align-items: center;
    }

    .data-table td {
        padding: 12px 0;
        border-bottom: 0;
    }

    .data-table tr {
        border-bottom: 1px solid var(--line);
    }

    .data-table td:first-child {
        padding-bottom: 14px;
    }

    .row-actions {
        padding-top: 12px;
        padding-bottom: 14px;
    }
}
