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

:root {
    --color-bg: #F5F5F7;
    --color-white: #FFFFFF;
    --color-text: #1D1D1F;
    --color-text-secondary: #86868B;
    --color-text-tertiary: #AEAEB2;
    --color-border: #E5E5EA;
    --color-border-light: #F2F2F7;
    --color-blue: #007AFF;
    --color-green: #34C759;
    --color-red: #FF3B30;
    --color-orange: #FF9F0A;
    --color-yellow: #FFCC00;
    --color-purple: #AF52DE;
    --color-gray: #8E8E93;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
    --font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', 'Helvetica Neue', sans-serif;
    --radius: 16px;
    --radius-sm: 8px;
}

html, body {
    height: 100%;
}

body {
    font-family: var(--font-family);
    background-color: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: var(--color-bg);
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background-color: var(--color-white);
    border-bottom: 1px solid var(--color-border);
}

.header h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

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

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--color-text-tertiary);
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}

.btn-logout:hover {
    background-color: var(--color-border-light);
    color: var(--color-red);
}

.toggle-group {
    display: flex;
    background-color: var(--color-border-light);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.toggle-btn {
    padding: 6px 14px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    border-radius: 6px;
    transition: all 0.2s;
}

.toggle-btn.active {
    background-color: var(--color-white);
    color: var(--color-text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.toggle-btn:hover:not(.active) {
    color: var(--color-text);
}

/* Tab Navigation */
.tabs {
    display: flex;
    padding: 0 24px;
    background-color: var(--color-white);
    border-bottom: 1px solid var(--color-border);
}

.tab-btn {
    padding: 12px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn.active {
    color: var(--color-text);
    border-bottom-color: var(--color-text);
}

.tab-btn:hover:not(.active) {
    color: var(--color-text);
}

/* Tab Content */
.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

.tab-content.active {
    display: block;
}

#dashboard.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* ===================== */
/*  DASHBOARD            */
/* ===================== */

.dashboard-layout {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    min-height: 0;
    max-width: 960px;
    margin: 0 auto;
    width: 100%;
}

.dashboard-card {
    background: var(--color-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* Gauges Card */
.gauges-card {
    padding: 24px 16px 16px;
    flex-shrink: 0;
}

.gauges-row {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
}

.gauge-item {
    text-align: center;
    flex: 1;
    max-width: 220px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.gauge-item.gauge-primary {
    max-width: 320px;
    opacity: 1;
}

.gauge-item .gauge-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-tertiary);
    margin-bottom: 2px;
    letter-spacing: 0.3px;
}

.gauge-item.gauge-primary .gauge-label {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.2px;
}

.gauge-item .gauge {
    width: 100%;
    height: 120px;
}

.gauge-item.gauge-primary .gauge {
    height: 180px;
}

/* Projects Card */
.projects-card {
    padding: 20px 24px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.dash-year-group {
    margin-bottom: 20px;
}

.dash-year-group:last-child {
    margin-bottom: 0;
}

.dash-year-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-bottom: 10px;
    margin-bottom: 2px;
    border-bottom: 2px solid var(--color-border-light);
}

.dash-year-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.2px;
}

.dash-year-total {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-blue);
    font-variant-numeric: tabular-nums;
}

.dash-project-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 14px;
}

.dash-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-right: 10px;
}

.dash-project-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-text);
}

.dash-project-value {
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-left: 24px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.dash-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--color-text-tertiary);
    font-size: 14px;
}

/* ===================== */
/*  PROJECTS TAB         */
/* ===================== */

.projects-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

#projectsContainer {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.year-section {
    background-color: var(--color-white);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.year-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--color-border-light);
}

.year-title {
    font-size: 15px;
    font-weight: 700;
}

.year-total {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-blue);
    font-variant-numeric: tabular-nums;
}

.projects-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.project-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background-color: var(--color-bg);
    border-radius: var(--radius-sm);
    transition: background-color 0.15s;
}

.project-card:hover {
    background-color: var(--color-border-light);
}

.project-info {
    flex: 1;
}

.project-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
}

.project-meta {
    display: flex;
    gap: 10px;
    font-size: 12px;
    color: var(--color-text-secondary);
    align-items: center;
}

.project-amount {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.status-badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-badge.offered { background-color: var(--color-gray); }
.status-badge.contract { background-color: var(--color-blue); }
.status-badge.completed { background-color: var(--color-purple); }
.status-badge.invoiced { background-color: var(--color-green); }

.project-actions {
    display: flex;
    gap: 4px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--color-text-tertiary);
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.btn-icon.edit:hover { color: var(--color-blue); }
.btn-icon.delete:hover { color: var(--color-red); }

/* ===================== */
/*  SETTINGS TAB         */
/* ===================== */

.settings-card {
    background-color: var(--color-white);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 520px;
    margin: 0 auto;
}

.settings-card h2 {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--color-text);
}

#globalTargetDisplay {
    margin-bottom: 20px;
}

.target-display-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border-light);
}

.target-display-row:last-child {
    border-bottom: none;
}

.target-display-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 13px;
}

.target-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.target-display-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-blue);
    font-variant-numeric: tabular-nums;
}

/* ===================== */
/*  BUTTONS              */
/* ===================== */

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

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

.btn-primary:hover {
    opacity: 0.9;
}

.btn-secondary {
    background-color: var(--color-border-light);
    color: var(--color-text);
}

.btn-secondary:hover {
    background-color: var(--color-border);
}

/* ===================== */
/*  FORMS                */
/* ===================== */

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--color-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.form-actions button {
    flex: 1;
}

/* ===================== */
/*  MODALS               */
/* ===================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.15s;
}

.modal.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: var(--color-white);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    width: 90%;
    max-width: 400px;
    padding: 24px;
    animation: slideUp 0.2s ease-out;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 17px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--color-text-tertiary);
    transition: color 0.15s;
    line-height: 1;
}

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

/* ===================== */
/*  EMPTY STATE          */
/* ===================== */

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--color-text-secondary);
}

.empty-state-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.empty-state h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--color-text);
}

.empty-state p {
    font-size: 13px;
    color: var(--color-text-secondary);
}

/* ===================== */
/*  LOGIN PAGE           */
/* ===================== */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--color-bg);
    padding: 20px;
}

.login-card {
    background: var(--color-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 48px 40px;
    text-align: center;
    width: 100%;
    max-width: 360px;
}

.login-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.5px;
    margin-bottom: 6px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin-bottom: 32px;
}

#loginButton {
    display: flex;
    justify-content: center;
}

.login-error {
    margin-top: 16px;
    font-size: 13px;
    color: var(--color-red);
    font-weight: 500;
}

.login-error.hidden {
    display: none;
}

/* ===================== */
/*  SCROLLBAR            */
/* ===================== */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #D1D1D6;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #AEAEB2;
}

/* ===================== */
/*  RESPONSIVE           */
/* ===================== */

@media (max-width: 768px) {
    .header {
        padding: 12px 16px;
    }

    .header h1 {
        font-size: 17px;
    }

    .tabs {
        padding: 0 16px;
    }

    .tab-content {
        padding: 16px;
    }

    .gauge-item:not(.gauge-primary) {
        display: none;
    }

    .gauge-item.gauge-primary {
        max-width: 300px;
        opacity: 1;
    }

    .gauges-card {
        padding: 20px 16px 12px;
    }

    .projects-card {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 15px;
    }

    .toggle-btn {
        padding: 5px 10px;
        font-size: 11px;
    }

    .tab-btn {
        padding: 10px 12px;
        font-size: 12px;
    }
}
