:root {
    --bg: #fafaf8;
    --surface: #ffffff;
    --border: #e8e4df;
    --text-primary: #1a1814;
    --text-secondary: #6b6560;
    --accent: #24d45a;
    --accent-hover: #1db84d;
    --warm-gray: #f4f1ed;

    --stage-new: #e8e4df;
    --stage-contacted: #fef3c7;
    --stage-responded: #dbeafe;
    --stage-demo: #ede9fe;
    --stage-closed: #dcfce7;
    --stage-dead: #f1f5f9;

    --red: #ef4444;
    --red-bg: #fef2f2;
    --red-border: #fecaca;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 16px;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.5;
}

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

/* Nav */
nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    gap: 1rem;
}

.nav-logo {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
    white-space: nowrap;
    text-decoration: none;
}

.nav-logo span { color: var(--accent); }

.nav-links {
    display: flex;
    gap: 1.5rem;
    list-style: none;
}

.nav-links a {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.15s;
}

.nav-links a:hover,
.nav-links a.active { color: var(--accent); }

/* Container */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem;
}

/* Flash messages */
.flash {
    padding: 0.85rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.flash-success {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.flash-error {
    background: var(--red-bg);
    color: #b91c1c;
    border: 1px solid var(--red-border);
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    margin-bottom: 1.25rem;
}

.card-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border-radius: 7px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
}

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

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

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--warm-gray);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid var(--red-border);
}

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

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn-copy {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-copy:hover {
    background: var(--warm-gray);
    color: var(--text-primary);
}

.btn-copy.copied {
    background: #dcfce7;
    color: #15803d;
    border-color: #bbf7d0;
}

/* Stage pills */
.stage-pill {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.stage-new       { background: var(--stage-new);       color: #57534e; }
.stage-contacted { background: var(--stage-contacted);  color: #92400e; }
.stage-responded { background: var(--stage-responded);  color: #1e40af; }
.stage-demo_sent { background: var(--stage-demo);       color: #6d28d9; }
.stage-closed    { background: var(--stage-closed);     color: #15803d; }
.stage-dead      { background: var(--stage-dead);       color: #94a3b8; }

/* Inline stage select — matches pill colors */
.stage-select {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    border: none;
    cursor: pointer;
    padding-right: 0.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text-primary);
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: auto;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(36,212,90,0.12);
}

.form-group textarea { resize: vertical; min-height: 80px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

/* Stats bar */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.1;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 0.25rem;
}

/* Pipeline */
.pipeline {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.pipeline-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--warm-gray);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.85rem;
    font-size: 0.85rem;
}

.pipeline-count {
    font-weight: 700;
    font-size: 1rem;
}

/* Queue / Table */
.queue-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-secondary);
}

.queue-empty .big-check { font-size: 2.5rem; margin-bottom: 0.5rem; }
.queue-empty p { margin-bottom: 1rem; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead th {
    text-align: left;
    padding: 0.6rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--warm-gray); }

tbody td {
    padding: 0.75rem 0.85rem;
    vertical-align: middle;
}

.overdue-badge {
    display: inline-block;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

/* Stepper */
.stepper {
    display: flex;
    gap: 0;
    margin: 1rem 0;
    overflow-x: auto;
    padding-bottom: 0.25rem;
}

.step {
    flex: 1;
    min-width: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 0 0.25rem;
}

.step::after {
    content: '';
    position: absolute;
    top: 15px;
    left: 50%;
    width: 100%;
    height: 2px;
    background: var(--border);
    z-index: 0;
}

.step:last-child::after { display: none; }

.step.done::after { background: var(--accent); }

.step-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    z-index: 1;
    position: relative;
    border: 2px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
}

.step.done .step-circle {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.step.due .step-circle {
    background: #dcfce7;
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 0 3px rgba(36,212,90,0.2);
}

.step-label {
    margin-top: 0.4rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.3;
}

.step.due .step-label { color: var(--accent); font-weight: 600; }
.step.done .step-label { color: #15803d; }

/* Touch history */
.touch-item {
    border-left: 3px solid var(--border);
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    background: var(--warm-gray);
    border-radius: 0 8px 8px 0;
}

.touch-item.has-response { border-left-color: var(--accent); }

.touch-meta {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.touch-message {
    font-size: 0.88rem;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
}

.touch-response {
    font-size: 0.85rem;
    color: #15803d;
    background: #dcfce7;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    margin-top: 0.4rem;
}

/* Contact header */
.contact-header {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-start;
}

.contact-info { flex: 1; min-width: 200px; }
.contact-info h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.25rem; }
.contact-meta { color: var(--text-secondary); font-size: 0.9rem; line-height: 1.8; }
.contact-meta a { color: var(--accent); }

.contact-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
}

/* Inline stage selector */
.stage-form select {
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    font-size: 0.85rem;
    cursor: pointer;
    background: var(--surface);
    font-family: inherit;
}

/* Notes inline */
.notes-form textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 0.6rem 0.85rem;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 70px;
    color: var(--text-primary);
}

.notes-form textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(36,212,90,0.12);
}

/* Template card */
.template-card {
    margin-bottom: 1.5rem;
}

.template-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.touch-badge {
    background: var(--accent);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
}

.placeholder-note {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 0.4rem;
}

.placeholder-note code {
    background: var(--warm-gray);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-family: monospace;
}

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.page-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
}

/* Filter bar */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    align-items: center;
}

.filter-bar select,
.filter-bar input {
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 0.88rem;
    background: var(--surface);
    color: var(--text-primary);
    font-family: inherit;
    min-width: 130px;
}

.filter-bar input { flex: 1; min-width: 160px; }

/* Danger zone */
.danger-zone {
    border: 1px solid var(--red-border);
    border-radius: 10px;
    padding: 1.25rem;
    background: var(--red-bg);
    margin-bottom: 1.25rem;
}

.danger-zone h3 {
    color: var(--red);
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.danger-zone p {
    color: #b91c1c;
    font-size: 0.85rem;
    margin-bottom: 0.85rem;
}

/* Back link */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.back-link:hover { color: var(--accent); }

/* Section spacing */
.section-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

/* Log touch form */
.log-touch-card {
    border: 2px solid var(--accent);
    border-radius: 10px;
    padding: 1.25rem;
    background: #f0fdf4;
    margin-bottom: 1.25rem;
}

.log-touch-card .card-title {
    color: #15803d;
}

/* Radio toggle */
.radio-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-primary);
}

.radio-group input[type="radio"] {
    width: auto;
    accent-color: var(--accent);
}

/* Mobile */
@media (max-width: 640px) {
    .stats-bar { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }

    table thead { display: none; }
    table tbody tr {
        display: block;
        padding: 0.85rem;
        margin-bottom: 0.75rem;
        border: 1px solid var(--border);
        border-radius: 10px;
        background: var(--surface);
    }
    table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.3rem 0;
        border: none;
        font-size: 0.88rem;
    }
    table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.78rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        flex-shrink: 0;
        margin-right: 0.5rem;
    }
    table tbody td.td-actions {
        justify-content: flex-end;
        gap: 0.5rem;
    }

    .nav-links { gap: 1rem; }
    .nav-links a { font-size: 0.82rem; }

    .contact-header { flex-direction: column; gap: 1rem; }

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

    .filter-bar { flex-direction: column; }
    .filter-bar select,
    .filter-bar input { min-width: 0; width: 100%; }
}

@media (max-width: 420px) {
    .stats-bar { grid-template-columns: 1fr; }
    .stepper { gap: 0; }
}
