/* ============================================================
   MP SOL CRM – Stílus
   Brand: navy #1E2D3D | arany #F8C901 | háttér #F0EFE9
   Font: Poppins
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

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

:root {
    --navy:      #1E2D3D;
    --navy-l:    #2a3d52;
    --gold:      #F8C901;
    --gold-d:    #d4a900;
    --bg:        #F0EFE9;
    --bg-white:  #ffffff;
    --border:    #d0cfc8;
    --text:      #1E2D3D;
    --muted:     #6b7280;
    --danger:    #dc2626;
    --success:   #16a34a;
    --warning:   #d97706;
    --info:      #2563eb;
    --sidebar-w: 240px;
    --radius:    10px;
    --shadow:    0 1px 8px rgba(30,45,61,.10);
    --shadow-md: 0 4px 20px rgba(30,45,61,.14);
}

body {
    font-family: 'Poppins', system-ui, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}

/* ---- Layout ---- */
.crm-layout {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.crm-sidebar {
    width: var(--sidebar-w);
    background: var(--navy);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.crm-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    color: #fff;
    font-family: 'Poppins', sans-serif;
    font-size: 18px;
    letter-spacing: .5px;
}
.crm-logo img { height: 32px; }
.crm-logo strong { color: var(--gold); }

.crm-nav {
    list-style: none;
    padding: 12px 0;
    flex: 1;
}
.crm-nav li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 18px;
    color: rgba(255,255,255,.72);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: all .15s;
    border-left: 3px solid transparent;
}
.crm-nav li a svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }
.crm-nav li a:hover { background: rgba(255,255,255,.07); color: #fff; }
.crm-nav li.active > a {
    background: rgba(248,201,1,.1);
    color: var(--gold);
    border-left-color: var(--gold);
}
.crm-nav .nav-group-label {
    padding: 12px 18px 4px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,.35);
    font-weight: 600;
}
.crm-nav .nav-sep {
    height: 1px;
    background: rgba(255,255,255,.08);
    margin: 8px 18px;
}
.nav-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    flex-shrink: 0;
}
.nav-badge.hu { background: #3b82f6; color: #fff; }
.nav-badge.at { background: #dc2626; color: #fff; }

.crm-user-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-top: 1px solid rgba(255,255,255,.08);
}
.crm-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--gold);
    color: var(--navy);
    display: flex; align-items: center; justify-content: center;
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}
.crm-user-name { color: rgba(255,255,255,.85); font-size: 13px; }
.crm-logout { margin-left: auto; color: rgba(255,255,255,.4); transition: color .15s; }
.crm-logout:hover { color: var(--gold); }
.crm-logout svg { width: 18px; height: 18px; fill: currentColor; display: block; }

/* ---- Main ---- */
.crm-main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.crm-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow);
}
.crm-page-title {
    font-family: 'Poppins', sans-serif;
    font-size: 22px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .3px;
    color: var(--navy);
}
.crm-topbar-actions { display: flex; gap: 10px; }

.crm-content { padding: 24px 28px; flex: 1; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .3px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all .15s;
    text-decoration: none;
    white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; fill: currentColor; }
.btn-primary { background: var(--gold); color: var(--navy); border-color: var(--gold); }
.btn-primary:hover { background: var(--gold-d); border-color: var(--gold-d); }
.btn-navy { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-navy:hover { background: var(--navy-l); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-ghost:hover { border-color: var(--navy); color: var(--navy); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; border-radius: 6px; }

/* ---- Cards ---- */
.card {
    background: var(--bg-white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-title {
    font-family: 'Poppins', sans-serif;
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .3px;
    color: var(--navy);
}
.card-body { padding: 20px; }

/* ---- Dashboard stats ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    border-top: 3px solid var(--navy);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}
.stat-card.gold  { border-top-color: var(--gold); }
.stat-card.green { border-top-color: var(--success); }
.stat-card.red   { border-top-color: var(--danger); }
.stat-card.blue  { border-top-color: var(--info); }
.stat-num {
    font-family: 'Poppins', sans-serif;
    font-size: 36px;
    font-weight: 700;
    color: var(--navy);
    line-height: 1;
}
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 4px; }

/* ---- Table ---- */
.crm-table-wrap { overflow-x: auto; }
.crm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.crm-table th {
    text-align: left;
    padding: 10px 14px;
    background: var(--bg);
    color: var(--navy);
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.crm-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.crm-table tr:hover td { background: #fafaf9; }
.crm-table tr:last-child td { border-bottom: none; }

/* ---- Státusz badge ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .3px;
    white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-uj       { background: #eff6ff; color: #2563eb; }
.badge-folyamatban { background: #fffbeb; color: #d97706; }
.badge-ajanlott { background: #f0fdf4; color: #16a34a; }
.badge-lezart   { background: #f1f5f9; color: #64748b; }
.badge-elveszett { background: #fef2f2; color: #dc2626; }
.badge-visszahiv { background: #faf5ff; color: #7c3aed; }
.badge-hu { background: #eff6ff; color: #1d4ed8; }
.badge-de { background: #fef2f2; color: #991b1b; }

/* ---- Prioritás ---- */
.prio-1::after { content: '↑'; color: var(--danger); font-weight: 700; }
.prio-2::after { content: '→'; color: var(--warning); font-weight: 700; }
.prio-3::after { content: '↓'; color: var(--muted); }

/* ---- Filters ---- */
.crm-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}
.crm-filters input,
.crm-filters select {
    padding: 7px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    background: var(--bg-white);
    transition: border-color .15s;
    min-width: 140px;
}
.crm-filters input:focus,
.crm-filters select:focus { outline: none; border-color: var(--gold); }
.crm-filters input[type="search"] { min-width: 220px; }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--navy);
    margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    transition: border-color .15s, background .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--gold); background: #fff; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 8px; }

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10,20,30,.6);
    z-index: 999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: var(--bg-white);
    border-radius: 14px;
    border-top: 4px solid var(--gold);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px 14px;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 {
    font-family: 'Poppins', sans-serif;
    font-size: 20px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--navy);
}
.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}
.modal-close:hover { color: var(--navy); }
.modal-box .quick-form { padding: 20px 24px; }
.modal-box.modal-lg { max-width: 800px; }

/* ---- Login ---- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--navy);
}
.login-box {
    background: var(--bg-white);
    border-radius: 16px;
    border-top: 4px solid var(--gold);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.login-logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo .brand {
    font-family: 'Poppins', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--navy);
}
.login-logo .brand strong { color: var(--gold); }
.login-logo small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.login-error { background: #fef2f2; color: #991b1b; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }

/* ---- Contact detail ---- */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    align-items: start;
}
.detail-field { margin-bottom: 14px; }
.detail-field label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); display: block; margin-bottom: 3px; }
.detail-field span { font-size: 14px; color: var(--text); }

.timeline { margin-top: 4px; }
.timeline-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--navy); flex-shrink: 0; margin-top: 5px; }
.timeline-dot.gold { background: var(--gold); }
.timeline-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ---- Kanban ---- */
.kanban-board {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 16px;
}
.kanban-col {
    min-width: 260px;
    max-width: 260px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.kanban-col-header {
    padding: 12px 14px;
    font-family: 'Poppins', sans-serif;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.kanban-count {
    background: var(--navy);
    color: #fff;
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 11px;
}
.kanban-cards { padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kanban-card {
    background: var(--bg-white);
    border-radius: 8px;
    border: 1px solid var(--border);
    padding: 12px 14px;
    cursor: pointer;
    transition: box-shadow .15s;
    box-shadow: var(--shadow);
}
.kanban-card:hover { box-shadow: var(--shadow-md); }
.kanban-card-name { font-weight: 600; font-size: 13.5px; margin-bottom: 4px; }
.kanban-card-meta { font-size: 11px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- Calendar ---- */
.calendar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.calendar-title {
    font-family: 'Poppins', sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--navy);
    flex: 1;
}
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.cal-day-head {
    text-align: center;
    padding: 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: .5px;
}
.cal-cell {
    background: var(--bg-white);
    border-radius: 6px;
    border: 1px solid var(--border);
    min-height: 90px;
    padding: 6px;
    cursor: pointer;
    transition: border-color .15s;
}
.cal-cell:hover { border-color: var(--gold); }
.cal-cell.today { border-color: var(--gold); background: #fffef0; }
.cal-cell.other-month { opacity: .4; }
.cal-cell-num {
    font-size: 12px;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 4px;
}
.cal-event {
    background: var(--navy);
    color: #fff;
    border-radius: 4px;
    padding: 2px 5px;
    font-size: 10px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

/* ---- Tasks ---- */
.task-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.task-item:last-child { border-bottom: none; }
.task-check {
    width: 20px; height: 20px;
    border-radius: 4px;
    border: 2px solid var(--border);
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 1px;
    display: flex; align-items: center; justify-content: center;
    transition: all .15s;
}
.task-check.done { background: var(--success); border-color: var(--success); }
.task-check.done::after { content: '✓'; color: #fff; font-size: 12px; }
.task-title { font-weight: 600; font-size: 14px; }
.task-title.done { text-decoration: line-through; color: var(--muted); }
.task-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.task-overdue { color: var(--danger) !important; }

/* ---- Alert ---- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.alert-success { background: #f0fdf4; color: #166534; border-left: 4px solid var(--success); }
.alert-error   { background: #fef2f2; color: #991b1b; border-left: 4px solid var(--danger); }
.alert-info    { background: #eff6ff; color: #1e40af; border-left: 4px solid var(--info); }

/* ---- Pagination ---- */
.pagination { display: flex; gap: 4px; margin-top: 16px; align-items: center; }
.pagination a, .pagination span {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1.5px solid var(--border);
    font-size: 13px;
    color: var(--navy);
    text-decoration: none;
    transition: all .15s;
}
.pagination a:hover { border-color: var(--navy); }
.pagination .current { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---- JSON viewer ---- */
.json-viewer {
    background: #1e1e2e;
    color: #cdd6f4;
    border-radius: 8px;
    padding: 14px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    overflow-x: auto;
    line-height: 1.6;
}

/* ---- Hamburger gomb ---- */
.crm-hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--navy);
}
.crm-hamburger svg { width: 24px; height: 24px; fill: currentColor; display: block; }

.crm-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 99;
}
.crm-sidebar-overlay.open { display: block; }

@media (max-width: 900px) {
    .crm-hamburger { display: flex; }

    .crm-sidebar {
        transform: translateX(-100%);
        transition: transform .28s cubic-bezier(.4,0,.2,1);
        z-index: 100;
    }
    .crm-sidebar.open { transform: translateX(0); }

    .crm-main { margin-left: 0; }

    .crm-topbar { padding: 12px 16px; }
    .crm-content { padding: 16px; }

    .detail-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    .kanban-board { flex-direction: column; }
    .kanban-col { min-width: 100%; max-width: 100%; }

    .crm-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    .crm-filters { gap: 8px; }
    .crm-filters input[type="search"] { min-width: 100%; }

    .modal-box { margin: 8px; max-width: calc(100vw - 16px); }

    .cal-grid { gap: 1px; }
    .cal-cell { min-height: 56px; padding: 4px; }
    .cal-cell-num { font-size: 11px; }
    .cal-event { font-size: 9px; padding: 1px 3px; }

    /* Topbar: hamburger bal oldalon */
    .crm-topbar { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; }
    .crm-page-title { font-size: 16px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .btn { font-size: 12px; padding: 7px 12px; }
    .crm-page-title { font-size: 14px; }
    .crm-content { padding: 12px; }
}
