:root {
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --color-bg: #f0f4f8;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-text: #0f172a;
    --color-text-muted: #64748b;
    --color-primary: #4f46e5;
    --color-primary-hover: #4338ca;
    --color-primary-soft: #eef2ff;
    --color-success: #059669;
    --color-success-soft: #ecfdf5;
    --color-warning: #d97706;
    --color-warning-soft: #fffbeb;
    --color-danger: #dc2626;
    --color-danger-soft: #fef2f2;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.1);
}

* { box-sizing: border-box; }

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Navbar */
.app-navbar {
    background: rgba(255, 255, 255, 0.92) !important;
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    padding: 0.65rem 0;
}

.app-navbar .navbar-brand {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--color-text) !important;
    letter-spacing: -0.02em;
}

.app-navbar .navbar-brand i {
    color: var(--color-primary);
    margin-right: 0.35rem;
}

.app-navbar .nav-link {
    color: var(--color-text-muted) !important;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.5rem 0.85rem !important;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.app-navbar .nav-link:hover,
.app-navbar .nav-link.active {
    color: var(--color-primary) !important;
    background: var(--color-primary-soft);
}

.app-navbar .dropdown-menu {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.35rem;
}

.app-navbar .dropdown-item {
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
}

.user-avatar {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    margin-right: 0.5rem;
}

/* Layout */
.app-main {
    padding: 1.75rem 0 3rem;
}

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1,
.page-header h2 {
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.25rem;
}

.page-header .subtitle {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    margin: 0;
}

/* Cards */
.app-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.app-card .card-header {
    background: transparent;
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.app-card .card-body {
    padding: 1.25rem;
}

/* Stat cards */
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    height: 100%;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
    color: inherit;
    display: block;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    color: inherit;
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.stat-card .stat-label {
    color: var(--color-text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.25rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.stat-icon-primary { background: var(--color-primary-soft); color: var(--color-primary); }
.stat-icon-success { background: var(--color-success-soft); color: var(--color-success); }
.stat-icon-info { background: #ecfeff; color: #0891b2; }
.stat-icon-warning { background: var(--color-warning-soft); color: var(--color-warning); }

/* Buttons */
.btn {
    font-weight: 500;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    transition: all 0.15s ease;
}

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

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

.btn-outline-secondary {
    border-color: var(--color-border);
    color: var(--color-text-muted);
}

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

.btn-group-modern {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0.25rem;
    display: inline-flex;
    gap: 0.25rem;
}

.btn-group-modern .btn {
    border: none;
    border-radius: var(--radius-sm);
}

.btn-group-modern .btn-outline-secondary,
.btn-group-modern .btn-outline-primary {
    border: none;
}

/* Forms */
.form-control,
.form-select {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.85rem;
    font-size: 0.9rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.form-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: 0.35rem;
}

/* Badges & status */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.status-pill-success { background: var(--color-success-soft); color: var(--color-success); }
.status-pill-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.status-pill-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.status-pill-muted { background: #f1f5f9; color: var(--color-text-muted); }
.status-pill-primary { background: var(--color-primary-soft); color: var(--color-primary); }

.save-status.saved { color: var(--color-success); font-weight: 600; }
.save-status.saving { color: var(--color-text-muted); }
.save-status.error { color: var(--color-danger); font-weight: 600; }

/* Week banner */
.week-banner {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}

.week-banner .week-range {
    font-weight: 600;
    font-size: 1rem;
}

.week-stats {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.week-stat {
    text-align: center;
}

.week-stat .value {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}

.week-stat .label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Day cards */
.day-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
    overflow: hidden;
    border-left: none;
}

.day-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: linear-gradient(to right, #fafbff, #ffffff);
}

.day-card-header .day-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.day-card-header .day-date {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    margin-left: 0.5rem;
}

.day-progress-wrap {
    flex: 1;
    min-width: 120px;
    max-width: 200px;
}

.day-progress {
    height: 6px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.day-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    border-radius: 999px;
    transition: width 0.3s ease;
}

.day-progress-bar.complete {
    background: linear-gradient(90deg, #059669, #10b981);
}

.day-progress-bar.warning {
    background: linear-gradient(90deg, #f59e0b, #ef4444);
}

.hours-pill {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

.hours-pill.total-warning {
    color: var(--color-danger);
}

.entry-table-header {
    display: none;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    padding: 0 0.5rem 0.5rem;
}

.entry-row {
    background: #f8fafc;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.entry-row:focus-within {
    border-color: #c7d2fe;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.08);
}

.entry-row .btn-danger {
    background: transparent;
    border: 1px solid #fecaca;
    color: var(--color-danger);
}

.entry-row .btn-danger:hover {
    background: var(--color-danger-soft);
    border-color: #fca5a5;
    color: var(--color-danger);
}

/* Tables */
.app-table {
    margin: 0;
}

.app-table thead th {
    background: #f8fafc;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    padding: 0.75rem 1rem;
}

.app-table tbody td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
    border-color: var(--color-border);
    font-size: 0.9rem;
}

.app-table tbody tr:hover {
    background: #fafbff;
}

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, #eef2ff 0%, #f0f4f8 50%, #ecfdf5 100%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.login-card-header {
    padding: 2rem 2rem 1rem;
    text-align: center;
}

.login-brand {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.4rem;
    margin-bottom: 1rem;
}

.login-card-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.25rem;
}

.login-card-body {
    padding: 0 2rem 2rem;
}

.login-hint {
    background: #f8fafc;
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.login-theme-toggle {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 100;
}

/* Alerts */
.alert {
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
}

.alert-info {
    background: var(--color-primary-soft);
    color: #3730a3;
}

.alert-success {
    background: var(--color-success-soft);
    color: #047857;
}

.alert-danger {
    background: var(--color-danger-soft);
    color: #b91c1c;
}

.alert-warning {
    background: var(--color-warning-soft);
    color: #b45309;
}

/* Action bar */
.action-bar {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    margin-bottom: 2rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.75rem;
    box-shadow: var(--shadow-sm);
}

/* Filter panel */
.filter-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.filter-panel .panel-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-panel .panel-title i {
    color: var(--color-primary);
}

/* Responsive */
@media (min-width: 768px) {
    .entry-table-header {
        display: flex;
    }

    .entry-table-header > div:nth-child(1) { flex: 0 0 25%; padding-left: 0.75rem; }
    .entry-table-header > div:nth-child(2) { flex: 0 0 25%; }
    .entry-table-header > div:nth-child(3) { flex: 0 0 16.666%; }
    .entry-table-header > div:nth-child(4) { flex: 0 0 16.666%; }
    .entry-table-header > div:nth-child(5) { flex: 0 0 16.666%; }
}

@media (max-width: 767px) {
    .page-header h1,
    .page-header h2 {
        font-size: 1.5rem;
    }

    .week-stats {
        width: 100%;
        justify-content: space-between;
    }

    .day-progress-wrap {
        width: 100%;
        max-width: none;
    }

    .day-card-toggle {
        cursor: pointer;
        user-select: none;
    }

    .day-card-toggle::after {
        content: '\f078';
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        font-size: 0.75rem;
        color: var(--color-text-muted);
        margin-left: auto;
        transition: transform 0.2s ease;
    }

    .day-card-toggle[aria-expanded="true"]::after {
        transform: rotate(180deg);
    }
}

/* Page transitions */
@keyframes pageEnter {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-enter {
    animation: pageEnter 0.35s ease-out both;
}

/* Theme toggle */
.btn-theme-toggle {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.15s ease;
}

.btn-theme-toggle:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
}

/* Empty states */
.empty-state {
    text-align: center;
    padding: 2.5rem 1.5rem;
}

.empty-state-illustration {
    position: relative;
    display: inline-block;
    margin-bottom: 1.25rem;
}

.empty-state-icon-ring {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary-soft), var(--color-surface));
    border: 2px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--color-primary);
    position: relative;
    z-index: 1;
}

.empty-state-dots {
    position: absolute;
    inset: -12px;
    pointer-events: none;
}

.empty-state-dots span {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-primary);
    opacity: 0.25;
}

.empty-state-dots span:nth-child(1) { top: 0; left: 50%; transform: translateX(-50%); }
.empty-state-dots span:nth-child(2) { bottom: 10%; left: 0; }
.empty-state-dots span:nth-child(3) { bottom: 10%; right: 0; }

.empty-state-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.empty-state-message {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    max-width: 360px;
    margin: 0 auto 1rem;
}

/* Dark mode */
html[data-theme="dark"] {
    color-scheme: dark;
    --color-bg: #0f172a;
    --color-surface: #1e293b;
    --color-border: #334155;
    --color-text: #f1f5f9;
    --color-text-muted: #94a3b8;
    --color-primary: #818cf8;
    --color-primary-hover: #a5b4fc;
    --color-primary-soft: #312e81;
    --color-success: #34d399;
    --color-success-soft: #064e3b;
    --color-warning: #fbbf24;
    --color-warning-soft: #78350f;
    --color-danger: #f87171;
    --color-danger-soft: #7f1d1d;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] body {
    background: var(--color-bg) !important;
    color: var(--color-text);
}

html[data-theme="dark"] .app-navbar {
    background: rgba(30, 41, 59, 0.95) !important;
}

html[data-theme="dark"] .app-navbar .navbar-brand,
html[data-theme="dark"] .app-navbar .nav-link {
    color: var(--color-text) !important;
}

html[data-theme="dark"] .app-card,
html[data-theme="dark"] .day-card,
html[data-theme="dark"] .week-banner,
html[data-theme="dark"] .filter-panel,
html[data-theme="dark"] .action-bar,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .login-card,
html[data-theme="dark"] .btn-group-modern,
html[data-theme="dark"] .card {
    background: var(--color-surface) !important;
    color: var(--color-text);
    border-color: var(--color-border) !important;
}

html[data-theme="dark"] .day-card-header,
html[data-theme="dark"] .app-card .card-header {
    background: linear-gradient(to right, #1e293b, #0f172a) !important;
    border-color: var(--color-border) !important;
    color: var(--color-text);
}

html[data-theme="dark"] .entry-row {
    background: #0f172a;
}

html[data-theme="dark"] .app-table thead th {
    background: #0f172a !important;
    color: var(--color-text-muted);
    border-color: var(--color-border);
}

html[data-theme="dark"] .app-table tbody td {
    border-color: var(--color-border);
    color: var(--color-text);
}

html[data-theme="dark"] .app-table tbody tr:hover {
    background: #1e293b !important;
}

html[data-theme="dark"] .login-page {
    background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 50%, #064e3b 100%) !important;
}

html[data-theme="dark"] .login-hint {
    background: #0f172a;
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select {
    background: #0f172a !important;
    color: var(--color-text) !important;
    border-color: var(--color-border) !important;
}

html[data-theme="dark"] .dropdown-menu {
    background: var(--color-surface);
    border-color: var(--color-border);
}

html[data-theme="dark"] .dropdown-item {
    color: var(--color-text);
}

html[data-theme="dark"] .dropdown-item:hover {
    background: #334155;
}

html[data-theme="dark"] .btn-theme-toggle {
    background: #0f172a;
    border-color: var(--color-border);
    color: var(--color-text);
}

html[data-theme="dark"] .btn-close {
    filter: invert(1);
}

html[data-theme="dark"] .navbar-toggler-icon {
    filter: invert(1);
}

html[data-theme="dark"] .text-muted {
    color: var(--color-text-muted) !important;
}

html[data-theme="dark"] .btn-outline-secondary {
    color: var(--color-text-muted);
    border-color: var(--color-border);
}

html[data-theme="dark"] .btn-outline-secondary:hover {
    background: #334155;
    color: var(--color-text);
}

/* Admin page helpers */
.page-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}
