:root {
  --ink: #0e1a2b;
  --ink-2: #16283f;
  --ink-3: #1e3252;
  --paper: #f5f6fa;
  --surface: #ffffff;
  --border: #e3e6ef;
  --text: #1a2438;
  --text-muted: #64748b;
  --text-on-ink: #f2f5fb;
  --text-on-ink-muted: #9fb0c9;
  --accent: #2f6fed;
  --accent-ink: #ffffff;
  --accent-soft: #e8f0ff;
  --live: #ff8a3d;
  --live-soft: #fff1e6;
  --good: #1fa971;
  --good-soft: #e7f8f1;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
}

h1, h2, h3, .brand-name {
  font-family: "Sora", "Manrope", sans-serif;
  text-wrap: balance;
}

.mono, .num, input[type="date"], .timer-readout {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

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

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

/* ── App shell ── */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--ink);
  color: var(--text-on-ink);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 16px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: linear-gradient(155deg, var(--accent), #1c4fc0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Sora", sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  flex-shrink: 0;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-on-ink-muted);
  letter-spacing: 0.02em;
}

.nav-group { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-on-ink-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-link:hover { background: rgba(255,255,255,0.06); color: var(--text-on-ink); }
.nav-link.active { background: var(--accent); color: #fff; }
.nav-link .icon { width: 18px; text-align: center; opacity: 0.9; }

.sidebar-foot {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 14px;
  margin-top: 14px;
}

.logout-link {
  color: var(--text-on-ink-muted);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
}
.logout-link:hover { color: var(--text-on-ink); }

.main {
  flex: 1;
  min-width: 0;
  padding: 32px 40px 60px;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.page-header h1 { font-size: 24px; margin: 0 0 4px; }
.page-header .subtitle { color: var(--text-muted); font-size: 13.5px; }

.badge-admin {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
}

/* ── Cards ── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.card + .card { margin-top: 20px; }

.card h2 {
  font-size: 15px;
  margin: 0 0 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Forms ── */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 24px;
}
.form-grid.narrow { grid-template-columns: 1fr; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field.span-2 { grid-column: 1 / -1; }

label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

input[type="text"], input[type="number"], input[type="date"], input[type="password"],
select, textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea { resize: vertical; min-height: 90px; }

.hours-stepper { display: flex; align-items: stretch; gap: 8px; max-width: 220px; }
.hours-stepper input { text-align: center; font-weight: 700; }
.step-btn {
  width: 40px;
  flex-shrink: 0;
  border-radius: 8px;
  border: none;
  background: var(--ink);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.step-btn:hover { background: var(--ink-3); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 8px;
  padding: 11px 20px;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  transition: filter 0.12s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary.full { width: 100%; padding: 13px; margin-top: 4px; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--paper); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { filter: brightness(0.97); }
.btn-live { background: var(--live); color: #fff; }
.btn-live:hover { filter: brightness(1.05); }
.btn-sm { padding: 7px 14px; font-size: 12.5px; }

/* ── Tables ── */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 700;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-size: 13.5px;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--paper); }
.notes-cell { color: var(--text-muted); max-width: 320px; }

.chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}
.chip.imported { background: #f1eefc; color: #7c4dff; }
.chip.status-active { background: var(--live-soft); color: var(--live); }
.chip.status-completed { background: var(--good-soft); color: var(--good); }

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

/* ── Dashboard stat tiles ── */

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-tile .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 700; }
.stat-tile .value { font-family: "IBM Plex Mono", monospace; font-size: 26px; font-weight: 700; margin-top: 6px; color: var(--ink); }
.stat-tile .value.accent { color: var(--accent); }
.stat-tile .value.live { color: var(--live); }

/* ── Projects / timer ── */

.project-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.project-info { min-width: 220px; }
.project-info .pname { font-weight: 700; font-size: 15px; }
.project-info .pclient { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }
.project-actions { display: flex; align-items: center; gap: 10px; }
.timer-readout {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  min-width: 88px;
  text-align: right;
}
.timer-readout.running { color: var(--live); }
.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--live);
  display: inline-block;
  animation: pulse 1.4s infinite ease-in-out;
  margin-right: 6px;
}
@media (prefers-reduced-motion: reduce) { .pulse-dot { animation: none; } }
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(255,138,61,0.5); }
  50% { opacity: 0.55; box-shadow: 0 0 0 5px rgba(255,138,61,0); }
}

.session-list { margin-top: 14px; border-top: 1px dashed var(--border); padding-top: 12px; }
.session-row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-muted); padding: 4px 0; }

/* ── Login ── */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1100px 600px at 50% -10%, #16294a, var(--ink) 60%);
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border-radius: 14px;
  padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  margin-top: 12px;
  display: none;
}
.login-error.show { display: block; }

/* ── Reports ── */

.report-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 20px 0; }
.breakdown-list { display: flex; flex-direction: column; gap: 8px; }
.breakdown-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.breakdown-bar-track { flex: 1; height: 6px; background: var(--paper); border-radius: 4px; margin: 0 12px; overflow: hidden; }
.breakdown-bar-fill { height: 100%; background: var(--accent); border-radius: 4px; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }

[hidden] { display: none !important; }

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; align-items: center; padding: 14px 16px; overflow-x: auto; }
  .brand { border: none; padding: 0; margin: 0 16px 0 0; }
  .nav-group { flex-direction: row; }
  .sidebar-foot { display: none; }
  .main { padding: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr 1fr; }
  .report-summary { grid-template-columns: 1fr; }
}
