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

/* ── ROOT VARIABLES ── */
:root {
    --bg: #0f1117;
    --bg2: #161b27;
    --bg3: #1e2535;
    --border: #2a3347;
    --text: #e8eaf0;
    --text2: #8b93a8;
    --text3: #5a6378;
    --accent: #4f8ef7;
    --accent2: #3d75d4;
    --accent-glow: rgba(79, 142, 247, 0.18);
    --green: #3ecf8e;
    --yellow: #f5c842;
    --red: #f56565;
    --purple: #a78bfa;
    --orange: #fb923c;
    --sidebar-w: 220px;
    --radius: 10px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --transition: 0.2s cubic-bezier(.4, 0, .2, 1);
    --topbar-bg: rgba(15, 17, 23, 0.85);
    --overlay-bg: rgba(0, 0, 0, 0.6);
    --brand-yellow: #f5c842;
    --brand-yellow2: #e0af1f;
    --brand-glow: rgba(245, 200, 66, 0.22);
    --kanban-min-col: 260px;
}

body.light-theme {
    --bg: #f4f5f9;
    --bg2: #ffffff;
    --bg3: #eef0f6;
    --border: #dde1ea;
    --text: #1a1d29;
    --text2: #5b6376;
    --text3: #8b93a8;
    --accent: #3d75d4;
    --accent2: #2f5fb0;
    --accent-glow: rgba(61, 117, 212, 0.12);
    --shadow: 0 4px 24px rgba(20, 25, 40, 0.08);
    --topbar-bg: rgba(255, 255, 255, 0.85);
    --overlay-bg: rgba(20, 22, 30, 0.4);
}

/* ── RESET & BASE ── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
html {
    font-size: 15px;
}
body {
    font-family: 'Sora', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background var(--transition), color var(--transition);
}

#app-shell {
    display: flex;
    min-height: 100vh;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 99px;
}

/* ── SIDEBAR ── */
#sidebar {
    width: var(--sidebar-w);
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-logo {
    padding: 22px 20px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
}
.logo-icon {
    width: 34px;
    height: 34px;
    background: var(--brand-yellow);
    color: #1a1d29;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 0 16px var(--brand-glow);
}
.logo-text {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.logo-sub {
    font-size: 0.65rem;
    color: var(--text3);
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    padding: 14px 10px;
    overflow-y: auto;
}
.nav-section-label {
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text3);
    padding: 10px 10px 6px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text2);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
    margin-bottom: 2px;
    user-select: none;
}
.nav-item:hover {
    background: var(--bg3);
    color: var(--text);
}
.nav-item.active {
    background: var(--accent-glow);
    color: var(--accent);
}
.nav-item.active .nav-icon {
    color: var(--accent);
}
.nav-icon {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}
.nav-badge {
    margin-left: auto;
    background: var(--brand-yellow);
    color: #1a1d29;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 99px;
    min-width: 18px;
    text-align: center;
}

.sidebar-footer {
    padding: 14px 10px;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text3);
    text-align: center;
}

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

/* ── TOPBAR ── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--topbar-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.topbar-title {
    font-size: 1.15rem;
    font-weight: 700;
    flex: 1;
}
.topbar-sub {
    font-size: 0.75rem;
    color: var(--text3);
    margin-top: 1px;
}
.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text2);
    cursor: pointer;
    font-size: 1.3rem;
    padding: 4px;
}
.theme-toggle {
    display: inline-flex;
    align-items: center;
    width: 50px;
    height: 26px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 99px;
    cursor: pointer;
    position: relative;
    padding: 2px;
    flex-shrink: 0;
    transition: background var(--transition), border-color var(--transition);
}
.theme-toggle .toggle-knob {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--brand-yellow);
    color: #1a1d29;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transform: translateX(0);
    transition: transform var(--transition), background var(--transition);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
body.light-theme .theme-toggle .toggle-knob {
    transform: translateX(24px);
    background: var(--accent);
    color: #fff;
}
body.light-theme .theme-toggle {
    background: var(--accent-glow);
}

/* ── BUTTONS ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    font-family: inherit;
    font-size: 0.825rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover {
    background: var(--accent2);
    box-shadow: 0 0 16px var(--accent-glow);
}
.btn-ghost {
    background: var(--bg3);
    color: var(--text2);
    border: 1px solid var(--border);
}
.btn-ghost:hover {
    color: var(--text);
    border-color: var(--text3);
}
.btn-danger {
    background: rgba(245, 101, 101, 0.12);
    color: var(--red);
    border: 1px solid rgba(245, 101, 101, 0.25);
}
.btn-danger:hover {
    background: rgba(245, 101, 101, 0.2);
}
.btn-sm {
    padding: 5px 11px;
    font-size: 0.775rem;
}
.btn-icon {
    padding: 7px;
}

/* ── PAGES ── */
.page {
    display: none;
    flex-direction: column;
    flex: 1;
}
.page.active {
    display: flex;
}
.page-body {
    flex: 1;
    padding: 28px;
    overflow-y: auto;
}
.page-body>* {
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

/* ── STATS ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--card-accent, var(--accent));
}
.stat-icon {
    font-size: 1.5rem;
    margin-bottom: 10px;
}
.stat-value {
    font-size: 2rem;
    font-weight: 700;
    font-family: 'DM Mono', monospace;
}
.stat-label {
    font-size: 0.75rem;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-top: 4px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ── CARDS ── */
.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 0.9rem;
}
.card-body {
    padding: 0;
}

.activity-list {
    list-style: none;
}
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 13px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 0.82rem;
    transition: background var(--transition);
}
.activity-item:last-child {
    border-bottom: none;
}
.activity-item:hover {
    background: var(--bg3);
}
.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 4px;
    flex-shrink: 0;
    background: var(--accent);
}
.activity-text {
    flex: 1;
    line-height: 1.5;
    color: var(--text2);
}
.activity-text strong {
    color: var(--text);
}
.activity-time {
    color: var(--text3);
    font-size: 0.72rem;
    white-space: nowrap;
    font-family: 'DM Mono', monospace;
}

.task-preview-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 0.82rem;
    transition: background var(--transition);
    cursor: pointer;
}
.task-preview-item:last-child {
    border-bottom: none;
}
.task-preview-item:hover {
    background: var(--bg3);
}

/* ── TOOLBAR ── */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.search-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 360px;
}
.search-wrap .search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text3);
    pointer-events: none;
}
.search-wrap input {
    padding-left: 34px;
}

/* ── FORM ELEMENTS ── */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.85rem;
    padding: 8px 12px;
    transition: border var(--transition);
    width: 100%;
}
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
select option {
    background: var(--bg3);
}

/* ── TABLES ── */
.table-wrap {
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
thead {
    background: var(--bg3);
}
th {
    padding: 11px 16px;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text3);
    white-space: nowrap;
}
td {
    padding: 13px 16px;
    border-top: 1px solid var(--border);
    color: var(--text2);
    vertical-align: middle;
}
tr:hover td {
    background: var(--bg3);
    color: var(--text);
}
.td-name {
    font-weight: 600;
    color: var(--text);
}
.td-mono {
    font-family: 'DM Mono', monospace;
    font-size: 0.8rem;
}

/* ── BADGES ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: capitalize;
}
.badge-lead {
    background: rgba(79, 142, 247, 0.15);
    color: var(--accent);
}
.badge-active {
    background: rgba(62, 207, 142, 0.15);
    color: var(--green);
}
.badge-inactive {
    background: rgba(90, 99, 120, 0.2);
    color: var(--text3);
}
.badge-prospect {
    background: rgba(245, 200, 66, 0.15);
    color: var(--yellow);
}
.badge-customer {
    background: rgba(167, 139, 250, 0.15);
    color: var(--purple);
}
.badge-high {
    background: rgba(245, 101, 101, 0.15);
    color: var(--red);
}
.badge-medium {
    background: rgba(245, 200, 66, 0.15);
    color: var(--yellow);
}
.badge-low {
    background: rgba(62, 207, 142, 0.15);
    color: var(--green);
}
.badge-won {
    background: rgba(62, 207, 142, 0.15);
    color: var(--green);
}
.badge-lost {
    background: rgba(245, 101, 101, 0.15);
    color: var(--red);
}

.actions {
    display: flex;
    gap: 6px;
}
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text3);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all var(--transition);
}
.icon-btn:hover {
    background: var(--bg3);
    color: var(--text);
}
.icon-btn.danger:hover {
    background: rgba(245, 101, 101, 0.15);
    color: var(--red);
    border-color: rgba(245, 101, 101, 0.3);
}

/* ── MODALS ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}
.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}
.modal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
    transform: scale(0.95) translateY(10px);
    transition: transform var(--transition);
}
.modal-overlay.open .modal {
    transform: scale(1) translateY(0);
}
.modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 1rem;
    position: sticky;
    top: 0;
    background: var(--bg2);
    z-index: 1;
}
.modal-body {
    padding: 20px 24px;
}
.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    position: sticky;
    bottom: 0;
    background: var(--bg2);
}

.form-grid {
    display: grid;
    gap: 16px;
}
.form-grid-2 {
    grid-template-columns: 1fr 1fr;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.form-label {
    font-size: 0.775rem;
    font-weight: 600;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
textarea {
    min-height: 90px;
    resize: vertical;
}

/* ── KANBAN BOARD ── */
.kanban-board {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 4px 20px 4px;
    min-height: 520px;
    max-height: calc(100vh - 200px);
    align-items: flex-start;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: auto;
    scrollbar-color: var(--accent) var(--bg3);
    transition: flex-direction 0.3s ease;
}

.kanban-board::-webkit-scrollbar {
    height: 12px;
    width: 12px;
}
.kanban-board::-webkit-scrollbar-track {
    background: var(--bg3);
    border-radius: 99px;
    border: 1px solid var(--border);
    margin: 0 4px;
}
.kanban-board::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 99px;
    border: 2px solid var(--bg3);
    min-width: 60px;
    transition: background 0.3s ease;
}
.kanban-board::-webkit-scrollbar-thumb:hover {
    background: var(--accent2);
    box-shadow: 0 0 16px var(--accent-glow);
}
.kanban-board::-webkit-scrollbar-corner {
    background: var(--bg3);
}

.kanban-col {
    scroll-snap-align: start;
    flex-shrink: 0;
    min-width: var(--kanban-min-col);
    max-width: 340px;
    width: 100%;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 220px);
    transition: border-color 0.3s ease, box-shadow 0.3s ease, min-width 0.3s ease;
}
.kanban-col:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 20px rgba(79, 142, 247, 0.06);
}

.kanban-col-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 0.82rem;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--bg2);
    z-index: 2;
}
.col-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
    flex-shrink: 0;
    display: inline-block;
}
.col-count {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 99px;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 9px;
    font-family: 'DM Mono', monospace;
    color: var(--text3);
    min-width: 24px;
    text-align: center;
}

.kanban-cards {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 220px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    transition: gap 0.2s ease;
}
.kanban-board.dnd-active .kanban-cards {
    gap: 30px;
}
.kanban-cards::-webkit-scrollbar {
    width: 4px;
}
.kanban-cards::-webkit-scrollbar-track {
    background: transparent;
}
.kanban-cards::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 99px;
}
.kanban-cards::-webkit-scrollbar-thumb:hover {
    background: var(--text3);
}
.kanban-cards.drag-over {
    background: var(--accent-glow);
    border-radius: 8px;
    border: 2px dashed var(--accent);
}

.kanban-col-header[draggable="true"] {
    cursor: grab;
}
.col-drag-handle {
    cursor: grab;
    color: var(--text3);
    font-size: 0.9rem;
    line-height: 1;
    margin-right: 2px;
    flex-shrink: 0;
}
.kanban-col.col-dragging {
    opacity: 0.4;
    transform: scale(0.97);
}
.kanban-col.col-drag-over {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow), 0 4px 20px rgba(79, 142, 247, 0.15);
}

/* ── DEAL CARDS ── */
.deal-card {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 18px;
    cursor: grab;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.deal-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 16px rgba(79, 142, 247, 0.12), 0 0 0 2px var(--accent-glow);
    transform: translateY(-2px);
}
.deal-card.dragging {
    opacity: 0.4;
    cursor: grabbing;
    transform: scale(0.96);
}
.deal-card.drop-before,
.deal-card.drop-after {
    z-index: 1;
}
.deal-card.drop-before::before,
.deal-card.drop-after::after {
    content: '';
    position: absolute;
    left: 4px;
    right: 4px;
    height: 3px;
    border-radius: 3px;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
}
.deal-card.drop-before::before {
    top: -15px;
}
.deal-card.drop-after::after {
    bottom: -15px;
}
.deal-card-title {
    font-weight: 600;
    font-size: 0.85rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.35;
}
.deal-card-desc {
    font-size: 0.75rem;
    color: var(--text3);
    line-height: 1.4;
    margin-top: -6px;
}
.deal-card-company {
    font-size: 0.75rem;
    color: var(--text3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.deal-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
    flex-wrap: wrap;
    gap: 6px;
}
.deal-card-meta-actions {
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.deal-value {
    font-family: 'DM Mono', monospace;
    font-weight: 600;
    color: var(--green);
}
.deal-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.deal-actions .icon-btn {
    width: 28px;
    height: 28px;
    font-size: 0.7rem;
}

/* ── DEAL CARD NOTES BUTTON ── */
.deal-card-notes-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.deal-notes-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: var(--text2);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 6px 4px 2px;
    border-radius: 6px;
    transition: color var(--transition), background var(--transition);
}
.deal-notes-toggle:hover {
    color: var(--accent);
    background: var(--accent-glow);
}
.deal-notes-chevron {
    display: inline-block;
    font-size: 0.8rem;
    line-height: 1;
    transform: rotate(-90deg);
}
.deal-notes-count {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 99px;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 7px;
    font-family: 'DM Mono', monospace;
    color: var(--text3);
    min-width: 18px;
    text-align: center;
}

/* ── DEAL NOTES MODAL LIST ── */
.deal-notes-modal-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 55vh;
    overflow-y: auto;
    padding-right: 2px;
}
.deal-notes-empty {
    font-size: 0.8rem;
    color: var(--text3);
    padding: 24px 2px;
    text-align: center;
}
.deal-note-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    transition: border-color var(--transition);
}
.deal-note-item:hover {
    border-color: var(--accent);
}
.deal-note-item-main {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}
.deal-note-item-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 3px;
    word-wrap: break-word;
}
.deal-note-item-preview {
    font-size: 0.75rem;
    color: var(--text3);
    line-height: 1.4;
    word-wrap: break-word;
}
.deal-note-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* ── LOCKED FORM FIELD ── */
.form-hint {
    display: block;
    font-size: 0.68rem;
    color: var(--text3);
    margin-top: 5px;
}
select:disabled,
input:disabled,
textarea:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    background: var(--bg3);
}

/* ── STAGE DROPDOWN ON DEAL CARD ── */
.deal-stage-select {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text2);
    font-family: 'Sora', sans-serif;
    font-size: 0.7rem;
    padding: 3px 6px;
    cursor: pointer;
    transition: border-color var(--transition), color var(--transition);
    min-width: 90px;
    max-width: 130px;
    outline: none;
}
.deal-stage-select:hover,
.deal-stage-select:focus {
    border-color: var(--accent);
    color: var(--text);
}
.deal-stage-select option {
    background: var(--bg2);
    color: var(--text);
}

.kanban-add-btn {
    margin: 10px;
    padding: 10px;
    border-radius: 8px;
    border: 2px dashed var(--border);
    background: transparent;
    color: var(--text3);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8rem;
    width: calc(100% - 20px);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.25s ease;
    flex-shrink: 0;
    font-weight: 500;
    letter-spacing: 0.3px;
}
.kanban-add-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
    transform: translateY(-1px);
}
.kanban-add-btn:active {
    transform: scale(0.96);
}

.kanban-col-add {
    min-width: 220px;
    flex-shrink: 0;
    padding-top: 2px;
}
.kanban-add-stage-btn {
    width: 100%;
    min-height: 46px;
    border-radius: var(--radius);
    border: 2px dashed var(--border);
    background: transparent;
    color: var(--text2);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.2px;
    transition: all 0.2s ease;
}
.kanban-add-stage-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
}

.stage-color-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.color-swatch:hover {
    transform: scale(1.12);
}
.color-swatch.selected {
    box-shadow: 0 0 0 2px var(--bg2), 0 0 0 4px var(--text);
}

.kanban-board::after {
    content: '';
    position: sticky;
    right: 0;
    top: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to right, transparent, var(--bg));
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.kanban-board.scrollable::after {
    opacity: 0.6;
}

.kanban-scroll-hint {
    display: none;
    text-align: center;
    font-size: 0.7rem;
    color: var(--text3);
    padding: 4px 0 8px 0;
    letter-spacing: 0.5px;
}
.kanban-scroll-hint.visible {
    display: block;
}
.kanban-scroll-hint .scroll-arrow {
    display: inline-block;
    animation: scroll-pulse 2s ease-in-out infinite;
}
@keyframes scroll-pulse {
    0%,
    100% {
        transform: translateX(0);
        opacity: 0.5;
    }
    50% {
        transform: translateX(8px);
        opacity: 1;
    }
}

/* ── TASK LIST ── */
.task-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.task-item {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    transition: all var(--transition);
}
.task-item:hover {
    border-color: var(--border);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}
.task-item.done {
    opacity: 0.5;
}
.task-item.done .task-title {
    text-decoration: line-through;
}
.task-check {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 2px solid var(--border);
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    margin-top: 1px;
    background: transparent;
}
.task-check:hover {
    border-color: var(--accent);
}
.task-item.done .task-check {
    background: var(--green);
    border-color: var(--green);
}
.task-body {
    flex: 1;
    min-width: 0;
}
.task-title {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 4px;
}
.task-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.task-due {
    font-size: 0.75rem;
    color: var(--text3);
    font-family: 'DM Mono', monospace;
}
.task-due.overdue {
    color: var(--red);
}
.task-assignee {
    font-size: 0.75rem;
    color: var(--text3);
}

/* ── NOTES ── */
.notes-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    height: calc(100vh - 180px);
}
.notes-list-pane {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.notes-list-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.85rem;
    position: sticky;
    top: 0;
    background: var(--bg2);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.note-list-item {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
}
.note-list-item:hover {
    background: var(--bg3);
}
.note-list-item.active {
    background: var(--accent-glow);
    border-left: 3px solid var(--accent);
}
.note-list-item:last-child {
    border-bottom: none;
}
.note-list-title {
    font-weight: 600;
    font-size: 0.83rem;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.note-list-preview {
    font-size: 0.75rem;
    color: var(--text3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.notes-detail-pane {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.notes-detail-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.note-linked {
    font-size: 0.75rem;
    color: var(--accent);
    background: var(--accent-glow);
    padding: 3px 10px;
    border-radius: 99px;
    margin-top: 3px;
    display: inline-block;
}
.notes-detail-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}
.note-content-text {
    font-size: 0.9rem;
    line-height: 1.75;
    color: var(--text2);
    white-space: pre-wrap;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 60px 20px;
    color: var(--text3);
    text-align: center;
}
.empty-state .es-icon {
    font-size: 2.5rem;
    opacity: 0.4;
}
.empty-state h3 {
    font-size: 0.95rem;
    color: var(--text2);
}
.empty-state p {
    font-size: 0.8rem;
    max-width: 260px;
    line-height: 1.5;
}

/* ── TOASTS ── */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.toast {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 18px;
    font-size: 0.83rem;
    color: var(--text);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toast-in 0.3s ease forwards;
    max-width: 300px;
    pointer-events: auto;
    border-left: 3px solid var(--accent);
}
.toast.success {
    border-left-color: var(--green);
}
.toast.error {
    border-left-color: var(--red);
}
@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}
@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

.sep {
    height: 1px;
    background: var(--border);
    margin: 20px 0;
}
.chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 99px;
    font-size: 0.72rem;
    color: var(--text2);
    gap: 5px;
}
.color-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.section-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.filter-select {
    padding: 7px 12px;
    min-width: 130px;
}

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    text-transform: uppercase;
}

.pipeline-summary {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.pipe-chip {
    display: flex;
    align-items: center;
    gap: 7px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.78rem;
}
.pipe-chip-val {
    font-family: 'DM Mono', monospace;
    font-weight: 600;
    color: var(--green);
}

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

.progress-bar-wrap {
    height: 4px;
    background: var(--bg3);
    border-radius: 99px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    border-radius: 99px;
    background: var(--accent);
    transition: width 0.5s ease;
}

.note-form-grid {
    display: grid;
    gap: 14px;
}
.inline-flex {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.text-green {
    color: var(--green);
}
.text-red {
    color: var(--red);
}
.text-yellow {
    color: var(--yellow);
}
.text-accent {
    color: var(--accent);
}
.text-muted {
    color: var(--text3);
}
.fw-600 {
    font-weight: 600;
}

/* ── LOGIN ── */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at 20% 20%, var(--accent-glow), transparent 55%), var(--bg);
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 36px 32px 28px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.login-header {
    text-align: center;
    margin-bottom: 28px;
}
.login-header .logo-icon {
    margin: 0 auto 14px;
}
.login-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.login-header p {
    font-size: 0.8rem;
    color: var(--text3);
    margin-top: 4px;
}
#login-form .form-group {
    margin-bottom: 18px;
}
#login-form label {
    display: block;
    font-size: 0.775rem;
    font-weight: 600;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}
.input-group {
    position: relative;
    display: flex;
    align-items: center;
}
.input-group .input-icon {
    position: absolute;
    left: 11px;
    font-size: 0.85rem;
    color: var(--text3);
    pointer-events: none;
}
.input-group input {
    padding-left: 34px;
}
.input-group .toggle-password {
    position: absolute;
    right: 6px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text3);
    padding: 6px;
    border-radius: 6px;
    line-height: 1;
}
.input-group .toggle-password:hover {
    color: var(--text2);
    background: var(--bg3);
}
.form-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: -6px 0 22px;
    font-size: 0.8rem;
}
.remember-me {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text2);
    cursor: pointer;
}
.remember-me input {
    width: auto;
}
.forgot-password {
    color: var(--accent);
    text-decoration: none;
}
.forgot-password:hover {
    text-decoration: underline;
}
.login-btn {
    width: 100%;
    justify-content: center;
    padding: 11px;
    font-size: 0.9rem;
    position: relative;
}
.login-error {
    margin-top: 14px;
    padding: 10px 12px;
    background: rgba(245, 101, 101, 0.1);
    border: 1px solid rgba(245, 101, 101, 0.25);
    color: var(--red);
    font-size: 0.8rem;
    border-radius: 8px;
    text-align: center;
}
.demo-credentials {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    text-align: center;
}
.demo-credentials p {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text3);
    margin-bottom: 6px;
}
.demo-credentials small {
    display: block;
    color: var(--text2);
    font-size: 0.78rem;
    line-height: 1.6;
    font-family: 'DM Mono', monospace;
}

.live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    color: var(--green);
    background: rgba(62, 207, 142, 0.12);
    padding: 4px 12px;
    border-radius: 99px;
    border: 1px solid rgba(62, 207, 142, 0.2);
}
.live-indicator .pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse-dot 1.5s ease-in-out infinite;
}
@keyframes pulse-dot {
    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.4;
        transform: scale(0.8);
    }
}

/* ════════════════════════════════════════════════
           RESPONSIVE — TABLET & MOBILE
           ════════════════════════════════════════════════ */

/* ── Tablet: 768–1024px ── */
@media (max-width: 1024px) {
    .kanban-col {
        min-width: 250px;
        max-width: 300px;
    }
    .deal-card {
        padding: 12px 14px;
        min-height: 70px;
    }
    .deal-card-title {
        font-size: 0.82rem;
    }
    .deal-stage-select {
        min-width: 70px;
        font-size: 0.65rem;
    }
}

/* ── Mobile: < 768px ── */
@media (max-width: 768px) {
    :root {
        --sidebar-w: 0px;
        --kanban-min-col: 100%;
    }

    #sidebar {
        transform: translateX(-220px);
        width: 220px;
    }
    #sidebar.open {
        transform: translateX(0);
    }
    #main {
        margin-left: 0;
    }
    .hamburger {
        display: block;
    }
    .page-body {
        padding: 16px;
    }
    .form-grid-2 {
        grid-template-columns: 1fr;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .topbar {
        padding: 12px 16px;
    }

    /* ── Kanban: vertical stack ── */
    .kanban-board {
        flex-direction: column !important;
        align-items: stretch !important;
        overflow-x: visible !important;
        overflow-y: auto !important;
        max-height: none !important;
        min-height: 420px;
        padding: 6px 0 16px 0;
        gap: 16px;
        scroll-snap-type: none;
        margin: 0;
    }

    .kanban-board::-webkit-scrollbar {
        height: 6px;
        width: 6px;
    }
    .kanban-board::-webkit-scrollbar-thumb {
        min-width: 40px;
        border-width: 1px;
    }

    .kanban-col {
        min-width: 100% !important;
        max-width: 100% !important;
        width: 100% !important;
        max-height: 400px;
        scroll-snap-align: none;
    }

    .kanban-cards {
        padding: 8px;
        gap: 8px;
        min-height: 80px;
        max-height: 280px;
    }

    .deal-card {
        padding: 10px 12px;
        min-height: 60px;
        border-radius: 6px;
    }
    .deal-card-title {
        font-size: 0.8rem;
    }
    .deal-card-company {
        font-size: 0.7rem;
        white-space: normal;
        overflow: visible;
    }
    .deal-card-meta {
        font-size: 0.7rem;
        flex-wrap: wrap;
    }
    .deal-actions .icon-btn {
        width: 28px;
        height: 28px;
        font-size: 0.7rem;
    }
    .deal-stage-select {
        min-width: 80px;
        font-size: 0.65rem;
        padding: 2px 4px;
    }
    .deal-card-notes-row {
        flex-wrap: wrap;
    }
    .deal-notes-modal-list {
        max-height: 60vh;
    }

    .kanban-col-header {
        padding: 12px 14px;
        font-size: 0.78rem;
    }
    .col-count {
        font-size: 0.65rem;
        padding: 1px 7px;
        min-width: 20px;
    }
    .kanban-add-btn {
        padding: 10px;
        font-size: 0.78rem;
        margin: 8px;
        width: calc(100% - 16px);
    }

    .section-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .section-toolbar .btn {
        width: 100%;
        justify-content: center;
    }
    .pipeline-summary {
        justify-content: center;
    }

    .kanban-board::after {
        display: none;
    }
    .kanban-scroll-hint {
        display: none !important;
    }

    /* ── Notes ── */
    .notes-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    .notes-list-pane {
        max-height: 280px;
    }

    /* ── Dashboard ── */
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    /* ── Tables ── */
    .table-wrap {
        margin: 0 -12px;
        padding: 0 12px;
    }
    table {
        font-size: 0.78rem;
    }
    th,
    td {
        padding: 10px 12px;
    }
    .td-mono {
        font-size: 0.72rem;
    }
}

/* ── Small Mobile: < 480px ── */
@media (max-width: 480px) {
    .kanban-board {
        min-height: 360px;
        gap: 14px;
        padding: 4px 0 12px 0;
    }
    .kanban-col {
        max-height: 350px;
    }
    .kanban-cards {
        padding: 6px;
        gap: 6px;
        min-height: 60px;
        max-height: 240px;
    }
    .deal-card {
        padding: 8px 10px;
        min-height: 50px;
        border-radius: 5px;
    }
    .deal-card-title {
        font-size: 0.75rem;
    }
    .deal-card-company {
        font-size: 0.65rem;
    }
    .deal-card-meta {
        font-size: 0.65rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }
    .deal-actions {
        align-self: flex-end;
        margin-top: 2px;
    }
    .deal-actions .icon-btn {
        width: 24px;
        height: 24px;
        font-size: 0.65rem;
    }
    .deal-stage-select {
        min-width: 70px;
        font-size: 0.6rem;
        padding: 2px 4px;
    }
    .kanban-col-header {
        padding: 10px 12px;
        font-size: 0.72rem;
    }
    .col-count {
        font-size: 0.6rem;
        padding: 1px 6px;
        min-width: 18px;
    }
    .kanban-add-btn {
        padding: 8px;
        font-size: 0.72rem;
        margin: 6px;
        width: calc(100% - 12px);
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    .stat-card {
        padding: 14px;
    }
    .stat-value {
        font-size: 1.5rem;
    }
    .topbar-title {
        font-size: 1rem;
    }
    .page-body {
        padding: 12px;
    }
    .modal {
        max-width: 100%;
        margin: 10px;
        border-radius: 12px;
    }
    .modal-body {
        padding: 16px;
    }
    .modal-header {
        padding: 16px 18px 12px;
    }
    .modal-footer {
        padding: 12px 18px;
        flex-wrap: wrap;
    }
    .modal-footer .btn {
        flex: 1;
        justify-content: center;
    }
    .search-wrap {
        max-width: 100%;
        min-width: 120px;
    }
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-select {
        min-width: 100%;
    }
    .notes-list-pane {
        max-height: 200px;
    }
}

/* ── Very Small: < 360px ── */
@media (max-width: 360px) {
    .kanban-col {
        max-height: 300px;
    }
    .kanban-cards {
        max-height: 200px;
    }
    .deal-card {
        padding: 6px 8px;
        min-height: 44px;
    }
    .deal-card-title {
        font-size: 0.7rem;
    }
    .deal-stage-select {
        min-width: 60px;
        font-size: 0.55rem;
    }
    .topbar {
        padding: 10px 12px;
        gap: 8px;
    }
    .topbar-title {
        font-size: 0.9rem;
    }
    .theme-toggle {
        width: 40px;
        height: 22px;
    }
    .theme-toggle .toggle-knob {
        width: 16px;
        height: 16px;
        font-size: 9px;
    }
    body.light-theme .theme-toggle .toggle-knob {
        transform: translateX(18px);
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .stat-card {
        padding: 10px;
    }
    .stat-value {
        font-size: 1.2rem;
    }
    .stat-icon {
        font-size: 1.2rem;
        margin-bottom: 6px;
    }
}