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

:root {
    --white: #ffffff;
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-300: #e0e0e0;
    --gray-400: #bdbdbd;
    --gray-500: #9e9e9e;
    --gray-600: #757575;
    --gray-700: #616161;
    --gray-800: #424242;
    --gray-900: #212121;

    --green: #4CAF50;
    --green-dark: #388E3C;
    --red: #F44336;
    --red-dark: #D32F2F;
    --orange: #FF9800;
    --orange-light: #FFF3E0;
    --blue: #2196F3;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --transition: 0.2s ease;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ===== NAVBAR ===== */
.navbar {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    margin: 0 auto;
    max-width: 600px;
}

.nav-brand { display: flex; align-items: center; text-decoration: none; }
.nav-logo { height: 32px; width: auto; }
.nav-actions { display: flex; gap: 1rem; align-items: center; }
.nav-link {
    color: var(--gray-600);
    transition: color var(--transition);
    display: flex;
    align-items: center;
}
.nav-link:hover { color: var(--gray-900); }

/* ===== CONTAINER ===== */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
    padding-bottom: 3rem;
}

/* ===== CARDS ===== */
.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--gray-800);
}

.card h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--gray-700);
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

/* ===== PAGE HEADER ===== */
.page-header {
    padding: 0.5rem 0 0.25rem;
    margin-bottom: 0.5rem;
}

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

.page-header .page-subtitle {
    font-size: 0.85rem;
    color: var(--gray-500);
}

.page-header .btn {
    margin-top: 0;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.25rem;
}

.back-link {
    width: 100%;
    font-size: 0.85rem;
    color: var(--gray-500);
    text-decoration: none;
}
.back-link:hover { color: var(--gray-700); }

/* ===== AUTH ===== */
.auth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    padding: 2rem 1rem;
}

.auth-logo { margin-bottom: 2rem; }
.auth-logo img { width: 120px; height: auto; }

.auth-card {
    width: 100%;
    max-width: 400px;
}

.auth-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    text-align: center;
    color: var(--gray-800);
}

.auth-subtitle {
    text-align: center;
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.auth-user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

.auth-email {
    font-size: 0.9rem;
    color: var(--gray-700);
    font-weight: 500;
}

.auth-change-link {
    font-size: 0.8rem;
    color: var(--gray-500);
    text-decoration: none;
}

.auth-links {
    text-align: center;
    margin-top: 1rem;
}
.auth-links a {
    color: var(--gray-500);
    font-size: 0.85rem;
    text-decoration: none;
}
.auth-links a:hover { color: var(--gray-700); }

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.35rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--gray-900);
    transition: border-color var(--transition);
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus {
    outline: none;
    border-color: var(--gray-600);
}

.form-hint {
    display: block;
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

.form-static {
    padding: 0.75rem 0;
    font-size: 0.95rem;
    color: var(--gray-600);
}

.form-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--gray-700);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--gray-800);
}

select.form-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23757575' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn-block { width: 100%; }

.btn-primary {
    background: var(--gray-900);
    color: var(--white);
}
.btn-primary:hover { background: var(--gray-800); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-800);
}
.btn-secondary:hover { background: var(--gray-300); }

.btn-start {
    background: var(--green);
    color: var(--white);
    font-size: 1.2rem;
    padding: 1rem 2rem;
    border-radius: var(--radius);
    min-height: 60px;
}
.btn-start:hover { background: var(--green-dark); }
.btn-start:active { transform: scale(0.97); }

.btn-stop {
    background: var(--red);
    color: var(--white);
    font-size: 1.2rem;
    padding: 1rem 2rem;
    border-radius: var(--radius);
    min-height: 60px;
}
.btn-stop:hover { background: var(--red-dark); }
.btn-stop:active { transform: scale(0.97); }

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== ALERTS ===== */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: #FFEBEE;
    color: var(--red-dark);
    border: 1px solid #FFCDD2;
}

.alert-success {
    background: #E8F5E9;
    color: var(--green-dark);
    border: 1px solid #C8E6C9;
}

.alert-warning {
    background: var(--orange-light);
    color: #E65100;
    border: 1px solid #FFE0B2;
}

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 4px;
    background: var(--gray-200);
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background: #E8F5E9;
    color: var(--green-dark);
}

.badge-warning {
    background: var(--orange-light);
    color: #E65100;
}

.badge-sm {
    padding: 0.1rem 0.35rem;
    font-size: 0.65rem;
}

/* ===== TIME TRACKER ===== */
.time-card { text-align: center; }

.time-status { padding: 1rem 0; }

.time-status-active {
    padding: 1rem 0;
}

.time-display {
    font-size: 3rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--gray-900);
    margin: 1rem 0;
    letter-spacing: 2px;
}

.time-display-idle {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--gray-400);
    margin-bottom: 1rem;
}

.time-type-label {
    font-size: 0.85rem;
    color: var(--gray-500);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

/* ===== STAT ROWS ===== */
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    font-size: 0.9rem;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-100);
    text-decoration: none;
}

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

.stat-row-total {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
}

.stat-row-sub {
    font-size: 0.8rem;
    color: var(--gray-600);
    padding-left: 0.5rem;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-900);
}

/* ===== REPORT SUMMARY ===== */
.report-summary-card {
    padding-bottom: 1rem;
}

.report-kpis {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.report-kpi {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 0.85rem;
}

.report-kpi-label {
    display: block;
    color: var(--gray-500);
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.report-kpi-value {
    display: block;
    font-size: 1.35rem;
    line-height: 1.15;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.amount-open {
    color: #C62828;
}

.amount-zero {
    color: var(--gray-900);
}

.report-card-actions {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.open-amount-pill {
    min-width: 7.5rem;
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.65rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.open-amount-pill span {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.05rem;
}

.open-amount-pill strong {
    display: block;
    font-size: 1.2rem;
    line-height: 1.1;
    font-weight: 800;
}

.open-amount-due {
    background: #FFEBEE;
    border: 1px solid #FFCDD2;
    color: #C62828;
}

.open-amount-zero {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    color: var(--gray-900);
}

/* ===== ENTRIES ===== */
.entries-list { margin-top: 0.5rem; }

.entry-date-header {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-500);
    padding: 0.75rem 0 0.25rem;
    border-bottom: 1px solid var(--gray-200);
    text-transform: capitalize;
}

.entry-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--gray-100);
    gap: 0.25rem;
}

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

.entry-auto-stopped {
    background: var(--orange-light);
    margin: 0.1rem -0.5rem;
    padding: 0.6rem 0.5rem;
    border-radius: var(--radius-sm);
}

.entry-times {
    display: flex;
    gap: 0.35rem;
    font-size: 0.9rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--gray-800);
}

.entry-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.entry-type {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.entry-duration {
    font-size: 0.8rem;
    color: var(--gray-600);
    font-weight: 500;
}

.entry-geo {
    font-size: 0.7rem;
    cursor: help;
}

.btn-correct {
    width: 100%;
    margin-top: 0.25rem;
}

.entry-actions {
    width: 100%;
    display: flex;
    gap: 0.5rem;
    margin-top: 0.35rem;
}

.entry-actions .btn {
    flex: 1;
}

.entry-billed {
    background: #E8F5E9;
    margin: 0.1rem -0.5rem;
    padding: 0.6rem 0.5rem;
    border-radius: var(--radius-sm);
    opacity: 0.7;
}

.btn-billed {
    background: var(--white);
    color: var(--gray-700);
    border: 1.5px solid var(--gray-300);
}

.btn-billed-active {
    background: #E8F5E9;
    color: var(--green-dark);
    border: 1.5px solid #A5D6A7;
}

/* ===== EMPLOYEE LIST ===== */
.employee-list { margin: -0.25rem 0; }

.employee-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--gray-100);
    text-decoration: none;
    color: inherit;
    transition: background var(--transition);
}
.employee-row:last-child { border-bottom: none; }
.employee-row:active { background: var(--gray-50); }

.employee-inactive { opacity: 0.5; }

.employee-info { display: flex; flex-direction: column; gap: 0.15rem; }

.employee-name {
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.employee-role {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.employee-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.1rem;
    font-size: 0.85rem;
    color: var(--gray-600);
}

.employee-amount { font-weight: 600; color: var(--gray-800); }

.employee-link {
    text-decoration: none;
    color: var(--gray-900);
}
.employee-link:hover { text-decoration: underline; }

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.status-active { background: var(--green); }
.status-off { background: var(--gray-400); }

/* ===== PRESENCE CARD ===== */
.presence-card { text-align: center; }

.presence-header {
    display: flex;
    justify-content: center;
    gap: 3rem;
}

.presence-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.presence-count {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

.presence-active { color: var(--green); }
.presence-off { color: var(--gray-400); }

.presence-label {
    font-size: 0.8rem;
    color: var(--gray-500);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== EMPLOYEE CARDS ===== */
.section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.section-active { color: var(--green-dark); }
.section-off { color: var(--gray-500); }

.employee-card {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}

.employee-card-active {
    border-left: 3px solid var(--green);
    background: #FAFFF9;
}

.employee-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.employee-live-timer {
    font-size: 1.3rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--green-dark);
    letter-spacing: 1px;
}

.employee-work-type {
    font-size: 0.8rem;
    color: var(--gray-500);
    display: block;
    margin-top: 0.1rem;
}

.employee-geo {
    margin: 0.4rem 0;
}

.employee-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.4rem;
    padding-top: 0.4rem;
    border-top: 1px solid var(--gray-100);
}

.employee-start-time {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.employee-row-off {
    opacity: 0.6;
}
.employee-row-off:active {
    opacity: 1;
}

/* ===== MONTH NAV ===== */
.month-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.month-label {
    font-weight: 600;
    font-size: 1rem;
    color: var(--gray-800);
}

/* ===== TYPE BREAKDOWN ===== */
.type-breakdown {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--gray-200);
}

/* ===== DIVIDER ===== */
.divider {
    border: none;
    border-top: 1px solid var(--gray-200);
    margin: 1rem 0;
}

/* ===== MODAL ===== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
}

.modal-content {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: var(--radius) var(--radius) 0 0;
    margin: 0;
    animation: slideUp 0.25s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* ===== UTILITIES ===== */
.text-muted { color: var(--gray-500) !important; }

/* ===== LOADING ===== */
.loading {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--gray-300);
    border-top-color: var(--gray-800);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ===== GEO PERMISSION ===== */
.geo-notice {
    background: var(--orange-light);
    border: 1px solid #FFE0B2;
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.8rem;
    font-size: 0.8rem;
    color: #E65100;
    margin-bottom: 0.75rem;
    text-align: center;
}

/* ===== GEO STATUS IN TRACKER ===== */
.geo-status {
    text-align: center;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border-radius: var(--radius-sm);
    background: var(--gray-50);
    font-size: 0.8rem;
}

.geo-status a {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    text-decoration: none;
}

/* ===== GEO ENTRIES ===== */
.entry-geo-row {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.15rem;
    font-size: 0.75rem;
}

.geo-link {
    text-decoration: none;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-variant-numeric: tabular-nums;
}

.geo-link-start {
    background: #E8F5E9;
    color: #2E7D32;
}

.geo-link-stop {
    background: #FFEBEE;
    color: #C62828;
}

.geo-link:active {
    opacity: 0.7;
}

.geo-missing {
    color: var(--gray-400);
    font-size: 0.75rem;
    font-style: italic;
}

/* ===== DETAILS TOGGLE ===== */
.entries-toggle {
    margin-top: 0.75rem;
    border-top: 1px solid var(--gray-200);
    padding-top: 0.5rem;
}

.entries-toggle-btn {
    font-size: 0.85rem;
    color: var(--gray-600);
    cursor: pointer;
    padding: 0.4rem 0;
    font-weight: 500;
    list-style: none;
}

.entries-toggle-btn::-webkit-details-marker { display: none; }

.entries-toggle-btn::before {
    content: '▸ ';
    display: inline;
}

.entries-toggle[open] > .entries-toggle-btn::before {
    content: '▾ ';
}

/* ===== RESPONSIVE ===== */
@media (min-width: 768px) {
    .modal-content {
        border-radius: var(--radius);
        margin-bottom: 2rem;
        align-self: center;
    }

    .container {
        padding: 1.5rem;
    }

    .navbar-inner {
        padding: 0.75rem 1.5rem;
    }

    .report-kpis {
        grid-template-columns: 1.4fr 1fr 1fr;
    }

    .card-header-row {
        align-items: flex-start;
    }
}

@media (min-width: 1024px) {
    .container,
    .navbar-inner {
        max-width: 1040px;
    }
}
