/* Default = WhatsApp. Alternate = Rose (tema sebelumnya). */
:root,
html[data-theme="whatsapp"] {
  --text: #111b21;
  --muted: #667781;
  --primary: #25d366;
  --primary-hover: #1da851;
  --primary-soft: #d1f4e0;
  --primary-ink: #075e54;
  --accent: #00a884;
  --danger: #ea4335;
  --bg: #efeae2;
  --bg-login: linear-gradient(160deg, #d1f4e0, #efeae2 45%, #dcf8c6);
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --surface-3: #e9edef;
  --border: #d1d7db;
  --border-strong: #8696a0;
  --sidebar: #f0f2f5;
  --active-bg: #e7fce3;
  --active-border: #25d366;
  --active-dot: #25d366;
  --tab-bg: #e7fce3;
  --tab-color: #075e54;
  --tab-border: #a7e9c7;
  --badge-bg: #e7fce3;
  --badge-border: #a7e9c7;
  --badge-color: #075e54;
  --ai-card: linear-gradient(145deg, #dcf8c6, #e7fce3 55%, #fff);
  --avatar: linear-gradient(135deg, #25d366, #128c7e);
  --tag1-bg: #e7fce3;
  --tag1-color: #075e54;
  --tag2-bg: #dcf8c6;
  --tag2-color: #128c7e;
  --tag3-bg: #eff6ff;
  --tag3-color: #2563eb;
  --progress-fill: #25d366;
  --hover-card-border: #25d366;
  --hover-card-shadow: 0 4px 12px rgba(37, 211, 102, 0.18);
  --row-hover: #e7fce3;
  --history-report-border: #25d366;
  --role-tag-bg: #e7fce3;
  --role-tag-color: #075e54;
  font-family: "Segoe UI", system-ui, sans-serif;
}

html[data-theme="rose"] {
  --text: #1f2937;
  --muted: #64748b;
  --primary: #ec4899;
  --primary-hover: #db2777;
  --primary-soft: #fdf2f8;
  --primary-ink: #be185d;
  --accent: #db2777;
  --danger: #ef4444;
  --bg: #eef1f6;
  --bg-login: linear-gradient(160deg, #eef2ff, #fdf2f8 50%, #ecfeff);
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --sidebar: #f7f8fb;
  --active-bg: #eff6ff;
  --active-border: #93c5fd;
  --active-dot: #3b82f6;
  --tab-bg: #eff6ff;
  --tab-color: #1d4ed8;
  --tab-border: #bfdbfe;
  --badge-bg: #eff6ff;
  --badge-border: #bfdbfe;
  --badge-color: #1d4ed8;
  --ai-card: linear-gradient(145deg, #dbeafe, #fce7f3);
  --avatar: linear-gradient(135deg, #60a5fa, #34d399);
  --tag1-bg: #eff6ff;
  --tag1-color: #2563eb;
  --tag2-bg: #fdf2f8;
  --tag2-color: #db2777;
  --tag3-bg: #ecfdf5;
  --tag3-color: #059669;
  --progress-fill: #3b82f6;
  --hover-card-border: #f9a8d4;
  --hover-card-shadow: 0 4px 12px rgba(236, 72, 153, 0.12);
  --row-hover: #fdf2f8;
  --history-report-border: #fbcfe8;
  --role-tag-bg: #eff6ff;
  --role-tag-color: #2563eb;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--danger); margin-top: 0.75rem; }

.btn {
  border: none; border-radius: 10px; padding: 0.55rem 1rem;
  cursor: pointer; font-weight: 600; font-size: 0.9rem;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: var(--surface); color: #475569; border: 1px solid var(--border-strong); }
.btn.sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background: var(--bg-login);
}
.login-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 1.75rem; box-shadow: 0 10px 30px rgba(15,23,42,0.06);
}
.login-card h1 { margin: 0 0 0.35rem; font-size: 1.45rem; color: var(--primary-ink); }
.login-card > .muted { margin: 0 0 1.25rem; }
label { display: block; margin-bottom: 0.9rem; font-size: 0.85rem; }
label input:not([type="checkbox"]):not([type="radio"]),
label textarea {
  display: block; width: 100%; margin-top: 0.35rem; padding: 0.65rem 0.75rem;
  border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
}
label input[type="checkbox"],
label input[type="radio"] {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  vertical-align: middle;
  accent-color: var(--primary);
}
.login-card .btn { width: 100%; margin-top: 0.35rem; }
.hint { margin-top: 1rem; font-size: 0.78rem; }

.top-tabs { display: flex; gap: 0.35rem; }
.top-tab {
  border: 1px solid transparent; background: transparent; color: var(--muted);
  padding: 0.4rem 0.75rem; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 0.85rem;
}
.top-tab.active {
  background: var(--tab-bg); color: var(--tab-color); border-color: var(--tab-border);
}
.view-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.manage-panel { padding: 1.25rem; overflow: auto; }
.manage-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.manage-toolbar h2 { margin: 0; font-size: 1.2rem; }
.manage-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 12px; overflow: hidden; }
.manage-table th, .manage-table td { padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--border); text-align: left; font-size: 0.88rem; }
.manage-table th { background: var(--surface-2); color: var(--muted); font-size: 0.75rem; text-transform: uppercase; }
.manage-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.manage-table th.sortable:hover { color: var(--primary-ink); }
.manage-table th.sortable .sort-ind { opacity: 0.45; font-size: 0.7rem; margin-left: 0.2rem; }
.manage-table th.sortable.is-sorted .sort-ind { opacity: 1; color: var(--primary-ink); }
.roles-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.85rem; }
.role-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1rem; }
.role-card h3 { margin: 0 0 0.35rem; font-size: 1rem; }
.role-card p { margin: 0 0 0.75rem; color: var(--muted); font-size: 0.82rem; }
.role-card .tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.75rem; }
.role-card .tag {
  font-size: 0.7rem; background: var(--role-tag-bg); color: var(--role-tag-color);
  padding: 0.15rem 0.45rem; border-radius: 999px;
}

dialog {
  border: none; border-radius: 16px; padding: 0; width: min(440px, 94vw);
  box-shadow: 0 20px 50px rgba(15,23,42,0.18); background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgba(17, 27, 33, 0.45); }
dialog form { padding: 1.25rem; }
dialog h3 { margin: 0 0 1rem; }
.switch-row {
  display: flex !important;
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.65rem;
  width: fit-content;
  max-width: 100%;
  cursor: pointer;
}
.switch-row input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  flex-shrink: 0;
}
.perm-grid { display: grid; gap: 0.35rem; max-height: 180px; overflow: auto; }
.perm-grid label { margin: 0; display: flex; align-items: center; gap: 0.45rem; font-size: 0.85rem; }
.manage-dialog { width: min(640px, 96vw); max-height: 90vh; overflow: auto; }
.manage-dialog .switch-row { margin-bottom: 0.55rem; }
.role-access-fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 0.75rem 0.85rem 0.9rem; margin: 0.75rem 0 0; }
.fieldset-hint { margin: 0 0 0.65rem; font-size: 0.78rem; }
.role-access-grid { display: grid; gap: 0.55rem; max-height: 240px; overflow: auto; }
.role-access-card {
  display: flex !important;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.7rem;
  margin: 0;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  cursor: pointer;
}
.role-access-card:has(input:checked) {
  border-color: var(--active-border); background: var(--active-bg);
}
.role-access-card > input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0.15rem 0 0;
  flex-shrink: 0;
}
.role-access-card > span { flex: 1; min-width: 0; }
.role-access-card strong { display: inline; font-size: 0.9rem; }
.role-access-card .role-desc { margin: 0.25rem 0 0.4rem; font-size: 0.78rem; color: var(--muted); }
.role-access-card .opens-chips {
  display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.35rem;
}
.role-access-card .open-chip {
  font-size: 0.68rem; padding: 0.12rem 0.4rem; border-radius: 999px;
  background: var(--role-tag-bg); color: var(--role-tag-color);
}
.user-opens-box {
  margin-top: 0.75rem; padding: 0.7rem 0.8rem; border-radius: 12px;
  border: 1px dashed var(--border-strong); background: var(--bg);
}
.user-opens-box h4 {
  margin: 0 0 0.45rem; font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--primary-ink);
}
.user-opens-summary { font-size: 0.82rem; line-height: 1.45; }
.user-opens-summary .opens-group { margin: 0 0 0.45rem; }
.user-opens-summary .opens-group:last-child { margin-bottom: 0; }
.user-opens-summary .opens-group strong { display: block; font-size: 0.72rem; color: var(--muted); margin-bottom: 0.25rem; }
.user-opens-summary .open-item {
  display: inline-flex; align-items: center; gap: 0.25rem;
  margin: 0 0.35rem 0.3rem 0; padding: 0.2rem 0.5rem; border-radius: 999px;
  font-size: 0.75rem; background: var(--surface-2); border: 1px solid var(--border);
}
.user-opens-summary .open-item.on {
  background: var(--active-bg); border-color: var(--active-border); color: var(--primary-ink); font-weight: 600;
}
.user-opens-summary .open-item.off { opacity: 0.45; text-decoration: line-through; }
.perm-category-grid { display: grid; gap: 0.75rem; max-height: 360px; overflow: auto; }
.perm-category {
  border: 1px solid var(--border); border-radius: 12px; padding: 0.65rem 0.75rem; background: var(--surface-2);
}
.perm-category h4 {
  margin: 0 0 0.5rem; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--primary-ink);
}
.perm-category label {
  margin: 0 0 0.5rem;
  display: flex !important;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.55rem;
  font-size: 0.84rem;
}
.perm-category label:last-child { margin-bottom: 0; }
.perm-category label > input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0.15rem 0 0;
  flex-shrink: 0;
}
.perm-category label > span { flex: 1; min-width: 0; }
.perm-category .perm-desc { font-size: 0.74rem; color: var(--muted); margin-top: 0.1rem; }
.perm-category .perm-code { font-size: 0.68rem; color: #94a3b8; }

.topbar-left { display: flex; align-items: center; gap: 0.55rem; min-width: 0; }
.burger-btn { display: none; padding: 0.35rem 0.55rem; font-size: 1.1rem; line-height: 1; }
.desktop-only {}
.mobile-only, .mobile-only-flex { display: none !important; }
.nav-backdrop {
  position: fixed; inset: 0; background: rgba(17, 27, 33, 0.45); z-index: 60;
}
.mobile-drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: min(300px, 86vw); z-index: 70;
  background: var(--surface); border-right: 1px solid var(--border);
  transform: translateX(-105%); transition: transform 0.2s ease;
  display: flex; flex-direction: column; gap: 0.75rem; padding: 1rem 0.9rem;
  box-shadow: 8px 0 24px rgba(0,0,0,0.08);
}
.mobile-drawer.open { transform: translateX(0); }
.mobile-drawer-head { display: flex; justify-content: space-between; align-items: center; }
.drawer-nav { display: flex; flex-direction: column; gap: 0.35rem; }
.drawer-link {
  border: 1px solid transparent; background: transparent; text-align: left;
  padding: 0.65rem 0.75rem; border-radius: 12px; font: inherit; font-weight: 600;
  color: var(--text); cursor: pointer;
}
.drawer-link.active, .drawer-link:hover {
  background: var(--active-bg); border-color: var(--active-border); color: var(--primary-ink);
}
.drawer-section { display: flex; flex-wrap: wrap; gap: 0.55rem; align-items: center; padding-top: 0.35rem; }
.drawer-logout { margin-top: auto; width: 100%; }
.toolbar-title-row { display: flex; justify-content: space-between; gap: 0.75rem; align-items: flex-start; width: 100%; }
.filter-toggle { display: none !important; }

.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }

#board-view { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.85rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border);
  gap: 0.75rem;
}
.topbar strong { color: var(--primary-ink); }
.topbar-actions { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.badge {
  font-size: 0.75rem; padding: 0.25rem 0.6rem; border-radius: 999px;
  background: var(--badge-bg); border: 1px solid var(--badge-border); color: var(--badge-color);
}
.badge.off { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }

.theme-select {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.78rem; color: var(--muted);
}
.theme-select select {
  padding: 0.35rem 0.55rem; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; font-size: 0.78rem;
}

.progress-shell {
  display: grid; grid-template-columns: 260px 1fr; flex: 1; min-height: 0;
}
.progress-sidebar {
  background: var(--sidebar); border-right: 1px solid var(--border);
  padding: 1rem 0.85rem; display: flex; flex-direction: column; gap: 1rem; overflow: auto;
}
.progress-side-head {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem;
}
.progress-side-head h3 {
  margin: 0; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
}
.progress-group-list, .progress-member-list { display: flex; flex-direction: column; gap: 0.35rem; }
.progress-group-item, .progress-member-item {
  display: flex; align-items: center; gap: 0.55rem; padding: 0.55rem 0.65rem;
  border-radius: 12px; border: 1px solid transparent; background: var(--surface);
  cursor: pointer; text-align: left; width: 100%; color: var(--text); font: inherit;
}
.progress-group-item:hover, .progress-member-item:hover { border-color: var(--border-strong); }
.progress-group-item.active {
  border-color: var(--active-border); background: var(--active-bg);
}
.progress-group-item .dot { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; flex-shrink: 0; }
.progress-group-item.active .dot { background: var(--active-dot); }
.progress-group-item .meta, .progress-member-item .meta {
  margin-left: auto; font-size: 0.72rem; color: #94a3b8;
}
.progress-group-item strong, .progress-member-item strong {
  font-size: 0.86rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.progress-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--avatar);
  color: #fff; font-size: 0.7rem; font-weight: 700; display: grid; place-items: center; flex-shrink: 0;
}
.progress-ai-card {
  margin-top: auto; background: var(--ai-card);
  border-radius: 16px; padding: 0.9rem; border: 1px solid var(--border);
}
.progress-ai-card strong { display: block; margin-bottom: 0.25rem; font-size: 0.9rem; color: var(--primary-ink); }
.progress-ai-card p { margin: 0; font-size: 0.78rem; color: #475569; }
.progress-main { padding: 1rem 1.25rem 1.5rem; overflow: auto; }
.progress-toolbar {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  align-items: flex-start; margin-bottom: 1rem;
}
.progress-toolbar h2 { margin: 0 0 0.25rem; font-size: 1.25rem; color: var(--primary-ink); }
.progress-toolbar-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.progress-toolbar-actions select {
  padding: 0.5rem 0.7rem; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
}
.kanban-board {
  display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 0.85rem; align-items: start;
}
.progress-empty { padding: 2rem 1rem; }
.kanban-col {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 16px; padding: 0.75rem; min-height: 280px;
}
.kanban-col-head {
  display: flex; align-items: center; gap: 0.45rem; margin-bottom: 0.75rem;
  font-weight: 700; font-size: 0.9rem; color: #334155;
}
.kanban-col-head .count {
  margin-left: auto; background: var(--surface-3); color: #475569; border-radius: 999px;
  font-size: 0.72rem; padding: 0.1rem 0.45rem;
}
.kanban-dot { width: 9px; height: 9px; border-radius: 50%; }
.kanban-dot.todo { background: #94a3b8; }
.kanban-dot.in_progress { background: #f59e0b; }
.kanban-dot.review { background: #3b82f6; }
.kanban-dot.completed { background: #22c55e; }
.kanban-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 0.85rem;
  margin-bottom: 0.65rem; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.kanban-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.45rem; }
.kanban-tag {
  font-size: 0.68rem; font-weight: 600; padding: 0.12rem 0.45rem; border-radius: 999px;
  background: var(--tag1-bg); color: var(--tag1-color);
}
.kanban-tag:nth-child(2) { background: var(--tag2-bg); color: var(--tag2-color); }
.kanban-tag:nth-child(3) { background: var(--tag3-bg); color: var(--tag3-color); }
.kanban-card h4 { margin: 0 0 0.35rem; font-size: 0.95rem; color: var(--text); line-height: 1.3; }
.kanban-card p {
  margin: 0 0 0.65rem; font-size: 0.78rem; color: var(--muted); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.kanban-progress-label {
  display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--muted); margin-bottom: 0.25rem;
}
.kanban-progress-bar {
  height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin-bottom: 0.55rem;
}
.kanban-progress-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--progress-fill); }
.kanban-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.kanban-card-foot .msgs { font-size: 0.72rem; color: #94a3b8; }
.kanban-card.clickable { cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.kanban-card.clickable:hover {
  border-color: var(--hover-card-border); box-shadow: var(--hover-card-shadow);
}

.view-toggle {
  display: inline-flex; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden;
}
.view-toggle-btn {
  border: none; background: transparent; padding: 0.45rem 0.75rem; cursor: pointer;
  font-weight: 600; font-size: 0.82rem; color: var(--muted);
}
.view-toggle-btn.active {
  background: var(--primary-soft); color: var(--primary-ink);
}

.date-range {
  display: inline-flex; align-items: center; gap: 0.35rem;
}
.date-range input[type="date"] {
  padding: 0.45rem 0.55rem; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
}

.person-select { position: relative; min-width: 180px; }
.person-select input[type="text"] {
  width: 100%; padding: 0.5rem 0.7rem; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit;
}
.person-dropdown {
  position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 28px rgba(15,23,42,0.12); max-height: 240px; overflow: auto;
}
.person-option {
  display: flex; align-items: center; gap: 0.5rem; width: 100%;
  padding: 0.55rem 0.75rem; border: none; background: transparent; cursor: pointer;
  text-align: left; font: inherit; color: var(--text);
}
.person-option:hover { background: var(--surface-2); }
.person-option .meta { margin-left: auto; font-size: 0.72rem; color: #94a3b8; }

.board-names-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 0.85rem 1rem; margin-top: 0.25rem;
}
.board-names-panel .manage-toolbar { margin-bottom: 0.5rem; }
.table-board { display: block; }
.table-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: auto;
}
.progress-table { width: 100%; border-collapse: collapse; min-width: 860px; }
.progress-table th, .progress-table td {
  padding: 0.7rem 0.85rem; border-bottom: 1px solid var(--border); text-align: left; font-size: 0.85rem; vertical-align: top;
}
.progress-table th {
  background: var(--surface-2); color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em;
  position: sticky; top: 0;
}
.progress-table th.sortable {
  cursor: pointer; user-select: none; white-space: nowrap;
}
.progress-table th.sortable:hover { color: var(--primary-ink); }
.progress-table th.sortable .sort-ind { opacity: 0.4; font-size: 0.68rem; margin-left: 0.2rem; }
.progress-table th.sortable.is-sorted { color: var(--primary-ink); }
.progress-table th.sortable.is-sorted .sort-ind { opacity: 1; }
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: var(--row-hover); }
.table-person { display: flex; align-items: center; gap: 0.55rem; }
.table-summary {
  max-width: 280px; color: var(--muted); font-size: 0.8rem;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.status-pill {
  display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 0.2rem 0.55rem;
  border-radius: 999px; background: var(--surface-3); color: #475569;
}
.status-pill.todo { background: #f1f5f9; color: #64748b; }
.status-pill.in_progress { background: #fffbeb; color: #b45309; }
.status-pill.review { background: #eff6ff; color: #1d4ed8; }
.status-pill.completed { background: #ecfdf5; color: #059669; }

.history-dialog {
  width: min(920px, 96vw); max-height: 90vh; padding: 0; border: none; border-radius: 16px;
  box-shadow: 0 20px 50px rgba(15,23,42,0.18);
}
.history-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
  padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--border); background: var(--surface);
}
.history-head h3 { margin: 0 0 0.25rem; color: var(--primary-ink); }
.history-head .muted { margin: 0; }
.history-controls {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
  padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.history-controls select {
  padding: 0.4rem 0.55rem; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 0.82rem;
}
.history-body {
  padding: 1rem 1.25rem 1.25rem; overflow: auto; max-height: calc(90vh - 160px);
  display: flex; flex-direction: column; gap: 0.75rem; background: var(--bg);
  min-width: 0;
}
.history-item {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 0.75rem 0.9rem;
}
.history-item.report { background: var(--surface); border-color: var(--history-report-border); }
.history-item-head {
  display: flex; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.45rem;
  font-size: 0.8rem; color: var(--muted); align-items: center;
}
.history-item pre {
  margin: 0; white-space: pre-wrap; word-break: break-word; font: inherit; font-size: 0.86rem; color: var(--text);
}
.history-other { margin-top: 0.5rem; }
.history-other summary { cursor: pointer; color: var(--muted); font-weight: 600; margin-bottom: 0.5rem; }

.timeline {
  position: relative; margin: 0; padding: 0.25rem 0 0.25rem 1.1rem;
  list-style: none; border-left: 2px solid var(--border-strong);
  min-width: 0; max-width: 100%;
}
.timeline-item {
  position: relative; margin: 0 0 1rem 0.85rem; padding: 0; min-width: 0;
}
.timeline-dot {
  position: absolute; left: -1.55rem; top: 0.85rem; width: 12px; height: 12px;
  border-radius: 50%; background: #94a3b8; border: 2px solid var(--surface); box-shadow: 0 0 0 2px var(--border);
}
.timeline-item.report .timeline-dot { background: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.timeline-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0.75rem 0.9rem;
  min-width: 0; max-width: 100%; overflow: hidden;
}
.timeline-item.report .timeline-card { border-color: var(--history-report-border); }
.timeline-card pre,
.history-body pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font: inherit;
  font-size: 0.86rem;
  color: var(--text);
  max-width: 100%;
}
.timeline-meta {
  display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; margin-bottom: 0.45rem;
  font-size: 0.78rem; color: var(--muted);
}
.timeline-badge {
  font-size: 0.68rem; font-weight: 700; padding: 0.12rem 0.45rem; border-radius: 999px;
  background: var(--surface-3); color: #475569;
}
.timeline-badge.report { background: var(--primary-soft); color: var(--primary-ink); }

.history-analysis {
  background: var(--surface);
  border: 1px solid var(--history-report-border);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.25rem;
}
.history-analysis-label {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--primary-ink); margin: 0 0 0.45rem;
}
.history-analysis h4 {
  margin: 0 0 0.35rem; font-size: 1rem; color: var(--text); line-height: 1.35;
  overflow-wrap: anywhere; word-break: break-word;
}
.history-analysis p {
  margin: 0 0 0.65rem; font-size: 0.86rem; color: var(--muted); line-height: 1.45;
  overflow-wrap: anywhere; word-break: break-word;
}
.history-analysis-meta {
  display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; margin-bottom: 0.55rem;
}
.history-analysis-empty {
  background: var(--surface-2); border: 1px dashed var(--border); border-radius: 14px;
  padding: 0.85rem 1rem; margin-bottom: 0.25rem; font-size: 0.85rem; color: var(--muted);
}

.history-table-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: auto;
  max-width: 100%;
}
.history-table { width: 100%; border-collapse: collapse; min-width: 640px; table-layout: fixed; }
.history-table th, .history-table td {
  padding: 0.55rem 0.65rem; border-bottom: 1px solid var(--border); text-align: left;
  font-size: 0.82rem; vertical-align: top;
}
.history-table th { background: var(--surface-2); color: var(--muted); position: sticky; top: 0; }
.history-table th.sortable { cursor: pointer; user-select: none; }
.history-table th.sortable:hover { color: var(--primary-ink); }
.history-table .col-search {
  width: 100%; margin-top: 0.35rem; padding: 0.3rem 0.45rem; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); font: inherit; font-size: 0.75rem;
}
.history-table .body-cell {
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
  max-width: none; font-size: 0.8rem;
}
.ask-fab {
  position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 50;
  border: none; border-radius: 999px; padding: 0.85rem 1.15rem;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 0.9rem;
  box-shadow: 0 10px 28px rgba(0,0,0,0.18); cursor: pointer;
}
.ask-fab:hover { background: var(--primary-hover); }
.ask-dialog {
  width: min(560px, 96vw); max-height: 85vh; padding: 0; border: none; border-radius: 16px;
  box-shadow: 0 20px 50px rgba(15,23,42,0.18);
}
.ask-body { display: flex; flex-direction: column; gap: 0.75rem; padding: 0 1.1rem 1.1rem; }
.ask-chat {
  min-height: 180px; max-height: 42vh; overflow: auto; display: flex; flex-direction: column; gap: 0.65rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 0.75rem;
}
.ask-bubble {
  max-width: 92%; padding: 0.65rem 0.8rem; border-radius: 12px; font-size: 0.86rem; line-height: 1.45;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
}
.ask-bubble.user { align-self: flex-end; background: var(--primary-soft); color: var(--primary-ink); }
.ask-bubble.ai { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); }
.ask-form { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; align-items: end; }
.ask-form textarea {
  width: 100%; padding: 0.65rem 0.75rem; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; resize: vertical;
}
.names-edit-input {
  width: 100%; padding: 0.4rem 0.55rem; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); font: inherit;
}
.charts-controls {
  display: flex; flex-wrap: wrap; gap: 0.65rem; align-items: end; margin-bottom: 0.85rem;
}
.charts-controls label {
  margin: 0; font-size: 0.8rem; color: var(--muted);
}
.charts-controls select,
.charts-controls input[type="text"] {
  display: block; margin-top: 0.3rem; min-width: 140px;
  padding: 0.45rem 0.6rem; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit;
}
.chart-builder {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 0.85rem 1rem; margin-bottom: 0.85rem;
}
.chart-builder h3 { margin: 0 0 0.65rem; font-size: 0.95rem; color: var(--primary-ink); }
.chart-builder-row { margin-bottom: 0.5rem; }
.chart-presets {
  display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.35rem 0 0.75rem;
}
.chart-preset-btn {
  border: 1px solid var(--border-strong); background: var(--bg);
  color: var(--text); border-radius: 999px; padding: 0.28rem 0.7rem;
  font: inherit; font-size: 0.8rem; cursor: pointer;
}
.chart-preset-btn:hover { border-color: var(--primary); color: var(--primary-ink); }
.chart-ai-box label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.35rem; }
.chart-ai-box textarea {
  width: 100%; box-sizing: border-box; min-height: 64px; resize: vertical;
  padding: 0.55rem 0.7rem; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--bg); color: var(--text); font: inherit; margin-bottom: 0.5rem;
}
.charts-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem; margin: 0.85rem 0;
}
.chart-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 0.85rem 1rem;
  position: relative; min-height: 260px;
}
.chart-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.55rem;
}
.chart-card h3 { margin: 0; font-size: 0.95rem; color: var(--primary-ink); }
.chart-cat {
  display: inline-block; font-size: 0.72rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.15rem;
}
.chart-card-wide { grid-column: 1 / -1; }
.chart-card canvas { max-height: 260px; }
.chart-remove-btn {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 0.85rem; padding: 0.2rem 0.4rem;
}
.chart-remove-btn:hover { color: #dc2626; }
.chart-summary {
  background: var(--surface); border: 1px solid var(--history-report-border);
  border-radius: 14px; padding: 0.9rem 1rem; white-space: pre-wrap;
  overflow-wrap: anywhere; word-break: break-word; line-height: 1.45; font-size: 0.9rem;
}
.chart-table-wrap { margin-top: 0.5rem; }
.chart-table-wrap h3 { margin: 0 0 0.55rem; font-size: 0.95rem; }

@media (max-width: 900px) {
  .charts-grid { grid-template-columns: 1fr; }
  .chart-card-wide { grid-column: auto; }
  .charts-controls label { width: 100%; }
  .charts-controls select,
  .charts-controls input[type="text"] { width: 100%; }
}
.history-photo {
  display: block; max-width: min(100%, 420px); max-height: 320px;
  border-radius: 12px; border: 1px solid var(--border); object-fit: contain; background: #00000008;
}
.history-table .history-photo { max-width: 220px; max-height: 160px; }

@media (max-width: 1100px) {
  .progress-shell { grid-template-columns: 1fr; }
  .kanban-board { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .burger-btn { display: inline-flex; }
  .desktop-only { display: none !important; }
  .mobile-only { display: inline-flex !important; }
  .mobile-only-flex { display: flex !important; }
  .filter-toggle { display: inline-flex !important; width: 100%; justify-content: space-between; }
  .progress-toolbar-actions {
    display: none;
    width: 100%;
    padding: 0.65rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
  }
  .progress-toolbar-actions.open { display: flex; }
  .progress-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(300px, 88vw); z-index: 70;
    transform: translateX(-105%); transition: transform 0.2s ease;
    box-shadow: 8px 0 24px rgba(0,0,0,0.1);
  }
  .progress-sidebar.open { transform: translateX(0); }
  .sidebar-mobile-head {
    justify-content: space-between; align-items: center; margin-bottom: 0.35rem;
  }
  .topbar { padding: 0.65rem 0.85rem; }
  .progress-main { padding: 0.85rem; }
  .ask-fab { right: 0.85rem; bottom: 0.85rem; }
  .manage-table { display: block; overflow-x: auto; }
}
@media (max-width: 700px) {
  .kanban-board { grid-template-columns: 1fr; }
  .person-select { min-width: 140px; width: 100%; }
  .user-label-short #user-label { display: none; }
}
