/* ── Page transitions (Chrome 126+) ────────────────────────────────────────── */
@view-transition {
  navigation: auto;
}
::view-transition-old(root) { animation-duration: 0.12s; }
::view-transition-new(root) { animation-duration: 0.12s; }

/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --sidebar-w: 350px;
  --sidebar-bg: linear-gradient(180deg, #0f1428 0%, #131a33 60%, #0f1428 100%);
  --sidebar-hover: rgba(255,255,255,0.09);
  --sidebar-active: rgba(113,128,255,0.25);
  --sidebar-active-border: #7180ff;
  --accent: #5f6fff;
  --accent-dark: #4d5df5;
  --accent-light: #eef0ff;
  --success: #12b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f5f7ff;
  --surface: #ffffff;
  --border: #e7eaf7;
  --text: #161c33;
  --text-muted: #6f7895;
  --text-light: #9ba3be;
  --radius: 14px;
  --shadow-sm: 0 2px 6px rgba(15, 24, 54, 0.05), 0 1px 2px rgba(15, 24, 54, 0.04);
  --shadow: 0 8px 20px rgba(27, 39, 94, 0.08), 0 2px 6px rgba(15, 24, 54, 0.06);
  --shadow-lg: 0 20px 40px rgba(19, 26, 51, 0.18), 0 4px 14px rgba(19, 26, 51, 0.1);
}


/* ── Base ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Manrope', 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 0.92rem;
  background: radial-gradient(1200px 600px at 10% -10%, #edf0ff 0%, transparent 55%), var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── App Layout ────────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
  box-shadow: 6px 0 22px rgba(8, 11, 25, 0.22);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #7e8bff 0%, #5f6fff 100%);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 1rem;
  flex-shrink: 0;
  box-shadow: 0 8px 18px rgba(95,111,255,0.4);
}
.brand-name {
  color: #f3f5ff;
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: -.01em;
}

.sidebar-nav {
  flex: 1;
  padding: 14px 10px;
  overflow-y: auto;
}

.nav-section-label {
  color: var(--text-light);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 0 8px 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 7px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
  border-left: 2px solid transparent;
}
.sidebar-link i { font-size: 1rem; flex-shrink: 0; }
.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}
.sidebar-link.active {
  background: var(--sidebar-active);
  color: #fff;
  border-left-color: var(--sidebar-active-border);
}

.nav-section-label-admin {
  color: #c4b5fd;
}

.sidebar-link-admin {
  background: rgba(124,58,237,.12);
  color: #ddd6fe;
  border-left-color: rgba(196,181,253,.18);
}

.sidebar-link-admin:hover {
  background: rgba(124,58,237,.22);
  color: #f5f3ff;
}

.sidebar-link-admin.active {
  background: linear-gradient(135deg, rgba(124,58,237,.5), rgba(109,40,217,.38));
  color: #fff;
  border-left-color: #c4b5fd;
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,.07);
}

.user-btn {
  background: none;
  border: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: background .15s;
}
.user-btn:hover { background: var(--sidebar-hover); }
.user-btn::after { margin-left: auto; border-color: #64748b; }

.user-avatar {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 50%;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-name { color: #e2e8f0; font-size: 0.82rem; font-weight: 600; line-height: 1.2; }
.user-role { color: #64748b; font-size: 0.72rem; text-transform: capitalize; }

/* ── Main Content ──────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 30px 34px;
  min-height: 100vh;
  max-width: calc(100vw - var(--sidebar-w));
}

/* ── Mobile Topbar ─────────────────────────────────────────────────────────── */
.mobile-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: rgba(255,255,255,0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 99;
  box-shadow: var(--shadow-sm);
}

@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-content { margin-left: 0; padding: 70px 16px 24px; max-width: 100vw; }
}

/* ── Auth Background ───────────────────────────────────────────────────────── */
.auth-bg {
  min-height: 100vh;
  background: radial-gradient(circle at 20% 0%, #818fff 0%, #4f5fe7 35%, #1f2a5b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* ── Auth Card ─────────────────────────────────────────────────────────────── */
.auth-card {
  background: rgba(255,255,255,0.96);
  border-radius: 20px;
  padding: 36px 40px;
  width: 100%;
  max-width: 420px;
  border: 1px solid rgba(255,255,255,0.55);
  box-shadow: 0 26px 60px rgba(12, 18, 49, .35);
}
.auth-logo {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, #7e8bff 0%, #5f6fff 100%);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 1.5rem;
  margin: 0 auto 16px;
}
.auth-title {
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
  color: var(--text);
}
.auth-subtitle {
  color: var(--text-muted);
  text-align: center;
  font-size: 0.875rem;
  margin-bottom: 28px;
}

/* ── Page Header ───────────────────────────────────────────────────────────── */
.page-header {
  margin-bottom: 24px;
}
.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  letter-spacing: -.02em;
}
.page-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 3px 0 0;
}

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}
.card-body { padding: 18px; }

/* Stat cards */
.stat-card {
  background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: 9px;
  transition: all .15s;
}
.btn-primary {
  background: linear-gradient(135deg, #6b79ff 0%, #5f6fff 100%);
  border-color: #5f6fff;
  box-shadow: 0 10px 22px rgba(95,111,255,0.24);
}
.btn-primary:hover, .btn-primary:focus {
  background: linear-gradient(135deg, #5f6fff 0%, #4d5df5 100%);
  border-color: var(--accent-dark);
  box-shadow: 0 12px 24px rgba(77,93,245,0.3);
}
.btn-success { background: var(--success); border-color: var(--success); }
.btn-success:hover { background: #0ea672; border-color: #0ea672; }

.btn-sm { font-size: 0.8rem; padding: 5px 12px; border-radius: 8px; }
.btn-xs { font-size: 0.75rem; padding: 3px 10px; border-radius: 7px; }

.btn-outline-primary { color: var(--accent); border-color: #c7cdfc; background: #f7f8ff; }
.btn-outline-primary:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-outline-secondary { border-color: #d9dff5; color: #525d7f; background: #fff; }
.btn-outline-secondary:hover { background: #f3f6ff; color: #36405f; border-color: #cfd7f4; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-label { font-weight: 600; font-size: 0.84rem; color: var(--text); margin-bottom: 5px; }
.form-control, .form-select {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.875rem;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  padding: 8px 12px;
}
.form-control:focus, .form-select:focus {
  border-color: #95a2ff;
  box-shadow: 0 0 0 4px rgba(95,111,255,.14);
  outline: none;
}
.form-text { color: var(--text-muted); font-size: 0.78rem; }

/* ── Tables ────────────────────────────────────────────────────────────────── */
.table { font-size: 0.875rem; color: var(--text); }
.table th {
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  background: #f8f9ff;
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  white-space: nowrap;
}
.table td { padding: 10px 14px; vertical-align: middle; border-color: var(--border); }
.table-hover tbody tr:hover { background: #f8f9ff; }

/* ── Time Grid ─────────────────────────────────────────────────────────────── */
.time-grid { border-collapse: separate; border-spacing: 0; }
.time-grid thead th:first-child { border-radius: 12px 0 0 0; }
.time-grid thead th:last-child  { border-radius: 0 12px 0 0; }

.area-row td {
  background: #f8f9ff !important;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 6px 14px !important;
  border-top: 2px solid var(--border) !important;
}

.hours-input {
  width: 64px !important;
  text-align: center;
  border: 1.5px solid transparent;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 4px 6px;
  transition: border-color .15s, background .15s, box-shadow .15s;
  background: transparent !important;
  color: var(--text) !important;
  -moz-appearance: textfield;
  appearance: textfield;
}
.hours-input::-webkit-outer-spin-button,
.hours-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.hours-input::placeholder { color: var(--text-light); opacity: 1; }
.hours-input:focus {
  border-color: #8e9bff !important;
  background: var(--surface) !important;
  box-shadow: 0 0 0 3px rgba(95,111,255,.16);
  outline: none;
  color: var(--text) !important;
}
.hours-input.has-value {
  background: var(--accent-light) !important;
  border-color: #c7cdfc !important;
  color: var(--accent-dark) !important;
  font-weight: 700;
}

.hours-input.weekly-total {
  background: var(--accent-light) !important;
  border-color: #7180ff !important;
  color: var(--accent-dark) !important;
  font-weight: 700;
  width: 80px !important;
}

.hours-input.auto-total {
  background: transparent !important;
  border-color: transparent !important;
  color: var(--text-muted) !important;
  font-weight: 600;
  cursor: default;
  width: 80px !important;
}
.hours-input.auto-total.has-value {
  background: transparent !important;
  border-color: transparent !important;
  color: var(--text) !important;
}

.total-col-header { border-left: 2px solid var(--border) !important; }
.time-grid td:last-child,
.time-grid th:last-child { border-left: 2px solid var(--border); }

.category-name { font-size: 0.855rem; color: var(--text); }
.category-desc-icon { color: var(--text-light); font-size: 0.75rem; cursor: help; }
.row-total { font-size: 0.875rem; font-weight: 600; color: var(--text); }

.time-grid tfoot td {
  background: #f8f9ff;
  font-weight: 700;
  font-size: 0.875rem;
  border-top: 2px solid var(--border) !important;
}

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  font-weight: 600;
  font-size: 0.72rem;
  border-radius: 999px;
  padding: 4px 9px;
}
.badge-soft-primary { background: var(--accent-light); color: var(--accent-dark); }
.badge-soft-success { background: #dcfce9; color: #0f6c4c; }
.badge-soft-warning { background: #fff5d8; color: #9a5d00; }
.badge-soft-danger  { background: #ffe3e3; color: #a92222; }
.badge-soft-muted   { background: #f3f5fb; color: var(--text-muted); border: 1px solid var(--border); }

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.alert {
  border: none;
  border-radius: 12px;
  font-size: 0.875rem;
  padding: 12px 16px;
}
.alert-success { background: #dcfce9; color: #0f6c4c; }
.alert-danger   { background: #ffe3e3; color: #a92222; }
.alert-warning  { background: #fff5d8; color: #9a5d00; }
.alert-info     { background: #e7f1ff; color: #184e8a; }
.alert-info a   { color: inherit; font-weight: 600; word-break: break-all; }

/* ── Week nav pill ─────────────────────────────────────────────────────────── */
.week-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 4px;
  box-shadow: var(--shadow-sm);
}
.week-nav .btn { margin: 0; }

/* ── Dropdown ──────────────────────────────────────────────────────────────── */
.dropdown-menu {
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  font-size: 0.875rem;
}
.dropdown-item {
  border-radius: 8px;
  padding: 7px 12px;
  color: var(--text);
  font-size: 0.875rem;
}
.dropdown-item:hover { background: #f3f6ff; }
.dropdown-header { font-size: 0.78rem; color: var(--text-muted); padding: 4px 12px; }
.dropdown-divider { border-color: var(--border); margin: 4px 0; }

/* ── Save status chip ──────────────────────────────────────────────────────── */
.save-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
}
.save-chip.saved    { background: #dcfce9; color: #0f6c4c; }
.save-chip.unsaved  { background: #fff5d8; color: #9a5d00; }
.save-chip.saving   { background: #e7f1ff; color: #184e8a; }
.save-chip.error    { background: #ffe3e3; color: #a92222; }

/* ── Report table status ───────────────────────────────────────────────────── */
.hours-missing  { color: var(--danger); font-weight: 600; }
.hours-low      { color: var(--warning); font-weight: 600; }
.hours-high     { color: #7350d6; font-weight: 600; }
.hours-ok       { color: var(--success); font-weight: 600; }

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c8cfe8; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #98a2c5; }

/* ── Responsive table ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .hours-input { width: 52px !important; font-size: 0.8rem; }
  .main-content { padding: 70px 12px 20px; }
}

/* ── Live Timer ─────────────────────────────────────────────────────────────── */
.timer-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1px solid #86efac;
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(18,185,129,.12);
}

@keyframes timer-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .45; transform: scale(.85); }
}
.timer-dot {
  width: 10px; height: 10px;
  background: var(--success);
  border-radius: 50%;
  flex-shrink: 0;
  animation: timer-pulse 1.4s ease-in-out infinite;
}

.timer-label { font-size: .78rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.timer-cat-name { font-weight: 700; color: var(--text); font-size: .92rem; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer-elapsed { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.05rem; color: var(--success); letter-spacing: .02em; white-space: nowrap; }

.timer-stop-btn {
  display: flex; align-items: center; gap: 5px;
  background: #fff; border: 1px solid #86efac; border-radius: 7px;
  padding: 4px 12px; font-size: .82rem; font-weight: 600;
  color: #15803d; cursor: pointer; transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.timer-stop-btn:hover { background: #fee2e2; border-color: #fca5a5; color: #dc2626; }

/* Clickable category cell */
.cat-timer-cell { cursor: pointer; user-select: none; }
.cat-timer-cell:hover .category-name { color: var(--accent); }
.cat-timer-cell:hover::after {
  content: ' ⏱';
  font-size: .75rem;
  color: var(--text-muted);
}

/* Active timer row highlight */
tr.timer-row > td:first-child {
  border-left: 3px solid var(--success) !important;
}
tr.timer-row {
  background: rgba(18,185,129,.04);
}

/* Today column highlight */
th.today-col { background: rgba(95,111,255,.06); }
td.today-col { background: rgba(95,111,255,.03); }
