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

/* ===== DARK FUTURISTIC VARIABLES ===== */
:root {
    --bg-dark: #0a0e1a;
    --bg-card: #111827;
    --bg-card-hover: #1a202c;
    --border-color: #1e293b;
    --border-light: #2d3748;

    --accent-cyan: #00d4ff;
    --accent-cyan-light: #00e5ff;
    --accent-cyan-glow: rgba(0, 212, 255, 0.15);
    --accent-cyan-strong-glow: rgba(0, 212, 255, 0.25);

    --secondary-indigo: #6366f1;
    --secondary-indigo-glow: rgba(99, 102, 241, 0.15);

    --text-light: #e2e8f0;
    --text-muted: #94a3b8;
    --text-darker: #64748b;

    --green: #10B981;
    --green-bg: rgba(16, 185, 129, 0.08);
    --orange: #F59E0B;
    --orange-bg: rgba(245, 158, 11, 0.08);
    --red: #EF4444;
    --red-bg: rgba(239, 68, 68, 0.08);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ===== RESET ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    background: var(--bg-dark);
    color: var(--text-light);
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
    padding-bottom: 80px;
    -webkit-font-smoothing: antialiased;
}

/* ===== AUTH SCREEN ===== */
.login-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #0a0e1a 0%, #0d1629 100%);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 1000;
    overflow-y: auto;
    padding: 24px 0;
}

.login-card {
    background: var(--bg-card);
    padding: 36px 28px;
    border-radius: 16px;
    width: 90%;
    max-width: 380px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    margin: auto 0;
    border: 1px solid var(--border-color);
    position: relative;
}

.login-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    padding: 1px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.1), rgba(99, 102, 241, 0.1));
    pointer-events: none;
}

.login-logo {
    font-size: 36px;
    margin-bottom: 8px;
}
.login-logo-img {
    width: 180px;
    height: 180px;
    border-radius: 16px;
    margin-bottom: 16px;
    object-fit: contain;
}

.login-brand {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-cyan);
    margin-bottom: 4px;
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

.login-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.login-card form {
    text-align: left;
}

.auth-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 4px;
    margin-top: 14px;
}

.auth-label:first-of-type { margin-top: 0; }

.login-card form input {
    margin-bottom: 2px;
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--secondary-indigo));
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.2);
}

.login-btn:hover {
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.4);
    transform: translateY(-2px);
}
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* OAuth Buttons */
.oauth-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
}

.oauth-google {
    background: var(--bg-card-hover);
    color: var(--text-light);
}
.oauth-google:hover {
    background: var(--bg-card);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.15);
}

.oauth-apple {
    background: #1a1a1a;
    color: #FFFFFF;
    border: 1px solid #333333;
}
.oauth-apple:hover {
    background: #2a2a2a;
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.15);
}

.auth-toggle {
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

.auth-toggle a {
    color: var(--accent-cyan);
    font-weight: 600;
    text-decoration: none;
}

.auth-toggle a:hover {
    text-decoration: underline;
}

/* ===== EMOJI & COLOR PICKERS ===== */
.emoji-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.emoji-opt {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card-hover);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}

.emoji-opt:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.2);
}
.emoji-opt.selected {
    border-color: var(--accent-cyan);
    background: rgba(0, 212, 255, 0.1);
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
}

.color-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.color-opt {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.4);
}

.color-opt:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
}
.color-opt.selected {
    border-color: var(--accent-cyan);
    transform: scale(1.15);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.4);
}

/* ===== LOGO UPLOAD ===== */
.logo-upload-area {
    margin-bottom: 8px;
}

.logo-preview-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-preview {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--bg-card-hover);
    flex-shrink: 0;
}

.logo-placeholder {
    font-size: 10px;
    color: var(--text-darker);
    text-align: center;
    line-height: 1.2;
}

.logo-preview-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.logo-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.logo-upload-btn {
    cursor: pointer;
}

.logo-remove-btn {
    background: var(--red-bg) !important;
    color: var(--red) !important;
    border-color: var(--red) !important;
}

.login-error {
    color: var(--red);
    font-size: 13px;
    margin-top: 12px;
    min-height: 20px;
}

/* ===== APP WRAPPER (hidden until auth) ===== */
.app-wrapper { display: none; }
.app-wrapper.visible { display: block; }

/* ===== TOP BAR ===== */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: linear-gradient(180deg, #111827 0%, #0d1219 100%);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s ease;
}

.topbar.topbar-hidden {
    transform: translateY(-100%);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    font-size: 20px;
}

.brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 0;
    object-fit: contain;
    background: none;
}

.brand-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent-cyan);
    letter-spacing: 0.3px;
    text-shadow: 0 0 15px rgba(0, 212, 255, 0.2);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    font-size: 13px;
    color: var(--text-muted);
}

.logout-btn {
    background: rgba(0, 212, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-light);
    padding: 5px 12px;
    border-radius: 6px;
    font-family: var(--font);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: rgba(0, 212, 255, 0.1);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.2);
}

.settings-btn {
    background: rgba(0, 212, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-light);
    padding: 5px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.settings-btn:hover {
    background: rgba(0, 212, 255, 0.1);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.2);
}

/* Settings Modal extras */
.settings-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-darker);
    margin-bottom: 8px;
}

.settings-account-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 14px;
}

.settings-provider-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.settings-provider-badge.google { background: #1e40af; color: #60a5fa; }
.settings-provider-badge.apple { background: #1a1a1a; color: #fff; }
.settings-provider-badge.email { background: var(--bg-card-hover); color: var(--text-light); }

.settings-account-email {
    color: var(--text-muted);
    font-size: 13px;
}

.settings-logout-btn {
    width: 100%;
    padding: 10px;
    background: var(--bg-card-hover);
    color: var(--text-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.settings-logout-btn:hover {
    background: var(--bg-card);
    border-color: var(--accent-cyan);
}

.settings-delete-btn {
    width: 100%;
    padding: 10px;
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid var(--red);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.settings-delete-btn:hover { background: var(--red); color: white; }
.settings-delete-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.settings-delete-btn:disabled:hover { background: var(--red-bg); color: var(--red); }

/* ===== NAVIGATION ===== */
.nav-bar {
    display: flex;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 15;
    padding: 0;
}

.nav-btn {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 10px 0 8px;
    background: none;
    border: none;
    color: var(--text-darker);
    font-family: var(--font);
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.nav-btn.active {
    color: var(--accent-cyan);
    border-bottom-color: var(--accent-cyan);
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

.nav-btn svg { flex-shrink: 0; opacity: 0.6; }
.nav-btn.active svg { opacity: 1; }

/* ===== STATS ROW ===== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 16px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px 8px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.05), transparent);
    pointer-events: none;
}

.stat-btn {
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.2s;
}

.stat-btn:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.2);
}

.stat-btn:active {
    transform: scale(0.97);
}

.stat-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent-cyan);
    line-height: 1.1;
    text-shadow: 0 0 12px rgba(0, 212, 255, 0.3);
}

.stat-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== SECTION CARDS ===== */
.section-card {
    background: var(--bg-card);
    margin: 0 16px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-cyan);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== ITEM LIST ===== */
.item-list { min-height: 40px; }

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    transition: all 0.15s;
}

.list-item:last-child { border-bottom: none; }
.list-item:hover {
    background: rgba(0, 212, 255, 0.05);
    border-bottom-color: var(--border-color);
}

.list-item-left { flex: 1; min-width: 0; }

.list-item-id {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-cyan);
    letter-spacing: 0.3px;
}

.list-item-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.list-item-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 1px;
}

.list-item-right { text-align: right; flex-shrink: 0; margin-left: 12px; }

.list-item-amount {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-cyan);
}

/* ===== STATUS BADGES ===== */
.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

.badge-active { background: rgba(16, 185, 129, 0.15); color: var(--green); }
.badge-proceed { background: rgba(99, 102, 241, 0.15); color: var(--secondary-indigo); }
.badge-quote { background: rgba(245, 158, 11, 0.15); color: var(--orange); }
.badge-lead { background: rgba(0, 212, 255, 0.15); color: var(--accent-cyan); }
.badge-delayed { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.badge-complete { background: rgba(100, 116, 139, 0.15); color: var(--text-darker); }

/* ===== FILTER ROW ===== */
.filter-row {
    display: flex;
    gap: 6px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-light);
    overflow-x: auto;
}

.filter-btn {
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.filter-btn.active {
    background: linear-gradient(135deg, var(--accent-cyan), var(--secondary-indigo));
    color: white;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
}

/* ===== FORM CARD ===== */
.form-card {
    background: var(--bg-card);
    margin: 16px;
    padding: 24px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.form-card h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-cyan);
    text-align: center;
    margin-bottom: 20px;
    text-shadow: 0 0 12px rgba(0, 212, 255, 0.2);
}

form { display: flex; flex-direction: column; gap: 14px; }

.form-section-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-darker);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
}

label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: -6px;
}

.hint {
    font-size: 12px;
    color: var(--text-darker);
    margin-top: -6px;
}

input, select, textarea {
    font-family: var(--font);
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-dark);
    color: var(--text-light);
    font-size: 15px;
    transition: all 0.2s;
    appearance: none;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px var(--accent-cyan-glow);
    background: var(--bg-card);
}

textarea { resize: none; }

select {
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

/* ===== BUTTONS ===== */
.client-select-row { display: flex; gap: 8px; }
.client-select-row select { flex: 1; }

.small-btn {
    font-family: var(--font);
    background: var(--bg-card-hover);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-cyan);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.small-btn:hover {
    border-color: var(--accent-cyan);
    background: rgba(0, 212, 255, 0.05);
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.2);
}

.save-btn {
    background: linear-gradient(135deg, var(--accent-cyan), var(--secondary-indigo));
    border: none;
    color: white;
    padding: 10px 16px;
    margin-top: 8px;
    width: 100%;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-weight: 600;
    cursor: pointer;
}

.new-client-box {
    background: var(--bg-dark);
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.action-btn {
    font-family: var(--font);
    background: linear-gradient(135deg, var(--accent-cyan), var(--secondary-indigo));
    color: white;
    padding: 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    margin-top: 8px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.2);
}

.action-btn:hover {
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.4);
    transform: translateY(-2px);
}
.action-btn:active { transform: translateY(0); }

/* ===== CHECKBOX ===== */
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 0;
}

.checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--accent-cyan);
    cursor: pointer;
}

.inline-label {
    margin: 0 !important;
    color: var(--text-light);
    font-weight: 400;
    font-size: 14px;
}

/* ===== OVERLAY ===== */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.success-card {
    background: var(--bg-card);
    padding: 36px 28px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    width: 85%;
    max-width: 360px;
    border: 1px solid var(--border-color);
}

.success-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.15);
    color: var(--green);
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
}

.success-card h3 {
    color: var(--text-light);
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.big-id {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent-cyan);
    margin: 14px 0;
    padding: 12px;
    background: rgba(0, 212, 255, 0.1);
    border-radius: var(--radius-sm);
    letter-spacing: 0.5px;
}

.success-card p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.close-btn {
    font-family: var(--font);
    background: var(--bg-card-hover);
    color: var(--text-light);
    padding: 10px 32px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.close-btn:hover {
    background: var(--bg-card);
    border-color: var(--accent-cyan);
}

/* ===== EDIT MODAL ===== */
.edit-modal {
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 92%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border-color);
}

.edit-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    border-radius: 16px 16px 0 0;
    z-index: 1;
}

.edit-modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-cyan);
    margin: 0;
}

.edit-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    transition: all 0.2s;
}

.edit-close-btn:hover {
    color: var(--accent-cyan);
}

.edit-modal form {
    padding: 16px 20px 20px;
}

.edit-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.edit-actions .close-btn {
    padding: 12px 20px;
}

/* ===== JOB DETAIL VIEW ===== */
.detail-edit-btn {
    background: rgba(0, 212, 255, 0.05);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 6px 8px;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    transition: all 0.15s;
}
.detail-edit-btn:hover {
    background: rgba(0, 212, 255, 0.15);
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
}
.job-detail-body {
    padding: 16px 20px 20px;
}
.detail-status-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}
.detail-date {
    font-size: 12px;
    color: var(--text-darker);
}
.detail-field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
    margin-bottom: 16px;
}
.detail-field.full-width {
    grid-column: 1 / -1;
}
.detail-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-darker);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 2px;
}
.detail-value {
    font-size: 14px;
    color: var(--text-light);
    word-break: break-word;
}

/* Labour hours inline display */
.labour-tag {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 6px;
}

/* ===== HOUR BANK ===== */
.hour-bank {
    margin: 4px 0 12px;
}
.hour-bank label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-darker);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.hour-bank-summary {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0, 212, 255, 0.08);
    border-radius: 8px;
    margin: 6px 0 8px;
    font-size: 14px;
}
.hour-bank-total {
    font-weight: 700;
    font-size: 18px;
    color: var(--accent-cyan);
}
.hour-bank-vs {
    color: var(--text-muted);
    font-size: 12px;
}
.hour-bank-entries {
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}
.hour-bank-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-light);
}
.hour-bank-entry:last-child {
    border-bottom: none;
}
.hb-name {
    font-weight: 600;
    color: var(--text-light);
}
.hb-date {
    color: var(--text-darker);
    font-size: 11px;
    margin-left: 6px;
}
.hb-notes {
    color: var(--text-darker);
    font-size: 11px;
    margin-left: 8px;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hb-hours {
    font-weight: 600;
    white-space: nowrap;
    margin-left: 8px;
    color: var(--accent-cyan);
}
.hour-bank-empty {
    padding: 12px;
    text-align: center;
    color: var(--text-darker);
    font-size: 13px;
}

/* ===== RELATED POs ===== */
.related-po {
    margin: 4px 0 12px;
}
.related-po label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-darker);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.related-po-list {
    margin-top: 6px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
}
.related-po-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 12px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-light);
    gap: 8px;
}
.related-po-item:last-child {
    border-bottom: none;
}
.rp-id {
    font-weight: 600;
    white-space: nowrap;
    color: var(--accent-cyan);
}
.rp-supplier {
    flex: 1;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rp-desc {
    flex: 1;
    color: var(--text-darker);
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rp-amount {
    font-weight: 600;
    white-space: nowrap;
    color: var(--accent-cyan);
}
.rp-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    white-space: nowrap;
}
.rp-badge-paid { background: rgba(16, 185, 129, 0.15); color: var(--green); }
.rp-badge-invoiced { background: rgba(0, 212, 255, 0.15); color: var(--accent-cyan); }
.rp-badge-open { background: rgba(245, 158, 11, 0.15); color: var(--orange); }
.related-po-total {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    background: rgba(0, 212, 255, 0.08);
    border-top: 1px solid var(--border-color);
}
.related-po-empty {
    padding: 12px;
    text-align: center;
    color: var(--text-darker);
    font-size: 13px;
}
.rp-sub-job {
    background: rgba(0, 212, 255, 0.05);
}
.rp-type-tag {
    font-size: 10px;
    color: var(--text-darker);
    margin-left: 4px;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-darker);
    font-size: 13px;
}

/* ===== ATTENTION ITEMS ===== */
.attention-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    color: var(--text-muted);
}

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

.attention-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-orange { background: var(--orange); }
.dot-red { background: var(--red); }

/* ===== UTILITIES ===== */
.hidden { display: none !important; }

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.2s ease-out; }

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

.overlay.hidden { display: none !important; }

#loading .spinner {
    border: 3px solid rgba(0, 212, 255, 0.2);
    border-top: 3px solid var(--accent-cyan);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 0.6s linear infinite;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== SETTINGS TABS & PREFERENCES ===== */
.settings-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    padding: 0 20px;
}

.settings-tab {
    font-family: var(--font);
    background: none;
    border: none;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-darker);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.settings-tab:hover { color: var(--text-light); }
.settings-tab.active {
    color: var(--accent-cyan);
    border-bottom-color: var(--accent-cyan);
    font-weight: 600;
}

.settings-panel {
    display: none;
    padding: 16px 20px 20px;
}

.settings-panel.active { display: block; }
.settings-panel form { display: flex; flex-direction: column; gap: 14px; }

/* Preference toggle rows */
.pref-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

.pref-toggle-row:last-of-type { border-bottom: none; }

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

.pref-toggle-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-light);
}

.pref-toggle-desc {
    font-size: 12px;
    color: var(--text-darker);
    margin-top: 2px;
}

/* Toggle switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border-color);
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: var(--text-light);
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent-cyan);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.toggle-slider.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== IMPORT TAB ===== */
.import-dropzone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 36px 20px;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
}

.import-dropzone.drag-over {
    border-color: var(--accent-cyan);
    background: rgba(0, 212, 255, 0.05);
}

.import-dropzone-text {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-light);
    margin: 12px 0 4px;
}

.import-browse-btn {
    display: inline-block;
    padding: 8px 24px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--secondary-indigo));
    color: white;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.import-browse-btn:hover {
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
}

.import-preview-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    max-height: 320px;
    overflow-y: auto;
}

.import-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.import-preview-table th {
    background: var(--bg-dark);
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    position: sticky;
    top: 0;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.import-preview-table td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-light);
}

.import-preview-table tr:nth-child(even) { background: rgba(0, 212, 255, 0.02); }

.import-row-skip { opacity: 0.4; text-decoration: line-through; }

/* ===== RESPONSIVE ===== */
@media (max-width: 400px) {
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .stat-number { font-size: 24px; }
}

/* ===== DESKTOP LAYOUT (768px+) ===== */
@media (min-width: 768px) {
    body {
        padding-bottom: 0;
        overflow: hidden;
        height: 100vh;
    }

    /* App wrapper becomes a sidebar + main layout */
    .app-wrapper.visible {
        display: grid;
        grid-template-columns: 240px 1fr;
        grid-template-rows: auto 1fr;
        height: 100vh;
        overflow: hidden;
    }

    /* --- Topbar spans full width --- */
    .topbar {
        grid-column: 1 / -1;
        grid-row: 1;
        padding: 14px 28px;
    }

    .brand-name {
        font-size: 18px;
    }

    .user-name {
        font-size: 14px;
    }

    /* --- Sidebar nav --- */
    .nav-bar {
        grid-column: 1;
        grid-row: 2;
        flex-direction: column;
        border-bottom: none;
        border-right: 1px solid var(--border-color);
        position: static;
        padding: 16px 0;
        overflow-y: auto;
        background: var(--bg-card);
    }

    .nav-btn {
        flex: 0 0 auto;
        flex-direction: row;
        justify-content: flex-start;
        gap: 12px;
        padding: 12px 24px;
        font-size: 14px;
        font-weight: 500;
        border-bottom: none;
        border-left: 3px solid transparent;
        border-radius: 0;
        transition: all 0.15s;
    }

    .nav-btn:hover {
        background: rgba(0, 212, 255, 0.08);
        color: var(--accent-cyan);
    }

    .nav-btn.active {
        color: var(--accent-cyan);
        border-bottom: none;
        border-left-color: var(--accent-cyan);
        background: rgba(0, 212, 255, 0.1);
        font-weight: 600;
    }

    .nav-btn svg {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
    }

    .nav-btn span {
        white-space: nowrap;
    }

    /* --- Main content area --- */
    .main-content {
        grid-column: 2;
        grid-row: 2;
        overflow-y: auto;
        background: var(--bg-dark);
    }

    .tab-content.active {
        display: block;
        padding-bottom: 40px;
    }

    /* Dashboard tab */
    #tab-dashboard.active {
        padding: 24px 32px;
    }

    .stats-row {
        max-width: 800px;
        gap: 16px;
        padding: 0;
        margin-bottom: 24px;
    }

    .stat-card {
        padding: 20px 16px;
        border-radius: var(--radius);
    }

    .stat-number {
        font-size: 32px;
    }

    .stat-label {
        font-size: 12px;
        margin-top: 6px;
    }

    /* Section cards */
    .section-card {
        max-width: 800px;
        margin: 0 0 20px 0;
        border-radius: var(--radius);
    }

    .section-title {
        padding: 14px 20px;
        font-size: 13px;
    }

    .list-item {
        padding: 14px 20px;
    }

    /* Jobs tab */
    #tab-jobs.active {
        padding: 24px 32px;
    }

    #tab-jobs .section-card {
        max-width: 900px;
    }

    /* Forms (New Lead, New Job, New PO) */
    .form-card {
        max-width: 560px;
        margin: 24px auto;
        padding: 32px 28px;
        border-radius: var(--radius);
    }

    .form-card h2 {
        font-size: 22px;
        margin-bottom: 24px;
    }

    /* PO tab - recent POs section */
    #tab-po .section-card {
        max-width: 560px;
        margin-left: auto;
        margin-right: auto;
    }

    /* Edit modal - wider on desktop */
    .edit-modal {
        max-width: 520px;
        width: 520px;
    }

    /* Filter row */
    .filter-row {
        padding: 12px 20px;
        gap: 8px;
    }

    .filter-btn {
        font-size: 13px;
        padding: 6px 18px;
    }

    /* Login card - larger on desktop */
    .login-card {
        padding: 48px 40px;
        max-width: 420px;
    }
}

/* ===== WIDE DESKTOP (1200px+) ===== */
@media (min-width: 1200px) {
    .app-wrapper.visible {
        grid-template-columns: 260px 1fr;
    }

    /* Dashboard gets a two-column grid for section cards */
    #tab-dashboard.active {
        padding: 28px 40px;
    }

    .stats-row {
        max-width: 100%;
    }

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

    .section-card {
        max-width: none;
        margin: 0;
    }

    /* Jobs list wider */
    #tab-jobs .section-card {
        max-width: 1100px;
    }

    .form-card {
        max-width: 620px;
    }

    #tab-po .section-card {
        max-width: 620px;
    }
}
