/* ============================================================
   Cloudix — design system
   Inter (UI) + JetBrains Mono (figures). One accent: iris.
   ============================================================ */

:root {
    --ink: #161420;
    --ink-2: #211E30;
    --ink-line: #2C2A3A;
    --iris: #5B5BD6;
    --iris-bright: #6E6ADE;
    --iris-soft: #ECECFB;

    --canvas: #F6F6F8;
    --surface: #FFFFFF;
    --line: #E7E7EC;
    --line-soft: #F0F0F3;

    --text: #1B1B23;
    --text-2: #6B6B7B;
    --text-3: #9A9AA8;

    --won: #0F7355;   --won-bg: #E2F5EE;
    --lost: #CB3A30;  --lost-bg: #FCEAE8;
    --arch: #6B6B7B;  --arch-bg: #ECECEF;

    --meta: #1C6FD6;   --meta-bg: #E7F0FB;
    --google: #A8660A; --google-bg: #FBF0DD;
    --tiktok: #C12C68; --tiktok-bg: #FBE9F1;
    --manual: #5A5A68; --manual-bg: #EDEDF0;

    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 1px 2px rgba(20,18,30,.06), 0 1px 3px rgba(20,18,30,.05);
    --shadow-md: 0 6px 22px rgba(20,18,30,.12);

    --font-ui: 'Inter', -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, "SF Mono", Menlo, monospace;
}

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

body {
    font-family: var(--font-ui);
    background: var(--canvas);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
    line-height: 1.45;
}

.num { font-family: var(--font-mono); font-feature-settings: "tnum" 1; letter-spacing: -0.02em; }

a { color: inherit; }
:focus-visible { outline: 2px solid var(--iris); outline-offset: 2px; border-radius: 4px; }

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

.sidebar {
    width: 224px; flex: 0 0 224px;
    background: var(--ink);
    color: #C9C7D6;
    display: flex; flex-direction: column;
    padding: 22px 14px;
    position: sticky; top: 0; height: 100vh;
}
.brand {
    font-size: 19px; font-weight: 700; color: #fff;
    letter-spacing: -0.02em; padding: 4px 10px 22px;
    display: flex; align-items: center; gap: 9px;
}
.brand::before {
    content: ""; width: 11px; height: 11px; border-radius: 3px;
    background: var(--iris); box-shadow: 0 0 0 4px rgba(91,91,214,.22);
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 11px; border-radius: var(--radius-sm);
    font-size: 13.5px; font-weight: 500; color: #ACAABB;
    text-decoration: none; transition: background .12s, color .12s;
}
.nav a:hover { background: var(--ink-2); color: #fff; }
.nav a.active { background: var(--ink-2); color: #fff; }
.nav a.active::before {
    content: ""; position: absolute; left: 0; width: 3px; height: 18px;
    background: var(--iris); border-radius: 0 3px 3px 0; margin-left: -14px;
}
.nav a { position: relative; }

.sidebar-foot { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--ink-line); }
.me { display: flex; align-items: center; gap: 10px; padding: 4px 6px 12px; }
.me-avatar {
    width: 32px; height: 32px; border-radius: 9px; flex: 0 0 auto;
    background: var(--iris); color: #fff; font-weight: 600; font-size: 13px;
    display: flex; align-items: center; justify-content: center;
}
.me-name { font-size: 13px; font-weight: 600; color: #fff; }
.me-role { font-size: 11px; color: #8C8A9C; text-transform: capitalize; }
.logout {
    width: 100%; background: transparent; border: 1px solid var(--ink-line);
    color: #ACAABB; font-family: var(--font-ui); font-size: 12.5px; font-weight: 500;
    padding: 8px; border-radius: var(--radius-sm); cursor: pointer; transition: .12s;
}
.logout:hover { background: var(--ink-2); color: #fff; }

/* ---------- Main + topbar ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    height: 64px; flex: 0 0 64px;
    background: rgba(246,246,248,.85); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 28px; position: sticky; top: 0; z-index: 5;
}
.topbar-title { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.content { padding: 24px 28px 40px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    font-family: var(--font-ui); font-size: 13px; font-weight: 600;
    padding: 9px 15px; border-radius: var(--radius-sm); border: 1px solid var(--line);
    background: var(--surface); color: var(--text); cursor: pointer;
    text-decoration: none; transition: .12s; white-space: nowrap;
}
.btn:hover { border-color: #D4D4DC; }
.btn-primary { background: var(--iris); border-color: var(--iris); color: #fff; }
.btn-primary:hover { background: var(--iris-bright); border-color: var(--iris-bright); }
.btn-sm { padding: 6px 11px; font-size: 12px; }

/* ---------- Segmented toggle ---------- */
.seg { display: inline-flex; background: #ECECEF; border-radius: var(--radius-sm); padding: 3px; }
.seg a {
    font-size: 12.5px; font-weight: 600; color: var(--text-2);
    text-decoration: none; padding: 5px 13px; border-radius: 5px; transition: .12s;
}
.seg a.on { background: var(--surface); color: var(--iris); box-shadow: var(--shadow); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card-label { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 14px; }

/* ---------- Tags / badges ---------- */
.tag { font-family: var(--font-mono); font-size: 10px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; padding: 3px 7px; border-radius: 5px; }
.tag-manual { background: var(--manual-bg); color: var(--manual); }
.tag-meta { background: var(--meta-bg); color: var(--meta); }
.tag-google { background: var(--google-bg); color: var(--google); }
.tag-tiktok { background: var(--tiktok-bg); color: var(--tiktok); }

.role-badge { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 5px; text-transform: capitalize; }
.role-admin { background: var(--iris-soft); color: #4A45B8; }
.role-sales { background: var(--meta-bg); color: var(--meta); }

.avatar {
    width: 26px; height: 26px; border-radius: 7px; flex: 0 0 auto;
    background: var(--iris); color: #fff; font-size: 11px; font-weight: 600;
    display: flex; align-items: center; justify-content: center;
}
.avatar-sm { width: 22px; height: 22px; border-radius: 6px; font-size: 10px; }

/* ---------- Board / kanban ---------- */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.col { flex: 0 0 252px; }
.col-head {
    display: flex; align-items: baseline; justify-content: space-between;
    padding: 0 4px 10px; margin-bottom: 4px; border-bottom: 2px solid var(--line);
}
.col-head .col-name { font-size: 12.5px; font-weight: 650; }
.col-head .col-meta { font-size: 11px; color: var(--text-3); }
.col-body { display: flex; flex-direction: column; gap: 9px; min-height: 40px; }

.lead-card {
    display: block; background: var(--surface); border: 1px solid var(--line);
    border-radius: 9px; padding: 12px; box-shadow: var(--shadow);
    text-decoration: none; color: inherit; transition: transform .1s, box-shadow .1s, border-color .1s;
}
.lead-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); border-color: #DBDBE3; }
.lead-card .lc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 9px; }
.lead-card .lc-name { font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.lead-card .lc-meta { display: flex; align-items: center; justify-content: space-between; }
.lead-card .lc-val { font-size: 12px; color: var(--text-2); }
.lead-card .lc-follow { margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line-soft); font-size: 11.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.lead-card .lc-follow::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.lead-card .lc-follow.overdue { color: var(--lost); font-weight: 600; }
.lead-card .lc-follow.overdue::before { background: var(--lost); }
.col-empty { font-size: 11.5px; color: var(--text-3); text-align: center; padding: 14px 0; border: 1px dashed var(--line); border-radius: 9px; }

/* ---------- Forms ---------- */
.form-narrow { max-width: 480px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.field .opt { font-weight: 400; color: var(--text-3); }
.input, .select, .textarea {
    width: 100%; font-family: var(--font-ui); font-size: 14px;
    padding: 10px 12px; border: 1px solid #D4D4DC; border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text);
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--iris); box-shadow: 0 0 0 3px rgba(91,91,214,.14); }
.textarea { resize: vertical; }
.inline-form { display: flex; gap: 8px; }
.inline-form .select, .inline-form .input { flex: 1; }

.errors { background: var(--lost-bg); color: var(--lost); font-size: 13px; border-radius: var(--radius-sm); padding: 11px 13px; margin-bottom: 16px; }
.errors ul { margin: 0; padding-left: 18px; }

/* ---------- Stacked detail layout ---------- */
.stack { display: flex; flex-direction: column; gap: 16px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.kv { display: flex; justify-content: space-between; font-size: 13.5px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--text-2); }

/* ---------- Banner (closed status) ---------- */
.banner { border-radius: var(--radius); padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.banner.won { background: var(--won-bg); }
.banner.lost { background: var(--lost-bg); }
.banner.archived { background: var(--arch-bg); }
.banner .b-label { font-size: 15px; font-weight: 700; }
.banner.won .b-label { color: var(--won); }
.banner.lost .b-label { color: var(--lost); }
.banner.archived .b-label { color: var(--arch); }
.banner .b-sub { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }

/* ---------- Close actions ---------- */
.close-row { display: flex; gap: 8px; margin-top: 12px; }
.close-row button { flex: 1; border: none; padding: 10px; font-family: var(--font-ui); font-size: 13px; font-weight: 600; border-radius: var(--radius-sm); cursor: pointer; transition: .12s; }
.c-won { background: var(--won-bg); color: var(--won); }
.c-won:hover { background: #d3efe4; }
.c-lost { background: var(--lost-bg); color: var(--lost); }
.c-lost:hover { background: #f9ddd9; }
.c-arch { background: var(--arch-bg); color: var(--arch); }
.c-arch:hover { background: #e2e2e6; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; }
.timeline li { display: flex; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.timeline li:last-child { border-bottom: none; }
.timeline .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--iris); margin-top: 6px; flex: 0 0 auto; }
.timeline .tl-body { font-size: 13px; }
.timeline .tl-when { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

/* ---------- List rows (today / closed / users) ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-row {
    display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 13px 16px; box-shadow: var(--shadow); transition: border-color .1s, transform .1s;
}
a.list-row:hover { border-color: #DBDBE3; transform: translateY(-1px); }
.list-row .lr-name { font-size: 14px; font-weight: 600; }
.list-row .lr-sub { font-size: 12px; color: var(--text-2); }
.list-row .lr-grow { flex: 1; min-width: 0; }
.list-row .lr-right { text-align: right; }
.list-row .lr-when { font-size: 11px; color: var(--text-3); }
.pill { font-size: 11px; background: #EDEDF0; color: var(--text-2); padding: 2px 9px; border-radius: 5px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.status-dot.won { background: var(--won); }
.status-dot.lost { background: var(--lost); }
.status-dot.archived { background: var(--arch); }

.section-title { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.section-sub { font-size: 12px; color: var(--text-2); margin-bottom: 11px; }
.muted { font-size: 13px; color: var(--text-3); }
.empty-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; font-size: 13px; color: var(--text-3); box-shadow: var(--shadow); }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background:
    radial-gradient(900px 500px at 50% -10%, #ECECFB 0%, var(--canvas) 55%); }
.auth-card { width: 380px; max-width: 92vw; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 34px; box-shadow: var(--shadow-md); }
.auth-brand { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; display: flex; align-items: center; gap: 10px; }
.auth-brand::before { content: ""; width: 13px; height: 13px; border-radius: 4px; background: var(--iris); box-shadow: 0 0 0 5px rgba(91,91,214,.18); }
.auth-sub { font-size: 13px; color: var(--text-2); margin: 6px 0 24px; }
.remember { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); margin-top: 14px; }
.btn-block { width: 100%; justify-content: center; margin-top: 22px; padding: 11px; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; flex: none; height: auto; position: static; flex-direction: row; align-items: center; padding: 10px 14px; overflow-x: auto; }
    .brand { padding: 0 14px 0 4px; }
    .nav { flex-direction: row; }
    .nav a.active::before { display: none; }
    .sidebar-foot { margin: 0 0 0 auto; padding: 0 0 0 14px; border: none; display: flex; align-items: center; gap: 10px; }
    .me { display: none; }
    .detail-grid { grid-template-columns: 1fr; }
    .content { padding: 18px; }
    .topbar { padding: 0 18px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* ---------- Branding / logo ---------- */
.brand::before { display: none; }
.brand-mark { width: 11px; height: 11px; border-radius: 3px; background: var(--iris); box-shadow: 0 0 0 4px rgba(91,91,214,.22); }
.brand-logo { max-height: 30px; max-width: 168px; width: auto; display: block; }
.auth-logo { max-height: 42px; max-width: 220px; display: block; margin-bottom: 4px; }
.logo-preview { display: flex; align-items: center; justify-content: center; height: 84px; background: var(--ink); border-radius: var(--radius); padding: 0 20px; margin-bottom: 16px; }
.logo-preview img { max-height: 42px; max-width: 200px; }
.logo-preview.empty { color: #8C8A9C; font-size: 13px; text-align: center; }
.hint { font-size: 12px; color: var(--text-2); margin-top: 8px; }

/* ---------- Stage manager ---------- */
.stage-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.stage-item { display: flex; align-items: center; gap: 10px; }
.stage-order { display: flex; flex-direction: column; gap: 2px; }
.stage-order form { line-height: 0; margin: 0; }
.stage-order button { width: 22px; height: 15px; border: 1px solid var(--line); background: var(--surface); border-radius: 4px; font-size: 9px; line-height: 1; cursor: pointer; color: var(--text-2); padding: 0; }
.stage-order button:disabled { opacity: .35; cursor: default; }
.stage-rename { flex: 1; display: flex; gap: 6px; margin: 0; }
.stage-rename .input { flex: 1; padding: 7px 10px; font-size: 13px; }
.stage-name-static { flex: 1; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.lock { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); background: #EDEDF0; padding: 2px 6px; border-radius: 4px; }
.stage-count { font-family: var(--font-mono); font-size: 12px; color: var(--text-3); min-width: 18px; text-align: center; }
.stage-del { color: var(--lost); }
.stage-del:disabled { opacity: .4; cursor: default; }
.stage-add { display: flex; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line-soft); margin: 0; }
.stage-add .input { flex: 1; }

/* ---------- Drag & drop ---------- */
.lead-card { cursor: grab; }
.lead-card:active { cursor: grabbing; }
.drag-ghost { opacity: .35; }
.col-body { transition: background .12s; }

.tag-website { background: #E6F0F2; color: #2A6F7B; }

/* ---------- Sales material ---------- */
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.folder-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.folder-link { display: flex; flex-direction: column; gap: 3px; text-decoration: none; color: inherit; }
.folder-link svg { color: var(--iris); margin-bottom: 6px; }
.folder-name { font-size: 14px; font-weight: 600; }
.folder-count { font-size: 12px; color: var(--text-3); }
.folder-del { color: var(--lost); align-self: flex-start; }
.folder-del:disabled { opacity: .4; cursor: default; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.file-row:last-child { border-bottom: none; }
.file-ico { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 8px; background: var(--iris-soft); color: #4A45B8; font-family: var(--font-mono); font-size: 10px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
