/* Shared inner-page layout, lists, forms, and tables */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.page-header-text {
    flex: 1;
    min-width: 0;
}

.page-header h2,
.panel > h2 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.25;
}

.page-subtitle {
    margin: 0.35rem 0 0;
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.45;
    max-width: 52rem;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.35rem 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.panel + .panel {
    margin-top: 0;
}

.panel h3,
.form-section-title {
    margin: 0 0 0.85rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.panel h4 {
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
}

.form-section {
    margin-top: 1.5rem;
    padding-top: 1.35rem;
    border-top: 1px solid var(--border-light);
}

.form-section:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.form-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-hint {
    margin: -0.35rem 0 0.85rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}

.sub-panel {
    background: linear-gradient(180deg, #fafbfc 0%, var(--bg-page) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.15rem 1.25rem;
    margin-bottom: 1.25rem;
}

.sub-panel h3 {
    margin: 0 0 1rem;
    font-size: 1.05rem;
    font-weight: 700;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.15rem;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.stat-card h3 {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-card p {
    margin: 0.45rem 0 0;
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-primary);
}

.stat-card-clickable {
    cursor: pointer;
}

.stat-card-clickable:hover {
    border-color: #c7d7fe;
    box-shadow: var(--shadow);
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -0.25rem;
    padding: 0 0.25rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--bg-surface);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table thead {
    background: #f9fafb;
}

.data-table th {
    text-align: left;
    padding: 0.8rem 0.9rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.data-table td {
    padding: 0.85rem 0.9rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    color: var(--text-primary);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:nth-child(even) {
    background: #fcfcfd;
}

.data-table td strong {
    font-weight: 600;
}

.clickable-row {
    cursor: pointer;
    transition: background 0.12s;
}

.clickable-row:hover {
    background: var(--brand-primary-light) !important;
}

.data-table tr.row-overdue td {
    background: #fff7ed;
}

.data-table tr.row-overdue:hover td {
    background: #ffedd5 !important;
}

.empty-state {
    text-align: center;
    padding: 2.5rem 1.5rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: #fafbfc;
}

.empty-state strong {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--text-primary);
    font-size: 1rem;
}

.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
    flex-wrap: wrap;
    gap: 0.75rem;
}

.pagination-bar p {
    margin: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border: none;
    border-radius: var(--radius);
    padding: 0.58rem 1.1rem;
    background: var(--brand-primary);
    color: #fff;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.88rem;
    line-height: 1.2;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}

.btn:hover {
    background: var(--brand-primary-hover);
    color: #fff;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--brand-primary-light);
    border-color: #86d275;
    color: var(--brand-primary);
}

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid #fecaca;
}

.btn-danger:hover {
    background: #fee2e2;
    color: #b91c1c;
}

.pending-users-panel {
    margin-bottom: 1.5rem;
    border: 1px solid var(--warning-bg, #fffbeb);
    background: linear-gradient(180deg, #fffdf5 0%, var(--bg-surface, #fff) 100%);
}

.pending-role-select {
    min-width: 9rem;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
}

.table-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.data-table tr.row-selected td {
    background: var(--brand-primary-light, #e4f3df);
}

.btn-sm {
    padding: 0.38rem 0.72rem;
    font-size: 0.8rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}

.badge-warm { background: var(--brand-orange-light); color: var(--brand-orange); }
.badge-running { background: var(--success-bg); color: var(--success); }
.badge-initial-send { background: #e0f2fe; color: #0369a1; }
.badge-paused { background: var(--warning-bg); color: var(--warning); }
.badge-completed { background: var(--info-bg); color: var(--info); }
.badge-stopped { background: var(--danger-bg); color: var(--danger); }
.badge-draft { background: var(--border-light); color: var(--text-secondary); }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.85rem 1rem;
}

.form-grid label,
.panel label,
.sub-panel label {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-grid input,
.form-grid select,
.form-grid textarea,
.panel input,
.panel textarea,
.panel select,
.sub-panel input,
.sub-panel textarea,
.sub-panel select {
    padding: 0.58rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-primary);
    background: var(--bg-surface);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus,
.panel input:focus,
.panel textarea:focus,
.panel select:focus,
.sub-panel input:focus,
.sub-panel textarea:focus,
.sub-panel select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(20, 168, 0, 0.12);
}

.form-field-full {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 1rem;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-field-full textarea,
.form-field-full input {
    width: 100%;
}

.checkbox-label {
    flex-direction: row !important;
    align-items: center;
    gap: 0.5rem !important;
    font-weight: 500 !important;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--brand-primary);
}

.alert {
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    line-height: 1.45;
}

.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.alert-info { background: var(--brand-primary-light); color: var(--brand-primary-dark); border: 1px solid #b6e0aa; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #a7f3d0; }

.search-input {
    flex: 1;
    min-width: 180px;
    padding: 0.58rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font: inherit;
    font-size: 0.9rem;
    background: var(--bg-surface);
}

.filter-panel {
    background: #f9fafb;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.15rem;
}

.filter-bar {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-bar + .filter-bar {
    margin-top: 0.75rem;
}

.filter-bar input,
.filter-bar select {
    padding: 0.58rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 140px;
    font: inherit;
    font-size: 0.88rem;
    background: var(--bg-surface);
}

.filter-date {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.filter-date input {
    min-width: 150px;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 400;
}

.toolbar {
    display: flex;
    gap: 0.65rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.text-muted {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.actions-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.settings-tabs {
    display: flex;
    gap: 0.45rem;
    margin-bottom: 1.15rem;
    flex-wrap: wrap;
}

.tab-btn {
    border: 1px solid var(--border);
    background: var(--bg-surface);
    padding: 0.52rem 0.95rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.86rem;
    color: var(--text-secondary);
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.tab-btn:hover {
    background: var(--border-light);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
}

.followup-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: flex-end;
    margin-bottom: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
}

.followup-row label {
    margin: 0;
}

.followup-step-body {
    margin-bottom: 0.85rem;
}

.lead-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.45rem;
    max-height: 280px;
    overflow-y: auto;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
}

.lead-picker-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    margin-bottom: 0.65rem;
}

.lead-picker-search {
    flex: 1 1 220px;
    min-width: 180px;
    max-width: 420px;
}

.lead-picker-select-all {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    white-space: nowrap;
}

.lead-picker-empty {
    grid-column: 1 / -1;
    margin: 0;
    padding: 0.5rem 0;
}

.lead-picker-item {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 0.5rem !important;
    padding: 0.45rem 0.55rem;
    border-radius: 8px;
    font-weight: 400 !important;
    font-size: 0.88rem !important;
    cursor: pointer;
}

.lead-picker-item:hover {
    background: var(--brand-primary-light);
}

.preview-box {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.preview-box pre {
    white-space: pre-wrap;
    margin: 0.5rem 0 0;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-primary);
}

.email-html-preview {
    margin-top: 0.75rem;
    padding: 1rem 1.15rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: #fff;
    color: #001e00;
    font-size: 0.95rem;
    line-height: 1.6;
}

.email-html-preview p {
    margin: 0 0 0.85rem;
}

.email-html-preview p:last-child {
    margin-bottom: 0;
}

.email-html-preview ul,
.email-html-preview ol {
    margin: 0.5rem 0 0.85rem;
    padding-left: 1.4rem;
}

.email-html-preview a {
    color: var(--brand-primary);
    text-decoration: underline;
}

.email-html-preview strong,
.email-html-preview b {
    font-weight: 700;
}

.warm-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.warm-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.1rem;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
    box-shadow: var(--shadow-sm);
}

.warm-card:hover {
    border-color: #86d275;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.warm-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.85rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-light);
    font-size: 0.82rem;
    color: var(--text-muted);
}

.list-count {
    margin: 0.85rem 0 0;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.panel-flush-tabs .settings-tabs {
    margin-bottom: 0;
}

.test-email-panel {
    margin-top: 1.25rem;
    padding: 1rem 1.15rem;
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.test-email-grid {
    max-width: 420px;
}

.test-email-hint {
    font-size: 0.88rem;
}

.page-error-boundary {
    margin: 1rem 0;
}

.section-title {
    margin: 1.25rem 0 0.65rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.inbox-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.inbox-item {
    padding: 1rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.12s;
}

.inbox-item:hover {
    border-color: #86d275;
    box-shadow: var(--shadow-sm);
    background: #fafcff;
}

.inbox-item.unread {
    border-left: 3px solid var(--brand-primary);
    background: var(--brand-primary-light);
}

.inbox-meta {
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.inbox-preview {
    margin-top: 0.45rem;
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.page-header .settings-tabs {
    margin-bottom: 0;
}

@media (max-width: 960px) {
    .panel {
        padding: 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .page-actions {
        width: 100%;
    }

    .page-actions .btn {
        flex: 1;
    }

    .data-table {
        min-width: 640px;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-bar input,
    .filter-bar select,
    .search-input {
        width: 100%;
        min-width: 0;
    }

    .leads-filter-bar {
        flex-direction: column;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .warm-card-grid {
        grid-template-columns: 1fr;
    }
}

/* Lead detail — discussion note */
.add-note {
    margin-bottom: 1.25rem;
    padding: 1rem 1.1rem;
    background: var(--bg-subtle, #f8fafc);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: var(--radius-lg, 14px);
}

.add-note-label {
    display: block;
    margin-bottom: 0.45rem;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
}

.add-note-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.75rem 0.85rem;
    font-family: inherit;
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--text-primary, #0f172a);
    background: #fff;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: var(--radius, 10px);
    resize: vertical;
    min-height: 96px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.add-note-input:focus {
    outline: none;
    border-color: var(--brand-primary, #14a800);
    box-shadow: 0 0 0 3px rgba(20, 168, 0, 0.12);
}

.add-note-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.75rem;
}

.btn-add-note {
    min-width: 120px;
    background: var(--brand-primary, #14a800);
    color: #fff;
    box-shadow: 0 2px 8px rgba(20, 168, 0, 0.25);
}

.btn-add-note:hover:not(:disabled) {
    background: var(--brand-primary-hover, #108a00);
    color: #fff;
}

.btn-add-note:disabled {
    opacity: 0.7;
    cursor: wait;
}

.timeline-body {
    margin-top: 0.35rem;
    font-size: 0.92rem;
    line-height: 1.55;
    color: var(--text-primary, #334155);
    white-space: pre-wrap;
    word-break: break-word;
}
