:root {
    --sidebar: #0f172a;
    --sidebar-2: #111c33;
    --line: rgba(255, 255, 255, .08);
    --text: #0f172a;
    --muted: #64748b;
    --bg: #f3f6fb;
    --card: #ffffff;
    --accent: #00adb5;
    --accent-dark: #008e95;
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 12px 32px rgba(15, 23, 42, .06);
    --radius: 16px;
    --font: "Inter", sans-serif;
    --display: "Sora", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}
a { color: var(--accent-dark); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }

.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 268px;
    flex: 0 0 268px;
    background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; }
.brand img, .login-brand img { width: 46px; height: 46px; object-fit: contain; }
.brand strong, .login-brand strong {
    font-family: var(--display);
    font-size: 20px;
    letter-spacing: -.03em;
    display: block;
    color: white;
}
.brand span, .login-brand span { color: var(--accent); }
.brand small, .login-brand small { color: #94a3b8; font-size: 12px; }
.sidebar-close { display: none; margin-left: auto; }
.nav-label {
    margin: 8px 12px;
    font-size: 11px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: #64748b;
    font-weight: 600;
}
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #cbd5e1;
    padding: 11px 12px;
    border-radius: 12px;
    font-weight: 500;
}
.nav a:hover { background: rgba(255,255,255,.06); color: white; }
.nav a.is-active { background: rgba(0, 173, 181, .18); color: white; }
.sidebar-foot { margin-top: auto; padding-top: 16px; }
.who { display: flex; gap: 10px; align-items: center; padding: 8px; }
.who strong { display: block; font-size: 14px; }
.who small, .sidebar .who small { color: #94a3b8; }
.avatar {
    width: 38px; height: 38px; border-radius: 12px;
    display: grid; place-items: center;
    background: rgba(0, 173, 181, .2); color: #7ef0f5; font-weight: 700;
}
.logout {
    width: 100%;
    margin-top: 8px;
    display: flex; align-items: center; gap: 8px; justify-content: center;
    background: transparent; color: #cbd5e1;
    border: 1px solid var(--line); border-radius: 12px; padding: 10px;
    cursor: pointer;
}
.logout:hover { background: rgba(255,255,255,.05); }
.main { flex: 1; min-width: 0; }
.topbar {
    display: flex; align-items: center; gap: 14px;
    padding: 18px 28px;
    position: sticky; top: 0; z-index: 5;
    background: rgba(243, 246, 251, .9);
    backdrop-filter: blur(10px);
}
.topbar h1 { margin: 0; font-family: var(--display); font-size: 26px; letter-spacing: -.03em; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.topbar-title { flex: 1; min-width: 0; }
.topbar-actions { display: flex; gap: 8px; }
.content { padding: 6px 28px 40px; }

.icon { width: 18px; height: 18px; }
.icon-btn {
    width: 38px; height: 38px; border-radius: 12px;
    border: 1px solid #e2e8f0; background: white; display: grid; place-items: center; cursor: pointer;
}
.icon-btn.menu-btn, .sidebar-close { display: none; }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border-radius: 12px; border: 1px solid transparent; padding: 10px 14px;
    font-weight: 600; cursor: pointer; text-decoration: none; color: var(--text); background: white;
}
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: white; border-color: #e2e8f0; color: #334155; }
.btn-tiny { padding: 7px 10px; font-size: 13px; border-color: #e2e8f0; }
.btn-block { width: 100%; }

.cards {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 14px;
    margin-bottom: 16px;
}
.stat {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    border: 1px solid #e8eef6;
    display: flex; flex-direction: column; gap: 6px;
    min-height: 118px;
    color: inherit;
}
.stat span { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat strong { font-family: var(--display); font-size: 32px; letter-spacing: -.04em; }
.stat small { color: #94a3b8; }
.stat:hover { transform: translateY(-2px); }
.tone-sky strong { color: #0284c7; }
.tone-violet strong { color: #7c3aed; }
.tone-green strong { color: #059669; }
.tone-amber strong { color: #d97706; }
.tone-rose strong { color: #e11d48; }

.flow {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    background: white; border: 1px solid #e8eef6; border-radius: 999px;
    padding: 10px 16px; margin-bottom: 16px; width: fit-content; max-width: 100%;
    box-shadow: var(--shadow);
}
.flow span { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-right: 4px; }
.flow strong { font-size: 13px; }
.flow i { width: 16px; height: 1px; background: #cbd5e1; display: inline-block; }

.panel {
    background: var(--card);
    border: 1px solid #e8eef6;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 8px 8px 12px;
    margin-bottom: 16px;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 12px 8px; gap: 12px; }
.panel-head h2 { margin: 0; font-size: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .9fr); gap: 16px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
.filter-panel + .panel table { min-width: 760px; }
th { text-align: left; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: #94a3b8; padding: 10px 12px; }
td { padding: 12px; border-top: 1px solid #eef2f7; vertical-align: top; font-size: 14px; }
td small, .muted { display: block; color: var(--muted); margin-top: 3px; font-size: 12px; }
.row-link { font-weight: 600; color: var(--text); }
.clip { max-width: 220px; color: #475569; }
.actions { white-space: nowrap; display: flex; gap: 6px; }
.empty { padding: 28px 16px; color: var(--muted); text-align: center; }
.pager { display: flex; justify-content: flex-end; gap: 12px; align-items: center; padding: 12px; color: var(--muted); }

.badge {
    display: inline-flex; align-items: center; border-radius: 999px;
    padding: 4px 9px; font-size: 12px; font-weight: 700; border: 1px solid transparent; background: #f1f5f9; color: #334155;
}
.status-new { background: #e0f2fe; color: #0369a1; }
.status-contacted { background: #ccfbf1; color: #0f766e; }
.status-follow_up { background: #fef3c7; color: #b45309; }
.status-interested { background: #ede9fe; color: #6d28d9; }
.status-converted { background: #dcfce7; color: #15803d; }
.status-not_interested { background: #ffe4e6; color: #be123c; }
.fu-today { background: #ffedd5; color: #c2410c; }
.fu-upcoming { background: #e0f2fe; color: #0369a1; }
.fu-overdue { background: #ffe4e6; color: #be123c; }
.fu-none, .fu-closed { background: #f1f5f9; color: #64748b; }
.is-current { outline: 2px solid var(--text); }

.filters { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px; align-items: center; }
.filters select, .search input, .stack input, .stack select, .stack textarea {
    width: 100%; border: 1px solid #e2e8f0; background: #fff; border-radius: 12px; padding: 11px 12px;
}
.filters select { width: auto; min-width: 160px; }
.search { position: relative; flex: 1; min-width: 220px; }
.search .icon { position: absolute; left: 12px; top: 12px; color: #94a3b8; }
.search input { padding-left: 38px; }
.stack { display: flex; flex-direction: column; gap: 12px; padding: 4px 12px 12px; }
.stack label, .check { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: #334155; }
.check { flex-direction: row; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.narrow { max-width: 560px; padding: 18px; }
.account-who { margin: 6px 12px 16px; }
.account-who strong { color: var(--text); }

.detail { display: grid; grid-template-columns: .9fr 1.1fr; gap: 16px; align-items: start; }
.contact-line { display: flex; gap: 8px; align-items: flex-start; padding: 4px 12px; color: #334155; }
.status-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 12px; }
.status-row form { margin: 0; }
.status-row button { cursor: pointer; }
.remark-form { border-bottom: 1px solid #eef2f7; margin-bottom: 8px; }
.timeline { list-style: none; margin: 0; padding: 8px 12px 16px; display: flex; flex-direction: column; gap: 12px; }
.timeline li { border: 1px solid #eef2f7; border-radius: 14px; padding: 12px; }
.timeline p { margin: 8px 0; white-space: pre-wrap; }
.timeline-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.timeline time, .timeline small { color: var(--muted); font-size: 12px; }

.modal { position: fixed; inset: 0; z-index: 30; display: none; }
.modal.is-open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .48); }
.modal-card {
    position: relative; z-index: 1; width: min(640px, calc(100% - 24px));
    margin: 6vh auto; background: white; border-radius: 20px; box-shadow: var(--shadow); max-height: 88vh; overflow: auto;
}
.modal-head, .modal-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 16px 16px 0; }
.modal-head h2 { margin: 0; font-family: var(--display); }
.modal-actions { justify-content: flex-end; padding: 0 0 8px; }
body.modal-open { overflow: hidden; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 40; }
.toast {
    min-width: 240px; max-width: 360px; background: #0f172a; color: white;
    padding: 12px 14px; border-radius: 14px; box-shadow: var(--shadow); border-left: 4px solid var(--accent);
}
.toast-error { border-left-color: #fb7185; }
.toast-info { border-left-color: #38bdf8; }
.toast.is-out { opacity: 0; transform: translateY(6px); transition: .3s ease; }

.login-body {
    min-height: 100vh; display: grid; place-items: center; padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(0,173,181,.18), transparent 32%),
        radial-gradient(circle at bottom right, rgba(15,23,42,.08), transparent 28%),
        var(--bg);
}
.login-card {
    width: min(440px, 100%); background: white; border-radius: 24px; padding: 28px;
    box-shadow: var(--shadow); border: 1px solid #e8eef6;
}
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.login-brand strong { color: var(--text); }
.login-card h1 { margin: 0 0 6px; font-family: var(--display); letter-spacing: -.03em; }
.backdrop { display: none; }

@media (max-width: 1200px) {
    .cards { grid-template-columns: repeat(3, 1fr); }
    .split, .detail { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .icon-btn.menu-btn, .sidebar-close { display: grid; }
    .sidebar {
        position: fixed; z-index: 20; transform: translateX(-105%); transition: transform .2s ease;
    }
    .sidebar.is-open { transform: none; }
    .backdrop.is-open { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 15; }
    .content, .topbar { padding-left: 16px; padding-right: 16px; }
    .cards, .grid-2 { grid-template-columns: 1fr 1fr; }
    .topbar h1 { font-size: 22px; }
}
@media (max-width: 560px) {
    .cards, .grid-2 { grid-template-columns: 1fr; }
    .filters select { width: 100%; }
}
