/* =====================================================================
   Event CRM — base styles (desktop first). Breakpoints live in responsive.css
   ===================================================================== */

:root {
    /* Colour */
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #f8f9fb;
    --border: #e2e5ea;
    --border-strong: #cbd0d8;
    --text: #1a1f2b;
    --text-2: #4b5261;
    --muted: #666d7a;

    --primary: #1d4ed8;
    --primary-hover: #1a3fb0;
    --primary-soft: #edf2fe;
    --danger: #b42318;
    --danger-hover: #912018;
    --danger-soft: #fef1f0;
    --warning-soft: #fff6e0;
    --warning-border: #f1d48a;
    --warning-text: #6f4a00;
    --success: #12713a;
    --whatsapp: #0f7a40;
    --whatsapp-hover: #0b6333;
    --chart: #2a78d6;

    /* Spacing scale */
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 24px;
    --s-6: 32px;

    --radius: 8px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-lg: 0 16px 40px rgba(16, 24, 40, 0.18);

    --sidebar-width: 232px;
    --topbar-height: 60px;
    --bottom-nav-height: 60px;

    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

body.has-modal {
    overflow: hidden;
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
dl,
dd {
    margin: 0;
}

ul,
ol {
    padding: 0;
    list-style: none;
}

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

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

code {
    padding: 1px 5px;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 12.5px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

[hidden] {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.skip-link {
    position: absolute;
    top: -48px;
    left: var(--s-2);
    z-index: 100;
    padding: var(--s-2) var(--s-3);
    color: #fff;
    background: var(--primary);
    border-radius: var(--radius-sm);
}

.skip-link:focus {
    top: var(--s-2);
}

.muted {
    color: var(--muted);
}

.nowrap {
    white-space: nowrap;
}

.icon {
    flex-shrink: 0;
    vertical-align: middle;
}

.noscript,
.loading {
    padding: var(--s-5);
    color: var(--muted);
}

/* ---------- Layout ---------- */

.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    padding: var(--s-4) var(--s-3);
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.sidebar-backdrop {
    display: none;
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-1) var(--s-2) var(--s-4);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    color: #fff;
    background: var(--primary);
    border-radius: var(--radius);
}

.brand-name {
    font-size: 16px;
    font-weight: 650;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: 9px var(--s-3);
    font-weight: 500;
    color: var(--text-2);
    text-decoration: none;
    border-radius: var(--radius-sm);
}

.nav-link:hover {
    color: var(--text);
    background: var(--surface-2);
}

.nav-link.is-active {
    color: var(--primary);
    background: var(--primary-soft);
}

.nav-badge {
    min-width: 20px;
    margin-left: auto;
    padding: 0 6px;
    font-size: 12px;
    font-weight: 600;
    line-height: 20px;
    text-align: center;
    color: var(--text-2);
    background: var(--border);
    border-radius: 10px;
}

.nav-badge.is-overdue {
    color: #fff;
    background: var(--danger);
}

.sidebar-note {
    margin-top: auto;
    padding: var(--s-3);
    font-size: 12px;
    color: var(--muted);
    background: var(--surface-2);
    border-radius: var(--radius-sm);
}

.main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: var(--s-4);
    height: var(--topbar-height);
    padding: 0 var(--s-5);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar .menu-toggle {
    display: none;
}

.topbar-event {
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-right: auto;
    line-height: 1.3;
}

.topbar-event-name {
    overflow: hidden;
    font-size: 15px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-event-meta {
    overflow: hidden;
    font-size: 12px;
    color: var(--muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-search {
    position: relative;
    width: 280px;
    max-width: 40vw;
}

.topbar-search-icon {
    position: absolute;
    top: 50%;
    left: 10px;
    display: flex;
    color: var(--muted);
    transform: translateY(-50%);
    pointer-events: none;
}

.topbar-search input[type="search"] {
    padding-left: 32px;
    background: var(--surface-2);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    font-weight: 500;
    color: var(--text-2);
}

.avatar {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: 50%;
}

.user-name {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.view {
    max-width: 1320px;
    padding: var(--s-5);
    outline: none;
}

.bottom-nav {
    display: none;
}

/* ---------- Page header ---------- */

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    margin-bottom: var(--s-4);
}

.page-header h1 {
    font-size: 20px;
    font-weight: 650;
    line-height: 1.3;
}

.page-subtitle {
    color: var(--muted);
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
}

/* ---------- Cards ---------- */

.card {
    padding: var(--s-4);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-flush {
    padding: 0;
    overflow: hidden;
}

.card-title {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    margin-bottom: var(--s-3);
    font-size: 14px;
    font-weight: 600;
}

.card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--s-1) var(--s-3);
    margin-bottom: var(--s-3);
}

.card-head .card-title {
    margin-bottom: 0;
}

.card-link {
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
}

.card-link:hover {
    text-decoration: underline;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 14px;
    font-weight: 500;
    line-height: 1;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
}

.btn:hover {
    background: var(--surface-2);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.btn-small {
    min-height: 30px;
    padding: 0 10px;
    font-size: 13px;
}

.btn-primary {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-danger {
    color: #fff;
    background: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger-hover);
    border-color: var(--danger-hover);
}

.btn-danger-outline {
    color: var(--danger);
    border-color: #e9b4ae;
}

.btn-danger-outline:hover {
    background: var(--danger-soft);
}

.btn-whatsapp {
    color: #fff;
    background: var(--whatsapp);
    border-color: var(--whatsapp);
}

.btn-whatsapp:hover {
    background: var(--whatsapp-hover);
    border-color: var(--whatsapp-hover);
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    color: var(--text-2);
    cursor: pointer;
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
}

.icon-btn:hover {
    color: var(--text);
    background: var(--surface-2);
}

.icon-btn-whatsapp {
    color: var(--whatsapp);
}

.icon-btn-whatsapp:hover {
    color: var(--whatsapp-hover);
    background: #e7f5ec;
}

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

.link-btn {
    padding: 0;
    font-weight: 600;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    background: none;
    border: 0;
}

.link-btn:hover {
    color: var(--primary);
    text-decoration: underline;
}

.chip {
    padding: 4px 10px;
    font-size: 13px;
    color: var(--text-2);
    cursor: pointer;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.chip:hover {
    color: var(--primary);
    border-color: var(--primary);
}

/* ---------- Badges ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    line-height: 18px;
    white-space: nowrap;
    border-radius: 10px;
}

.status-new {
    color: #1a4fb8;
    background: #e6effe;
}

.status-contacted {
    color: #7a4f00;
    background: #fff1cc;
}

.status-registered {
    color: #5b32b5;
    background: #eee8fd;
}

.status-committed {
    color: #9a3d0a;
    background: #ffe6d8;
}

.status-paid {
    color: #12713a;
    background: #daf4e3;
}

.status-attended {
    color: #fff;
    background: #0f6468;
}

.payment-not_paid {
    color: var(--text-2);
    background: #eceef2;
}

.payment-partial {
    color: #9a3d0a;
    background: #ffe6d8;
}

.payment-paid {
    color: #12713a;
    background: #daf4e3;
}

.followup-overdue {
    color: #fff;
    background: var(--danger);
}

.followup-today {
    color: #1a4fb8;
    background: #e6effe;
}

.followup-upcoming {
    color: var(--text-2);
    background: #eceef2;
}

.badge-on {
    color: #12713a;
    background: #daf4e3;
}

.badge-off {
    color: var(--text-2);
    background: #eceef2;
}

.count-pill {
    padding: 0 8px;
    font-size: 12px;
    font-weight: 600;
    line-height: 20px;
    color: var(--text-2);
    background: #eceef2;
    border-radius: 10px;
}

/* ---------- Forms ---------- */

.field {
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
    min-width: 0;
}

.field > label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
}

.required {
    color: var(--danger);
}

input[type="text"],
input[type="tel"],
input[type="email"],
input[type="url"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="search"],
select,
textarea {
    width: 100%;
    min-height: 36px;
    padding: 6px 10px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
}

textarea {
    min-height: 0;
    line-height: 1.45;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    outline: 2px solid rgba(29, 78, 216, 0.2);
    outline-offset: 0;
}

input[readonly] {
    color: var(--text-2);
    background: var(--surface-2);
}

input::placeholder,
textarea::placeholder {
    color: #8a909c;
}

.has-error input,
.has-error select,
.has-error textarea {
    border-color: var(--danger);
}

.field-error {
    font-size: 12.5px;
    color: var(--danger);
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    margin-top: 2px;
    font-size: 13px;
    color: var(--text-2);
    cursor: pointer;
}

.checkbox input,
.choice input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--primary);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s-3) var(--s-4);
}

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

.form-section-title {
    margin: var(--s-5) 0 var(--s-3);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--muted);
    text-transform: uppercase;
}

.form-section-title:first-child,
[data-role="duplicate-warning"]:empty + .form-section-title {
    margin-top: 0;
}

.form-section-title .muted {
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
}

.form-details {
    margin-top: var(--s-5);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.form-details summary {
    padding: var(--s-3);
    font-weight: 500;
    cursor: pointer;
}

.form-details .form-grid {
    padding: 0 var(--s-3) var(--s-3);
}

.form-intro {
    margin-bottom: var(--s-3);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--s-2);
    margin-top: var(--s-4);
}

.form-actions-start {
    justify-content: flex-start;
}

.quick-dates {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
    margin-bottom: var(--s-3);
}

/* ---------- Notices ---------- */

.notice {
    display: flex;
    align-items: flex-start;
    gap: var(--s-2);
    margin-top: var(--s-3);
    padding: var(--s-3);
    font-size: 13px;
    color: var(--text-2);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.notice .icon {
    margin-top: 2px;
}

.notice-warning {
    color: var(--warning-text);
    background: var(--warning-soft);
    border-color: var(--warning-border);
}

.notice-block {
    margin: 0 0 var(--s-4);
}

.plain-list {
    margin: var(--s-1) 0;
}

/* ---------- Filters ---------- */

.filters {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--s-3);
    align-items: end;
    margin-bottom: var(--s-4);
}

.filter-search {
    grid-column: span 2;
}

.filter-toggle {
    display: none;
}

.filter-clear .btn {
    width: 100%;
}

/* ---------- Tables ---------- */

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

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

.table th {
    padding: 10px var(--s-3);
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-align: left;
    white-space: nowrap;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 10px var(--s-3);
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

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

.leads-table tbody tr:hover {
    background: var(--surface-2);
}

.table-compact {
    margin-top: var(--s-4);
    font-variant-numeric: tabular-nums;
}

.table-compact th,
.table-compact td {
    padding: 7px var(--s-3);
}

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

.cell-name {
    min-width: 180px;
}

.leads-table .cell-sub {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-sub {
    font-size: 12.5px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

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

.row-actions {
    display: flex;
    gap: 2px;
}

.status-select {
    width: auto;
    min-height: 28px;
    max-width: 210px;
    padding: 2px 26px 2px 10px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234b5261' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    border-color: transparent;
    border-radius: 14px;
    appearance: none;
}

.status-select.status-attended {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

.status-select option {
    font-weight: 400;
    color: var(--text);
    background: var(--surface);
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    border-top: 1px solid var(--border);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: var(--s-3);
}

.pagination-page {
    font-size: 13px;
    color: var(--text-2);
}

/* ---------- Empty state ---------- */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-6) var(--s-4);
    text-align: center;
}

.empty-state-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    color: var(--muted);
    background: var(--surface-2);
    border-radius: 50%;
}

.empty-state-title {
    font-weight: 600;
}

.empty-state-text {
    max-width: 380px;
    color: var(--muted);
}

.empty-state .btn {
    margin-top: var(--s-2);
}

.card .card-title + .empty-state,
.followup-summary + .empty-state {
    padding: var(--s-4);
}

.panel-empty {
    padding: var(--s-1) 0;
}

/* ---------- Bar chart ---------- */

.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bar-row {
    display: grid;
    grid-template-columns: 176px minmax(0, 1fr);
    gap: var(--s-3);
    align-items: center;
}

.bar-label {
    overflow: hidden;
    font-size: 13px;
    color: var(--text-2);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bar-track {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    /* keeps room for the value label at the tip of the longest bar */
    padding-right: 36px;
}

.bar-fill {
    height: 12px;
    background: var(--chart);
    border-radius: 0 4px 4px 0;
}

.bar-row:hover .bar-fill {
    background: #1c5cab;
}

.bar-value {
    margin-right: -36px;
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ---------- Dashboard ---------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: var(--s-3);
    margin-bottom: var(--s-4);
}

.stat-card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px var(--s-2);
    padding: var(--s-4);
    text-align: left;
    cursor: pointer;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.stat-card:hover {
    border-color: var(--border-strong);
}

.stat-icon {
    grid-row: 1;
    grid-column: 2;
    color: var(--muted);
}

.stat-label {
    grid-row: 1;
    grid-column: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
}

.stat-value {
    grid-column: 1 / -1;
    font-size: 26px;
    font-weight: 650;
    line-height: 1.25;
}

.stat-hint {
    grid-column: 1 / -1;
    font-size: 12.5px;
    color: var(--muted);
}

.stat-alert .stat-hint {
    font-weight: 600;
    color: var(--danger);
}

.stat-alert .stat-icon {
    color: var(--danger);
}

.dashboard-grid,
.report-grid,
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s-4);
    align-items: start;
}

.followup-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--s-2);
    margin-bottom: var(--s-2);
}

.followup-count {
    padding: var(--s-2) var(--s-3);
    font-size: 13px;
    color: var(--text-2);
    text-decoration: none;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.followup-count strong {
    display: block;
    font-size: 18px;
    line-height: 1.3;
    color: var(--text);
}

.followup-count.is-overdue {
    color: var(--danger);
    background: var(--danger-soft);
    border-color: #f3c9c4;
}

.followup-count.is-overdue strong {
    color: var(--danger);
}

.list-item {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.list-item:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.list-main {
    flex: 1;
    min-width: 0;
}

.list-time {
    flex-shrink: 0;
    width: 68px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
}

.list-meta {
    flex-shrink: 0;
    font-size: 12.5px;
    color: var(--muted);
    white-space: nowrap;
}

.list-more {
    display: inline-block;
    margin-top: var(--s-3);
}

/* ---------- Follow-ups page ---------- */

.followup-section {
    margin-bottom: var(--s-4);
}

.followup-section-overdue {
    border-left: 3px solid var(--danger);
}

.followup-section-overdue .card-title {
    color: var(--danger);
}

.followup-item {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr) auto;
    gap: var(--s-3);
    align-items: center;
    padding: var(--s-3) 0;
    border-top: 1px solid var(--border);
}

.followup-when {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
}

.followup-when.is-overdue {
    color: var(--danger);
}

.followup-main .badge {
    margin-left: var(--s-1);
}

.followup-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}

/* ---------- Reports ---------- */

.figure-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: var(--s-3);
}

.figure-row-divided {
    margin-top: var(--s-4);
    padding-top: var(--s-4);
    border-top: 1px solid var(--border);
}

.figure {
    display: flex;
    flex-direction: column;
}

.figure-label {
    font-size: 13px;
    color: var(--text-2);
}

.figure-value {
    font-size: 22px;
    font-weight: 650;
    line-height: 1.35;
}

.figure-hint {
    font-size: 12.5px;
    color: var(--muted);
}

/* ---------- Settings ---------- */

.mode-list li {
    display: flex;
    align-items: flex-start;
    gap: var(--s-3);
    padding: var(--s-2) 0;
}

.mode-list .badge {
    flex-shrink: 0;
    justify-content: center;
    width: 96px;
    margin-top: 2px;
}

.data-summary {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2) var(--s-5);
    margin: var(--s-4) 0 var(--s-2);
    color: var(--text-2);
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    padding: var(--s-3) 0;
    border-top: 1px solid var(--border);
}

.action-row > div:first-child {
    flex: 1 1 220px;
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
}

.choice-list {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    margin-top: var(--s-4);
}

.choice {
    display: flex;
    align-items: flex-start;
    gap: var(--s-3);
    padding: var(--s-3);
    cursor: pointer;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.choice input {
    margin-top: 3px;
}

.choice:has(input:checked) {
    background: var(--primary-soft);
    border-color: var(--primary);
}

.fatal-error {
    max-width: 560px;
    margin: var(--s-6) auto;
}

.fatal-error h1 {
    font-size: 18px;
}

.fatal-error p {
    margin: var(--s-2) 0 var(--s-3);
}

/* ---------- Modals ---------- */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 5vh var(--s-4);
    overflow-y: auto;
    background: rgba(16, 24, 40, 0.5);
}

.modal {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-height: 90vh;
    background: var(--surface);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
}

.modal-small {
    max-width: 420px;
}

.modal-medium {
    max-width: 520px;
}

.modal-large {
    max-width: 680px;
}

.modal-xlarge {
    max-width: 1040px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-3) var(--s-3) var(--s-5);
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
}

.modal-body {
    flex: 1;
    padding: var(--s-5);
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--s-2);
    padding: var(--s-3) var(--s-5);
    border-top: 1px solid var(--border);
}

.confirm-message {
    color: var(--text-2);
}

.wa-recipient {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    margin-bottom: var(--s-4);
}

.wa-recipient-icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    color: #fff;
    background: var(--whatsapp);
    border-radius: 50%;
}

.wa-recipient + .field,
.wa-recipient ~ .field + .field {
    margin-bottom: var(--s-3);
}

.wa-recipient ~ .field {
    margin-bottom: var(--s-3);
}

/* ---------- Lead profile ---------- */

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

.profile-name {
    font-size: 20px;
    font-weight: 650;
    line-height: 1.3;
}

.profile-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: var(--s-1);
    font-size: 12.5px;
}

.profile-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
}

.pipeline {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    margin: var(--s-5) 0;
}

.pipeline-step {
    position: relative;
}

/* connector line between steps */
.pipeline-step + .pipeline-step::before {
    position: absolute;
    top: 13px;
    right: 50%;
    left: -50%;
    height: 2px;
    content: "";
    background: var(--border);
}

.pipeline-step.is-done + .pipeline-step::before {
    background: var(--primary);
}

.pipeline-step button {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    width: 100%;
    padding: 0 var(--s-1);
    cursor: pointer;
    background: none;
    border: 0;
    border-radius: var(--radius-sm);
}

.pipeline-dot {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    background: var(--surface);
    border: 2px solid var(--border-strong);
    border-radius: 50%;
}

.pipeline-label {
    font-size: 12px;
    line-height: 1.3;
    color: var(--muted);
    text-align: center;
}

.pipeline-step button:hover .pipeline-dot {
    border-color: var(--primary);
}

.pipeline-step.is-done .pipeline-dot {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

.pipeline-step.is-current .pipeline-dot {
    color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}

.pipeline-step.is-current .pipeline-label {
    font-weight: 600;
    color: var(--text);
}

.profile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s-4);
    align-items: start;
}

.profile-column {
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
    min-width: 0;
}

.panel {
    padding: var(--s-4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.panel-title {
    margin-bottom: var(--s-2);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--muted);
    text-transform: uppercase;
}

.panel-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-2);
    margin-bottom: var(--s-2);
}

.panel-head .panel-title {
    margin-bottom: 0;
}

.panel-actions {
    display: flex;
    gap: 6px;
}

.info-row {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: var(--s-3);
    padding: 5px 0;
}

.info-row dt {
    color: var(--muted);
}

.info-row dd {
    overflow-wrap: anywhere;
}

.notes-text {
    max-height: 180px;
    overflow-y: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.note-form {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    align-items: flex-end;
    margin-top: var(--s-3);
}

.timeline-item {
    position: relative;
    display: flex;
    gap: var(--s-3);
    padding-bottom: var(--s-4);
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-item:not(:last-child)::before {
    position: absolute;
    top: 28px;
    bottom: 2px;
    left: 12px;
    width: 2px;
    content: "";
    background: var(--border);
}

.timeline-icon {
    display: grid;
    flex-shrink: 0;
    place-items: center;
    width: 26px;
    height: 26px;
    color: var(--text-2);
    background: #eceef2;
    border-radius: 50%;
}

.activity-created,
.activity-status {
    color: #1a4fb8;
    background: #e6effe;
}

.activity-payment,
.activity-attendance,
.activity-followup_completed {
    color: #12713a;
    background: #daf4e3;
}

.activity-followup {
    color: #7a4f00;
    background: #fff1cc;
}

.activity-whatsapp,
.activity-confirmation {
    color: var(--whatsapp);
    background: #e7f5ec;
}

.timeline-content {
    min-width: 0;
}

.timeline-text {
    overflow-wrap: anywhere;
}

.timeline-meta {
    font-size: 12.5px;
    color: var(--muted);
}

/* ---------- View switch (Table / Board) ---------- */

.view-switch {
    display: inline-flex;
    padding: 2px;
    background: #eceef2;
    border-radius: var(--radius-sm);
}

.view-switch-link {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    min-height: 32px;
    padding: 0 12px;
    font-weight: 500;
    color: var(--text-2);
    text-decoration: none;
    border-radius: 5px;
}

.view-switch-link:hover {
    color: var(--text);
}

.view-switch-link.is-active {
    color: var(--text);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

/* ---------- Kanban board ---------- */

.board-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 2fr);
    gap: var(--s-3);
    align-items: end;
    margin-bottom: var(--s-4);
}

.board-hint {
    display: flex;
    gap: 6px;
    align-items: center;
    min-height: 36px;
    font-size: 13px;
}

.kanban {
    display: grid;
    /* 170px lets all six stages fit on a 1366px laptop without sideways scrolling */
    grid-auto-columns: minmax(170px, 1fr);
    grid-auto-flow: column;
    gap: var(--s-2);
    align-items: start;
    padding-bottom: var(--s-2);
    overflow-x: auto;
}

.kanban-column {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 200px;
    max-height: calc(100vh - 290px);
    background: #eceef2;
    border: 2px solid transparent;
    border-top: 3px solid var(--border-strong);
    border-radius: var(--radius);
}

.kanban-new {
    border-top-color: #1a4fb8;
}

.kanban-contacted {
    border-top-color: #b57a00;
}

.kanban-registered {
    border-top-color: #5b32b5;
}

.kanban-committed {
    border-top-color: #c2520f;
}

.kanban-paid {
    border-top-color: #12713a;
}

.kanban-attended {
    border-top-color: #0f6468;
}

.kanban-column.is-drop-target {
    background: var(--primary-soft);
    border-right-color: var(--primary);
    border-bottom-color: var(--primary);
    border-left-color: var(--primary);
}

.kanban-column-head {
    display: flex;
    flex-wrap: wrap;
    gap: 2px var(--s-2);
    align-items: center;
    padding: var(--s-3) var(--s-3) var(--s-2);
}

.kanban-column-title {
    font-size: 13px;
    font-weight: 600;
}

.kanban-column-head .count-pill {
    background: var(--surface);
}

.kanban-column-sum {
    width: 100%;
    font-size: 12px;
    color: var(--muted);
}

.kanban-list {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--s-2);
    padding: 0 var(--s-2) var(--s-2);
    overflow-y: auto;
}

.kanban-empty {
    padding: var(--s-4) var(--s-2);
    font-size: 13px;
    color: var(--muted);
    text-align: center;
}

.kanban-more {
    width: 100%;
}

.kanban-card {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    gap: 6px;
    padding: var(--s-3);
    cursor: grab;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.kanban-card:hover {
    border-color: var(--border-strong);
}

.kanban-card.is-dragging {
    opacity: 0.45;
}

.kanban-card-head {
    display: flex;
    gap: var(--s-2);
    align-items: flex-start;
    justify-content: space-between;
}

.kanban-card-head .link-btn {
    padding-top: 5px;
    overflow-wrap: anywhere;
}

.kanban-card-head .icon-btn {
    margin: -2px -4px 0 0;
}

.kanban-card-followup,
.kanban-card-payment {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    font-size: 12.5px;
    color: var(--text-2);
}

.kanban-card-when {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    white-space: nowrap;
}

.kanban-card-followup.is-overdue {
    color: var(--danger);
}

.kanban-move {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 2px;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}

.kanban-move select {
    min-height: 28px;
    padding: 2px 6px;
    font-size: 12.5px;
}

/* ---------- Automations ---------- */

.notice-link {
    text-decoration: none;
}

.notice-link:hover {
    border-color: var(--border-strong);
}

.automation-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--s-4);
    align-items: start;
}

.rule {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: var(--s-3);
    align-items: start;
    padding: var(--s-3) 0;
    border-top: 1px solid var(--border);
}

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

.rule:last-child {
    padding-bottom: 0;
}

.rule-title {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
    align-items: center;
    font-weight: 600;
}

.rule-flow {
    font-size: 13px;
    color: var(--text-2);
}

.rule-when,
.rule-then {
    display: inline-block;
    min-width: 38px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--muted);
    text-transform: uppercase;
}

.rule-days {
    display: flex;
    gap: var(--s-2);
    align-items: center;
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-2);
}

.rule-days input[type="number"] {
    width: 72px;
    min-height: 30px;
    padding: 2px 8px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
    margin-top: 1px;
    cursor: pointer;
}

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

.switch-track {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: #868d99;
    border-radius: 11px;
    transition: background 0.15s;
}

.switch-track::after {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    content: "";
    background: #fff;
    border-radius: 50%;
    transition: transform 0.15s;
}

.switch input:checked + .switch-track {
    background: var(--primary);
}

.switch input:checked + .switch-track::after {
    transform: translateX(16px);
}

.switch input:focus-visible + .switch-track {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.tabs {
    display: flex;
    gap: var(--s-4);
    margin-bottom: var(--s-2);
    border-bottom: 1px solid var(--border);
}

.tab {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    padding: var(--s-2) 0;
    margin-bottom: -1px;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
}

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

.tab.is-active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.outbox-list {
    max-height: 640px;
    overflow-y: auto;
}

.outbox-item {
    padding: var(--s-3) 0;
    border-bottom: 1px solid var(--border);
}

.outbox-item:last-child {
    border-bottom: 0;
}

.outbox-head {
    display: flex;
    flex-wrap: wrap;
    gap: 4px var(--s-2);
    align-items: center;
}

.outbox-meta {
    width: 100%;
    font-size: 12.5px;
    color: var(--muted);
}

.outbox-message {
    margin-top: var(--s-2);
    padding: var(--s-2) var(--s-3);
    font-size: 13px;
    color: var(--text-2);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: var(--surface-2);
    border-left: 3px solid var(--border-strong);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.outbox-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
    margin-top: var(--s-2);
}

.preview-steps {
    margin: var(--s-4) 0 var(--s-2);
}

.preview-steps li {
    padding: 2px 0;
}

.preview-steps + .outbox-message {
    margin-bottom: var(--s-3);
}

.activity-automation {
    color: #5b32b5;
    background: #eee8fd;
}

/* ---------- Toasts ---------- */

.toast-root {
    position: fixed;
    right: var(--s-4);
    bottom: var(--s-4);
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    align-items: flex-end;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    max-width: 360px;
    padding: 10px 14px;
    color: #fff;
    background: #1f2937;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    transition: opacity 0.2s;
}

.toast-success .icon {
    color: #6ee7a0;
}

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

.toast-info .icon {
    color: #93c5fd;
}

.toast-leaving {
    opacity: 0;
}

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