/* KULUAR Задачі — токени з ui-design/assets/kuluar-tokens.css, лише світла тема, mobile first. */
:root {
  --k-green: #8DC449; --k-green-dark: #5a8a20; --k-green-ink: #4a7a14;
  --k-red: #e84b4b; --k-red-ink: #c62828; --k-red-bg: #fdecec;
  --k-orange-ink: #8a4b0f; --k-orange-bg: #fdeedd; --k-orange: #F2994A;
  --k-warn: #FFD800; --k-warn-bg: #fff8e0;
  --k-bg: #ffffff; --k-surface: #ffffff; --k-soft: #f7faf0; --k-tint: #edf7e1;
  --k-ink: #2D2D2D; --k-ink-2: #4F4F4F; --k-muted: #6b6b6b;
  --k-line: #e6e6e6; --k-line-green: #dcead0; --k-field-border: #8a8a8a; --k-on-green: #ffffff;
  --k-radius: 8px; --k-radius-lg: 10px; --k-shadow: 0 10px 50px rgba(0, 0, 0, .12);
  --k-font: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
  --k-fast: 150ms; --k-base: 220ms; --k-ease-out: cubic-bezier(.2, .8, .2, 1);
  --tabbar-h: 64px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--k-bg); color: var(--k-ink); font: 400 1rem/1.5 var(--k-font); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--k-green-ink); text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 800; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; font-weight: 700; }
:focus-visible { outline: 3px solid var(--k-green-ink); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--k-muted); }
.small { font-size: .875rem; }
.boot { padding: 48px 16px; text-align: center; color: var(--k-muted); }

/* ---------- каркас ---------- */
.shell { min-height: 100vh; }
.side { display: none; }
.main { padding: 0 16px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); max-width: 960px; margin: 0 auto; }
.topbar { position: sticky; top: 0; z-index: 5; background: rgba(255, 255, 255, .96); backdrop-filter: blur(8px);
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 0; margin-bottom: 8px; border-bottom: 1px solid var(--k-line); }
.topbar h1 { font-size: 1.25rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .back { margin-left: -8px; }
.logo { width: 32px; height: 32px; border-radius: 50%; flex: none; }

.tabbar { position: fixed; z-index: 10; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--k-line);
  display: grid; grid-template-columns: repeat(5, 1fr); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--tabbar-h);
  color: var(--k-muted); text-decoration: none; font-size: .75rem; position: relative; }
.tabbar a[aria-current="page"] { color: var(--k-green-ink); font-weight: 700; }
.tabbar svg { width: 24px; height: 24px; }
.tabbar .tab-new span.plus { width: 44px; height: 44px; border-radius: 50%; background: var(--k-green); color: #fff; display: grid; place-items: center; }
.tabbar .tab-new svg { width: 26px; height: 26px; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--k-red); color: #fff; font-size: .75rem; font-weight: 700; line-height: 1; }
.tabbar .badge { position: absolute; top: 6px; left: calc(50% + 6px); }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 248px 1fr; }
  .tabbar { display: none; }
  .side { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; padding: 20px 12px;
    border-right: 1px solid var(--k-line); background: var(--k-soft); overflow-y: auto; }
  .side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-weight: 800; font-size: 1.125rem; }
  .side .brand img { width: 36px; height: 36px; border-radius: 50%; }
  .side .k-btn { margin: 0 4px 12px; }
  .side a.nav { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 12px; border-radius: var(--k-radius);
    color: var(--k-ink); text-decoration: none; }
  .side a.nav:hover { background: var(--k-tint); }
  .side a.nav[aria-current="page"] { background: var(--k-tint); color: var(--k-green-ink); font-weight: 700; }
  .side a.nav .badge { margin-left: auto; }
  .side .sep { height: 1px; background: var(--k-line); margin: 8px 4px; }
  .side .me { margin-top: auto; padding: 12px 8px 0; font-size: .875rem; color: var(--k-muted); }
  .main { padding: 8px 32px 48px; width: 100%; }
  .topbar .logo { display: none; }
}

/* ---------- кнопки ---------- */
.k-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px;
  border-radius: var(--k-radius); border: 2px solid transparent; background: transparent; cursor: pointer; text-decoration: none;
  font-weight: 400; line-height: 1.2; transition: opacity var(--k-fast), background-color var(--k-fast); white-space: nowrap; }
.k-btn--primary { background: var(--k-green); color: var(--k-on-green); }
.k-btn--primary:hover { opacity: .85; }
.k-btn--secondary { color: var(--k-green-ink); border-color: var(--k-green); background: #fff; }
.k-btn--secondary:hover { background: var(--k-tint); }
.k-btn--ghost { color: var(--k-ink); }
.k-btn--ghost:hover { background: var(--k-soft); }
.k-btn--danger { color: var(--k-red-ink); border-color: var(--k-red); background: #fff; }
.k-btn svg { width: 20px; height: 20px; flex: none; }
.k-btn--sm { min-height: 36px; padding: 6px 12px; font-size: .875rem; }
.k-btn[aria-busy="true"] { opacity: .6; pointer-events: none; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; background: transparent; border-radius: 50%; cursor: pointer; color: var(--k-ink); flex: none; }
.icon-btn:hover { background: var(--k-soft); }
.icon-btn svg { width: 24px; height: 24px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- список задач ---------- */
.group { margin: 20px 0 8px; display: flex; align-items: baseline; gap: 8px; }
.group h2 { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--k-muted); font-weight: 700; }
.group h2.danger { color: var(--k-red-ink); }
.group .count { font-size: .75rem; color: var(--k-muted); }
ul.tasks { list-style: none; margin: 0; padding: 0; }
.task { display: flex; align-items: flex-start; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--k-line); transition: opacity var(--k-base); }
.task.is-done { opacity: .45; }
.task.is-done .t-title { text-decoration: line-through; }
.task.rejected { background: var(--k-red-bg); border-radius: var(--k-radius); border-bottom: 0; margin-bottom: 6px; padding: 10px 10px 10px 6px; }
.check { width: 44px; height: 44px; margin: -4px 0 -4px -10px; flex: none; display: grid; place-items: center; border: 0; background: none; cursor: pointer; border-radius: 50%; }
.check span { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--k-field-border); display: grid; place-items: center; transition: background-color var(--k-fast), border-color var(--k-fast); }
.check:hover span { border-color: var(--k-green-ink); background: var(--k-tint); }
.check svg { width: 16px; height: 16px; color: #fff; opacity: 0; }
.task.is-done .check span { background: var(--k-green); border-color: var(--k-green); }
.task.is-done .check svg { opacity: 1; }
.t-body { flex: 1; min-width: 0; display: block; color: inherit; text-decoration: none; padding: 2px 0; }
.t-title { display: block; font-weight: 500; overflow-wrap: anywhere; }
.t-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 2px; font-size: .875rem; color: var(--k-muted); }
.t-meta .overdue { color: var(--k-red-ink); font-weight: 700; }
.t-meta .today { color: var(--k-green-ink); font-weight: 700; }
.t-reason { margin-top: 4px; font-size: .875rem; color: var(--k-ink); }
.t-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.no-check { width: 6px; flex: none; }

.chip { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 1px 8px; font-size: .75rem; font-weight: 700; line-height: 1.5; white-space: nowrap; }
.chip.urgent { background: var(--k-red-bg); color: var(--k-red-ink); }
.chip.important { background: var(--k-orange-bg); color: var(--k-orange-ink); }
.chip.st-new { background: #e8f1fb; color: #1d4f86; }
.chip.st-in_progress { background: var(--k-tint); color: var(--k-green-ink); }
.chip.st-rejected { background: var(--k-red-bg); color: var(--k-red-ink); }
.chip.st-done { background: var(--k-green); color: #fff; }
.chip.st-cancelled { background: #eee; color: var(--k-ink-2); }

.empty { text-align: center; padding: 48px 16px; color: var(--k-muted); }
.empty b { display: block; color: var(--k-ink); font-size: 1.125rem; margin-bottom: 4px; }
.empty .k-btn { margin-top: 16px; }

/* ---------- фільтри ---------- */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 4px; }
.filters .wide { grid-column: 1 / -1; }
.filters select, .filters input[type="search"] { width: 100%; min-height: 44px; padding: 8px 10px; border: 1.5px solid var(--k-field-border); border-radius: var(--k-radius); background: #fff; font-size: 1rem; }
.toggles { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 12px; border-radius: 999px; border: 1.5px solid var(--k-line); cursor: pointer; font-size: .875rem; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle:has(input:checked) { background: var(--k-tint); border-color: var(--k-green); color: var(--k-green-ink); font-weight: 700; }
.toggle:has(input:focus-visible) { outline: 3px solid var(--k-green-ink); outline-offset: 2px; }
.result-count { font-size: .875rem; color: var(--k-muted); margin: 8px 0 0; display: flex; justify-content: space-between; align-items: center; }
.linkish { background: none; border: 0; color: var(--k-green-ink); text-decoration: underline; cursor: pointer; padding: 8px 0; font-size: .875rem; }
@media (min-width: 900px) {
  .filters { grid-template-columns: repeat(4, 1fr); }
  .filters .wide { grid-column: span 2; }
}

/* ---------- форми ---------- */
.form { display: grid; gap: 16px; max-width: 560px; }
.field { display: grid; gap: 6px; }
.field > label, .field > .label { font-weight: 700; font-size: .875rem; }
.field .opt { font-weight: 400; color: var(--k-muted); }
.field .hint { color: var(--k-muted); font-size: .875rem; margin-top: -2px; }
.field .err { color: var(--k-red-ink); font-size: .875rem; font-weight: 700; }
.input, .field input:not([type="radio"]):not([type="checkbox"]), .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1.5px solid var(--k-field-border); border-radius: var(--k-radius); background: #fff; font-size: 1rem; line-height: 1.4; }
.field textarea { min-height: 88px; resize: vertical; }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible, .input:focus-visible { outline: none; border-color: var(--k-green-ink); box-shadow: 0 0 0 3px var(--k-tint); }
[aria-invalid="true"] { border-color: var(--k-red-ink) !important; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-flex; align-items: center; min-height: 40px; padding: 6px 14px; border-radius: var(--k-radius); border: 1.5px solid var(--k-line); cursor: pointer; background: #fff; }
.seg input:checked + span { background: var(--k-tint); border-color: var(--k-green); color: var(--k-green-ink); font-weight: 700; }
.seg input:focus-visible + span { outline: 3px solid var(--k-green-ink); outline-offset: 2px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checks { display: grid; gap: 4px; }
.checks label { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.checks input { width: 20px; height: 20px; accent-color: var(--k-green-ink); }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
.err-summary { background: var(--k-red-bg); border-left: 4px solid var(--k-red); border-radius: 0 6px 6px 0; padding: 10px 14px; color: var(--k-ink); }

/* ---------- картка задачі ---------- */
.card-head { display: grid; gap: 8px; margin: 8px 0 16px; }
.card-head h1 { font-size: 1.375rem; overflow-wrap: anywhere; }
.card-head .chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0 0 16px; font-size: .9375rem; }
.facts dt { color: var(--k-muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts dd.overdue { color: var(--k-red-ink); font-weight: 700; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--k-soft); border-radius: var(--k-radius); padding: 12px 14px; margin: 0 0 16px; }
.note-red { background: var(--k-red-bg); border-left: 4px solid var(--k-red); border-radius: 0 6px 6px 0; padding: 10px 14px; margin: 0 0 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.actions-2 { display: flex; flex-wrap: wrap; gap: 4px 8px; margin: -4px 0 20px; }
.section-title { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--k-muted); font-weight: 700; margin: 24px 0 8px;
  padding-bottom: 6px; border-bottom: 2px solid var(--k-green); }
ul.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
ul.feed li { display: grid; gap: 2px; }
ul.feed .who { font-size: .875rem; font-weight: 700; }
ul.feed .when { font-weight: 400; color: var(--k-muted); margin-left: 6px; }
ul.feed .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-form { display: flex; gap: 8px; align-items: flex-end; margin-top: 12px; }
.comment-form textarea { flex: 1; min-height: 44px; height: 44px; max-height: 160px; padding: 10px 12px; border: 1.5px solid var(--k-field-border); border-radius: var(--k-radius); resize: none; font-size: 1rem; }
details.history summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--k-green-ink); }
ul.history { list-style: none; margin: 0; padding: 0; font-size: .875rem; color: var(--k-ink-2); display: grid; gap: 6px; }

/* ---------- команда ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--k-line); margin: 4px 0 12px; overflow-x: auto; }
.tabs a { padding: 10px 12px; min-height: 44px; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--k-ink-2); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--k-green-ink); border-bottom-color: var(--k-green); font-weight: 700; }
ul.people { list-style: none; margin: 0; padding: 0; }
ul.people li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--k-line); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--k-tint); color: var(--k-green-ink); display: grid; place-items: center; font-weight: 700; flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
ul.people .info { flex: 1; min-width: 0; }
ul.people .info b { display: block; }
ul.people .info span { font-size: .875rem; color: var(--k-muted); }
ul.people li.inactive { opacity: .55; }
.warn-line { color: var(--k-orange-ink); font-size: .8125rem; }
.more-list { list-style: none; margin: 8px 0; padding: 0; }
.more-list a, .more-list button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 4px; border: 0; border-bottom: 1px solid var(--k-line);
  background: none; color: var(--k-ink); text-decoration: none; cursor: pointer; text-align: left; font-size: 1rem; }
.more-list .badge { margin-left: auto; }
.token-box { font-family: "SF Mono", Menlo, Consolas, monospace; background: var(--k-warn-bg); border-left: 3.5px solid var(--k-warn); padding: 10px 14px; overflow-wrap: anywhere; border-radius: 0 6px 6px 0; }

/* ---------- діалог (на телефоні — лист знизу) ---------- */
dialog.sheet { border: 0; padding: 0; width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 16px 16px 0 0; box-shadow: var(--k-shadow); max-height: 90vh; }
dialog.sheet::backdrop { background: rgba(0, 0, 0, .35); }
dialog.sheet .sheet-in { padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); display: grid; gap: 16px; }
dialog.sheet .sheet-head { display: flex; align-items: center; gap: 8px; }
dialog.sheet .sheet-head h2 { flex: 1; font-size: 1.125rem; }
dialog.sheet[open] { animation: sheet-in var(--k-base) var(--k-ease-out); }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 640px) {
  dialog.sheet { max-width: 520px; margin: auto; border-radius: var(--k-radius-lg); }
  dialog.sheet .sheet-in { padding: 24px; }
  dialog.sheet .form-actions { justify-content: flex-end; }
}

/* ---------- тост ---------- */
#toast { position: fixed; z-index: 20; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  width: calc(100% - 32px); max-width: 480px; pointer-events: none; }
#toast .t { pointer-events: auto; display: flex; align-items: center; gap: 12px; background: var(--k-ink); color: #fff; border-radius: var(--k-radius); padding: 10px 10px 10px 16px; box-shadow: var(--k-shadow); min-height: 48px; }
#toast .t span { flex: 1; }
#toast .t button { background: none; border: 0; color: #c5e59c; font-weight: 700; cursor: pointer; min-height: 36px; padding: 4px 8px; text-decoration: underline; }
#toast .t.error { background: var(--k-red-ink); }
#toast .t.error button { color: #fff; }
@media (min-width: 900px) { #toast { bottom: 24px; } }

/* ---------- вхід ---------- */
.login { max-width: 420px; margin: 0 auto; padding: 64px 16px; text-align: center; display: grid; gap: 16px; justify-items: center; }
.login img.big { width: 96px; height: 96px; border-radius: 50%; }
.login h1 { font-size: 1.875rem; }
.login .dev { display: grid; gap: 8px; width: 100%; margin-top: 24px; padding-top: 16px; border-top: 1px dashed var(--k-line); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}
