/* Filt Tasks */
:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #1a1f26; --muted: #68707c;
  --line: #e3e6ea; --accent: #2563eb; --accent-soft: #eff4ff;
  --red: #dc2626; --red-soft: #fef2f2; --green: #16a34a; --green-soft: #f0fdf4;
  --blue: #2563eb; --blue-soft: #eff6ff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151a; --panel: #1a1f26; --text: #e8eaee; --muted: #8b94a1;
    --line: #2a313b; --accent: #5b8def; --accent-soft: #1c2739;
    --red: #ef4444; --red-soft: #2a1717; --green: #34d399; --green-soft: #12241a;
    --blue: #5b8def; --blue-soft: #16202f;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.err { color: var(--red); }
.overdue-text { color: var(--red); font-weight: 600; }

button { font: inherit; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 8px; padding: 6px 14px; cursor: pointer; }
button:hover { filter: brightness(1.08); }
button.ghost { background: transparent; color: var(--muted); border-color: var(--line); }
button.danger { background: transparent; color: var(--red); border-color: var(--red); }
button.small { padding: 3px 10px; font-size: 13px; }
input, textarea, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* login */
.login { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 36px; width: 320px; display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; }

/* layout */
.main { display: flex; min-height: 100vh; }
.sidebar { width: 240px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { font-weight: 700; font-size: 18px; cursor: pointer; padding: 0 8px; }
.brand span { color: var(--accent); }
#client-list { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.client-link { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; color: var(--text); }
.client-link:hover { background: var(--accent-soft); }
.client-link.active { background: var(--accent-soft); font-weight: 600; }
.client-link.disabled .name { color: var(--muted); text-decoration: line-through; }
.client-link .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badges { display: flex; gap: 4px; }
.badge { background: var(--line); color: var(--text); border-radius: 999px; font-size: 12px; padding: 0 8px; line-height: 20px; }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.green { background: var(--green-soft); color: var(--green); }

.content { flex: 1; padding: 28px 32px; max-width: 980px; }
.page-head h1 { margin: 0 0 4px; font-size: 24px; }
.page-head { margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin-bottom: 18px; }
.card h2 { margin: 0 0 12px; font-size: 17px; }

/* overview */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.client-card { display: block; color: var(--text); margin: 0; }
.client-card:hover { border-color: var(--accent); }
.client-card h2 { margin-bottom: 6px; }
.client-card .stats { display: flex; gap: 12px; margin-bottom: 6px; }

/* targets */
.targets table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 14px; }
.targets th, .targets td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.targets th { color: var(--muted); font-weight: 600; }
.targets p { margin: 6px 0; }
.targets details { margin-top: 8px; }
.targets summary { cursor: pointer; color: var(--muted); }

/* tasks */
.add-task { display: flex; gap: 8px; margin-bottom: 14px; }
.add-task input#new-title { flex: 1; }
.group-title { font-weight: 600; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; margin: 14px 0 6px; }
summary.group-title { cursor: pointer; }
.tasks { list-style: none; margin: 0; padding: 0; }
.task { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 6px; background: var(--bg); }
.task.doing { border-left: 3px solid var(--accent); }
.task.overdue { border-left: 3px solid var(--red); }
.task.due-today { border-left: 3px solid #d97706; }
.task.done .title { text-decoration: line-through; color: var(--muted); }
.task-row { display: flex; align-items: center; gap: 10px; }
.task-row .title { flex: 1; }
.task-row .due { font-size: 13px; color: var(--muted); }
.task.overdue .due { color: var(--red); font-weight: 600; }
.check { width: 24px; height: 24px; padding: 0; border-radius: 999px; background: transparent; border: 2px solid var(--line); color: var(--green); font-weight: 700; flex-shrink: 0; }
.task.done .check { border-color: var(--green); background: var(--green-soft); }
.editor { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.editor-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.e-title { width: 100%; }
.e-notes { width: 100%; resize: vertical; }
.empty { margin: 4px 0 10px; }

.pointers { margin: 10px 0; padding-left: 20px; }
.pointers li { margin: 4px 0; }
.client-chip { font-size: 12px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 1px 9px; white-space: nowrap; flex-shrink: 0; }
.recur-badge { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; white-space: nowrap; }
.sec-overdue { color: var(--red); }
.sec-today { color: #d97706; }
.client-link.myday { margin-bottom: 8px; }
.add-task select { max-width: 140px; }

.range-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.range-row select, .range-row input { padding: 4px 8px; font-size: 13px; }

/* loading bar */
body.loading::before { content: ""; position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100;
  background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 50% 100%;
  animation: loadslide 1s linear infinite; }
@keyframes loadslide { from { background-position: -50% 0; } to { background-position: 150% 0; } }

/* toasts */
#toasts { position: fixed; bottom: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--green);
  border-radius: 10px; padding: 10px 16px; box-shadow: 0 4px 16px rgba(0,0,0,.15); max-width: 340px; font-size: 14px; }
.toast.err-toast { border-left-color: var(--red); }

/* tracked today (My Day) */
.tracked-today { margin: 8px 0 0; font-size: 14px; }

/* time tracking */
.time-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.time-head h2 { margin: 0; }
.pipe { height: 14px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 12px 0 8px; position: relative; }
.pipe-tick { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); opacity: .45; cursor: help; }
.pipe-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.pipe.warn .pipe-fill { background: #d97706; }
.pipe.over .pipe-fill { background: var(--red); }
.pipe.mini { height: 8px; margin: 0; flex: 1; }
.hist-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.hist-month { font-family: ui-monospace, monospace; font-size: 13px; color: var(--muted); width: 62px; flex-shrink: 0; }
.hist-row .small { white-space: nowrap; }
#timer-chip { background: var(--accent-soft); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; font-size: 13px; }
#timer-chip .chip-line { font-weight: 600; margin-bottom: 2px; }
#timer-chip .chip-desc { color: var(--muted); margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task .track { color: var(--green); border-color: var(--green); }

/* performance chart (small multiples) — palette slots 1-3, validated all-pairs */
:root {
  --viz-s1: #2a78d6; --viz-s2: #eb6834; --viz-s3: #1baf7a;
  --viz-grid: #e1e0d9; --viz-base: #c3c2b7; --viz-muted: #898781;
}
@media (prefers-color-scheme: dark) {
  :root { --viz-s1: #3987e5; --viz-s2: #d95926; --viz-s3: #199e70; --viz-grid: #2c2c2a; --viz-base: #383835; }
}
.pc-wrap { position: relative; margin: 4px 0 14px; }
.pc-wrap svg { display: block; max-width: 100%; }
.pc-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.pc-line.s1 { stroke: var(--viz-s1); } .pc-line.s2 { stroke: var(--viz-s2); } .pc-line.s3 { stroke: var(--viz-s3); }
.pc-swatch.s1 { fill: var(--viz-s1); } .pc-swatch.s2 { fill: var(--viz-s2); } .pc-swatch.s3 { fill: var(--viz-s3); }
.pc-label { font: 600 12px system-ui, sans-serif; fill: var(--muted); }
.pc-latest { font: 600 13px system-ui, sans-serif; fill: var(--text); }
.pc-tick { font: 11px ui-monospace, monospace; fill: var(--viz-muted); }
.pc-grid { stroke: var(--viz-grid); stroke-width: 1; }
.pc-base { stroke: var(--viz-base); stroke-width: 1; }
.pc-dot { fill: var(--muted); stroke: var(--panel); stroke-width: 2; cursor: pointer; }
.pc-cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.pc-tip { position: absolute; top: 0; z-index: 20; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px; box-shadow: 0 6px 20px rgba(0,0,0,.18); font-size: 13px;
  pointer-events: none; min-width: 180px; max-width: 340px; }
.pc-tip-date { font-family: ui-monospace, monospace; color: var(--muted); margin-bottom: 4px; }
.pc-tip .chip-dot { display: inline-block; width: 8px; height: 8px; border-radius: 999px; margin-right: 6px; }
.chip-dot.s1 { background: var(--viz-s1); } .chip-dot.s2 { background: var(--viz-s2); } .chip-dot.s3 { background: var(--viz-s3); }
.pc-tip-ch { margin-top: 6px; border-top: 1px solid var(--line); padding-top: 6px; color: var(--muted); }

/* notes */
#client-notes { width: 100%; resize: vertical; margin-bottom: 8px; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: none; }
.tl-date { font-family: ui-monospace, monospace; font-size: 13px; color: var(--muted); margin-right: 8px; }
.tl-cat { font-size: 13px; color: var(--muted); margin-left: 6px; }
.tl-text { margin-top: 2px; white-space: pre-wrap; }
.tl-text.has-detail { cursor: pointer; }
.tl-text .more { border-bottom: 1px dotted var(--muted); }
.tl-text .info { color: var(--muted); font-size: 12px; }
.tl-detail { white-space: pre-wrap; font-size: 13px; color: var(--muted); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin-top: 6px; }

@media (max-width: 720px) {
  .main { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: sticky; top: 0; z-index: 50;
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px;
    border-right: none; border-bottom: 1px solid var(--line); overflow: visible; }
  .brand { font-size: 16px; padding: 0; }
  #logout { margin-left: auto; order: 2; }
  #client-list { order: 3; flex: 1 1 100%; flex-direction: row; flex-wrap: nowrap; overflow-x: auto;
    gap: 6px; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
  .client-link { flex: 0 0 auto; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 13px; }
  .client-link.myday { margin-bottom: 0; }
  #timer-chip { order: 4; flex: 1 1 100%; margin-bottom: 0; }
  .content { padding: 14px; max-width: none; }
  .add-task { flex-wrap: wrap; }
  .add-task input#new-title, .add-task input#qa-title { flex: 1 1 100%; }
  .task-row { flex-wrap: wrap; }
}
