/* ── Reset & Variables ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --clr-primary:       #dc2626;
  --clr-primary-dark:  #b91c1c;
  --clr-danger:        #f97316;
  --clr-danger-dark:   #ea580c;
  --clr-success:       #16a34a;
  --clr-bg:            #f5f5f5;
  --clr-card:          #ffffff;
  --clr-text:          #0f0f0f;
  --clr-muted:         #6b7280;
  --clr-border:        #e5e5e5;
  --radius-sm:         6px;
  --radius-md:         12px;
  --g-primary:         linear-gradient(135deg, #991b1b 0%, #dc2626 100%);
  --g-sidebar:         linear-gradient(160deg, #0d0d0d 0%, #1c0808 52%, #0d0d0d 100%);
  --shadow-sm:         0 1px 4px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:         0 6px 24px rgba(0,0,0,.09), 0 2px 8px rgba(0,0,0,.05);
  --shadow-glow:       0 6px 24px rgba(220,38,38,.38);
  --ease:              cubic-bezier(.4,0,.2,1);
  --font:              -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
}

body {
  font-family: var(--font);
  background: var(--clr-bg);
  background-image: radial-gradient(circle, #d8d8d8 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--clr-text);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ─────────────────────────────────────────── */
.app { display: flex; height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: 235px;
  background: var(--g-sidebar);
  display: flex;
  flex-direction: column;
  padding: 24px 14px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
/* ambient orbs */
.sidebar::before {
  content: '';
  position: absolute;
  width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(220,38,38,.4) 0%, transparent 68%);
  top: -70px; right: -70px;
  pointer-events: none;
}
.sidebar::after {
  content: '';
  position: absolute;
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(153,27,27,.28) 0%, transparent 68%);
  bottom: 50px; left: -50px;
  pointer-events: none;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 22px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 18px;
  position: relative; z-index: 1;
}
.logo-img {
  height: 36px;
  width: auto;
  object-fit: contain;
  display: block;
  filter: brightness(1.05);
  flex-shrink: 0;
}
.logo-text { color: #fff; font-size: 13px; font-weight: 700; letter-spacing: -.2px; line-height: 1.2; }

.nav-links { list-style: none; display: flex; flex-direction: column; gap: 3px; flex: 1; position: relative; z-index: 1; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  color: rgba(255,255,255,.55);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  transition: all .2s var(--ease);
}
.nav-link:hover  { color: #fff; background: rgba(255,255,255,.09); }
.nav-link.active {
  color: #fff;
  background: var(--g-primary);
  box-shadow: 0 4px 14px rgba(220,38,38,.45);
}
.nav-icon { font-size: 15px; }

.sidebar-footer {
  font-size: 11px;
  color: rgba(255,255,255,.25);
  text-align: center;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  position: relative; z-index: 1;
}

/* ── Main ────────────────────────────────────────────── */
.main { flex: 1; overflow-y: auto; padding: 30px 36px; }

.tab { display: none; }
.tab.active { display: block; }

/* ── Page header ─────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h1 { font-size: 22px; font-weight: 700; letter-spacing: -.4px; }

/* ── Segment control ─────────────────────────────────── */
.segment {
  display: flex;
  background: rgba(0,0,0,.06);
  border-radius: 99px;
  padding: 3px;
  gap: 2px;
}
.seg-btn {
  padding: 5px 16px;
  border: none;
  background: transparent;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--clr-muted);
  transition: all .2s var(--ease);
  font-family: var(--font);
}
.seg-btn.active {
  background: var(--g-primary);
  color: #fff;
  box-shadow: 0 2px 10px rgba(220,38,38,.35);
}

/* ── Stats grid ──────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--clr-card);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--clr-border);
  position: relative;
  overflow: hidden;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--g-primary);
}
.stat-card:nth-child(2)::before { background: linear-gradient(135deg, #10b981, #06b6d4); }
.stat-card:nth-child(3)::before { background: linear-gradient(135deg, #f59e0b, #f97316); }
.stat-card:nth-child(4)::before { background: linear-gradient(135deg, #ec4899, #f43f5e); }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--clr-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 10px;
}
.stat-value {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -.6px;
  color: var(--clr-primary);
}
.stat-card:nth-child(2) .stat-value { color: var(--clr-success); }
.stat-card:nth-child(3) .stat-value { color: #d97706; }
.stat-card:nth-child(4) .stat-value { color: #e11d48; }

/* ── Cards ───────────────────────────────────────────── */
.card {
  background: var(--clr-card);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--clr-border);
  margin-bottom: 16px;
  transition: box-shadow .2s var(--ease);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 18px; letter-spacing: -.2px; }
.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-header-row .card-title { margin-bottom: 0; }

/* ── Two-column layout ───────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Table ───────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--clr-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 0 14px 12px;
  border-bottom: 2px solid var(--clr-border);
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--clr-border);
  transition: background .12s;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr {
  position: relative;
  transition: background .12s var(--ease);
}
.table tbody tr:hover td { background: #fff5f5; }
.table tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--clr-primary);
}
.table tfoot td {
  padding-top: 14px;
  font-weight: 700;
  font-size: 13px;
  border-top: 2px solid var(--clr-border);
  border-bottom: none;
  color: var(--clr-text);
}

/* ── Progress bar ────────────────────────────────────── */
.progress {
  height: 6px;
  background: var(--clr-border);
  border-radius: 99px;
  min-width: 80px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: 99px;
  transition: width .5s var(--ease);
  opacity: .85;
}

/* ── Project badge ───────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .01em;
}

/* ── Forms ───────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--clr-muted);
  margin-bottom: 5px;
}
.optional { font-weight: 400; opacity: .7; }

.field input {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--clr-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  background: var(--clr-bg);
  color: var(--clr-text);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), background .2s;
  -webkit-appearance: none;
}
.field input:focus {
  outline: none;
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 4px rgba(220,38,38,.1);
  background: #fff;
}
.field input::placeholder { color: #a0aec0; }

.date-input-sm {
  padding: 5px 10px;
  border: 1.5px solid var(--clr-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  background: var(--clr-bg);
  color: var(--clr-text);
  cursor: pointer;
}
.date-input-sm:focus { outline: none; border-color: var(--clr-primary); }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all .2s var(--ease);
  white-space: nowrap;
}
.btn-primary {
  background: var(--g-primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(220,38,38,.32);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}
.btn-primary:active { transform: translateY(0); }
.btn-danger  { background: var(--clr-danger);  color: #fff; box-shadow: 0 4px 14px rgba(239,68,68,.25); }
.btn-danger:hover  { background: var(--clr-danger-dark); transform: translateY(-1px); }
.btn-ghost   { background: var(--clr-border);  color: var(--clr-text); }
.btn-ghost:hover   { background: #d1d9e6; }
.btn-full  { width: 100%; margin-top: 6px; }
.btn-lg    { padding: 13px 30px; font-size: 15px; border-radius: 12px; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px 6px;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1;
  color: var(--clr-muted);
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: rgba(239,68,68,.1); color: var(--clr-danger); }

/* ── Entry list ──────────────────────────────────────── */
.entry-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px;
  border-bottom: 1px solid var(--clr-border);
  gap: 10px;
  border-radius: 8px;
  transition: background .15s var(--ease), box-shadow .15s;
  margin: 0 -4px;
}
.entry-item:last-child { border-bottom: none; }
.entry-item:hover {
  background: #fff5f5;
  border-bottom-color: transparent;
  box-shadow: inset 3px 0 0 var(--clr-primary);
}
.entry-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.entry-meta { font-size: 13px; color: var(--clr-muted); }
.entry-note { font-size: 12px; color: var(--clr-muted); font-style: italic; width: 100%; }

/* ── Timer ───────────────────────────────────────────── */
.timer-card { text-align: center; max-width: 460px; margin: 0 auto; }
.timer-card .field { text-align: left; }

.timer-display {
  font-size: 72px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -4px;
  background: var(--g-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 32px 0;
  line-height: 1;
  transition: opacity .3s;
}
.timer-display.running { animation: pulse-glow 2s ease-in-out infinite; }
@keyframes pulse-glow {
  0%, 100% { opacity: 1; filter: drop-shadow(0 0 0px rgba(220,38,38,0)); }
  50%       { opacity: .8; filter: drop-shadow(0 0 14px rgba(220,38,38,.55)); }
}

.timer-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.timer-msg   { margin-top: 20px; font-size: 13.5px; color: var(--clr-muted); min-height: 20px; }

/* ── Empty state ─────────────────────────────────────── */
.empty-state {
  text-align: center;
  color: var(--clr-muted);
  padding: 32px 16px;
  font-size: 14px;
}

/* ── Projects ────────────────────────────────────────── */
.projects-layout { grid-template-columns: 240px 1fr; align-items: start; }
.proj-list-card  { margin-bottom: 0; }
.proj-empty-hint { padding-top: 80px; font-size: 14px; }

.proj-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all .2s var(--ease);
  margin-bottom: 4px;
}
.proj-list-item:last-child { margin-bottom: 0; }
.proj-list-item:hover  { background: #fff5f5; border-color: rgba(220,38,38,.25); }
.proj-list-item.active {
  background: linear-gradient(135deg, rgba(220,38,38,.08), rgba(153,27,27,.05));
  border-color: var(--clr-primary);
  box-shadow: 0 2px 10px rgba(220,38,38,.15);
}
.proj-list-meta { font-size: 12px; color: var(--clr-muted); font-weight: 500; }

.proj-stats { margin-bottom: 16px; }
.proj-stats.stats-grid { grid-template-columns: repeat(3, 1fr); }

/* ── History ─────────────────────────────────────────── */
.history-group { margin-bottom: 20px; }
.history-group:last-child { margin-bottom: 0; }

.history-date-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1.5px solid var(--clr-border);
  margin-bottom: 8px;
}
.history-date  { font-size: 13px; font-weight: 600; }
.history-total { font-size: 12px; color: var(--clr-muted); font-weight: 500; }

.history-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 6px 14px;
  border-left: 2px solid;
  border-image: var(--g-primary) 1;
  margin-bottom: 4px;
  border-radius: 0 6px 6px 0;
  transition: background .15s;
}
.history-entry:hover { background: #fff5f5; }
.history-entry:last-child { margin-bottom: 0; }
.history-hours { font-size: 13px; font-weight: 700; min-width: 110px; color: var(--clr-primary); flex-shrink: 0; }
.history-note  { font-size: 12px; color: var(--clr-muted); font-style: italic; flex: 1; }
.no-note       { opacity: .4; }

/* ── Note inline editing ───────────────────────────────── */
.btn-edit-note {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 3px 6px;
  border-radius: 6px;
  color: var(--clr-muted);
  opacity: 0;
  flex-shrink: 0;
  transition: opacity .15s, background .15s;
  line-height: 1;
}
.history-entry:hover .btn-edit-note { opacity: 1; }
.btn-edit-note:hover { background: rgba(220,38,38,.1); color: var(--clr-primary); }

.note-edit-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
}
.note-edit-input {
  flex: 1;
  padding: 5px 10px;
  border: 1.5px solid var(--clr-primary);
  border-radius: 7px;
  font-size: 13px;
  font-family: var(--font);
  background: #fff;
  color: var(--clr-text);
  box-shadow: 0 0 0 3px rgba(220,38,38,.12);
  outline: none;
}
.btn-note-save, .btn-note-cancel {
  background: none;
  border: none;
  cursor: pointer;
  width: 26px; height: 26px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.btn-note-save   { color: var(--clr-success); }
.btn-note-save:hover   { background: rgba(16,185,129,.12); }
.btn-note-cancel { color: var(--clr-danger); }
.btn-note-cancel:hover { background: rgba(239,68,68,.1); }
