@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --bg: #F2F3EF;
  --surface: #FFFFFF;
  --border: #DEDFD7;
  --ink: #1B1F1D;
  --muted: #6B6F68;
  --accent: #1F6F5C;
  --accent-ink: #0F3D32;
  --accent-light: #E3EFEA;
  --pulse: #D98E2C;
  --pulse-light: #FBEEDA;
  --danger: #B3392C;
  --danger-light: #F8E7E3;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(20, 24, 21, 0.04), 0 8px 24px rgba(20, 24, 21, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: 'Space Grotesk', sans-serif;
  margin: 0;
  letter-spacing: -0.01em;
}

button { font-family: inherit; }

a { color: var(--accent); }

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand h1 { font-size: 19px; font-weight: 600; }

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
}

.brand-dot.running {
  background: var(--pulse);
  box-shadow: 0 0 0 0 rgba(217, 142, 44, 0.5);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(217, 142, 44, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(217, 142, 44, 0); }
  100% { box-shadow: 0 0 0 0 rgba(217, 142, 44, 0); }
}

/* ---------- Layout ---------- */

.layout {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ---------- Tracker card ---------- */

.tracker-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.tracker-idle { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; flex: 1; }

.tracker-running { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; flex: 1; }

.timer-readout {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 34px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  color: var(--accent-ink);
  min-width: 150px;
}

.tracker-meta { display: flex; flex-direction: column; gap: 2px; }

.tracker-meta .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.tracker-meta .project-name { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; }

.swatch {
  width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0;
}

select, input[type="text"], input[type="date"], input[type="time"], textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

select:focus, input:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

input[type="color"] {
  width: 38px; height: 38px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}

.btn {
  font-weight: 600;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.05s ease;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }

.btn-stop { background: var(--danger); color: #fff; }
.btn-stop:hover { filter: brightness(1.08); }

.btn-secondary { background: var(--accent-light); color: var(--accent-ink); }
.btn-secondary:hover { filter: brightness(0.97); }

.btn-text { background: transparent; color: var(--muted); padding: 10px 12px; }
.btn-text:hover { color: var(--ink); }
.btn-text.danger { color: var(--danger); }
.btn-text.danger:hover { color: #8a2a20; }

.btn-block { width: 100%; }

/* ---------- Summary ---------- */

.summary-strip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}

.summary-tabs { display: flex; gap: 6px; margin-bottom: 14px; }

.tab {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.summary-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.summary-card .proj { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }

.summary-card .hrs { font-family: 'IBM Plex Mono', monospace; font-size: 20px; font-weight: 600; }

.summary-card.total { background: var(--accent-light); border-color: var(--accent-light); }

.summary-empty { color: var(--muted); font-size: 13px; padding: 4px 2px; }

/* ---------- Columns ---------- */

.columns { display: grid; grid-template-columns: 260px 1fr; gap: 20px; align-items: start; }

@media (max-width: 760px) {
  .columns { grid-template-columns: 1fr; }
}

.projects-panel, .entries-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }

.panel-header h2 { font-size: 15px; font-weight: 600; }

.inline-form { display: flex; gap: 6px; margin-bottom: 14px; }

.inline-form input[type="text"] { flex: 1; min-width: 0; }

.project-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }

.project-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
}

.project-item:hover { background: var(--bg); }

.project-item.archived { opacity: 0.5; }

.project-item .name { flex: 1; }

.project-item .badge {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
}

.hint { font-size: 12px; color: var(--muted); margin: 12px 2px 0; line-height: 1.5; }

.entries-controls { display: flex; gap: 8px; align-items: center; }

.table-wrap { overflow-x: auto; }

.ledger { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.ledger th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.ledger th.num, .ledger td.num { text-align: right; font-family: 'IBM Plex Mono', monospace; }

.ledger td { padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }

.ledger tbody tr:hover { background: var(--bg); }

.ledger .proj-cell { display: flex; align-items: center; gap: 8px; font-weight: 500; }

.ledger .notes-cell { color: var(--muted); max-width: 240px; }

.ledger .running-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--pulse);
  background: var(--pulse-light);
  border-radius: 999px;
  padding: 2px 8px;
}

.row-edit-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 8px;
}

.row-edit-btn:hover { color: var(--accent); }

.empty-state { color: var(--muted); font-size: 13.5px; padding: 20px 4px; text-align: center; }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 21, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-overlay[hidden] {
  display: none;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
  max-height: 90vh;
  overflow-y: auto;
}

.modal h3 { font-size: 17px; margin-bottom: 16px; }

.modal form { display: flex; flex-direction: column; gap: 4px; }

.modal label { font-size: 12.5px; color: var(--muted); margin-top: 10px; margin-bottom: 4px; font-weight: 600; }

.modal select, .modal input, .modal textarea { width: 100%; }

.time-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; flex-direction: row !important; margin-top: 14px; }

.checkbox-row input { width: auto; }

.field-hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

.form-error {
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-light);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin-top: 10px;
}

.modal-actions { display: flex; align-items: center; gap: 6px; margin-top: 18px; }

.spacer { flex: 1; }

/* ---------- Login ---------- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 30px 28px;
  width: 100%;
  max-width: 340px;
}

.login-card .brand { justify-content: center; margin-bottom: 18px; }

.login-card label { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 4px; font-weight: 600; }

.login-card input { width: 100%; }

.login-card .btn { margin-top: 18px; }

.error-msg {
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-light);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin: 0 0 6px;
}
