:root {
    --font-sans: "Sora", ui-sans-serif, system-ui, sans-serif;
    --font-display: "Fraunces", ui-serif, Georgia, serif;
    --ink: #10221f;
    --muted: #5a6f6a;
    --panel: #f2f7f5;
    --line: #d5e3de;
    --accent: #0f766e;
    --accent-dark: #0b5a54;
    --warn: #b45309;
    --danger: #b91c1c;
    --ok: #15803d;
    --white: #ffffff;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--ink);
    font-family: var(--font-sans);
    background:
        radial-gradient(ellipse 80% 50% at 0% -20%, rgba(15, 118, 110, 0.12), transparent),
        radial-gradient(ellipse 60% 40% at 100% 0%, rgba(180, 83, 9, 0.08), transparent),
        linear-gradient(180deg, #eef5f2 0%, #f2f7f5 40%, #edf3f0 100%);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.crm-shell {
    width: min(1120px, calc(100% - 2rem));
    margin-inline: auto;
    padding-block: 1.5rem;
}

.crm-nav {
    position: sticky;
    top: 0;
    z-index: 40;
    border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
    background: color-mix(in srgb, #f7fbf9 80%, transparent);
    backdrop-filter: blur(10px);
}

.crm-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-block: 1rem;
}

.brand-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.brand-sub { margin: 0; font-size: 0.75rem; color: var(--muted); }

.nav-links { display: none; gap: 0.25rem; align-items: center; }
@media (min-width: 640px) { .nav-links { display: flex; } }

.nav-link {
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--muted);
}
.nav-link:hover { color: var(--ink); }
.nav-link.active { background: color-mix(in srgb, var(--accent) 10%, white); color: var(--accent); }

.flash {
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}
.flash-ok { border: 1px solid #a7f3d0; background: #ecfdf5; color: #065f46; }
.flash-err { border: 1px solid #fecaca; background: #fff1f2; color: #9f1239; }

.page-title {
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 3vw, 2.25rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: 0;
}
.page-sub { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.875rem; max-width: 40rem; }

.metrics {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 1.5rem;
}
@media (min-width: 1024px) {
    .metrics { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

.metric-card, .panel {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--line);
    background: color-mix(in srgb, white 85%, transparent);
    border-radius: 1rem;
    padding: 1.25rem;
    box-shadow: 0 1px 2px rgba(16, 34, 31, 0.04);
}
.metric-card { transition: transform 220ms ease, box-shadow 220ms ease; }
.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(16, 34, 31, 0.08);
}
.metric-label, .section-label {
    margin: 0;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}
.metric-value {
    margin: 0.75rem 0 0;
    font-family: var(--font-display);
    font-size: 1.875rem;
    font-weight: 600;
}
.metric-hint { margin: 0.25rem 0 0; font-size: 0.75rem; color: var(--muted); }

.grid-3 {
    display: grid;
    gap: 1.5rem;
    margin-top: 1.5rem;
}
@media (min-width: 1024px) {
    .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.grid-detail {
    display: grid;
    gap: 1.5rem;
    margin-top: 1.5rem;
}
@media (min-width: 1024px) {
    .grid-detail { grid-template-columns: 1fr 2fr; }
}

.stack { display: grid; gap: 1.5rem; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.list-item {
    border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
    border-radius: 0.75rem;
    padding: 0.75rem;
    background: color-mix(in srgb, var(--panel) 60%, white);
}
.muted { color: var(--muted); font-size: 0.75rem; }
.tiny { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.875rem; }
th {
    padding-bottom: 0.75rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}
td { padding: 0.75rem 1rem 0.75rem 0; border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent); vertical-align: top; }
.link { color: var(--accent); font-weight: 500; }
.link:hover { text-decoration: underline; }

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-radius: 0.75rem;
    padding: 0.5rem 0.9rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 0;
    cursor: pointer;
    transition: background 160ms ease, color 160ms ease;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: white; color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { background: var(--panel); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #991b1b; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.2rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 600;
}
.status-new { background: #f0fdfa; color: #115e59; }
.status-contacted { background: #f0f9ff; color: #075985; }
.status-interested { background: #fffbeb; color: #92400e; }
.status-qualified { background: #eef2ff; color: #3730a3; }
.status-meeting { background: #ecfdf5; color: #065f46; }
.status-closed { background: #f0fdf4; color: #166534; }
.status-lost { background: #fff1f2; color: #9f1239; }

.label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
}
.input, .select, .textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 0.75rem;
    padding: 0.55rem 0.75rem;
    background: white;
    outline: none;
}
.input:focus, .select:focus, .textarea:focus {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
.form-stack { display: grid; gap: 0.75rem; margin-top: 1rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.header-row {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
@media (min-width: 640px) {
    .header-row {
        flex-direction: row;
        align-items: flex-end;
        justify-content: space-between;
    }
}

.timeline-card {
    border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
    border-radius: 1rem;
    padding: 1rem;
}
.ai-bubble {
    margin-top: 0.75rem;
    border-radius: 0.75rem;
    background: color-mix(in srgb, var(--accent) 6%, white);
    padding: 0.75rem;
}
.fade-in { animation: fadeIn 500ms ease; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.space-y > * + * { margin-top: 1.5rem; }
.two-col {
    display: grid;
    gap: 1.5rem;
}
@media (min-width: 768px) {
    .two-col { grid-template-columns: 1fr 1fr; }
}
.line-clamp {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
