/* Activity Tracker — web dashboard. Tokens follow docs/brand-guidelines.md */

:root {
  /* Monochrome: black on light, white on dark. */
  --primary: #111111;
  --primary-hover: #333333;
  --primary-fg: #FFFFFF;
  --primary-text: #111111;
  --primary-soft: rgba(0, 0, 0, 0.06);
  --indigo: #111111;
  --amber: #111111;
  --amber-text: #111111;

  --bg: #F5F5F5;
  --surface: #FFFFFF;
  --surface-2: #F0F0F0;
  --text: #111111;
  --text-2: #6B6B6B;
  --border: #E2E2E2;

  --success: #111111;
  --warning: #6B6B6B;
  --error: #C62828;
  --info: #111111;
  --muted-dot: #9E9E9E;

  --font-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  --font-numeric: ui-rounded, "SF Pro Rounded", -apple-system, "Inter", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", monospace;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-pop: 0 12px 40px rgba(0, 0, 0, 0.16), 0 1px 3px rgba(0, 0, 0, 0.08);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #F2F2F2;
    --primary-hover: #FFFFFF;
    --primary-fg: #000000;
    --primary-text: #F2F2F2;
    --primary-soft: rgba(255, 255, 255, 0.08);
    --indigo: #F2F2F2;
    --amber: #F2F2F2;
    --amber-text: #F2F2F2;
    --success: #F2F2F2;
    --warning: #A0A0A0;
    --error: #FF6B6B;
    --info: #F2F2F2;

    --bg: #000000;
    --surface: #111111;
    --surface-2: #1A1A1A;
    --text: #F2F2F2;
    --text-2: #A0A0A0;
    --border: #2A2A2A;
    --shadow-pop: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px #2A2A2A;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 28px; font-weight: 700; line-height: 1.2; }
h2 { font-size: 17px; font-weight: 600; line-height: 1.3; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--primary-text); }
.num { font-family: var(--font-numeric); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.eyebrow { font-size: 11px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--text-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--primary-text); outline-offset: 2px; border-radius: 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; cursor: pointer;
  font-weight: 500; white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease), opacity .15s;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--primary); color: var(--primary-fg); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { border-color: var(--border); background: var(--surface); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(.92); }
.btn-icon { width: 32px; padding: 0; }
.btn svg { width: 16px; height: 16px; }

/* ---------- Inputs ---------- */
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; }
.input, .select {
  height: 36px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  transition: border-color .15s, box-shadow .15s; width: 100%;
}
.input:focus, .select:focus { outline: none; border-color: var(--primary-text); box-shadow: 0 0 0 3px var(--primary-soft); }
.input-row { display: flex; gap: 6px; }
.input-row .input { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 13px; }
.form-error { color: var(--error); font-size: 13px; min-height: 1em; margin: 0; }

/* ---------- Sign in ---------- */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.signin-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; padding: 32px 28px;
  display: grid; gap: 18px;
}
.signin-brand { display: grid; gap: 12px; justify-items: start; }
.signin-brand img { width: 44px; height: 44px; }
.signin-brand p { margin: 0; color: var(--text-2); }
.signin-card .btn { height: 38px; width: 100%; }

/* ---------- App shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 24px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; text-decoration: none; color: var(--text); }
.brand img { width: 26px; height: 26px; }
.topbar .spacer { flex: 1; }
.me { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 13px; }
.main { max-width: 1120px; margin: 0 auto; padding: 28px 24px 64px; display: grid; gap: 20px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head .titles { display: grid; gap: 6px; }
.back { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-2); text-decoration: none; border: 0; background: none; cursor: pointer; padding: 0; }
.back:hover { color: var(--text); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat { display: grid; gap: 4px; }
.stat .label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; }
.stat .label svg { width: 15px; height: 15px; }
.stat .value { font-family: var(--font-numeric); font-variant-numeric: tabular-nums; font-size: 26px; font-weight: 600; line-height: 1.1; }
.stat .caption { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tone-teal .label { color: var(--primary-text); }
.tone-amber .label { color: var(--amber-text); }
.tone-indigo .label { color: var(--indigo); }
.tone-green .label { color: var(--success); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Status pill ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--surface-2); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-dot); flex: none; }
.pill.working { background: color-mix(in srgb, var(--success) 12%, transparent); color: var(--text); }
.pill.working .dot { background: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 25%, transparent); }
.pill.focus { background: color-mix(in srgb, var(--indigo) 14%, transparent); color: var(--text); }
.pill.focus .dot { background: var(--indigo); }
.pill.idle, .pill.break { background: color-mix(in srgb, var(--amber) 14%, transparent); color: var(--text); }
.pill.idle .dot, .pill.break .dot { background: var(--amber); }
.pill .pill-text { overflow: hidden; text-overflow: ellipsis; }
@media (prefers-reduced-motion: no-preference) {
  .pill.working .dot { animation: breathe 2.4s ease-in-out infinite; }
}
@keyframes breathe { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--success) 8%, transparent); } }

/* ---------- Team table ---------- */
.table-wrap { overflow-x: auto; margin: 0 -16px -16px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--text-2); padding: 8px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th.right, td.right { text-align: right; }
.team-row { cursor: pointer; transition: background .12s; }
.team-row:hover { background: var(--surface-2); }
.person { display: flex; align-items: center; gap: 12px; min-width: 200px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 13px; font-weight: 600;
  background: var(--primary) !important; color: var(--primary-fg);
}
.person .who { display: grid; min-width: 0; }
.person .who strong { font-weight: 600; }
.person .who span { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }
.role-badge { font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); text-transform: capitalize; }
.role-badge.admin { background: var(--primary-soft); color: var(--primary-text); }
.status-cell { min-width: 180px; max-width: 280px; }
.status-sub { display: block; font-size: 12px; color: var(--text-2); margin-top: 3px; }

/* Mobile: table becomes cards */
@media (max-width: 680px) {
  .table-wrap { margin: 0 -16px -16px; }
  table thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  .team-row { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .team-row td { padding: 0; border: 0; }
  .team-row td.c-person { grid-column: 1 / 2; }
  .team-row td.c-actions { grid-column: 2; grid-row: 1; }
  .team-row td.c-status { grid-column: 1 / -1; max-width: none; }
  .team-row td.c-today, .team-row td.c-week { text-align: left; font-size: 13px; }
  .team-row td.c-today::before { content: "Today "; color: var(--text-2); }
  .team-row td.c-week::before { content: "Week "; color: var(--text-2); }
  .team-row td.c-role { display: none; }
}

/* ---------- Menu ---------- */
.menu-anchor { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 180px;
  background: var(--surface); border-radius: 10px; box-shadow: var(--shadow-pop); padding: 5px;
  display: grid;
}
.menu button { text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.menu button:hover, .menu button:focus-visible { background: var(--primary-soft); outline: none; }
.menu button.danger { color: var(--error); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

/* ---------- Dialog ---------- */
dialog {
  border: 0; border-radius: 14px; padding: 0; width: min(440px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop);
}
dialog::backdrop { background: rgba(8, 14, 16, .42); backdrop-filter: blur(2px); }
@media (prefers-reduced-motion: no-preference) {
  dialog[open] { animation: pop .18s var(--ease); }
}
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.dialog-body { padding: 22px; display: grid; gap: 14px; }
.dialog-body p { margin: 0; color: var(--text-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.segmented-radio { display: flex; gap: 6px; }
.segmented-radio label { flex: 1; display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; cursor: pointer; font-size: 13px; }
.segmented-radio label:has(input:checked) { border-color: var(--primary-text); background: var(--primary-soft); }
.segmented-radio input { accent-color: var(--primary); margin: 0; }

/* ---------- Segmented control ---------- */
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 2px; }
.segmented button { border: 0; background: none; padding: 5px 14px; border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-2); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 .5px var(--border); }

/* ---------- Chart ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 240px; overflow: visible; }
.chart .grid line { stroke: var(--border); }
.chart .axis text { fill: var(--text-2); font-size: 11px; font-family: var(--font-body); }
.chart .bar { fill: var(--primary); transition: opacity .12s; }
@media (prefers-color-scheme: dark) { .chart .bar { fill: #14B8A6; } }
.chart .bar.goal-met { fill: var(--success); }
.chart .bar.today { fill: url(#todayStripe); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar:hover { opacity: .8; }
.chart .goal { stroke: var(--amber); stroke-dasharray: 4 4; stroke-width: 1.25; }
.chart .goal-label { fill: var(--amber-text); font-size: 11px; font-weight: 500; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--text); color: var(--bg); font-size: 12px; padding: 6px 9px; border-radius: 7px;
  transform: translate(-50%, calc(-100% - 8px)); white-space: nowrap;
}
.tooltip strong { font-family: var(--font-numeric); font-variant-numeric: tabular-nums; }

/* ---------- Bars (projects / apps) ---------- */
.bars { display: grid; gap: 12px; }
.bar-row { display: grid; gap: 6px; }
.bar-top { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.bar-top .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.bar-top .val { font-family: var(--font-numeric); font-variant-numeric: tabular-nums; }
.bar-top .pct { color: var(--text-2); width: 40px; text-align: right; font-family: var(--font-numeric); font-variant-numeric: tabular-nums; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.track { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.fill { height: 100%; border-radius: 99px; background: var(--primary); }
@media (prefers-reduced-motion: no-preference) { .fill { transition: width .4s var(--ease); } }
.app-glyph { width: 20px; height: 20px; border-radius: 5px; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #fff; flex: none; }

/* ---------- Sessions ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); white-space: nowrap; }
.badge { font-size: 11px; font-weight: 500; padding: 1px 6px; border-radius: 5px; background: color-mix(in srgb, var(--indigo) 14%, transparent); color: var(--indigo); margin-left: 6px; }
.note { color: var(--text-2); max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sessions td { font-size: 13px; }
@media (max-width: 680px) {
  .sessions thead { display: none; }
  .sessions tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .sessions td { padding: 0; border: 0; }
  .sessions td.s-dur { grid-column: 2; grid-row: 1; text-align: right; }
  .sessions td.s-note { grid-column: 1 / -1; }
  .sessions td.s-note:empty { display: none; }
}

/* ---------- Empty / loading ---------- */
.empty { text-align: center; padding: 40px 16px; color: var(--text-2); display: grid; gap: 6px; justify-items: center; }
.empty svg { width: 28px; height: 28px; opacity: .6; }
.empty strong { color: var(--text); font-weight: 600; }
.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; border: 1px solid var(--border); }
@media (prefers-reduced-motion: no-preference) { .skeleton { animation: shimmer 1.4s linear infinite; } }
@keyframes shimmer { to { background-position: -200% 0; } }

.banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px; font-size: 13px; background: color-mix(in srgb, var(--warning) 12%, transparent); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow-pop);
  max-width: calc(100vw - 32px);
}

@media (max-width: 520px) {
  .topbar { padding: 10px 16px; }
  .main { padding: 20px 16px 48px; }
  .me .me-name { display: none; }
  h1 { font-size: 24px; }
}
