:root {
    --bg-app: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-hover: #f8fafc;
    --border: #e2e8f0;

    --text-main: #0f172a;
    --text-muted: #64748b;

    --primary: #2563eb;
    --primary-hover: #1d4ed8;

    --green: #16a34a;
    --amber: #d97706;
    --red: #dc2626;
    --blue: #2563eb;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);

    --font-ui: 'Inter', system-ui, sans-serif;
    --sidebar-w: 240px;
}

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

body {
    font-family: var(--font-ui);
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.5;
}

/* Layout */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-w);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.brand {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.brand h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.logo {
    background: var(--primary);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.main-nav {
    padding: 1rem 0;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-main);
}

.nav-item.active {
    background-color: var(--bg-hover);
    color: var(--primary);
    border-left-color: var(--primary);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
}

.w-full {
    width: 100%;
    justify-content: center;
}

.main-content {
    flex: 1;
    overflow-y: auto;
    position: relative;
}

.view-section {
    display: none;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.view-section.active {
    display: block;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.stat-card h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
}

.text-green {
    color: var(--green);
}

.text-amber {
    color: var(--amber);
}

.text-blue {
    color: var(--blue);
}

.text-red {
    color: var(--red);
}

.text-muted {
    color: var(--text-muted);
}

/* Dashboard Panels */
.dashboard-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.panel h2 {
    padding: 1.25rem 1.5rem;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-hover);
    margin: 0;
}

.panel-content {
    padding: 0;
}

.list-item {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-item:last-child {
    border-bottom: none;
}

.list-item:hover {
    background: var(--bg-hover);
    cursor: pointer;
}

.item-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.item-title {
    font-weight: 600;
    color: var(--text-main);
}

.item-val {
    font-weight: 600;
}

.empty-state {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge.overdue {
    background: #fee2e2;
    color: var(--red);
}

.badge.due-soon {
    background: #fef3c7;
    color: var(--amber);
}

/* Kanban Board */
#view-pipeline {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.kanban-board {
    display: flex;
    gap: 1.25rem;
    flex: 1;
    overflow-x: auto;
    padding-bottom: 1rem;
}

.kanban-col {
    flex: 1;
    min-width: 260px;
    background: #e2e8f0;
    /* Slightly darker than app bg for contrast */
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

.kanban-header {
    padding: 1rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid rgba(0, 0, 0, 0.05);
}

.col-count {
    background: var(--bg-surface);
    padding: 0.1rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.kanban-cards {
    padding: 0.75rem;
    flex: 1;
    overflow-y: auto;
    min-height: 150px;
}

/* Kanban Card */
.k-card {
    background: var(--bg-surface);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    cursor: grab;
    user-select: none;
}

.k-card:active {
    cursor: grabbing;
    box-shadow: var(--shadow-md);
    transform: scale(1.02);
}

.k-card.dragging {
    opacity: 0.5;
}

.k-client {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.k-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.k-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.k-val {
    font-weight: 600;
    color: var(--green);
}

/* Clients Grid */
.clients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.client-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.client-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.client-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.client-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.client-meta svg {
    color: var(--text-muted);
}

/* Buttons & Inputs */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    font-family: var(--font-ui);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-outline {
    background: var(--bg-surface);
    border-color: var(--border);
    color: var(--text-main);
}

.btn-outline:hover {
    background: var(--bg-hover);
}

.btn-danger {
    background: #fee2e2;
    color: var(--red);
    border-color: #fecaca;
}

.btn-danger:hover {
    background: #fca5a5;
}

.input-text,
.input-select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-surface);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s;
}

.input-text:focus,
.input-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--bg-surface);
    width: 100%;
    max-width: 500px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.25rem;
}

.btn-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
}

.btn-close:hover {
    color: var(--text-main);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
}

.form-row {
    display: flex;
    gap: 1rem;
}

.flex-1 {
    flex: 1;
}

.modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-hover);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    border-radius: 0 0 12px 12px;
}

.mr-auto {
    margin-right: auto;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-main);
    color: var(--bg-surface);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
        overflow: visible;
        height: auto;
    }

    .sidebar {
        width: 100%;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 0.5rem 1rem;
    }

    .brand {
        border: none;
        padding: 0;
    }

    .main-nav {
        display: none;
    }

    /* Could implement mobile menu */
    .sidebar-footer {
        display: none;
    }

    .view-section {
        padding: 1rem;
    }

    .dashboard-panels {
        grid-template-columns: 1fr;
    }

    .kanban-board {
        flex-direction: column;
        gap: 1rem;
    }

    .kanban-col {
        min-height: 250px;
    }
}