/*
 * CT Flat Roofing — Operations Platform v2
 * High-spec design system: desktop-first, responsive, professional
 */

/* ── CSS Custom Properties ── */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --primary-bg: #eff6ff;
    --primary-border: #bfdbfe;
    --accent: #f97316;
    --accent-dark: #ea580c;
    --purple: #7c3aed;
    --purple-bg: #f5f3ff;
    --purple-border: #ddd6fe;

    --bg: #f1f5f9;
    --bg-card: #ffffff;
    --bg-dark: #0f172a;
    --bg-sidebar: #111827;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-white: #ffffff;

    --success: #16a34a;
    --success-bg: #f0fdf4;
    --success-border: #bbf7d0;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --warning-border: #fde68a;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --danger-border: #fecaca;
    --info: #0284c7;
    --info-bg: #f0f9ff;
    --info-border: #bae6fd;

    --nav-height: 56px;
    --bottom-nav-height: 68px;
    --sidebar-width: 260px;
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.12);

    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Monaco, monospace;

    --transition: 0.15s ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; scroll-behavior: smooth; }
body { font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.55; min-height: 100dvh; overflow-x: hidden; -webkit-font-smoothing: antialiased; }
img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }
table { border-collapse: collapse; width: 100%; }

/* ── Typography ── */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.25; color: var(--text); }
h1 { font-size: 1.6rem; letter-spacing: -0.02em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: 0.95rem; }

.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.text-purple { color: var(--purple); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-mono { font-family: var(--font-mono); }

.big-number { font-size: 1.85rem; font-weight: 800; line-height: 1.1; letter-spacing: -0.03em; }
.label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.subtext { font-size: 0.8rem; color: var(--text-secondary); }

/* ── App Layout ── */
.app { display: flex; min-height: 100dvh; }
.app-main { flex: 1; display: flex; flex-direction: column; min-height: 100dvh; width: 100%; }

/* ── Sidebar ── */
.sidebar {
    display: none; width: var(--sidebar-width); background: var(--bg-sidebar);
    color: var(--text-white); flex-shrink: 0; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 200; overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 0; }

.sidebar-logo {
    padding: 20px 24px; border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex; align-items: center; gap: 12px;
}
.sidebar-logo img { height: 36px; width: auto; }
.sidebar-logo .logo-text { font-size: 0.85rem; font-weight: 700; color: var(--text-white); line-height: 1.2; }
.sidebar-logo .logo-sub { font-size: 0.6rem; color: rgba(255,255,255,0.4); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }

.sidebar-section { padding: 16px 0 8px; }
.sidebar-section-label {
    padding: 0 24px 8px; font-size: 0.6rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.1em; color: rgba(255,255,255,0.3);
}

.sidebar-nav { flex: 1; padding: 8px 0; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 12px; padding: 9px 24px;
    color: rgba(255,255,255,0.55); font-size: 0.85rem; font-weight: 500;
    transition: all var(--transition); border-left: 3px solid transparent; position: relative;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.04); color: rgba(255,255,255,0.9); }
.sidebar-nav a.active { background: rgba(255,255,255,0.08); color: var(--text-white); border-left-color: var(--primary-light); font-weight: 600; }
.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }
.sidebar-nav a.active svg { opacity: 1; }

.nav-badge {
    position: absolute; right: 16px; background: var(--danger); color: white;
    font-size: 0.6rem; font-weight: 700; padding: 2px 6px; border-radius: 10px; min-width: 18px; text-align: center;
}

.sidebar-footer {
    padding: 16px 24px; border-top: 1px solid rgba(255,255,255,0.08);
    display: flex; align-items: center; justify-content: space-between;
}
.sidebar-footer .user-name { font-size: 0.8rem; color: rgba(255,255,255,0.6); font-weight: 500; }
.sidebar-footer a { color: rgba(255,255,255,0.4); font-size: 0.75rem; }
.sidebar-footer a:hover { color: rgba(255,255,255,0.7); }

/* ── Top Bar ── */
.top-bar {
    position: sticky; top: 0; z-index: 100; display: flex; align-items: center;
    justify-content: space-between; height: var(--nav-height); padding: 0 var(--space-lg);
    background: var(--bg-card); border-bottom: 1px solid var(--border);
}
.top-bar-left { display: flex; align-items: center; gap: 16px; }
.top-bar-title { font-size: 1rem; font-weight: 700; }
.top-bar-right { display: flex; align-items: center; gap: 12px; }

/* ── Breadcrumbs ── */
.breadcrumbs {
    display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--text-muted);
}
.breadcrumbs a { color: var(--text-muted); font-weight: 500; }
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs .sep { color: var(--border); }
.breadcrumbs .current { color: var(--text); font-weight: 600; }

/* ── Search Bar ── */
.search-bar {
    position: relative; width: 280px;
}
.search-bar input {
    width: 100%; padding: 8px 12px 8px 36px; border: 1.5px solid var(--border);
    border-radius: var(--radius); font-size: 0.85rem; font-family: var(--font);
    color: var(--text); background: var(--bg); transition: all var(--transition);
}
.search-bar input:focus { outline: none; border-color: var(--primary); background: var(--bg-card); box-shadow: 0 0 0 3px var(--primary-bg); }
.search-bar input::placeholder { color: var(--text-muted); }
.search-bar .search-icon {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px; color: var(--text-muted); pointer-events: none;
}
.search-bar kbd {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 4px;
    padding: 1px 6px; font-size: 0.65rem; color: var(--text-muted); font-family: var(--font);
}
.search-results {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
    max-height: 400px; overflow-y: auto; display: none; z-index: 500;
}
.search-results.active { display: block; }
.search-results-group { padding: 8px 0; }
.search-results-label { padding: 4px 14px; font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.search-result-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 14px;
    color: var(--text); text-decoration: none; transition: background var(--transition); cursor: pointer;
}
.search-result-item:hover, .search-result-item.highlighted { background: var(--primary-bg); }
.search-result-item .result-title { font-size: 0.85rem; font-weight: 600; }
.search-result-item .result-sub { font-size: 0.75rem; color: var(--text-muted); }
.search-no-results { padding: 16px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }

/* ── Action Badge (top bar) ── */
.action-badge-btn {
    position: relative; background: none; border: none; cursor: pointer; padding: 6px;
    color: var(--text-secondary); border-radius: var(--radius-sm); transition: background var(--transition);
}
.action-badge-btn:hover { background: var(--bg); }
.action-badge-btn svg { width: 20px; height: 20px; }
.action-badge-count {
    position: absolute; top: 0; right: 0; background: var(--danger); color: white;
    font-size: 0.55rem; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* ── Content Area ── */
.content {
    flex: 1; padding: var(--space-md); padding-bottom: calc(var(--bottom-nav-height) + var(--space-lg));
    width: 100%; margin: 0 auto;
}

/* ── Page Header ── */
.page-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    margin-bottom: var(--space-lg); gap: var(--space-md); flex-wrap: wrap;
}
.page-header h1 { font-size: 1.4rem; }
.page-subtitle { font-size: 0.85rem; color: var(--text-secondary); margin-top: 2px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ── Cards ── */
.card {
    background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow);
    overflow: hidden; border: 1px solid var(--border);
}
.card-body { padding: var(--space-lg); }
.card-header {
    padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 0.95rem; }
.card-footer { padding: var(--space-md) var(--space-lg); border-top: 1px solid var(--border-light); background: var(--bg); }
.card + .card { margin-top: var(--space-md); }
.card-sm .card-body { padding: var(--space-md); }

/* ── Stat Cards ── */
.stats-grid {
    display: grid; grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md); margin-bottom: var(--space-lg);
}
.stat-card {
    background: var(--bg-card); border-radius: var(--radius); padding: var(--space-lg);
    box-shadow: var(--shadow); border: 1px solid var(--border); position: relative; overflow: hidden;
}
.stat-card .label { margin-bottom: 6px; }
.stat-card .big-number { margin-bottom: 4px; }
.stat-card .stat-sub { font-size: 0.78rem; color: var(--text-secondary); }
.stat-card .stat-icon {
    position: absolute; top: 16px; right: 16px; width: 40px; height: 40px;
    border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center;
    opacity: 0.15;
}
.stat-card .stat-icon svg { width: 24px; height: 24px; }

.stat-card.highlight { background: var(--primary); color: white; border-color: var(--primary-dark); }
.stat-card.highlight .label { color: rgba(255,255,255,0.8); }
.stat-card.highlight .big-number { color: white; }
.stat-card.highlight .stat-sub { color: rgba(255,255,255,0.8); }

.stat-card.success-accent { border-left: 4px solid var(--success); }
.stat-card.warning-accent { border-left: 4px solid var(--warning); }
.stat-card.danger-accent { border-left: 4px solid var(--danger); }
.stat-card.info-accent { border-left: 4px solid var(--info); }
.stat-card.purple-accent { border-left: 4px solid var(--purple); }

/* ── Pipeline Bar ── */
.pipeline-bar {
    display: flex; gap: 2px; margin-bottom: var(--space-lg);
    background: var(--bg); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border);
}
.pipeline-stage {
    flex: 1; padding: 14px 10px; text-align: center; background: var(--bg-card);
    cursor: pointer; transition: all var(--transition); text-decoration: none; color: var(--text);
    border-right: 1px solid var(--border);
}
.pipeline-stage:last-child { border-right: none; }
.pipeline-stage:hover { background: var(--primary-bg); }
.pipeline-stage.active { background: var(--primary); color: white; }
.pipeline-stage .stage-count { font-size: 1.5rem; font-weight: 800; display: block; line-height: 1; }
.pipeline-stage .stage-label { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 4px; display: block; opacity: 0.7; }
.pipeline-stage.active .stage-label { opacity: 1; }

/* ── Data Tables ── */
.data-table { width: 100%; }
.data-table thead th {
    padding: 10px 14px; text-align: left; font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted);
    border-bottom: 2px solid var(--border); background: var(--bg); white-space: nowrap;
    cursor: pointer; user-select: none; position: sticky; top: 0; z-index: 1;
}
.data-table thead th:hover { color: var(--text); }
.data-table thead th .sort-icon { display: inline-block; margin-left: 4px; opacity: 0.3; font-size: 0.6rem; }
.data-table thead th.sorted .sort-icon { opacity: 1; color: var(--primary); }

.data-table tbody tr {
    border-bottom: 1px solid var(--border-light); transition: background var(--transition); cursor: pointer;
}
.data-table tbody tr:hover { background: var(--primary-bg); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody td {
    padding: 12px 14px; font-size: 0.88rem; vertical-align: middle;
}
.data-table .col-ref { font-weight: 700; font-family: var(--font-mono); font-size: 0.82rem; color: var(--primary); white-space: nowrap; }
.data-table .col-money { font-weight: 700; text-align: right; font-family: var(--font-mono); white-space: nowrap; }
.data-table .col-date { white-space: nowrap; color: var(--text-secondary); font-size: 0.82rem; }
.data-table .col-actions { text-align: right; white-space: nowrap; }
.data-table .col-narrow { width: 1%; white-space: nowrap; }

.data-table .row-profit-positive .col-money.col-profit { color: var(--success); }
.data-table .row-profit-negative .col-money.col-profit { color: var(--danger); }

/* Table filter row */
.table-filter {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin-bottom: var(--space-md); flex-wrap: wrap;
}
.table-filter-search {
    position: relative; flex: 1; min-width: 200px; max-width: 320px;
}
.table-filter-search input {
    width: 100%; padding: 8px 12px 8px 34px; border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); font-size: 0.85rem; font-family: var(--font);
    background: var(--bg-card); color: var(--text); transition: all var(--transition);
}
.table-filter-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }
.table-filter-search .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-muted); pointer-events: none; }

/* ── List Items ── */
.list { display: flex; flex-direction: column; }
.list-item {
    display: flex; align-items: center; gap: var(--space-md); padding: 12px var(--space-md);
    border-bottom: 1px solid var(--border-light); text-decoration: none;
    color: var(--text); transition: background var(--transition);
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--bg); }
.list-item-content { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-sub { font-size: 0.78rem; color: var(--text-secondary); margin-top: 1px; }
.list-item-value { font-weight: 700; font-size: 0.95rem; text-align: right; white-space: nowrap; }
.list-item-value small { display: block; font-size: 0.72rem; font-weight: 500; color: var(--text-muted); }

/* ── Badges ── */
.badge {
    display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px;
    font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.badge-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.badge-info { background: var(--info-bg); color: var(--info); border: 1px solid var(--info-border); }
.badge-neutral { background: var(--bg); color: var(--text-secondary); border: 1px solid var(--border); }
.badge-purple { background: var(--purple-bg); color: var(--purple); border: 1px solid var(--purple-border); }
.badge-primary { background: var(--primary-bg); color: var(--primary); border: 1px solid var(--primary-border); }

.badge-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.badge-dot.green { background: var(--success); }
.badge-dot.amber { background: var(--warning); }
.badge-dot.red { background: var(--danger); }
.badge-dot.blue { background: var(--primary); }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 18px; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 600;
    font-family: var(--font); border: none; cursor: pointer; text-decoration: none;
    transition: all var(--transition); white-space: nowrap; -webkit-tap-highlight-color: transparent; line-height: 1.4;
}
.btn:active { transform: scale(0.97); }
.btn svg { width: 16px; height: 16px; }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #b45309; color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; color: white; }
.btn-purple { background: var(--purple); color: white; }
.btn-purple:hover { background: #6d28d9; color: white; }

.btn-outline { background: transparent; color: var(--text-secondary); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--text-secondary); color: var(--text); background: var(--bg); }
.btn-ghost { background: transparent; color: var(--text-secondary); padding: 8px 12px; }
.btn-ghost:hover { background: var(--bg); }
.btn-white { background: white; color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); }
.btn-white:hover { background: var(--bg); color: var(--text); }

.btn-sm { padding: 5px 12px; font-size: 0.78rem; }
.btn-xs { padding: 3px 8px; font-size: 0.7rem; border-radius: 4px; }
.btn-lg { padding: 12px 24px; font-size: 0.95rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; }
.btn-icon.btn-sm { padding: 5px; }

.btn-group { display: inline-flex; gap: 1px; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ── Forms ── */
.form-group { margin-bottom: var(--space-md); }
.form-label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-label .required { color: var(--danger); margin-left: 2px; }

.form-input, .form-select, .form-textarea {
    width: 100%; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.92rem; font-family: var(--font); color: var(--text); background: var(--bg-card);
    transition: border-color var(--transition), box-shadow var(--transition); appearance: none; -webkit-appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg);
}
.form-input::placeholder { color: var(--text-muted); }
.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; padding-right: 36px;
}
.form-textarea { min-height: 80px; resize: vertical; }
.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 0.75rem; color: var(--danger); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-md); }

.form-prefix { position: relative; }
.form-prefix .prefix {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-weight: 600; font-size: 0.95rem; pointer-events: none;
}
.form-prefix .form-input { padding-left: 28px; }

.form-inline { display: flex; align-items: center; gap: 8px; }
.form-inline .form-input { flex: 1; }

/* ── File Upload ── */
.file-upload {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: var(--space-xl) var(--space-md); border: 2px dashed var(--border); border-radius: var(--radius);
    background: var(--bg); cursor: pointer; transition: all var(--transition); text-align: center;
}
.file-upload:hover { border-color: var(--primary); background: var(--primary-bg); }
.file-upload input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-upload svg { width: 28px; height: 28px; color: var(--text-muted); margin-bottom: var(--space-sm); }
.file-upload-text { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.file-upload-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.file-preview { margin-top: var(--space-md); display: none; }
.file-preview.active { display: block; }
.file-preview img { max-width: 200px; max-height: 200px; border-radius: var(--radius-sm); object-fit: cover; }

/* ── Flash Messages ── */
.flash {
    padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: var(--space-md);
    font-size: 0.85rem; font-weight: 500; display: flex; align-items: center; gap: 8px;
    animation: flashIn 0.3s ease;
}
.flash-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.flash-error { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.flash-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.flash-info { background: var(--info-bg); color: var(--info); border: 1px solid var(--info-border); }

@keyframes flashIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Filter Bar ── */
.filter-bar { display: flex; gap: 6px; margin-bottom: var(--space-md); overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.filter-chip {
    padding: 6px 14px; border-radius: 20px; font-size: 0.78rem; font-weight: 600;
    color: var(--text-secondary); background: var(--bg-card); border: 1.5px solid var(--border);
    white-space: nowrap; cursor: pointer; transition: all var(--transition); text-decoration: none; font-family: var(--font);
}
.filter-chip.active, .filter-chip:hover { background: var(--primary); color: white; border-color: var(--primary); }
.filter-chip .chip-count {
    display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px;
    background: rgba(0,0,0,0.08); border-radius: 9px; font-size: 0.65rem; padding: 0 5px; margin-left: 4px;
}
.filter-chip.active .chip-count { background: rgba(255,255,255,0.25); }

/* ── Tabs ── */
.tabs {
    display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: var(--space-lg);
    overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.tab {
    padding: 10px 18px; font-size: 0.85rem; font-weight: 600; text-align: center;
    color: var(--text-muted); background: transparent; border: none; cursor: pointer;
    white-space: nowrap; transition: all var(--transition); font-family: var(--font);
    border-bottom: 2px solid transparent; margin-bottom: -2px; position: relative;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab:hover:not(.active) { color: var(--text); }
.tab .tab-count { font-size: 0.7rem; color: var(--text-muted); margin-left: 4px; }
.tab.active .tab-count { color: var(--primary); }

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Pipeline Progress (job detail) ── */
.pipeline-progress {
    display: flex; align-items: center; gap: 0; margin-bottom: var(--space-lg);
    background: var(--bg); border-radius: var(--radius); padding: 4px; border: 1px solid var(--border);
}
.pipeline-step {
    flex: 1; text-align: center; padding: 8px 6px; font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted);
    border-radius: var(--radius-sm); transition: all var(--transition); position: relative;
}
.pipeline-step.completed { color: var(--success); background: var(--success-bg); }
.pipeline-step.current { color: white; background: var(--primary); }
.pipeline-step.upcoming { color: var(--text-muted); }

/* ── Profit / Loss ── */
.profit-positive { color: var(--success); }
.profit-negative { color: var(--danger); }

.profit-bar { height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; }
.profit-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }
.profit-bar-fill.good { background: var(--success); }
.profit-bar-fill.ok { background: var(--warning); }
.profit-bar-fill.bad { background: var(--danger); }

.budget-bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; margin-top: 6px; }
.budget-bar-fill { height: 100%; border-radius: 3px; transition: width 0.6s ease; }

/* ── Activity Timeline ── */
.timeline { padding: 0; margin: 0; list-style: none; }
.timeline-item {
    display: flex; gap: 12px; padding: 10px 0; position: relative;
}
.timeline-dot {
    width: 10px; height: 10px; border-radius: 50%; background: var(--border); flex-shrink: 0; margin-top: 5px;
    border: 2px solid var(--bg-card); box-shadow: 0 0 0 2px var(--border);
}
.timeline-dot.green { background: var(--success); box-shadow: 0 0 0 2px var(--success-border); }
.timeline-dot.blue { background: var(--primary); box-shadow: 0 0 0 2px var(--primary-border); }
.timeline-dot.amber { background: var(--warning); box-shadow: 0 0 0 2px var(--warning-border); }
.timeline-dot.red { background: var(--danger); box-shadow: 0 0 0 2px var(--danger-border); }

.timeline-content { flex: 1; }
.timeline-text { font-size: 0.85rem; color: var(--text); }
.timeline-text strong { font-weight: 600; }
.timeline-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

/* ── Section Headers ── */
.section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: var(--space-md); margin-top: var(--space-xl);
}
.section-header:first-child { margin-top: 0; }
.section-header h2 { font-size: 1.05rem; }

/* ── Empty State ── */
.empty-state { text-align: center; padding: var(--space-2xl) var(--space-lg); color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; margin: 0 auto var(--space-md); opacity: 0.4; }
.empty-state h3 { color: var(--text-secondary); margin-bottom: var(--space-sm); font-size: 1rem; }
.empty-state p { font-size: 0.85rem; margin-bottom: var(--space-md); max-width: 320px; margin-inline: auto; }

/* ── Metric Boxes (inline) ── */
.metrics-row {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
    background: var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: var(--space-lg);
    border: 1px solid var(--border);
}
.metric-box { background: var(--bg-card); padding: 16px; text-align: center; }
.metric-box .label { margin-bottom: 4px; }
.metric-box .metric-value { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.02em; }

/* ── Action Cards ── */
.action-card {
    display: flex; align-items: center; gap: 14px; padding: 14px 16px;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    transition: all var(--transition); text-decoration: none; color: var(--text);
}
.action-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-1px); color: var(--text); }
.action-card .action-icon {
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.action-card .action-icon svg { width: 20px; height: 20px; }
.action-card .action-text { flex: 1; }
.action-card .action-title { font-weight: 600; font-size: 0.88rem; }
.action-card .action-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 1px; }
.action-card .action-arrow { color: var(--text-muted); }
.action-card .action-arrow svg { width: 16px; height: 16px; }

/* ── Profit Summary ── */
.profit-summary {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px;
    background: var(--border-light); border-radius: var(--radius); overflow: hidden; margin-bottom: var(--space-md);
}
.profit-summary-item { background: var(--bg-card); padding: var(--space-md); text-align: center; }
.profit-summary-item:first-child { grid-column: 1 / -1; }
.profit-summary-item .label { margin-bottom: 4px; }

/* ── Receipt Image ── */
.receipt-thumb {
    width: 40px; height: 40px; border-radius: var(--radius-sm); object-fit: cover;
    border: 1px solid var(--border); cursor: pointer;
}
.receipt-full {
    position: fixed; inset: 0; z-index: 500; background: rgba(0,0,0,0.9);
    display: flex; align-items: center; justify-content: center; padding: var(--space-md);
    opacity: 0; visibility: hidden; transition: all 0.2s ease;
}
.receipt-full.active { opacity: 1; visibility: visible; }
.receipt-full img { max-width: 100%; max-height: 90vh; border-radius: var(--radius); }
.receipt-full-close {
    position: absolute; top: var(--space-md); right: var(--space-md);
    color: white; background: rgba(255,255,255,0.2); border: none; border-radius: 50%;
    width: 40px; height: 40px; font-size: 1.5rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}

/* ── Modal / Slide Panel ── */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 400;
    opacity: 0; visibility: hidden; transition: all 0.2s ease;
}
.modal-overlay.active { opacity: 1; visibility: visible; }

.slide-panel {
    position: fixed; top: 0; right: 0; bottom: 0; width: 480px; max-width: 100vw;
    background: var(--bg-card); z-index: 401; transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
}
.modal-overlay.active .slide-panel { transform: translateX(0); }
.slide-panel-header {
    padding: 20px 24px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.slide-panel-header h2 { font-size: 1.1rem; }
.slide-panel-body { flex: 1; overflow-y: auto; padding: 24px; }
.slide-panel-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── Bottom Navigation (Mobile) ── */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-around;
    height: var(--bottom-nav-height); background: var(--bg-card);
    border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    padding: 6px 12px; color: var(--text-muted); font-size: 0.6rem; font-weight: 600;
    text-decoration: none; background: none; border: none; cursor: pointer;
    -webkit-tap-highlight-color: transparent; transition: color var(--transition); min-width: 52px;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--primary); }
.nav-item:hover { color: var(--primary); }

.nav-add { position: relative; margin-top: -16px; }
.nav-add-btn {
    width: 48px; height: 48px; border-radius: 50%; background: var(--primary); color: white;
    display: flex; align-items: center; justify-content: center;
    border: 3px solid var(--bg-card); box-shadow: var(--shadow-md);
    transition: transform 0.2s ease, background var(--transition);
}
.nav-add-btn:active { transform: scale(0.95); }
.nav-add-btn svg { width: 24px; height: 24px; }
.nav-add span { margin-top: 2px; }

/* ── Quick Add Sheet (Mobile) ── */
.quick-add-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 300;
    opacity: 0; visibility: hidden; transition: all 0.2s ease;
}
.quick-add-overlay.active { opacity: 1; visibility: visible; }
.quick-add-sheet {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 301;
    background: var(--bg-card); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: var(--space-md) var(--space-md) var(--space-xl);
    padding-bottom: calc(var(--space-xl) + env(safe-area-inset-bottom, 0));
    transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
.quick-add-overlay.active .quick-add-sheet { transform: translateY(0); }
.quick-add-handle { width: 36px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto var(--space-md); }
.quick-add-title { font-size: 1rem; font-weight: 700; margin-bottom: var(--space-md); text-align: center; }
.quick-add-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-sm); }
.quick-add-item {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 12px 8px; border-radius: var(--radius); background: var(--bg);
    color: var(--text); text-decoration: none; font-size: 0.72rem; font-weight: 600;
    text-align: center; transition: background var(--transition);
}
.quick-add-item:hover { background: var(--border); color: var(--text); }
.quick-add-item .icon {
    width: 36px; height: 36px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
}
.quick-add-item .icon svg { width: 18px; height: 18px; }
.quick-add-item .icon.blue { background: var(--primary-bg); color: var(--primary); }
.quick-add-item .icon.green { background: var(--success-bg); color: var(--success); }
.quick-add-item .icon.orange { background: var(--warning-bg); color: var(--warning); }
.quick-add-item .icon.red { background: var(--danger-bg); color: var(--danger); }
.quick-add-item .icon.purple { background: var(--purple-bg); color: var(--purple); }
.quick-add-item .icon.slate { background: var(--bg); color: var(--text-secondary); }

/* ── Login Page ── */
.login-page {
    min-height: 100dvh; display: flex; align-items: center; justify-content: center;
    padding: var(--space-md); background: #d1d5db; position: relative;
}
.login-card {
    max-width: 400px; width: 100%; background: #ffffff; border-radius: 16px;
    overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 4px 16px rgba(0,0,0,0.1);
}
.login-brand {
    background: linear-gradient(135deg, #0f1a2e 0%, #1a2d4a 100%);
    padding: 36px 32px; text-align: center;
}
.login-brand img { max-width: 200px; height: auto; margin: 0 auto 12px; }
.login-brand .brand-sub {
    font-size: 0.7rem; font-weight: 600; color: rgba(255,255,255,0.5);
    letter-spacing: 0.12em; text-transform: uppercase;
}
.login-form { padding: 32px; }
.login-error {
    background: var(--danger-bg); color: var(--danger); padding: 12px; border-radius: var(--radius-sm);
    font-size: 0.85rem; margin-bottom: var(--space-md); text-align: center; border: 1px solid var(--danger-border);
}
.login-footer { text-align: center; margin-top: var(--space-lg); font-size: 0.72rem; color: var(--text-muted); }

/* ── Chart (CSS-only bar chart) ── */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding: 0 4px; }
.bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bar-wrapper { flex: 1; display: flex; align-items: flex-end; gap: 2px; width: 100%; }
.bar {
    flex: 1; border-radius: 3px 3px 0 0; min-height: 2px;
    transition: height 0.5s ease;
}
.bar.revenue { background: var(--success); }
.bar.costs { background: var(--danger); opacity: 0.7; }
.bar-label { font-size: 0.6rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; }

/* ── Utilities ── */
.mt-0 { margin-top: 0; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.p-0 { padding: 0; }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.rounded { border-radius: var(--radius); }
.border { border: 1px solid var(--border); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-md); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-md); }

/* ── Responsive ── */
@media (min-width: 768px) {
    html { font-size: 14px; }
    .sidebar { display: flex; }
    .app-main { margin-left: var(--sidebar-width); }
    .bottom-nav, .quick-add-overlay, .quick-add-sheet { display: none; }
    .content { padding: var(--space-xl) var(--space-xl); padding-bottom: var(--space-xl); }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .metrics-row { grid-template-columns: repeat(4, 1fr); }
    h1 { font-size: 1.6rem; }
    .big-number { font-size: 2rem; }
    .top-bar { padding: 0 var(--space-xl); }
    .mobile-only { display: none !important; }
    .profit-summary { grid-template-columns: repeat(4, 1fr); }
    .profit-summary-item:first-child { grid-column: auto; }
}

@media (min-width: 1024px) {
    .content { padding: var(--space-xl) var(--space-2xl); max-width: 1200px; }
}

@media (min-width: 1400px) {
    .content { max-width: 1400px; }
}

@media (max-width: 767px) {
    .desktop-only { display: none !important; }
    .form-row { grid-template-columns: 1fr; }
    .form-row-3 { grid-template-columns: 1fr; }
    .metrics-row { grid-template-columns: repeat(2, 1fr); }
    .pipeline-bar { flex-wrap: wrap; }
    .pipeline-stage { min-width: 70px; }
    .data-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .search-bar { width: 100%; }
    .top-bar .search-bar { display: none; }
    .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
}

/* ── 404 Page ── */
.error-page { text-align: center; padding: var(--space-2xl); }
.error-page h1 { font-size: 4rem; color: var(--text-muted); margin-bottom: var(--space-md); }

/* ── Print Styles ── */
@media print {
    .sidebar, .bottom-nav, .top-bar, .quick-add-overlay, .btn, .page-actions, .filter-bar, .tabs { display: none !important; }
    .app-main { margin-left: 0; }
    .content { padding: 0; max-width: none; }
    .card { box-shadow: none; border: 1px solid #e5e5e5; break-inside: avoid; }
    body { background: white; font-size: 12px; color: #000; }
    .stat-card { border: 1px solid #ddd; box-shadow: none; }
    .stat-card.highlight { background: #f0f0f0; color: #000; }
    .stat-card.highlight .label, .stat-card.highlight .stat-sub { color: #555; }
    .stat-card.highlight .big-number { color: #000; }
    .badge { border: 1px solid #ccc; }
    .data-table thead th { background: #f5f5f5; }
    h1 { font-size: 1.4rem; }
    .print-header { display: block !important; text-align: center; margin-bottom: 24px; padding-bottom: 16px; border-bottom: 2px solid #000; }
    .print-header img { max-width: 160px; margin: 0 auto 8px; }
    .print-header h1 { font-size: 1.2rem; margin-bottom: 4px; }
    .print-header .print-date { font-size: 0.8rem; color: #666; }
    .no-print { display: none !important; }
}

.print-header { display: none; }
