*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: #1a1a2e;
    background: #f5f6fa;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Layout */

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    background: #1a1a2e;
    color: #e0e0e0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-brand {
    display: block;
    padding: 20px 16px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.nav-links {
    list-style: none;
    padding: 12px 0;
    flex: 1;
}

.nav-links li a {
    display: block;
    padding: 10px 16px;
    border-radius: 6px;
    margin: 2px 8px;
    transition: background 0.15s;
}

.nav-links li a:hover,
.nav-links li a.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 13px;
    color: #aaa;
}

.sidebar-footer a:hover {
    color: #fff;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: 52px;
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    color: #555;
}

.tenant-name {
    font-size: 14px;
    font-weight: 700;
    color: #1a1a2e;
}

.topbar-user {
    font-size: 12px;
    color: #777;
    margin-top: 2px;
}

.page-body {
    padding: 24px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
}

.page-header h1 {
    font-size: 26px;
    line-height: 1.2;
    margin-bottom: 6px;
}

.page-subtitle,
.header-meta {
    color: #666;
}

.header-meta {
    font-size: 13px;
    font-weight: 600;
    padding-top: 7px;
}

/* Dashboard */

.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.card {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    padding: 20px;
}

.card h3 {
    font-size: 13px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.metric-card {
    min-height: 130px;
}

.metric-value {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a2e;
}

.placeholder {
    color: #bbb;
    font-style: italic;
}

.error-card {
    max-width: 520px;
}

.error-card p {
    margin-bottom: 16px;
    color: #555;
}

.empty-state {
    color: #666;
}

/* Auth */

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f6fa;
}

.login-card {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    padding: 36px 40px;
    width: 100%;
    max-width: 380px;
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 24px;
    color: #1a1a2e;
    text-align: center;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #444;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}

.form-control:focus {
    border-color: #1a1a2e;
}

.btn {
    display: inline-block;
    padding: 9px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity 0.15s;
}

.btn:disabled { opacity: 0.6; cursor: default; }

.btn-primary {
    background: #1a1a2e;
    color: #fff;
    width: 100%;
    margin-top: 8px;
}

.btn-primary:hover:not(:disabled) { opacity: 0.85; }

.btn-secondary {
    background: #f0f1f5;
    color: #1a1a2e;
    border: 1px solid #d9dbe4;
}

.btn-inline {
    width: auto;
    margin-top: 0;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

.alert {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 14px;
}

.alert-error {
    background: #fff0f0;
    border: 1px solid #ffc0c0;
    color: #c00;
}

/* Sidebar user info */

.user-email {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-link {
    display: inline-block;
    color: #aaa;
    font-size: 13px;
    padding: 0;
}

.logout-link:hover { color: #fff; }

.logout-page {
    color: #666;
}

/* Prospect list */

.filter-panel {
    margin-bottom: 16px;
}

.filter-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr 160px 160px auto;
    gap: 14px;
    align-items: end;
}

.filter-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.table-card {
    padding: 0;
    overflow: hidden;
}

.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #ececf0;
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

.data-table th {
    font-size: 12px;
    font-weight: 700;
    color: #666;
    text-transform: uppercase;
    background: #fafbfc;
}

.data-table tbody tr:hover {
    background: #fafbfc;
}

.action-column {
    width: 96px;
    text-align: right;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.status-qualified {
    background: #e8f1ff;
    color: #1554b8;
}

.status-offered {
    background: #fff1df;
    color: #9b4d00;
}

.status-converted {
    background: #e5f7ed;
    color: #116b37;
}

.status-muted,
.status-default {
    background: #eeeeef;
    color: #555;
}

.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 14px;
    color: #666;
    border-top: 1px solid #ececf0;
}

.pagination-actions {
    display: flex;
    gap: 8px;
}

/* Prospect detail */

.detail-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.detail-grid {
    display: grid;
    grid-template-columns: minmax(360px, 1fr) minmax(360px, 1.1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.detail-card {
    min-height: 320px;
}

.detail-list {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 12px 16px;
}

.detail-list dt {
    color: #777;
    font-weight: 700;
}

.detail-list dd {
    min-width: 0;
    color: #1a1a2e;
    overflow-wrap: anywhere;
}

.text-link {
    color: #1554b8;
}

.text-link:hover {
    text-decoration: underline;
}

.message-preview,
.outreach-body {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-family: "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #2f3242;
    background: #fafbfc;
    border: 1px solid #ececf0;
    border-radius: 6px;
}

.message-preview {
    min-height: 190px;
    padding: 14px;
    margin-bottom: 12px;
}

.outreach-body {
    max-width: 680px;
    max-height: 260px;
    overflow: auto;
    padding: 12px;
    margin-top: 10px;
}

.outreach-card {
    margin-top: 16px;
}

.card-header-row {
    padding: 16px 18px;
    border-bottom: 1px solid #ececf0;
}

.card-header-row h3 {
    margin-bottom: 0;
}

.padded-empty {
    padding: 18px;
}

/* Dashboard */

.last-run-card {
    margin-bottom: 16px;
}

.last-run-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

.last-run-main {
    display: flex;
    align-items: center;
    gap: 12px;
}

.last-run-date {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a2e;
}

.last-run-duration {
    font-size: 13px;
    color: #888;
}

.run-stats {
    display: flex;
    gap: 28px;
}

.run-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.run-stat-value {
    font-size: 22px;
    font-weight: 700;
    color: #1a1a2e;
}

.run-stat-label {
    font-size: 11px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.run-error {
    margin-top: 12px;
    font-size: 13px;
    color: #c00;
}

.dashboard-cards {
    margin-bottom: 16px;
}

.scraper-card {
    margin-top: 0;
}

.reason-cell {
    color: #888;
    font-size: 13px;
    white-space: normal;
    max-width: 320px;
}

/* Modal */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal {
    background: #fff;
    border-radius: 10px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid #e8e8e8;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.modal-subtitle {
    font-size: 13px;
    color: #666;
}

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-body .form-group:last-child {
    margin-bottom: 0;
}

.message-textarea {
    height: 240px;
    resize: vertical;
    font-family: "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e8e8e8;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
