/* ═══════════════════════════════════════════════════════════════
   Cockpit (p12) — az Twenty CRM Companion "Electric Midnight"
   design rendszerére építve (backend/web/static/style.css tokenek).
   Mobil-first: telefonon is egy képernyő, vízszintes túlcsordulás nélkül.
   ═══════════════════════════════════════════════════════════════ */

:root {
    --bg-deep: #06080f;
    --bg: #0a0e1a;
    --surface: #111827;
    --surface-elevated: #1a2236;
    --surface-glass: rgba(17, 24, 39, 0.65);
    --border: rgba(99, 102, 241, 0.12);
    --border-subtle: rgba(148, 163, 184, 0.08);
    --border-glow: rgba(99, 102, 241, 0.3);
    --text: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-glow: rgba(99, 102, 241, 0.25);
    --accent: #22d3ee;
    --green: #34d399;
    --amber: #fbbf24;
    --danger: #ef4444;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.15);
    --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* világos téma (addon yin-yang toggle mintájára) */
[data-theme="light"] {
    --bg-deep: #f4f6fb;
    --bg: #eef1f7;
    --surface: #ffffff;
    --surface-elevated: #f8fafc;
    --surface-glass: rgba(255, 255, 255, 0.78);
    --border: rgba(99, 102, 241, 0.18);
    --border-subtle: rgba(15, 23, 42, 0.08);
    --border-glow: rgba(99, 102, 241, 0.35);
    --text: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --primary-deep: #4338ca;
    --green: #059669;
    --amber: #b45309;
    --danger: #dc2626;
    --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.12);
}
[data-theme="light"] .col-empty { color: #cbd5e1; }

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

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--bg-deep);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
}

/* ambient háttér (az addonból) */
body::before, body::after {
    content: ''; position: fixed; pointer-events: none; z-index: 0;
}
body::before {
    top: -30%; left: -10%; width: 60%; height: 60%;
    background: radial-gradient(ellipse, rgba(99, 102, 241, 0.06) 0%, transparent 70%);
}
body::after {
    bottom: -20%; right: -10%; width: 50%; height: 50%;
    background: radial-gradient(ellipse, rgba(34, 211, 238, 0.04) 0%, transparent 70%);
}

a { color: inherit; text-decoration: none; }

/* ── topbar (glass, sticky) ─────────────────────────────────── */
.topbar {
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 12px 16px;
    background: rgba(6, 8, 15, 0.8);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border-subtle);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 {
    font-size: 15px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase;
}
.dot {
    width: 8px; height: 8px; border-radius: 50%; background: var(--green);
    box-shadow: 0 0 12px var(--green);
}
.meta { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 12px; }
.sep { opacity: .35; }
.btn {
    background: var(--surface-elevated); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 7px 13px; cursor: pointer; font-size: 12px; font-weight: 600;
    font-family: var(--font); transition: var(--transition);
}
.btn:hover { border-color: var(--primary-light); color: var(--primary-light); }
.btn-icon { padding: 6px 10px; font-size: 14px; line-height: 1; }

.banner {
    margin: 12px 16px; padding: 11px 14px; border-radius: var(--radius);
    background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5; font-size: 13px;
}

/* ── KPI ────────────────────────────────────────────────────── */
.kpis {
    position: relative; z-index: 1;
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px; padding: 14px 16px 4px;
}
.kpi {
    background: var(--surface-glass); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 14px 16px;
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    transition: var(--transition);
}
.kpi:hover { border-color: var(--border-glow); box-shadow: var(--shadow-glow); }
.kpi-label {
    color: var(--text-muted); font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.08em;
}
.kpi-value {
    font-size: 27px; font-weight: 800; margin-top: 5px; letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
.kpi-value .small { font-size: 14px; font-weight: 600; color: var(--text-muted); }
.kpi-hint { color: var(--text-muted); font-size: 12px; margin-top: 3px; }
.kpi-secured { border-left: 3px solid var(--green); }
.kpi-secured .kpi-value { color: var(--green); }
.kpi-expected { border-left: 3px solid var(--primary-light); }
.kpi-expected .kpi-value { color: var(--primary-light); }
.kpi-paid { border-left: 3px solid var(--text-muted); }
.kpi-tasks { border-left: 3px solid var(--amber); }
.kpi-tasks .kpi-value { color: var(--amber); }

/* ── arányszám-sáv ──────────────────────────────────────────── */
.ratios {
    position: relative; z-index: 1;
    display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px; padding: 10px 16px 2px;
}
.ratio {
    background: var(--surface); border: 1px solid var(--border-subtle);
    border-radius: var(--radius); padding: 11px 13px; transition: var(--transition);
}
.ratio:hover { border-color: var(--border-glow); }
.ratio-value {
    font-size: 24px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.ratio-value .unit { font-size: 13px; font-weight: 700; margin-left: 2px; color: var(--text-muted); }
.ratio-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-secondary); margin-top: 4px; }
.ratio-hint { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.r-win .ratio-value { color: var(--green); }
.r-funnel .ratio-value, .r-cov .ratio-value { color: var(--accent); }
.r-avg .ratio-value { color: var(--primary-light); }
.r-age .ratio-value { color: var(--text); }
.r-late .ratio-value { color: var(--danger); }
.r-month .ratio-value { color: var(--amber); }

/* ── funnel ─────────────────────────────────────────────────── */
.funnel { list-style: none; }
.funnel li {
    display: grid; grid-template-columns: 92px 1fr 34px 54px;
    align-items: center; gap: 8px; padding: 5px 0;
}
.fn-name { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.fn-track { height: 16px; background: var(--surface-elevated); border-radius: var(--radius-sm); overflow: hidden; min-width: 0; }
.fn-fill {
    display: block; height: 100%; border-radius: var(--radius-sm);
    background: linear-gradient(90deg, rgba(99,102,241,.85), rgba(34,211,238,.75));
}
.fn-num { font-size: 13px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.fn-step { font-size: 11px; color: var(--accent); text-align: right; font-variant-numeric: tabular-nums; }
.hint { margin-top: 10px; line-height: 1.45; }

/* ── panelek ────────────────────────────────────────────────── */
.grid-2 {
    position: relative; z-index: 1;
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px; padding: 12px 16px;
}
.panel {
    background: var(--surface-glass); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 15px 16px;
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    min-width: 0; overflow: hidden;
}
.panel h2 {
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--text-muted); margin-bottom: 12px;
}
.panel h2.mt { margin-top: 24px; }
.count {
    background: var(--surface-elevated); border-radius: var(--radius-full);
    padding: 1px 8px; color: var(--text-secondary); font-size: 11px; margin-left: 6px;
    letter-spacing: 0;
}
h3 { font-size: 13px; font-weight: 700; margin: 16px 0 8px; }
h3:first-of-type { margin-top: 0; }
.b-overdue { color: var(--danger); }
.b-today { color: var(--amber); }
.b-upcoming { color: var(--accent); }
.empty { color: var(--text-muted); font-size: 13px; }

/* hosszú, szóköz nélküli note/task címek ne feszítsék szét a layoutot */
.tasks a, .card-name, .card-task, .act-title, .act-deal, .card-contact {
    overflow-wrap: anywhere; word-break: break-word;
}

/* ── taskok ─────────────────────────────────────────────────── */
.tasks { list-style: none; }
.tasks li { padding: 9px 0; border-bottom: 1px solid var(--border-subtle); font-size: 14px; }
.tasks li:last-child { border-bottom: 0; }
.tasks a { transition: var(--transition); }
.tasks a:hover { color: var(--primary-light); }
.task-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.task-meta .due { font-variant-numeric: tabular-nums; color: var(--danger); }
.deal { color: var(--accent); }

/* ── előrejelzés ────────────────────────────────────────────── */
.bars { list-style: none; }
.bars li { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 13px; }
.bar-label { width: 60px; color: var(--text-muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.bar-track {
    flex: 1; min-width: 0; height: 8px; background: var(--surface-elevated);
    border-radius: var(--radius-full); overflow: hidden;
}
.bar-fill {
    display: block; height: 100%; border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--primary-deep, #4f46e5), var(--primary-light));
}
.bar-value {
    width: 104px; text-align: right; font-variant-numeric: tabular-nums;
    font-size: 12px; font-weight: 600;
}

/* ── aktivitás ──────────────────────────────────────────────── */
.activity { list-style: none; font-size: 13px; }
.activity li { padding: 7px 0; border-bottom: 1px solid var(--border-subtle); display: flex; gap: 8px; }
.activity li:last-child { border-bottom: 0; }
.act-time { color: var(--text-muted); font-variant-numeric: tabular-nums; flex: 0 0 74px; font-size: 12px; }
.act-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-deal { color: var(--accent); flex: 0 0 auto; max-width: 38%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── kanban ─────────────────────────────────────────────────── */
.kanban-panel { position: relative; z-index: 1; margin: 0 16px 16px; }
.kanban {
    display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px;
    scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
}
.column {
    flex: 0 0 236px; background: var(--surface); border: 1px solid var(--border-subtle);
    border-radius: var(--radius); padding: 10px; scroll-snap-align: start;
}
.col-closed { opacity: .68; }
.col-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.col-name {
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
    color: var(--text-muted);
}
.col-sum { font-size: 11px; color: var(--green); font-variant-numeric: tabular-nums; font-weight: 600; }
.col-count { font-size: 21px; font-weight: 800; margin: 1px 0 10px; letter-spacing: -0.02em; }
.col-empty { color: #334155; font-size: 13px; padding: 8px 2px; }

.card {
    display: block; background: var(--surface-elevated); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm); padding: 10px 11px; margin-bottom: 8px;
    transition: var(--transition);
}
.card:hover { border-color: var(--primary-light); transform: translateY(-1px); }
.card-overdue { border-left: 3px solid var(--danger); }
.card-name { font-size: 13.5px; font-weight: 600; line-height: 1.35; }
.card-contact { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card-money { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; font-variant-numeric: tabular-nums; }
.card-money .loan { color: var(--text-muted); font-size: 12.5px; }
.card-type { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.card-money .commission { color: var(--green); font-weight: 700; font-size: 12.5px; margin-left: auto; }
.card-tags { display: flex; gap: 5px; margin-top: 8px; flex-wrap: wrap; }
.tag {
    font-size: 10.5px; background: rgba(99, 102, 241, 0.12); color: var(--text-secondary);
    border-radius: 5px; padding: 2px 7px; font-weight: 600;
}
.tag-status { color: var(--amber); background: rgba(251, 191, 36, 0.12); }
.card-task {
    margin-top: 8px; font-size: 12px; color: var(--text-secondary);
    border-top: 1px dashed var(--border-subtle); padding-top: 7px;
}
.card-task.overdue { color: var(--danger); }
.card-task.stale { color: var(--amber); }
.card-due { display: block; color: var(--danger); font-variant-numeric: tabular-nums; font-weight: 600; }

/* ── login ──────────────────────────────────────────────────── */
.login-wrap {
    position: relative; z-index: 1; min-height: 100vh;
    display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
    width: 100%; max-width: 360px;
    background: var(--surface-glass); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 28px 26px;
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-glow);
    display: flex; flex-direction: column; gap: 14px;
}
.login-brand h1 { font-size: 17px; }
.login-sub { color: var(--text-muted); font-size: 13px; margin-top: -6px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field span { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); }
.field input {
    background: var(--surface-elevated); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 11px 12px; color: var(--text);
    font-family: var(--font); font-size: 15px;
}
.field input:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px var(--primary-glow); }
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-deep, #4f46e5));
    border-color: transparent; color: #fff; padding: 11px 16px; font-size: 14px;
}
.btn-primary:hover { color: #fff; filter: brightness(1.1); }
.btn-ghost { background: transparent; }
.login-error { margin: 0; }

.foot { position: relative; z-index: 1; color: var(--text-muted); font-size: 11.5px; padding: 0 16px 28px; }

/* ── tablet ─────────────────────────────────────────────────── */
@media (max-width: 1100px) {
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ratios { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

/* ── telefon (a fő felhasználási mód) ───────────────────────── */
@media (max-width: 640px) {
    body { font-size: 15px; }
    .topbar { padding: 10px 12px; }
    .meta .when { display: none; }
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 12px 12px 2px; }
    .kpi { padding: 12px 13px; }
    .kpi-value { font-size: 21px; }
    .kpi-hint { font-size: 11px; }
    .grid-2 { padding: 10px 12px; gap: 10px; }
    .ratios { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 8px 12px 2px; }
    .ratio { padding: 10px 11px; }
    .ratio-value { font-size: 20px; }
    .funnel li { grid-template-columns: 78px 1fr 28px 46px; gap: 6px; }
    .panel { padding: 14px; }
    .kanban-panel { margin: 0 12px 14px; }
    .kanban { gap: 8px; }
    .column { flex: 0 0 78%; }
    .card { padding: 11px 12px; }
    .bar-value { width: 88px; font-size: 11.5px; }
    .act-time { flex: 0 0 62px; }
    .foot { padding: 0 12px 24px; }
}

/* sötét háttér + iOS safe area (telefon) */
@supports (padding: env(safe-area-inset-left)) {
    .topbar { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
    .kpis, .grid-2, .foot { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
    .kanban-panel { margin-left: max(12px, env(safe-area-inset-left)); margin-right: max(12px, env(safe-area-inset-right)); }
}
