/* ═══════════════════════════════════════════════════════
   BidacorOS — Client Tracker
   Design tokens from landing page
   ═══════════════════════════════════════════════════════ */

:root {
    --ink: #0a0f1a;
    --paper: #f8f6f1;
    --accent: #1a5c3a;
    --accent-light: #2d8f5e;
    --accent-bg: rgba(26, 92, 58, 0.06);
    --warm: #c4956a;
    --warm-light: #f0e4d6;
    --muted: #6b7280;
    --border: #d6d0c4;
    --white: #ffffff;
    --red: #dc2626;
    --red-bg: #fef2f2;
    --orange: #d97706;
    --orange-bg: #fffbeb;
    --blue: #2563eb;
    --blue-bg: #eff6ff;
    --green: #16a34a;
    --green-bg: #f0fdf4;
    --gray-bg: #f3f2ee;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
    --radius: 6px;
    --radius-lg: 10px;
}

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

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--paper);
    color: var(--ink);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ─── Top Navigation ─────────────────────────────────── */

.top-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    padding: 0 24px;
    height: 60px;
    gap: 32px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--ink);
    flex-shrink: 0;
}

.brand-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--accent);
    color: var(--white);
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 16px;
    border-radius: 6px;
}

.brand-text {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 17px;
    letter-spacing: -0.3px;
}

.nav-tabs {
    display: flex;
    gap: 4px;
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    background: transparent;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    border-radius: var(--radius);
    transition: all 0.15s;
}

.nav-tab:hover {
    background: var(--gray-bg);
    color: var(--ink);
}

.nav-tab.active {
    background: var(--accent-bg);
    color: var(--accent);
}

.nav-tab svg {
    flex-shrink: 0;
}

.nav-right {
    margin-left: auto;
}

.nav-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--muted);
    opacity: 0.6;
}

/* ─── Main Content ───────────────────────────────────── */

#app-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
    min-height: calc(100vh - 60px);
}

/* ─── Page Header ────────────────────────────────────── */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--ink);
}

.page-subtitle {
    font-size: 0.9rem;
    color: var(--muted);
    margin-top: 2px;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ─── Buttons ────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border: 1px solid var(--border);
    background: var(--white);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn:hover {
    background: var(--gray-bg);
    border-color: #bbb5a8;
}

.btn-primary {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-light);
    border-color: var(--accent-light);
}

.btn-danger {
    color: var(--red);
    border-color: var(--red);
}

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

.btn-sm {
    padding: 5px 12px;
    font-size: 13px;
}

.btn-ghost {
    border: none;
    background: transparent;
    color: var(--muted);
    padding: 6px 10px;
}

.btn-ghost:hover {
    color: var(--ink);
    background: var(--gray-bg);
}

/* ─── Search & Filter Bar ────────────────────────────── */

.toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    background: var(--white);
    color: var(--ink);
    outline: none;
    transition: border-color 0.15s;
}

.search-input:focus {
    border-color: var(--accent);
}

.search-input::placeholder {
    color: #b5b0a4;
}

.filter-select {
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    background: var(--white);
    color: var(--ink);
    outline: none;
    cursor: pointer;
    min-width: 160px;
}

.filter-select:focus {
    border-color: var(--accent);
}

/* ─── Stats Row ──────────────────────────────────────── */

.stats-row {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.stat-card {
    flex: 1;
    min-width: 140px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.stat-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

/* ─── Table ──────────────────────────────────────────── */

.table-wrap {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--muted);
    text-align: left;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--gray-bg);
}

.data-table td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid rgba(214, 208, 196, 0.4);
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: rgba(26, 92, 58, 0.02);
}

.client-name {
    font-weight: 600;
    color: var(--ink);
}

.client-contact {
    font-size: 13px;
    color: var(--muted);
    margin-top: 2px;
}

.cell-actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}

/* ─── Badges ─────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.badge-prospect { background: var(--orange-bg); color: var(--orange); }
.badge-active { background: var(--green-bg); color: var(--green); }
.badge-on_hold { background: var(--gray-bg); color: var(--muted); }
.badge-completed { background: var(--blue-bg); color: var(--blue); }
.badge-churned { background: var(--red-bg); color: var(--red); }

.badge-upcoming { background: var(--blue-bg); color: var(--blue); }
.badge-in_progress { background: var(--orange-bg); color: var(--orange); }
.badge-overdue { background: var(--red-bg); color: var(--red); }

.badge-tax_filing { background: var(--accent-bg); color: var(--accent); }
.badge-installment { background: var(--warm-light); color: #8b6540; }
.badge-gst_qst { background: var(--blue-bg); color: var(--blue); }
.badge-review { background: #f3e8ff; color: #7c3aed; }
.badge-other { background: var(--gray-bg); color: var(--muted); }

/* ─── Service Tags ───────────────────────────────────── */

.service-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.service-tag {
    display: inline-block;
    padding: 2px 8px;
    background: var(--gray-bg);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
}

/* ─── Empty State ────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 80px 24px;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 8px;
}

.empty-desc {
    font-size: 0.95rem;
    color: var(--muted);
    margin-bottom: 24px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* ─── Deadline Cards ─────────────────────────────────── */

.deadline-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.deadline-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.15s;
}

.deadline-card:hover {
    border-color: #bbb5a8;
    box-shadow: var(--shadow-sm);
}

.deadline-card.overdue {
    border-left: 3px solid var(--red);
}

.deadline-card.urgent {
    border-left: 3px solid var(--orange);
}

.deadline-date-col {
    text-align: center;
    min-width: 60px;
    flex-shrink: 0;
}

.deadline-day {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
    color: var(--ink);
}

.deadline-month {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    margin-top: 2px;
}

.deadline-info {
    flex: 1;
    min-width: 0;
}

.deadline-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--ink);
}

.deadline-client {
    font-size: 13px;
    color: var(--muted);
    margin-top: 2px;
}

.deadline-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.days-until {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.days-until.overdue { color: var(--red); }
.days-until.urgent { color: var(--orange); }
.days-until.normal { color: var(--muted); }

/* ─── Month Group Headers ────────────────────────────── */

.month-group {
    margin-bottom: 28px;
}

.month-header {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--warm);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* ─── Modal ──────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 26, 0.4);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 60px 24px;
    z-index: 200;
    overflow-y: auto;
    backdrop-filter: blur(2px);
}

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

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 600px;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.modal-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 20px;
    color: var(--muted);
    cursor: pointer;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--gray-bg);
    color: var(--ink);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* ─── Form ───────────────────────────────────────────── */

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: 0.2px;
}

.form-input,
.form-select,
.form-textarea {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    color: var(--ink);
    background: var(--white);
    outline: none;
    transition: border-color 0.15s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--accent);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-hint {
    font-size: 12px;
    color: var(--muted);
}

/* ─── Checkbox Group ─────────────────────────────────── */

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.checkbox-item input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}

.checkbox-item label {
    font-size: 13px;
    color: var(--ink);
    cursor: pointer;
}

/* ─── Fiscal Year Selector ───────────────────────────── */

.fy-row {
    display: flex;
    gap: 10px;
}

.fy-row .form-select {
    flex: 1;
}

/* ─── Confirm Dialog ─────────────────────────────────── */

.confirm-msg {
    font-size: 15px;
    color: var(--ink);
    margin-bottom: 8px;
    line-height: 1.6;
}

.confirm-warn {
    font-size: 13px;
    color: var(--muted);
}

/* ─── Toast ──────────────────────────────────────────── */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    background: var(--ink);
    color: var(--white);
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    animation: toastIn 0.25s ease;
    max-width: 360px;
}

.toast.success { background: var(--accent); }
.toast.error { background: var(--red); }

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

/* ─── Responsive ─────────────────────────────────────── */

@media (max-width: 768px) {
    .nav-inner {
        padding: 0 16px;
    }

    .nav-label {
        display: none;
    }

    #app-main {
        padding: 20px 16px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

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

    .stats-row {
        flex-direction: column;
    }

    .data-table {
        font-size: 13px;
    }

    .data-table th,
    .data-table td {
        padding: 10px 12px;
    }

    .hide-mobile {
        display: none;
    }

    .deadline-card {
        flex-wrap: wrap;
    }

    .deadline-meta {
        width: 100%;
        justify-content: flex-end;
    }
}

@media (max-width: 480px) {
    .toolbar {
        flex-direction: column;
    }

    .search-input,
    .filter-select {
        min-width: unset;
    }
}
