:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --ink: #172033;
    --muted: #647086;
    --brand: #0d47a1;
    --brand2: #1976d2;
    --line: #e2e8f0;
    --danger: #b42318;
    --success: #067647;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: var(--brand2);
    text-decoration: none;
}

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

.sidebar {
    width: 255px;
    background: #0b1736;
    color: #fff;
    padding: 24px 18px;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 30px;
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #2196f3, #0d47a1);
    font-weight: 800;
}

.brand span {
    display: block;
    color: #b8c4dc;
    font-size: 13px;
    margin-top: 2px;
}

nav {
    display: grid;
    gap: 8px;
}

nav a {
    color: #dbe7ff;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255,255,255,.06);
}

nav a:hover {
    background: rgba(255,255,255,.12);
}

.main {
    flex: 1;
    padding: 34px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

h1, h2 {
    margin: 0 0 8px;
}

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

.button,
button {
    border: 0;
    background: linear-gradient(135deg, var(--brand2), var(--brand));
    color: #fff;
    padding: 12px 18px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    display: inline-block;
}

.button.secondary {
    background: #eef4ff;
    color: var(--brand);
}

.cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.card,
.panel,
.login-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 14px 38px rgba(15, 23, 42, .06);
}

.card {
    padding: 20px;
}

.card span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.card strong {
    display: block;
    font-size: 34px;
    margin-top: 8px;
}

.panel {
    padding: 22px;
    margin-bottom: 22px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
}

th,
td {
    text-align: left;
    border-bottom: 1px solid var(--line);
    padding: 13px 10px;
    vertical-align: top;
}

th {
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}

.pill {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 999px;
    background: #eef4ff;
    color: var(--brand);
    font-weight: 700;
    font-size: 12px;
}

.empty {
    padding: 22px;
    color: var(--muted);
    border: 1px dashed var(--line);
    border-radius: 14px;
    background: #fbfdff;
}

.login-card {
    display: grid;
    place-items: center;
    min-height: calc(100vh - 68px);
}

.login-panel {
    width: min(460px, 100%);
    padding: 30px;
}

form label {
    display: grid;
    gap: 7px;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 14px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 13px;
    font: inherit;
    background: #fff;
}

textarea {
    resize: vertical;
}

.grid-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 14px;
}

.grid-form label {
    margin-bottom: 0;
}

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

.alert {
    border-radius: 14px;
    padding: 13px 15px;
    margin-bottom: 18px;
    border: 1px solid #b7ebc6;
    background: #ecfdf3;
    color: var(--success);
    font-weight: 700;
}

.alert.error {
    border-color: #fecdca;
    background: #fff1f0;
    color: var(--danger);
}

@media (max-width: 900px) {
    .shell {
        display: block;
    }

    .sidebar {
        width: 100%;
    }

    .main {
        padding: 20px;
    }

    .cards,
    .grid-form {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }
}

.actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.mini-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    padding: 8px 10px;
    font-weight: 800;
    font-size: 12px;
    background: #eef4ff;
    color: var(--brand);
}

.mini-button.light {
    background: #f8fafc;
    color: #334155;
}

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

.filter-form {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 14px;
    align-items: end;
}

.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(320px, .8fr);
    gap: 22px;
    margin-bottom: 22px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    gap: 14px;
}

.info-grid div {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    background: #fbfdff;
}

.info-grid span,
.notes-box span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 7px;
}

.info-grid strong {
    display: block;
    overflow-wrap: anywhere;
}

.notes-box {
    margin-top: 18px;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    background: #fbfdff;
}

.stack-form {
    display: grid;
    gap: 14px;
}

.stack-form label {
    margin-bottom: 0;
}

hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 22px 0;
}

.danger-button {
    background: linear-gradient(135deg, #dc2626, #991b1b);
}

.alert.warning {
    border-color: #fde68a;
    background: #fffbeb;
    color: #92400e;
}

.section-gap {
    margin-top: 28px;
}

.timeline {
    display: grid;
    gap: 12px;
}

.timeline-item {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    background: #fbfdff;
}

.timeline-item strong {
    display: block;
    margin-bottom: 4px;
}

.timeline-item span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 8px;
}

.timeline-item p {
    margin: 0;
    color: var(--ink);
}

@media (max-width: 1100px) {
    .filter-form,
    .detail-grid,
    .info-grid {
        grid-template-columns: 1fr;
    }
}

/* TIKTECH_IMPORT_PHASE3_CSS */
.compact-cards {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
}

.columns-list {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
}

.columns-list span {
    display: inline-flex;
    border-radius: 999px;
    padding: 7px 11px;
    background: #eef4ff;
    color: var(--brand);
    font-weight: 800;
    font-size: 12px;
}

.import-actions {
    margin: 18px 0;
}

.import-actions form {
    margin: 0;
}

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

.table-scroll {
    width: 100%;
    overflow-x: auto;
}

.state {
    display: inline-flex;
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 12px;
    font-weight: 800;
}

.state.ok {
    background: #ecfdf3;
    color: #067647;
}

.state.warn {
    background: #fffbeb;
    color: #92400e;
}

.state.bad {
    background: #fff1f0;
    color: #b42318;
}

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

/* TIKTECH_PHASE4_REVIEW_CSS */
.phase4-cards {
    grid-template-columns: repeat(7, minmax(130px, 1fr));
}

.card-link {
    color: var(--ink);
}

.card-link:hover {
    transform: translateY(-1px);
}

.queue-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.queue-tabs a {
    display: inline-flex;
    border-radius: 999px;
    padding: 10px 13px;
    background: #f8fafc;
    color: #334155;
    font-weight: 800;
    border: 1px solid var(--line);
}

.queue-tabs a.active {
    background: #eef4ff;
    color: var(--brand);
    border-color: #bfdbfe;
}

.inline-form {
    margin: 0;
}

.inline-form button {
    border: 0;
}

.danger-mini {
    background: #fff1f0;
    color: #b42318;
}

.contact-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.check-row {
    display: flex !important;
    align-items: center;
    grid-template-columns: auto 1fr !important;
    gap: 10px !important;
}

.check-row input {
    width: auto;
}

@media (max-width: 1300px) {
    .phase4-cards {
        grid-template-columns: repeat(3, minmax(140px, 1fr));
    }
}

@media (max-width: 760px) {
    .phase4-cards {
        grid-template-columns: 1fr;
    }
}

/* TIKTECH_PHASE5_EMAIL_CSS */
.one-col {
    grid-template-columns: 1fr;
}

#email_body {
    min-height: 360px;
    line-height: 1.5;
}

#email-composer textarea {
    white-space: pre-wrap;
}

.timeline-item p {
    overflow-wrap: anywhere;
}

/* TIKTECH_PHASE5B_SMTP_SETTINGS_CSS */
.check-row.full {
    grid-column: 1 / -1;
    display: flex !important;
    align-items: center;
    gap: 10px;
    font-weight: 800;
}

.check-row.full input {
    width: auto;
}

/* TIKTECH_LEADS_FOLLOWUP_TASK_SYSTEM_V1 */
.followup-cards {
    grid-template-columns: repeat(4, minmax(140px, 1fr));
}

.followup-create-form .form-row {
    align-items: end;
}

.actions-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

@media (max-width: 900px) {
    .followup-cards {
        grid-template-columns: 1fr;
    }
}

/* TIKTECH_LEADS_SMART_PYTHON_COLLECTOR_V1 */
.collector-cards {
    grid-template-columns: repeat(4, minmax(140px, 1fr));
}

.collector-output {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    background: #0f172a;
    color: #dbeafe;
    overflow-x: auto;
    white-space: pre-wrap;
    font-size: 12px;
}

@media (max-width: 900px) {
    .collector-cards {
        grid-template-columns: 1fr;
    }
}
