/* BOT — Hybrid Theme (Dark Sidebar + Light Content) */
/* PANNA Group — PMF Manufacturing */
/* Palette: coolors.co/palette/2b2d42-8d99ae-edf2f4-ef233c-d90429 */
/* Backup: assets/css/app-dark-original.css */

:root {
    /* Sidebar palette (dark) */
    --sidebar-bg: #2b2d42;
    --sidebar-bg-hover: #353751;
    --sidebar-border: #3d3f56;
    --sidebar-text: #c8cad7;
    --sidebar-text-active: #ffffff;
    --sidebar-accent-soft: rgba(239, 35, 60, 0.15);

    /* Main content palette (light) */
    --bg-root: #edf2f4;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-elevated: #f8f9fb;
    --bg-hover: #e8ecf0;
    --bg-input: #f3f5f7;

    /* Borders */
    --border: #d5dbe3;
    --border-focus: #ef233c;
    --border-subtle: #e8ecf0;

    /* Text */
    --text-primary: #2b2d42;
    --text-secondary: #5c5f73;
    --text-muted: #8d99ae;
    --text-inverse: #ffffff;

    /* Accent — Punch Red */
    --accent: #ef233c;
    --accent-hover: #d90429;
    --accent-soft: rgba(239, 35, 60, 0.10);
    --accent-glow: rgba(239, 35, 60, 0.20);

    /* Status colors */
    --green: #10b981;
    --green-soft: rgba(16, 185, 129, 0.10);
    --yellow: #f59e0b;
    --yellow-soft: rgba(245, 158, 11, 0.10);
    --red: #d90429;
    --red-soft: rgba(217, 4, 41, 0.10);
    --blue: #3b82f6;
    --blue-soft: rgba(59, 130, 246, 0.10);
    --gray: #8d99ae;
    --gray-soft: rgba(141, 153, 174, 0.12);
    --purple: #7c3aed;
    --purple-soft: rgba(124, 58, 237, 0.10);

    /* Typography */
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Spacing */
    --sidebar-width: 240px;
    --topbar-height: 56px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-sm: 6px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(43,45,66,0.08);
    --shadow-md: 0 4px 12px rgba(43,45,66,0.10);
    --shadow-lg: 0 8px 24px rgba(43,45,66,0.14);

    /* Aliases used in inline styles */
    --surface: #ffffff;
    --error: var(--red);
    --success: var(--green);
}

/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
    font-family: var(--font-sans);
    background: var(--bg-root);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c4cbd6; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
/* Dark scrollbar inside sidebar */
.sidebar::-webkit-scrollbar-thumb { background: var(--sidebar-border); }
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--sidebar-text); }

/* === LOGIN === */
.login-wrapper {
    display: flex; align-items: center; justify-content: center;
    height: 100vh; width: 100vw;
    background: var(--bg-root);
    background-image: radial-gradient(ellipse at 30% 50%, rgba(239,35,60,0.05) 0%, transparent 60%);
}
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 400px;
    box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.logo-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 56px; height: 56px; border-radius: 14px;
    background: linear-gradient(135deg, #ef233c, #d90429);
    color: white; font-size: 24px; font-weight: 700;
    margin-bottom: 16px;
}
.logo-sm { width: 36px; height: 36px; font-size: 16px; border-radius: 10px; margin-bottom: 0; }
.login-logo h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.login-logo p { color: var(--text-secondary); font-size: 13px; margin-top: 4px; }
.login-footer { text-align: center; color: var(--text-muted); font-size: 12px; margin-top: 32px; }

/* === LAYOUT === */
#app-shell { display: flex; height: 100vh; }
.sidebar {
    width: var(--sidebar-width); min-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex; flex-direction: column;
    transition: transform 0.2s ease;
    z-index: 100;
}
.sidebar-header {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 20px; border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-brand { font-weight: 700; font-size: 18px; letter-spacing: -0.3px; color: #fff; }
.sidebar-nav { flex: 1; padding: 12px; overflow-y: auto; }
.sidebar-footer { padding: 16px; border-top: 1px solid var(--sidebar-border); }
.user-info { font-size: 12px; color: var(--sidebar-text); margin-bottom: 8px; }
.user-info .user-role { color: var(--accent); font-weight: 600; text-transform: uppercase; font-size: 10px; letter-spacing: 0.5px; }
.sidebar-footer .btn-ghost {
    color: var(--sidebar-text); border-color: var(--sidebar-border);
}
.sidebar-footer .btn-ghost:hover:not(:disabled) {
    background: var(--sidebar-bg-hover); color: var(--sidebar-text-active);
}

.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: var(--radius-sm);
    color: var(--sidebar-text); cursor: pointer;
    transition: all 0.15s ease; font-weight: 500;
    margin-bottom: 2px;
}
.nav-item:hover { background: var(--sidebar-bg-hover); color: var(--sidebar-text-active); }
.nav-item.active { background: var(--sidebar-accent-soft); color: var(--sidebar-text-active); }
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; display: inline-flex; align-items: center; justify-content: center; }
.nav-item .nav-badge {
    margin-left: auto; background: var(--accent); color: white;
    font-size: 10px; font-weight: 700; padding: 2px 7px;
    border-radius: 10px; min-width: 18px; text-align: center;
}
.nav-section { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: rgba(200,202,215,0.45); padding: 16px 14px 6px; }

.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
    display: flex; align-items: center; gap: 16px;
    padding: 0 24px; height: var(--topbar-height); min-height: var(--topbar-height);
    border-bottom: 1px solid var(--border); background: var(--bg-surface);
}
.topbar h2 { font-size: 16px; font-weight: 600; flex: 1; color: var(--text-primary); }
#topbar-actions { display: flex; gap: 8px; align-items: center; }
.sidebar-toggle { display: flex; align-items: center; justify-content: center; cursor: pointer; background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 20px; padding: 4px 10px; }

/* Desktop sidebar collapse */
@media (min-width: 1025px) {
    .sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-width)); }
}

.page-content { flex: 1; overflow-y: auto; padding: 24px; }

/* === CARDS & PANELS === */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 24px;
    margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.card-subtitle { color: var(--text-secondary); font-size: 12px; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 24px; }
.stat-card {
    background: #ffffff; border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px; box-shadow: 0 2px 8px rgba(43,45,66,0.07);
}
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; font-family: var(--font-mono); }
.stat-value.green { color: var(--green); }
.stat-value.blue { color: var(--accent); }
.stat-value.yellow { color: var(--yellow); }
.stat-value.red { color: var(--red); }

/* === TABLES === */
.table-wrap { overflow-x: auto; }
table {
    width: 100%; border-collapse: collapse; font-size: 13px;
    background: #ffffff; border-radius: var(--radius-lg); overflow: hidden;
    box-shadow: var(--shadow-sm); border: 1px solid var(--border);
}
thead th {
    text-align: left; padding: 10px 12px; font-weight: 600; font-size: 11px;
    text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted);
    border-bottom: 1px solid var(--border); white-space: nowrap;
    background: #fafbfc;
}
tbody td {
    padding: 12px; border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}
tbody tr { transition: background 0.1s; cursor: pointer; }
tbody tr:hover { background: #eef1f6; }
tbody td:first-child { color: var(--text-primary); font-weight: 500; }
.card table { box-shadow: none; border: none; border-radius: 0; }

/* === BUTTONS === */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 16px; border-radius: var(--radius-sm); font-weight: 500;
    border: 1px solid transparent; cursor: pointer; transition: all 0.15s;
    font-size: 13px; white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-success { background: var(--green); color: white; }
.btn-success:hover:not(:disabled) { background: #059669; }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn svg { flex-shrink: 0; }
.btn-full { width: 100%; }
.btn-icon { padding: 8px; }

/* === FORMS === */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; font-size: 12px; font-weight: 500;
    color: var(--text-secondary); margin-bottom: 6px;
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="date"], input[type="tel"], select, textarea {
    width: 100%; padding: 9px 12px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-primary);
    transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
select { cursor: pointer; }
textarea { resize: vertical; min-height: 80px; }
.form-error { color: var(--red); font-size: 12px; margin-top: 8px; }
.form-hint { color: var(--text-muted); font-size: 11px; margin-top: 4px; }

.select-add-wrap { display: flex; gap: 6px; align-items: stretch; }
.select-add-wrap select { flex: 1; min-width: 0; }
.btn-add-inline {
    flex-shrink: 0; width: 38px; display: flex; align-items: center; justify-content: center;
    background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent);
    border-radius: var(--radius-sm); font-size: 18px; font-weight: 600;
    cursor: pointer; transition: all 0.15s;
}
.btn-add-inline:hover { background: var(--accent); color: #fff; }

.form-check {
    display: flex; align-items: center; gap: 8px;
    cursor: pointer; padding: 4px 0;
}
.form-check input[type="checkbox"] {
    width: 16px; height: 16px; accent-color: var(--accent);
}

.multi-select {
    display: flex; flex-wrap: wrap; gap: 6px;
    padding: 8px; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); min-height: 42px;
}
.multi-select .chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; border-radius: 12px; font-size: 12px;
    background: var(--accent-soft); color: var(--accent); cursor: default;
}
.multi-select .chip .chip-remove { cursor: pointer; opacity: 0.6; }
.multi-select .chip .chip-remove:hover { opacity: 1; }

/* === STATUS PILLS === */
.pill {
    display: inline-flex; align-items: center; padding: 3px 10px;
    border-radius: 12px; font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.3px;
}
.pill-green { background: var(--green-soft); color: var(--green); }
.pill-yellow { background: var(--yellow-soft); color: var(--yellow); }
.pill-red { background: var(--red-soft); color: var(--red); }
.pill-blue { background: var(--blue-soft); color: var(--blue); }
.pill-gray { background: var(--gray-soft); color: var(--gray); }
.pill-purple { background: var(--purple-soft); color: var(--purple); }

/* === STEP TRACKER === */
.step-tracker {
    display: flex; gap: 2px; margin-bottom: 24px; padding: 0 4px;
    overflow-x: auto;
}
.step-item {
    flex: 1; min-width: 80px; text-align: center; padding: 12px 8px;
    border-radius: var(--radius-sm); font-size: 11px; font-weight: 500;
    cursor: pointer; transition: all 0.15s;
    background: var(--bg-elevated); color: var(--text-muted);
    border: 1px solid transparent;
}
.step-item:hover { background: var(--bg-hover); }
.step-item.completed { background: var(--green-soft); color: var(--green); border-color: rgba(16,185,129,0.2); }
.step-item.current { background: var(--accent-soft); color: var(--accent); border-color: rgba(59,130,246,0.3); }
.step-item.terminated { background: var(--red-soft); color: var(--red); border-color: rgba(239,68,68,0.2); }
.step-item .step-num { font-size: 16px; font-weight: 700; display: block; margin-bottom: 2px; }
.step-item .step-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* === TABS === */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
    padding: 10px 20px; font-weight: 500; font-size: 13px; cursor: pointer;
    color: var(--text-muted); border-bottom: 2px solid transparent;
    transition: all 0.15s;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* === MODAL === */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(43,45,66,0.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; backdrop-filter: blur(4px);
}
.modal {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); width: 560px; max-width: 90vw;
    max-height: 85vh; display: flex; flex-direction: column;
    box-shadow: 0 12px 40px rgba(43,45,66,0.20);
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 24px; cursor: pointer; padding: 0; line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 16px 24px; border-top: 1px solid var(--border);
}

/* === TOASTS === */
.toast-container {
    position: fixed; top: 16px; right: 16px; z-index: 2000;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    padding: 12px 20px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500; min-width: 280px;
    box-shadow: var(--shadow-md);
    animation: toastIn 0.3s ease;
}
.toast-success { background: var(--green); color: white; }
.toast-error { background: var(--red); color: white; }
.toast-info { background: var(--accent); color: white; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

/* === EMPTY STATES === */
.empty-state {
    text-align: center; padding: 60px 24px; color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { font-size: 18px; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 13px; margin-bottom: 20px; }

/* === GOD VIEW MATRIX === */
.matrix-table { font-size: 12px; }
.matrix-table th { font-size: 10px; padding: 8px 6px; }
.matrix-table td { padding: 8px 6px; text-align: center; }
.matrix-table .opp-name { text-align: left; font-weight: 600; color: var(--accent); }
.matrix-table .opp-customer { text-align: left; color: var(--text-secondary); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-dot {
    display: inline-block; width: 10px; height: 10px;
    border-radius: 50%;
}
.step-dot.green { background: var(--green); }
.step-dot.yellow { background: var(--yellow); }
.step-dot.red { background: var(--red); }
.step-dot.blue { background: var(--accent); }
.step-dot.gray { background: var(--gray); opacity: 0.4; }

/* === FUNNEL === */
.funnel { margin: 24px auto; max-width: 600px; }
.funnel-step {
    display: flex; align-items: center; gap: 16px;
    padding: 12px 24px; margin-bottom: 2px;
    background: var(--bg-elevated); border-radius: var(--radius-sm);
}
.funnel-bar {
    flex: 1; height: 28px; background: var(--bg-input); border-radius: 4px;
    overflow: hidden; position: relative;
}
.funnel-fill {
    height: 100%; background: linear-gradient(90deg, var(--accent), #d90429);
    border-radius: 4px; transition: width 0.5s ease;
    display: flex; align-items: center; justify-content: flex-end;
    padding-right: 8px; font-size: 11px; font-weight: 600; color: white;
    min-width: 30px;
}
.funnel-label { font-size: 12px; font-weight: 500; width: 100px; color: var(--text-secondary); }
.funnel-count { font-size: 13px; font-weight: 600; width: 40px; text-align: right; font-family: var(--font-mono); }

/* === LOADING === */
.spinner {
    display: inline-block; width: 20px; height: 20px;
    border: 2px solid var(--border); border-top-color: var(--accent);
    border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; justify-content: center; padding: 40px; }

/* === RESPONSIVE === */

/* Tablet breakpoint — stat grids */
@media (max-width: 1200px) {
    .stat-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Tablet + Mobile — collapsible sidebar */
@media (max-width: 1024px) {
    #app-shell { flex-direction: column; }
    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0;
        transform: translateX(-100%);
        z-index: 1000;
        transition: transform 0.25s ease;
        box-shadow: 4px 0 20px rgba(43,45,66,0.25);
        width: 260px; min-width: 260px;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar.collapsed { margin-left: 0; } /* on mobile, collapsed class does nothing — mobile uses .open */
    .main-content { width: 100% !important; }
    .topbar { padding: 0 12px; }
    .page-content { padding: 12px; }
    .form-row { grid-template-columns: 1fr; }
    .card { overflow-x: auto; }
    table { font-size: 12px; min-width: 500px; }
    .tabs { overflow-x: auto; flex-wrap: nowrap; }
    .tab { white-space: nowrap; flex-shrink: 0; }
    .modal { width: 95vw; max-width: 95vw; margin: 10px; max-height: 90vh; }
    #topbar-actions .btn { font-size: 12px; padding: 4px 8px; }
}

/* Phone — tighter layout */
@media (max-width: 600px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .btn-label { display: none; }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(43,45,66,0.35); z-index: 999;
}
.sidebar-overlay.active { display: block; }

/* === EXPORT OVERLAY === */
@keyframes eo-fade-in { from { opacity: 0 } to { opacity: 1 } }
@keyframes eo-scale-in { from { opacity: 0; transform: scale(0.88) } to { opacity: 1; transform: scale(1) } }
@keyframes eo-check-draw { from { stroke-dashoffset: 60 } to { stroke-dashoffset: 0 } }
@keyframes eo-pulse { 0%,100% { opacity: 1 } 50% { opacity: 0.45 } }

#export-overlay {
    display: none; position: fixed; inset: 0; z-index: 9999;
    background: rgba(43,45,66,0.55);
    align-items: center; justify-content: center;
    animation: eo-fade-in 0.2s ease;
}
#export-overlay.active { display: flex; }
#export-overlay .eo-card {
    background: var(--bg-card); border-radius: 14px;
    padding: 36px 48px; display: flex; flex-direction: column;
    align-items: center; gap: 14px;
    animation: eo-scale-in 0.22s ease; min-width: 230px;
    box-shadow: 0 8px 32px rgba(43,45,66,0.25);
}
#export-overlay .eo-spinner {
    width: 54px; height: 54px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
#export-overlay .eo-check { display: none; width: 54px; height: 54px; }
#export-overlay .eo-check circle { fill: none; stroke: var(--green); stroke-width: 3; }
#export-overlay .eo-check polyline {
    fill: none; stroke: var(--green); stroke-width: 3;
    stroke-linecap: round; stroke-linejoin: round;
    stroke-dasharray: 60; stroke-dashoffset: 60;
}
#export-overlay .eo-label { font-size: 15px; font-weight: 600; color: var(--text-primary); text-align: center; }
#export-overlay .eo-sub { font-size: 13px; color: var(--text-muted); text-align: center; animation: eo-pulse 1.4s ease infinite; }
#export-overlay .eo-sub.done { animation: none; color: var(--green); }
