/* TimePilot — Light mode, Source Sans 3 (sans-serif) */
@import url('https://fonts.googleapis.com/css2?family=Source+Sans+3:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg: #f5f7fa;
  --bg-card: #ffffff;
  --bg-soft: #fafbfc;
  --bg-hover: #f1f4f8;
  --bg-accent: #eef4ff;
  --border: #e3e8ef;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --primary-soft: #dbe7ff;
  --success: #15803d;
  --success-soft: #dcfce7;
  --warning: #b45309;
  --warning-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --info: #0369a1;
  --info-soft: #e0f2fe;
  --grey-soft: #f1f5f9;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.04);
  --shadow: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow-md: 0 4px 12px rgba(15,23,42,.06);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }
html, body { margin:0; padding:0; }
body {
  font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }

input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ---------- LAYOUT ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: #ffffff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  top: 0; left: 0;
  z-index: 100;
}

.brand {
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
}
.brand-link {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: inherit;
}
.brand-link:hover { text-decoration: none; }
.brand-logo { flex-shrink: 0; }
.brand-name {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text);
  line-height: 1.05;
}
.brand-name-accent {
  color: var(--primary);
}
.brand-tag {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
}

.nav { flex: 1; padding: 14px 12px; overflow-y: auto; }
.nav-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  padding: 14px 12px 6px;
  font-weight: 600;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
}
.nav a:hover { background: var(--bg-hover); text-decoration: none; }
.nav a.active { background: var(--bg-accent); color: var(--primary); font-weight: 600; }
.nav a .nav-icon {
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
}

.user-card {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  font-size: 13px;
}
.user-card .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  margin-right: 10px;
}
.user-card .uname { font-weight: 600; font-size: 14px; }
.user-card .urole { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.user-card a { display: block; margin-top: 8px; font-size: 12px; color: var(--text-muted); }

.main { margin-left: 240px; flex: 1; min-width: 0; }
.topbar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-title { font-size: 18px; font-weight: 600; }
.page-title .crumb { color: var(--text-muted); font-weight: 400; font-size: 14px; margin-left: 6px; }

.content { padding: 28px 32px 60px; max-width: 1400px; }

/* ---------- TILES / KPI ---------- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.tile-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.tile-value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 6px;
  letter-spacing: -0.02em;
}
.tile-value.small { font-size: 22px; }
.tile-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.tile-sub.up { color: var(--success); }
.tile-sub.down { color: var(--danger); }

/* ---------- CARDS ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.card-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 18px 20px; }
.card-body.tight { padding: 0; }

/* ---------- TABLES ---------- */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.tbl th, .tbl td {
  padding: 11px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.tbl th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  background: var(--bg-soft);
}
.tbl tbody tr:hover { background: var(--bg-hover); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td.center, .tbl th.center { text-align: center; }
.tbl tr.muted td { color: var(--text-muted); }

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: white;
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--bg-hover); text-decoration: none; }
.btn.primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn.primary:hover { background: var(--primary-dark); }
.btn.success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}
.btn.danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.xs { padding: 3px 8px; font-size: 12px; }
.btn.ghost { border: 1px solid transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- BADGES / PILLS ---------- */
.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.pill.draft { background: var(--grey-soft); color: var(--text-muted); }
.pill.submitted { background: var(--warning-soft); color: var(--warning); }
.pill.approved { background: var(--success-soft); color: var(--success); }
.pill.rejected { background: var(--danger-soft); color: var(--danger); }
.pill.locked { background: #ede9fe; color: #6d28d9; }
.pill.billable { background: var(--success-soft); color: var(--success); }
.pill.non_billable { background: var(--grey-soft); color: var(--text-muted); }
.pill.recoverable { background: var(--info-soft); color: var(--info); }
.pill.fixed_fee { background: #ede9fe; color: #6d28d9; }
.pill.capex { background: var(--info-soft); color: var(--info); }
.pill.opex { background: var(--warning-soft); color: var(--warning); }

/* ---------- FORMS ---------- */
.form-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.field { flex: 1; min-width: 200px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input[type=text],
.field input[type=email],
.field input[type=password],
.field input[type=number],
.field input[type=date],
.field select,
.field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: white;
  font-size: 14px;
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 95, 217, 0.12);
}
.field textarea { min-height: 80px; resize: vertical; }
.field-inline { display: flex; align-items: center; gap: 8px; }
.field-help { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---------- LOGIN ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f0f4fa 0%, #fafbfc 100%);
  padding: 20px;
}
.login-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 38px 36px;
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border);
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand h1 { font-size: 30px; letter-spacing: -0.03em; }
.login-brand p { color: var(--text-muted); margin: 4px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 8px; padding: 11px; font-weight: 600; }
.demo-creds {
  margin-top: 22px;
  padding: 12px 14px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  font-size: 12px;
  border: 1px solid var(--border);
}
.demo-creds strong { display: block; margin-bottom: 6px; color: var(--text); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.demo-creds code { background: white; padding: 1px 5px; border-radius: 3px; font-size: 12px; color: var(--primary); border: 1px solid var(--border); }

.alert { padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 14px; }
.alert.error { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }
.alert.success { background: var(--success-soft); color: var(--success); border: 1px solid #bbf7d0; }
.alert.warning { background: var(--warning-soft); color: var(--warning); border: 1px solid #fde68a; }
.alert.info { background: var(--info-soft); color: var(--info); border: 1px solid #bae6fd; }

/* ---------- TIMESHEET GRID ---------- */
.ts-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.ts-week-nav { display: flex; align-items: center; gap: 8px; }
.ts-week-nav .week-label {
  font-size: 16px;
  font-weight: 600;
  padding: 6px 14px;
  background: white;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  min-width: 230px;
  text-align: center;
}

.ts-grid-wrap { overflow-x: auto; background: white; border: 1px solid var(--border); border-radius: var(--radius); }
.ts-grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  min-width: 950px;
}
.ts-grid th, .ts-grid td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.ts-grid th:last-child, .ts-grid td:last-child { border-right: none; }
.ts-grid th {
  background: var(--bg-soft);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-align: center;
}
.ts-grid th.day-head { text-align: center; }
.ts-grid th.day-head .day-name { display: block; font-size: 11px; }
.ts-grid th.day-head .day-num { display: block; font-size: 16px; color: var(--text); margin-top: 2px; font-weight: 700; }
.ts-grid th.day-head.today { background: var(--bg-accent); color: var(--primary); }
.ts-grid th.day-head.weekend { color: var(--text-subtle); }

.ts-grid td.proj { font-weight: 500; }
.ts-grid td.proj small { display: block; color: var(--text-muted); font-weight: 400; font-size: 12px; }
.ts-grid td.day-cell { text-align: center; padding: 4px; }
.ts-grid td.day-cell input {
  width: 60px;
  padding: 6px;
  text-align: center;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.ts-grid td.day-cell input:hover { background: var(--bg-soft); }
.ts-grid td.day-cell input:focus {
  background: white;
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(30, 95, 217, 0.15);
}
.ts-grid td.day-cell.weekend { background: #fafbfc; }
.ts-grid td.total { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; background: var(--bg-soft); }
.ts-grid tfoot td { font-weight: 700; background: var(--bg-soft); }

.ts-side {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.ts-side h3 { font-size: 14px; margin-bottom: 10px; }
.ts-side .stat-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--bg-soft);
}
.ts-side .stat-row:last-child { border-bottom: none; }
.ts-side .stat-row .lbl { color: var(--text-muted); }
.ts-side .stat-row .val { font-weight: 600; font-variant-numeric: tabular-nums; }

.ts-layout { display: grid; grid-template-columns: 1fr 280px; gap: 16px; }
@media (max-width: 1100px) { .ts-layout { grid-template-columns: 1fr; } }

.add-row-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  align-items: end;
}
.add-row-form .field { min-width: 150px; }
.add-row-form .field label { font-size: 10px; }
.add-row-form .field select, .add-row-form .field input { padding: 6px 8px; font-size: 13px; }

/* ---------- PROGRESS BAR ---------- */
.progress {
  height: 8px;
  background: var(--grey-soft);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}
.progress > div { height: 100%; background: var(--primary); border-radius: 999px; transition: width 0.3s; }
.progress > div.warning { background: var(--warning); }
.progress > div.danger { background: var(--danger); }
.progress > div.success { background: var(--success); }

/* ---------- CHARTS ---------- */
.chart-wrap { position: relative; height: 280px; }
.chart-wrap.tall { height: 360px; }

/* ---------- DASHBOARD GRID ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }

/* ---------- TIMER ---------- */
.timer-widget {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
}
.timer-display {
  font-size: 34px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--primary);
  min-width: 130px;
}
.timer-info { flex: 1; min-width: 200px; }
.timer-info .field { margin-bottom: 0; }
.timer-info .field input, .timer-info .field select { padding: 6px 10px; font-size: 13px; }

/* ---------- CALENDAR ---------- */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-day-head {
  background: var(--bg-soft);
  text-align: center;
  padding: 8px;
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.cal-day {
  background: white;
  min-height: 110px;
  padding: 6px 8px;
  position: relative;
  cursor: pointer;
}
.cal-day.muted { background: var(--bg-soft); color: var(--text-subtle); }
.cal-day.today .day-num { background: var(--primary); color: white; }
.cal-day:hover { background: var(--bg-hover); }
.cal-day .day-num {
  font-weight: 700;
  font-size: 14px;
  display: inline-block;
  width: 22px; height: 22px;
  text-align: center;
  border-radius: 50%;
  line-height: 22px;
}
.cal-event {
  display: block;
  font-size: 11px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 3px;
  padding: 1px 5px;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-event.opex { background: var(--warning-soft); color: var(--warning); }
.cal-event.capex { background: var(--info-soft); color: var(--info); }

/* ---------- UTILITY ---------- */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-end { display: flex; justify-content: flex-end; gap: 8px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.tabular { font-variant-numeric: tabular-nums; }
.hide { display: none; }

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: end;
  background: white;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filter-bar .field { min-width: 160px; margin: 0; }
.filter-bar .field label { font-size: 10px; }
.filter-bar .field select, .filter-bar .field input { padding: 6px 10px; font-size: 13px; }

/* Empty state */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}
.empty .empty-icon { font-size: 28px; margin-bottom: 8px; opacity: 0.4; }

/* Mobile */
@media (max-width: 800px) {
  .sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border); }
  .nav { display: flex; overflow-x: auto; padding: 8px; }
  .nav-section { display: none; }
  .nav a { white-space: nowrap; padding: 6px 12px; font-size: 13px; }
  .user-card { display: none; }
  .main { margin-left: 0; }
  .topbar { padding: 12px 18px; }
  .content { padding: 18px; }
  .tile-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .tile-value { font-size: 22px; }
}
