:root {
  --bg: #f7f8fa;
  --fg: #1f2330;
  --muted: #6b7280;
  --line: #e5e7eb;
  --card: #fff;
  --primary: #2563eb;
  --prod: #10b981;
  --dist: #ef4444;
  --neutral: #94a3b8;
  --idle: #d1d5db;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #f0f1f5; padding: 1px 6px; border-radius: 4px; font-size: 12.5px; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px;
  background: #fff; border-bottom: 1px solid var(--line);
}
.topbar .brand a { font-weight: 700; color: var(--fg); }
.topnav { flex: 1; display: flex; gap: 16px; }
.topnav a { color: var(--muted); padding: 4px 0; }
.topnav a:hover { color: var(--fg); text-decoration: none; }
.topbar .user { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; }

.main { padding: 24px; max-width: 1400px; margin: 0 auto; }
h1 { margin: 0 0 16px; font-size: 22px; }
h2 { margin: 24px 0 12px; font-size: 16px; color: var(--fg); }
.page-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.page-head h1 { margin: 0; }
.muted { color: var(--muted); }

.flashes { margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 6px; }
.flash-ok { background: #ecfdf5; color: #047857; }
.flash-error { background: #fef2f2; color: #b91c1c; }

button, .btn {
  background: #fff; border: 1px solid var(--line); padding: 7px 14px;
  border-radius: 6px; cursor: pointer; color: var(--fg); font: inherit;
}
button:hover, .btn:hover { background: #f3f4f6; }
button.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
button.primary:hover { background: #1d4ed8; }
button.link { background: none; border: none; color: var(--primary); padding: 4px 6px; }
button.link.danger { color: #dc2626; }

input, select {
  font: inherit; padding: 7px 10px; border: 1px solid var(--line);
  border-radius: 6px; background: #fff;
}
label { display: block; margin-bottom: 12px; }
label input { display: block; width: 100%; margin-top: 4px; }

table { border-collapse: collapse; width: 100%; background: var(--card); border-radius: 8px; overflow: hidden; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #fafbfc; font-weight: 600; font-size: 13px; }
tbody tr:hover { background: #fafbfc; }

.toolbar { display: flex; gap: 8px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.form-inline { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; align-items: center; }
.form-inline input, .form-inline select { min-width: 0; }
.inline-edit { display: inline-flex; gap: 6px; align-items: center; }
.inline-edit input { padding: 4px 8px; font-size: 13px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 12px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* Login */
.login-box {
  max-width: 360px; margin: 80px auto; background: #fff; padding: 28px;
  border-radius: 10px; border: 1px solid var(--line);
}
.login-box h1 { margin: 0 0 8px; }
.login-box form { margin-top: 16px; }
.login-box button { width: 100%; }

/* Dashboard cards */
.card-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; display: block; color: inherit;
}
.card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.05); text-decoration: none; }
.card-head { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.card-title { flex: 1; }
.card-meta { margin-top: 2px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-on { background: var(--prod); }
.dot-off { background: #cbd5e1; }
.bar { display: flex; height: 8px; background: #f1f5f9; border-radius: 4px; margin: 10px 0 6px; overflow: hidden; }
.bar-prod { background: var(--prod); }
.bar-dist { background: var(--dist); }
.card-stats { display: flex; gap: 10px; font-size: 12.5px; }
.stat-prod { color: var(--prod); }
.stat-dist { color: var(--dist); }
.thumb { display: block; width: 100%; margin-top: 10px; border-radius: 6px; border: 1px solid var(--line); }

/* Timeline */
.timeline {
  position: relative; height: 40px; background: #fff;
  border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
  background-image: linear-gradient(to right, transparent 0, transparent calc(100%/24 - 1px), #f1f5f9 calc(100%/24 - 1px), #f1f5f9 calc(100%/24));
  background-size: calc(100%/24) 100%;
}
.seg { position: absolute; top: 0; bottom: 0; }
.seg-productive { background: var(--prod); }
.seg-neutral { background: var(--neutral); }
.seg-distracting { background: var(--dist); }
.seg-idle { background: var(--idle); }
.legend { display: flex; gap: 16px; align-items: center; font-size: 12.5px; margin-top: 8px; color: var(--muted); }
.legend .seg { position: static; display: inline-block; width: 14px; height: 14px; border-radius: 3px; margin-right: 4px; vertical-align: middle; }

.cat-pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; color: #fff; }
.cat-productive { background: var(--prod); }
.cat-distracting { background: var(--dist); }
.cat-neutral { background: var(--neutral); }
.cat-idle { background: var(--idle); color: #555; }
.cat-totals { display: flex; gap: 8px; margin: 12px 0; }

/* Screenshots */
.ss-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.ss-cell { display: block; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 6px; text-align: center; color: var(--muted); }
.ss-cell img { width: 100%; height: auto; border-radius: 4px; }
.ss-cell:hover { border-color: var(--primary); text-decoration: none; }

.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.lightbox.hidden { display: none; }
.lightbox img { max-width: 96vw; max-height: 90vh; }
.lb-close, .lb-prev, .lb-next {
  position: absolute; background: rgba(255,255,255,.1); color: #fff;
  border: none; font-size: 22px; padding: 8px 14px; cursor: pointer; border-radius: 6px;
}
.lb-close { top: 16px; right: 16px; }
.lb-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lb-caption { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); color: #fff; font-size: 13px; background: rgba(0,0,0,.5); padding: 4px 10px; border-radius: 4px; }
