:root {
    --th-primary: #c41313;
    --th-primary-hover: #a31010;
    --th-primary-light: #fce8e8;
    --th-primary-dark: #8b0e0e;
    --th-secondary: #212529;
    --th-secondary-light: #495057;
    --th-accent: #ffffff;
    --th-bg: #f5f6fa;
    --th-card: #ffffff;
    --th-border: #e0e0e0;
    --th-text: #212529;
    --th-text-muted: #6c757d;
    --th-success: #198754;
    --th-warning: #fd7e14;
    --th-info: #0dcaf0;
    --th-danger: #dc3545;
    --th-sidebar-width: 260px;
    --th-header-height: 60px;
    --th-border-radius: 8px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--th-bg);
    color: var(--th-text);
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

/* ── Scrollbar ────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #999; }

/* ── Login Page ───────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--th-primary) 0%, var(--th-primary-dark) 100%);
    position: relative;
    overflow: hidden;
}
.login-page::before {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
    top: -100px; right: -100px;
}
.login-page::after {
    content: '';
    position: absolute;
    width: 300px; height: 300px;
    background: rgba(255,255,255,0.03);
    border-radius: 50%;
    bottom: -80px; left: -80px;
}
.login-card {
    background: var(--th-card);
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    position: relative;
    z-index: 1;
}
.login-logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo svg { width: 56px; height: 56px; }
.login-logo h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--th-primary);
    margin: 8px 0 0;
}
.login-logo p { color: var(--th-text-muted); font-size: 14px; margin: 4px 0 0; }

/* ── Sidebar ──────────────────────────────────────── */
.sidebar {
    position: fixed;
    left: 0; top: 0;
    width: var(--th-sidebar-width);
    height: 100vh;
    background: var(--th-secondary);
    color: #fff;
    overflow-y: auto;
    z-index: 1040;
    transition: transform 0.3s ease;
}
.sidebar-brand {
    height: var(--th-header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand svg { width: 32px; height: 32px; }
.sidebar-brand span {
    font-size: 20px;
    font-weight: 700;
    margin-left: 10px;
    color: #fff;
}
.sidebar-nav { padding: 16px 0; }
.sidebar-nav .nav-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.4);
    padding: 16px 20px 6px;
    font-weight: 600;
}
.sidebar-nav .nav-item {
    padding: 0 12px;
    margin-bottom: 2px;
}
.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}
.sidebar-nav .nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}
.sidebar-nav .nav-link.active {
    background: var(--th-primary);
    color: #fff;
}
.sidebar-nav .nav-link i {
    font-size: 18px;
    width: 24px;
    margin-right: 12px;
    text-align: center;
}

/* ── Main Content ─────────────────────────────────── */
.main-content {
    margin-left: var(--th-sidebar-width);
    min-height: 100vh;
}

/* ── Top Header ───────────────────────────────────── */
.top-header {
    height: var(--th-header-height);
    background: var(--th-card);
    border-bottom: 1px solid var(--th-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 1030;
}
.header-left { display: flex; align-items: center; gap: 16px; }
.header-right { display: flex; align-items: center; gap: 16px; }

.team-selector {
    min-width: 200px;
}
.team-selector .form-select {
    border-radius: var(--th-border-radius);
    font-size: 13px;
    border-color: var(--th-border);
    padding: 6px 36px 6px 12px;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--th-border-radius);
    transition: background 0.2s;
}
.header-user:hover { background: var(--th-bg); }
.header-user .avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--th-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}
.header-user .user-info { line-height: 1.2; }
.header-user .user-name { font-weight: 600; font-size: 13px; }
.header-user .user-role { font-size: 11px; color: var(--th-text-muted); }

/* ── Page Content ─────────────────────────────────── */
.page-content { padding: 24px; }
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.page-header h2 { font-size: 24px; font-weight: 700; margin: 0; }
.page-header .breadcrumb { margin: 4px 0 0; font-size: 13px; }
.page-header .breadcrumb a { color: var(--th-primary); text-decoration: none; }

/* ── Cards ────────────────────────────────────────── */
.th-card {
    background: var(--th-card);
    border-radius: var(--th-border-radius);
    border: 1px solid var(--th-border);
    padding: 24px;
    margin-bottom: 20px;
}
.th-card .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--th-border);
}
.th-card .card-header h5 { margin: 0; font-weight: 600; }

/* ── Timer Bar ────────────────────────────────────── */
.timer-bar {
    background: var(--th-card);
    border: 1px solid var(--th-border);
    border-radius: var(--th-border-radius);
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.timer-bar .timer-input {
    flex: 1;
    display: flex;
    gap: 8px;
}
.timer-bar input[type="text"] {
    flex: 2;
    border: 1px solid var(--th-border);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 14px;
}
.timer-bar select {
    flex: 1;
    border: 1px solid var(--th-border);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
}
.timer-display {
    font-size: 24px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--th-primary);
    min-width: 100px;
    text-align: center;
}

/* ── Buttons ──────────────────────────────────────── */
.btn-th-primary {
    background: var(--th-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 20px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
    cursor: pointer;
}
.btn-th-primary:hover {
    background: var(--th-primary-hover);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(196,19,19,0.3);
}
.btn-th-secondary {
    background: var(--th-secondary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 20px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
    cursor: pointer;
}
.btn-th-secondary:hover { background: var(--th-secondary-light); color: #fff; }
.btn-th-outline {
    background: transparent;
    color: var(--th-primary);
    border: 2px solid var(--th-primary);
    border-radius: 8px;
    padding: 6px 18px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
    cursor: pointer;
}
.btn-th-outline:hover { background: var(--th-primary); color: #fff; }

.btn-timer-start {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--th-primary);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-timer-start:hover { background: var(--th-primary-hover); transform: scale(1.1); }
.btn-timer-start.running { background: var(--th-danger); }
.btn-timer-start.running:hover { background: #c82333; }

/* ── Tables ───────────────────────────────────────── */
.th-table {
    width: 100%;
    border-collapse: collapse;
}
.th-table thead th {
    background: var(--th-bg);
    padding: 12px 16px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--th-text-muted);
    font-weight: 600;
    border-bottom: 2px solid var(--th-border);
    text-align: left;
}
.th-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--th-border);
    vertical-align: middle;
}
.th-table tbody tr:hover { background: #fafbfc; }

/* ── Stats Cards ──────────────────────────────────── */
.stat-card {
    background: var(--th-card);
    border-radius: var(--th-border-radius);
    border: 1px solid var(--th-border);
    padding: 20px;
    text-align: center;
}
.stat-card .stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 22px;
}
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--th-text); }
.stat-card .stat-label { font-size: 13px; color: var(--th-text-muted); margin-top: 4px; }

/* ── Badges ───────────────────────────────────────── */
.badge-th {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge-th-red { background: var(--th-primary-light); color: var(--th-primary); }
.badge-th-green { background: #d1e7dd; color: #0f5132; }
.badge-th-orange { background: #fff3cd; color: #664d03; }
.badge-th-gray { background: #e2e3e5; color: #41464b; }
.badge-th-blue { background: #cfe2ff; color: #084298; }

/* ── Forms ────────────────────────────────────────── */
.th-form .form-group { margin-bottom: 20px; }
.th-form label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 6px;
    color: var(--th-text);
}
.th-form .form-control, .th-form .form-select {
    border: 1px solid var(--th-border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    transition: border-color 0.2s;
}
.th-form .form-control:focus, .th-form .form-select:focus {
    border-color: var(--th-primary);
    box-shadow: 0 0 0 3px rgba(196,19,19,0.15);
}

/* ── Timesheet Grid ───────────────────────────────── */
.timesheet-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--th-border);
    border-radius: var(--th-border-radius);
    overflow: hidden;
}
.timesheet-cell {
    background: var(--th-card);
    min-height: 120px;
    padding: 8px;
}
.timesheet-cell .day-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--th-text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}
.timesheet-cell .day-date {
    font-size: 20px;
    font-weight: 700;
    color: var(--th-text);
}
.timesheet-cell.today {
    background: var(--th-primary-light);
}
.timesheet-cell .entry {
    font-size: 12px;
    padding: 4px 6px;
    margin-top: 4px;
    border-radius: 4px;
    background: #f0f0f0;
    border-left: 3px solid var(--th-primary);
}

/* ── Permission Matrix ────────────────────────────── */
.perm-matrix { width: 100%; }
.perm-matrix th, .perm-matrix td {
    text-align: center;
    padding: 10px;
    border: 1px solid var(--th-border);
}
.perm-matrix th { background: var(--th-bg); font-size: 12px; }
.perm-matrix td:first-child { text-align: left; font-weight: 500; }
.perm-matrix .form-check-input:checked {
    background-color: var(--th-primary);
    border-color: var(--th-primary);
}

/* ── Utilities ────────────────────────────────────── */
.text-primary-th { color: var(--th-primary) !important; }
.bg-primary-th { background-color: var(--th-primary) !important; }
.border-primary-th { border-color: var(--th-primary) !important; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.fw-600 { font-weight: 600; }
.fs-12 { font-size: 12px; }
.fs-13 { font-size: 13px; }
.cursor-pointer { cursor: pointer; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .btn-sidebar-toggle { display: block !important; }
}
@media (min-width: 993px) {
    .btn-sidebar-toggle { display: none !important; }
}

/* ── Color dots for projects/clients ──────────────── */
.color-dot {
    width: 12px; height: 12px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
    vertical-align: middle;
}

/* ── Empty state ──────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}
.empty-state i { font-size: 48px; color: var(--th-border); }
.empty-state h4 { color: var(--th-text-muted); margin: 16px 0 8px; }
.empty-state p { color: var(--th-text-muted); font-size: 14px; }

/* ── Dropdown ─────────────────────────────────────── */
.dropdown-th .dropdown-menu {
    border-radius: var(--th-border-radius);
    border: 1px solid var(--th-border);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    padding: 8px;
}
.dropdown-th .dropdown-item {
    border-radius: 6px;
    font-size: 13px;
    padding: 8px 12px;
}
.dropdown-th .dropdown-item:hover { background: var(--th-bg); }

/* ── Chart container ──────────────────────────────── */
.chart-container { position: relative; height: 300px; width: 100%; }