/* Taskflow — work management UI */
:root {
  --bg: #ffffff;
  --bg-soft: #f9f8f8;
  --bg-muted: #f5f3f3;
  --bg-hover: #f6f5f4;
  --bg-active: #edeae9;
  --text: #1e1f21;
  --text-2: #6d6e6f;
  --text-3: #a2a0a2;
  --border: #edeae9;
  --border-2: #e0dedd;
  --sidebar: #2e2e30;
  --sidebar-2: #3d3e40;
  --sidebar-active: #4b4c4e;
  --sidebar-text: #f5f4f3;
  --sidebar-text-2: #c7c4c4;
  --accent: #f06a6a;
  --accent-2: #e85c5c;
  --primary: #4573d2;
  --primary-2: #3561c0;
  --success: #58a182;
  --success-bg: #e2f6ec;
  --danger: #c92f54;
  --warn: #b98a00;
  --card: #ffffff;
  --shadow-1: 0 1px 2px rgba(0,0,0,.06), 0 0 0 1px rgba(0,0,0,.04);
  --shadow-2: 0 4px 16px rgba(0,0,0,.12);
  --shadow-3: 0 12px 40px rgba(0,0,0,.18);
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
body.dark {
  --bg: #1e1f21;
  --bg-soft: #252628;
  --bg-muted: #2a2b2d;
  --bg-hover: #2a2b2d;
  --bg-active: #353638;
  --text: #f5f4f3;
  --text-2: #a2a0a2;
  --text-3: #6d6e6f;
  --border: #353638;
  --border-2: #424244;
  --sidebar: #161718;
  --sidebar-2: #252628;
  --sidebar-active: #353638;
  --card: #2a2b2d;
  --success-bg: #1f3a2e;
  --shadow-1: 0 1px 2px rgba(0,0,0,.4), 0 0 0 1px rgba(255,255,255,.05);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--text); }
h1, h2, h3, h4 { margin: 0; font-weight: 500; }
svg.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 14px; height: 14px; }
svg.i.lg { width: 20px; height: 20px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; grid-template-rows: 48px 1fr; height: 100vh; }
.app.collapsed { grid-template-columns: 0 1fr; }
.app.collapsed .sidebar { visibility: hidden; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 0 12px; background: var(--sidebar); color: var(--sidebar-text); border-bottom: 1px solid #1a1a1b; z-index: 30; }
.topbar .icon-btn { color: var(--sidebar-text-2); }
.topbar .icon-btn:hover { background: var(--sidebar-2); color: #fff; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; letter-spacing: -.2px; color: #fff; padding-right: 8px; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg, #f06a6a, #f1bd6c); display: grid; place-items: center; }
.brand-mark svg { width: 16px; height: 16px; stroke: #fff; stroke-width: 2.6; fill: none; }
.create-btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px 0 8px; border-radius: 16px; background: transparent; border: 1px solid #5b5c5e; color: #fff; font-weight: 500; }
.create-btn .plus { width: 20px; height: 20px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; }
.create-btn:hover { background: var(--sidebar-2); }
.search-box { flex: 1; max-width: 560px; margin: 0 auto; position: relative; }
.search-box input { width: 100%; height: 32px; border-radius: 16px; border: 1px solid #5b5c5e; background: #565557; color: #fff; padding: 0 14px 0 34px; outline: none; }
.search-box input::placeholder { color: #d3d1d1; }
.search-box input:focus { background: #fff; color: var(--text); border-color: #fff; }
.search-box > svg { position: absolute; left: 11px; top: 8px; color: #d3d1d1; }
.search-results { position: absolute; top: 38px; left: 0; right: 0; background: var(--card); color: var(--text); border-radius: 10px; box-shadow: var(--shadow-3); padding: 6px; max-height: 70vh; overflow: auto; }
.search-results .grp { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--text-2); padding: 8px 10px 4px; letter-spacing: .4px; }
.search-results a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; }
.search-results a:hover, .search-results a.sel { background: var(--bg-hover); }
.top-right { display: flex; align-items: center; gap: 6px; }
.upgrade-pill { font-size: 12px; padding: 3px 10px; border-radius: 12px; background: #f1bd6c; color: #1e1f21; font-weight: 600; }

.sidebar { background: var(--sidebar); color: var(--sidebar-text); overflow-y: auto; padding: 8px 0 24px; display: flex; flex-direction: column; }
.sidebar::-webkit-scrollbar { width: 8px; } .sidebar::-webkit-scrollbar-thumb { background: #4b4c4e; border-radius: 4px; }
.nav { padding: 0 8px; }
.nav a, .nav .nav-item { display: flex; align-items: center; gap: 10px; padding: 0 10px; height: 32px; border-radius: 6px; color: var(--sidebar-text); font-size: 14px; }
.nav a:hover { background: var(--sidebar-2); }
.nav a.active { background: var(--sidebar-active); }
.nav a .count { margin-left: auto; font-size: 11px; background: var(--accent); color: #fff; border-radius: 9px; padding: 0 6px; line-height: 18px; }
.nav-sep { height: 1px; background: #424244; margin: 10px 16px; }
.nav-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 18px; font-size: 14px; color: var(--sidebar-text); font-weight: 500; }
.nav-head .icon-btn { color: var(--sidebar-text-2); width: 24px; height: 24px; }
.nav-head .icon-btn:hover { background: var(--sidebar-2); color: #fff; }
.proj-dot { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.sidebar-foot { margin-top: auto; padding: 16px; }
.invite-card { border: 1px solid #424244; border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--sidebar-text-2); }
.invite-card a { display: flex; align-items: center; gap: 8px; color: var(--sidebar-text); }

.main { overflow: auto; background: var(--bg); position: relative; display: flex; flex-direction: column; min-width: 0; }

/* ---------- Generic controls ---------- */
.icon-btn { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; border: 0; background: transparent; color: var(--text-2); padding: 0; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--border-2); background: var(--bg); color: var(--text); font-weight: 500; font-size: 14px; white-space: nowrap; }
.btn:hover { background: var(--bg-hover); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg-hover); }
.input, select.input, textarea.input { width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--border-2); border-radius: 6px; background: var(--bg); outline: none; }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; min-height: 80px; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(69,115,210,.15); }
label.lbl { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); margin: 12px 0 4px; }
.err { color: var(--danger); font-size: 12px; margin-top: 4px; }
.pill { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 13px; font-size: 13px; border: 1px solid var(--border-2); background: var(--bg); }
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; }
.avatar { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 10px; font-weight: 600; color: #1e1f21; flex: none; text-transform: uppercase; }
.avatar.lg { width: 36px; height: 36px; font-size: 13px; }
.avatar.xl { width: 64px; height: 64px; font-size: 22px; }
.avatar.sm { width: 20px; height: 20px; font-size: 9px; }
.avatar.empty { border: 1px dashed var(--text-3); background: transparent; color: var(--text-3); }
.avatar-stack { display: flex; } .avatar-stack .avatar { margin-left: -6px; box-shadow: 0 0 0 2px var(--bg); } .avatar-stack .avatar:first-child { margin-left: 0; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tabs a { padding: 8px 4px; margin: 0 6px -1px; color: var(--text-2); border-bottom: 2px solid transparent; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--text); }
.dropdown { position: relative; display: inline-block; }
.menu { position: absolute; top: calc(100% + 4px); left: 0; min-width: 200px; background: var(--card); border-radius: 8px; box-shadow: var(--shadow-3); border: 1px solid var(--border); padding: 6px; z-index: 60; display: none; }
.menu.right { left: auto; right: 0; }
.menu.open { display: block; }
.menu a, .menu button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 7px 10px; border-radius: 5px; background: none; border: 0; font-size: 14px; color: var(--text); }
.menu a:hover, .menu button:hover { background: var(--bg-hover); }
.menu .sep { height: 1px; background: var(--border); margin: 6px 0; }
.menu .menu-label { font-size: 11px; color: var(--text-2); padding: 6px 10px 2px; text-transform: uppercase; letter-spacing: .3px; }
.menu form { margin: 0; }
.toast { position: fixed; left: 24px; bottom: 24px; background: #1e1f21; color: #fff; padding: 12px 16px; border-radius: 8px; box-shadow: var(--shadow-3); z-index: 200; display: flex; gap: 10px; align-items: center; animation: toastIn .2s ease-out; }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } }
.empty-state { text-align: center; padding: 56px 24px; color: var(--text-2); }
.empty-state svg { width: 56px; height: 56px; stroke: var(--text-3); stroke-width: 1.2; margin-bottom: 8px; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(30,31,33,.45); display: none; align-items: flex-start; justify-content: center; padding-top: 10vh; z-index: 100; }
.modal-bg.open { display: flex; }
.modal { width: 560px; max-width: calc(100vw - 32px); background: var(--card); border-radius: 10px; box-shadow: var(--shadow-3); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); font-size: 16px; font-weight: 500; }
.modal-body { padding: 8px 20px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); }

/* ---------- Page header ---------- */
.page-head { padding: 16px 24px 0; border-bottom: 1px solid var(--border); background: var(--bg); position: sticky; top: 0; z-index: 10; }
.page-head .title-row { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.page-head h1 { font-size: 20px; font-weight: 500; }
.page-head .tabs { border-bottom: 0; margin-top: 6px; }
.proj-icon { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; color: #fff; flex: none; }
.proj-icon svg { stroke: #fff; width: 20px; height: 20px; }
.toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 24px; border-bottom: 1px solid var(--border); background: var(--bg); position: sticky; top: 0; z-index: 9; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.page { padding: 24px; }
.page.narrow { max-width: 1040px; margin: 0 auto; width: 100%; }

/* ---------- Home ---------- */
.home { max-width: 1100px; margin: 0 auto; padding: 32px 24px 64px; width: 100%; }
.home-date { text-align: center; color: var(--text-2); font-size: 15px; }
.home h1.greet { text-align: center; font-size: 32px; font-weight: 400; margin: 4px 0 16px; }
.home-stats { display: flex; justify-content: center; }
.home-stats .box { display: flex; align-items: center; gap: 18px; background: var(--bg-muted); border-radius: 24px; padding: 8px 20px; color: var(--text-2); font-size: 14px; }
.home-stats .box b { color: var(--text); font-size: 18px; font-weight: 500; margin-right: 4px; }
.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 28px; }
.widget { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 20px 24px; min-height: 380px; }
.widget.wide { grid-column: 1 / -1; min-height: 0; }
.widget-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.widget-head h2 { font-size: 20px; font-weight: 500; }
.widget .tabs { margin: 8px 0 4px; }
.mini-task { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
.mini-task:hover { background: var(--bg-hover); }
.mini-task .proj-chip { font-size: 12px; padding: 1px 8px; border-radius: 10px; max-width: 140px; }
.proj-tile { display: flex; align-items: center; gap: 14px; padding: 10px; border-radius: 8px; }
.proj-tile:hover { background: var(--bg-hover); }
.proj-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 12px; }
.add-tile { display: flex; align-items: center; gap: 14px; padding: 10px; border-radius: 8px; color: var(--text-2); }
.add-tile .proj-icon { border: 1px dashed var(--text-3); background: transparent; color: var(--text-2); }
.add-tile .proj-icon svg { stroke: var(--text-2); }

/* ---------- Checkbox ---------- */
.check { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--text-2); display: inline-grid; place-items: center; flex: none; background: transparent; padding: 0; color: transparent; transition: all .12s; }
.check svg { width: 10px; height: 10px; stroke-width: 3; stroke: currentColor; }
.check:hover { border-color: var(--success); color: var(--success); background: var(--success-bg); }
.check.done { background: var(--success); border-color: var(--success); color: #fff; }
.check.milestone { border-radius: 3px; transform: rotate(45deg) scale(.85); }
.check.milestone svg { transform: rotate(-45deg); }
.completed-name { color: var(--text-2); }

/* ---------- List view ---------- */
.list { min-width: 900px; }
.list-head, .task-row { display: grid; grid-template-columns: var(--cols); align-items: stretch; }
.list-head { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--border); font-size: 12px; color: var(--text-2); }
.list-head > div { padding: 8px 10px; border-left: 1px solid var(--border); white-space: nowrap; }
.list-head > div:first-child { border-left: 0; padding-left: 52px; }
.section-head { display: flex; align-items: center; gap: 6px; padding: 18px 24px 8px 20px; font-weight: 600; font-size: 16px; }
.section-head .caret { transition: transform .15s; }
.section.collapsed .caret { transform: rotate(-90deg); }
.section.collapsed .section-body { display: none; }
.section-head .sec-name { border: 1px solid transparent; border-radius: 4px; padding: 2px 4px; background: transparent; font-weight: 600; font-size: 16px; min-width: 40px; }
.section-head .sec-name:hover { border-color: var(--border-2); }
.section-head .sec-actions { opacity: 0; } .section-head:hover .sec-actions { opacity: 1; }
.task-row { border-bottom: 1px solid var(--border); min-height: 37px; background: var(--bg); }
.task-row:hover { background: var(--bg-hover); }
.task-row.selected { background: #edf2fc; }
body.dark .task-row.selected { background: #2b3550; }
.task-row > .cell { border-left: 1px solid var(--border); padding: 0 10px; display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13px; }
.task-row > .cell:first-child { border-left: 0; padding-left: 24px; }
.task-row .drag { opacity: 0; cursor: grab; color: var(--text-3); width: 14px; }
.task-row:hover .drag { opacity: 1; }
.task-row .tname { flex: 1; min-width: 0; font-size: 14px; border: 1px solid transparent; border-radius: 4px; padding: 3px 4px; background: transparent; outline: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-row .tname:focus { border-color: var(--border-2); background: var(--bg); }
.task-row .meta { display: inline-flex; align-items: center; gap: 2px; color: var(--text-2); font-size: 12px; white-space: nowrap; }
.task-row .details-btn { opacity: 0; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-2); border: 0; background: none; padding: 2px 6px; border-radius: 4px; white-space: nowrap; }
.task-row:hover .details-btn { opacity: 1; }
.task-row .details-btn:hover { background: var(--bg-active); color: var(--text); }
.cell-btn { display: flex; align-items: center; gap: 6px; width: 100%; height: 100%; border: 0; background: none; padding: 0; text-align: left; min-width: 0; font-size: 13px; }
.cell-btn .placeholder { opacity: 0; color: var(--text-3); }
.task-row:hover .cell-btn .placeholder { opacity: 1; }
.add-task-row { display: flex; align-items: center; gap: 8px; height: 37px; padding-left: 52px; color: var(--text-2); font-size: 14px; cursor: pointer; border-bottom: 1px solid transparent; }
.add-task-row:hover { color: var(--text); }
.add-section { margin: 20px 24px; }
.due-overdue { color: var(--danger); }
.due-soon { color: var(--success); }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 10px; font-size: 12px; color: #1e1f21; }
.sortable-ghost { opacity: .4; }
.sortable-chosen { box-shadow: var(--shadow-2); }

/* ---------- Board view ---------- */
.board { display: flex; gap: 12px; padding: 16px 24px 24px; align-items: flex-start; overflow-x: auto; flex: 1; }
.column { width: 280px; flex: none; background: var(--bg-soft); border-radius: 10px; padding: 8px; max-height: calc(100vh - 200px); display: flex; flex-direction: column; }
.column-head { display: flex; align-items: center; gap: 6px; padding: 6px 6px 10px; font-weight: 600; font-size: 15px; }
.column-head .count { color: var(--text-2); font-weight: 400; font-size: 14px; }
.column-body { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 40px; padding: 2px; }
.tcard { background: var(--card); border: 1px solid var(--border-2); border-radius: 8px; padding: 12px; cursor: pointer; box-shadow: 0 1px 1px rgba(0,0,0,.03); }
.tcard:hover { border-color: var(--text-3); box-shadow: var(--shadow-1); }
.tcard .tc-title { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.tcard .tc-meta { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--text-2); min-height: 24px; }
.tcard .tc-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.tcard.done { opacity: .7; }
.column .add-card { display: flex; align-items: center; gap: 6px; padding: 8px; color: var(--text-2); border-radius: 6px; border: 0; background: none; width: 100%; }
.column .add-card:hover { background: var(--bg-active); color: var(--text); }
.add-column { width: 280px; flex: none; }
.add-column input { background: var(--bg-soft); border: 1px dashed var(--border-2); }

/* ---------- Calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--border); border-left: 1px solid var(--border); flex: 1; }
.cal-dow { padding: 6px 8px; font-size: 12px; color: var(--text-2); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); text-align: left; }
.cal-day { min-height: 118px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 4px 6px; overflow: hidden; }
.cal-day.other { background: var(--bg-soft); }
.cal-day.other .dnum { color: var(--text-3); }
.cal-day .dnum { font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.cal-day.today .dnum { background: var(--accent); color: #fff; border-radius: 10px; padding: 0 6px; display: inline-block; }
.cal-chip { display: flex; align-items: center; gap: 6px; padding: 3px 6px; margin-bottom: 3px; border-radius: 4px; font-size: 12px; background: var(--card); border: 1px solid var(--border-2); cursor: pointer; white-space: nowrap; overflow: hidden; }
.cal-chip:hover { box-shadow: var(--shadow-1); }
.cal-chip .bar { width: 3px; align-self: stretch; border-radius: 2px; }
.cal-chip.done { opacity: .55; text-decoration: line-through; }

/* ---------- Timeline ---------- */
.timeline { display: grid; grid-template-columns: 280px 1fr; flex: 1; min-height: 0; overflow: auto; }
.tl-left { border-right: 1px solid var(--border); position: sticky; left: 0; background: var(--bg); z-index: 3; }
.tl-left .tl-row { padding: 0 12px; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.tl-left .tl-row:hover { background: var(--bg-hover); }
.tl-row { height: 40px; border-bottom: 1px solid var(--border); }
.tl-head { height: 52px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); z-index: 2; }
.tl-grid { position: relative; }
.tl-days { display: grid; }
.tl-days .d { font-size: 11px; color: var(--text-2); text-align: center; border-left: 1px solid var(--border); padding-top: 28px; }
.tl-days .d.wk { background: var(--bg-soft); }
.tl-days .d.today { color: var(--accent); font-weight: 700; }
.tl-months { position: absolute; top: 6px; left: 0; right: 0; font-size: 12px; font-weight: 600; }
.tl-months span { position: absolute; padding-left: 6px; }
.tl-body { position: relative; }
.tl-body .tl-row { position: relative; }
.tl-bar { position: absolute; top: 8px; height: 24px; border-radius: 5px; color: #fff; font-size: 12px; display: flex; align-items: center; padding: 0 8px; white-space: nowrap; overflow: hidden; cursor: grab; box-shadow: 0 1px 2px rgba(0,0,0,.15); user-select: none; }
.tl-bar.done { opacity: .5; }
.tl-bar .handle { position: absolute; top: 0; bottom: 0; width: 8px; cursor: ew-resize; }
.tl-bar .handle.l { left: 0; } .tl-bar .handle.r { right: 0; }
.tl-milestone { position: absolute; top: 11px; width: 16px; height: 16px; transform: rotate(45deg); background: var(--text); border-radius: 2px; }
.tl-todayline { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); z-index: 1; opacity: .7; }
.tl-gridlines { position: absolute; inset: 0; display: grid; pointer-events: none; }
.tl-gridlines div { border-left: 1px solid var(--border); }
.tl-gridlines div.wk { background: var(--bg-soft); }
.tl-unsched { font-size: 12px; color: var(--text-3); padding-left: 8px; line-height: 40px; }

/* ---------- Dashboard ---------- */
.dash { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; padding: 24px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 20px; text-align: center; }
.stat .n { font-size: 40px; font-weight: 300; margin-top: 4px; }
.stat .l { font-size: 13px; color: var(--text-2); }
.chart-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 20px; grid-column: span 2; }
.chart-card h3 { font-size: 15px; font-weight: 500; margin-bottom: 16px; }
.bars { display: flex; align-items: flex-end; gap: 14px; height: 200px; padding-bottom: 24px; position: relative; border-bottom: 1px solid var(--border); }
.bars .b { flex: 1; display: flex; flex-direction: column-reverse; align-items: stretch; position: relative; min-width: 18px; height: 100%; }
.bars .b span { display: block; border-radius: 3px 3px 0 0; }
.bars .b label { position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--text-2); white-space: nowrap; max-width: 90px; overflow: hidden; text-overflow: ellipsis; }
.hbar { display: grid; grid-template-columns: 130px 1fr 40px; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 13px; }
.hbar .track { height: 18px; background: var(--bg-muted); border-radius: 4px; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 4px; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); margin-top: 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.donut-wrap { display: flex; align-items: center; gap: 24px; }

/* ---------- Task pane ---------- */
.pane { position: fixed; top: 48px; right: 0; bottom: 0; width: min(680px, 100vw); background: var(--bg); box-shadow: -8px 0 30px rgba(0,0,0,.14); border-left: 1px solid var(--border); transform: translateX(100%); transition: transform .2s ease, visibility .2s; visibility: hidden; z-index: 50; display: flex; flex-direction: column; }
.pane.open { transform: none; visibility: visible; }
.pane-top { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.complete-btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border: 1px solid var(--border-2); border-radius: 6px; background: var(--bg); font-size: 13px; }
.complete-btn:hover { border-color: var(--success); color: var(--success); background: var(--success-bg); }
.complete-btn.done { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.pane-scroll { flex: 1; overflow-y: auto; padding: 20px 24px; }
.pane-scroll.full { max-width: 760px; margin: 0 auto; width: 100%; }
.task-title { width: 100%; font-size: 24px; font-weight: 500; border: 1px solid transparent; border-radius: 6px; padding: 4px 6px; margin-left: -7px; background: transparent; resize: none; outline: none; overflow: hidden; line-height: 1.3; }
.task-title:hover { border-color: var(--border-2); }
.task-title:focus { border-color: var(--primary); }
.fields { display: grid; grid-template-columns: 130px 1fr; row-gap: 4px; margin: 14px 0 18px; align-items: center; font-size: 13px; }
.fields .k { color: var(--text-2); padding: 6px 0; }
.fields .v { min-height: 34px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.field-btn { display: inline-flex; align-items: center; gap: 8px; padding: 4px 8px; margin-left: -8px; border-radius: 6px; border: 1px solid transparent; background: none; font-size: 13px; min-height: 30px; }
.field-btn:hover { border-color: var(--border-2); }
.field-input { height: 30px; padding: 0 8px; border: 1px solid transparent; border-radius: 6px; background: transparent; outline: none; margin-left: -8px; font-size: 13px; }
.field-input:hover { border-color: var(--border-2); }
.field-input:focus { border-color: var(--primary); }
select.field-input { padding-right: 24px; }
.desc { width: 100%; min-height: 90px; border: 1px solid transparent; border-radius: 6px; padding: 8px 10px; margin-left: -10px; background: transparent; resize: vertical; outline: none; line-height: 1.5; }
.desc:hover { border-color: var(--border-2); }
.desc:focus { border-color: var(--primary); }
.pane h4 { font-size: 15px; font-weight: 500; margin: 22px 0 8px; display: flex; align-items: center; gap: 8px; }
.subtask { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 1px solid var(--border); font-size: 14px; }
.subtask:first-of-type { border-top: 1px solid var(--border); }
.subtask .grow { cursor: pointer; }
.attach-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.attach { width: 150px; border: 1px solid var(--border-2); border-radius: 8px; overflow: hidden; font-size: 12px; position: relative; background: var(--card); }
.attach .thumb { height: 86px; background: var(--bg-muted); display: grid; place-items: center; font-weight: 700; color: var(--text-2); }
.attach .thumb img { width: 100%; height: 100%; object-fit: cover; }
.attach .nm { padding: 6px 8px; }
.attach .del { position: absolute; top: 4px; right: 4px; background: var(--card); opacity: 0; }
.attach:hover .del { opacity: 1; }
.dropzone { border: 1px dashed var(--border-2); border-radius: 8px; padding: 14px; text-align: center; color: var(--text-2); font-size: 13px; cursor: pointer; }
.dropzone.over { border-color: var(--primary); background: #edf2fc; }
.feed { background: var(--bg-soft); margin: 24px -24px 0; padding: 16px 24px; border-top: 1px solid var(--border); }
.feed-item { display: flex; gap: 10px; padding: 8px 0; font-size: 13px; }
.feed-item.activity { color: var(--text-2); font-size: 12px; padding: 4px 0 4px 34px; }
.feed-item .body { white-space: pre-wrap; word-wrap: break-word; margin-top: 2px; font-size: 14px; }
.feed-item .mention { color: var(--primary); font-weight: 500; }
.comment-box { border-top: 1px solid var(--border); padding: 12px 24px; display: flex; gap: 10px; align-items: flex-start; background: var(--bg); }
.comment-box textarea { flex: 1; min-height: 44px; border: 1px solid var(--border-2); border-radius: 8px; padding: 10px; resize: none; outline: none; background: var(--bg); }
.comment-box textarea:focus { border-color: var(--primary); }
.comment-box textarea:focus, .comment-box textarea:not(:placeholder-shown) { min-height: 90px; }
.collab { display: flex; align-items: center; gap: 8px; padding: 10px 24px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-2); }
.picker { position: absolute; z-index: 120; background: var(--card); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-3); width: 280px; max-height: 320px; overflow: auto; padding: 6px; }
.picker input { width: 100%; margin-bottom: 6px; }
.picker .opt { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 5px; cursor: pointer; font-size: 13px; }
.picker .opt:hover, .picker .opt.sel { background: var(--bg-hover); }
.breadcrumb { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.breadcrumb a:hover { color: var(--text); text-decoration: underline; }
.lock-note { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--success); background: var(--success-bg); padding: 2px 8px; border-radius: 10px; }

/* ---------- Tables / generic lists ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 500; font-size: 12px; color: var(--text-2); padding: 8px 12px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.table tr:hover td { background: var(--bg-hover); }
.progress { height: 6px; background: var(--bg-active); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; background: var(--success); border-radius: 3px; }
.goal-row { display: grid; grid-template-columns: 1fr 140px 150px 120px 90px; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.goal-row:hover { background: var(--bg-hover); }
.inbox-item { display: flex; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.inbox-item.unread { background: #f4f7fd; }
body.dark .inbox-item.unread { background: #232a3a; }
.inbox-item .acts { opacity: 0; } .inbox-item:hover .acts { opacity: 1; }
.overview-grid { display: grid; grid-template-columns: 1fr 320px; gap: 32px; padding: 24px; max-width: 1180px; margin: 0 auto; width: 100%; }
.overview-grid h3 { font-size: 18px; margin: 0 0 12px; }
.status-card { border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 12px; border-left: 4px solid; background: var(--card); }
.rule-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; background: var(--card); }
.rule-card .bolt { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: #fff2e0; color: #c97a00; }
.switch { width: 34px; height: 20px; border-radius: 10px; background: var(--border-2); position: relative; border: 0; padding: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch.on { background: var(--success); }
.switch.on::after { left: 16px; }
.wf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 24px; max-width: 1180px; margin: 0 auto; width: 100%; }
.wf-grid section h3 { font-size: 16px; margin-bottom: 4px; }
.wf-grid section > p { margin: 0 0 14px; font-size: 13px; color: var(--text-2); }
.copy-field { display: flex; gap: 6px; }
.copy-field input { flex: 1; font-size: 12px; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-left { display: flex; flex-direction: column; justify-content: center; padding: 48px; max-width: 480px; margin: 0 auto; width: 100%; }
.auth-left h1 { font-size: 28px; font-weight: 500; margin: 24px 0 6px; }
.auth-right { background: linear-gradient(160deg, #fdeee8 0%, #fbe0e6 45%, #e8e3fb 100%); display: flex; align-items: center; justify-content: center; padding: 48px; }
.auth-art { width: 100%; max-width: 460px; background: #fff; border-radius: 14px; box-shadow: var(--shadow-3); padding: 18px; color: #1e1f21; }
.auth-art .ln { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid #edeae9; font-size: 14px; }
.auth .brand { color: var(--text); }
.secure-badges { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 24px; font-size: 12px; color: var(--text-2); }
.secure-badges span { display: inline-flex; align-items: center; gap: 6px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 0 1fr; }
  .app .sidebar { visibility: hidden; }
  .app.mobile-open { grid-template-columns: 240px 1fr; }
  .app.mobile-open .sidebar { visibility: visible; }
  .home-grid, .overview-grid, .wf-grid { grid-template-columns: 1fr; }
  .dash { grid-template-columns: 1fr 1fr; }
  .chart-card { grid-column: span 2; }
  .auth { grid-template-columns: 1fr; } .auth-right { display: none; }
  .create-btn span.lbl, .upgrade-pill { display: none; }
}

/* ---------- Platform portal ---------- */
.platform { min-height: 100vh; background: var(--bg-soft); }
.platform-main { max-width: 1320px; margin: 0 auto; padding: 24px; }
.platform-nav { display: flex; gap: 4px; margin-left: 16px; }
.platform-nav a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 6px; color: var(--sidebar-text-2); }
.platform-nav a:hover { background: var(--sidebar-2); color: #fff; }
.platform-nav a.active { background: var(--sidebar-active); color: #fff; }
.platform .stat, .platform .chart-card, .platform .card { background: var(--card); }

/* ---------- Performance report ---------- */
.perf-filters { padding: 14px 16px; margin-bottom: 20px; display: flex; flex-direction: column; gap: 12px; }
.perf-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.perf-presets .chip { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border: 1px solid var(--border-2); border-radius: 15px; font-size: 13px; cursor: pointer; user-select: none; }
.perf-presets .chip input { display: none; }
.perf-presets .chip:hover { background: var(--bg-hover); }
.perf-presets .chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.kpi-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 20px; }
.kpi-grid .stat { padding: 16px 12px; }
.kpi-grid .stat .n { font-size: 32px; }
.kpi-delta { display: inline-block; font-size: 12px; color: var(--text-2); margin: 2px 0 4px; }
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }
.perf-table th { white-space: nowrap; user-select: none; }
.perf-table th.sorted { color: var(--text); }
.perf-table th[data-dir=desc]::after { content: ' ↓'; }
.perf-table th[data-dir=asc]::after { content: ' ↑'; }
.perf-table td { white-space: nowrap; }
.perf-table .rate { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.perf-table .rate .track { flex: 1; height: 6px; background: var(--bg-muted); border-radius: 3px; overflow: hidden; }
.perf-table .rate .fill { height: 100%; border-radius: 3px; }
.perf-table .rate span { font-size: 13px; width: 44px; text-align: right; }
.perf-two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.perf-help { padding: 14px 18px; margin-top: 24px; font-size: 13px; color: var(--text-2); }
.perf-help summary { cursor: pointer; color: var(--text); font-weight: 500; }
.perf-help ul { margin: 10px 0 0 18px; display: grid; gap: 6px; }
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } .perf-two { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---------- License banner ---------- */
.license-banner { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 16px; font-size: 13px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 900; box-shadow: 0 -2px 8px rgba(0,0,0,.08); }
.license-banner.warn { background: #fff4d6; color: #7a5d00; border-top: 1px solid #f1d58a; }
.license-banner.danger { background: #fdeeee; color: #b82a2a; border-top: 1px solid #f6caca; }

/* ---------- Developer portal ---------- */
.dev-auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.dev-auth-card { width: 100%; max-width: 420px; padding: 28px; }
.dev-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.dev-card { padding: 20px; }
.dev-card h2 { font-size: 16px; font-weight: 500; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.dev-kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; font-size: 13px; }
.dev-kv dt { color: var(--text-2); }
.dev-kv dd { margin: 0; word-break: break-all; }
.dev-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.state-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 14px; font-size: 13px; font-weight: 500; }
.state-active { background: var(--success-bg); color: var(--success); }
.state-expiring { background: #fff4d6; color: #7a5d00; }
.state-grace, .state-expired, .state-suspended, .state-invalid, .state-missing { background: #fdeeee; color: #b82a2a; }
.dev-log { background: #1e1f21; color: #d6d6d6; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; border-radius: 8px; padding: 12px 14px; margin: 0 0 16px; white-space: pre-wrap; }
.dev-check { display: grid; grid-template-columns: 22px 200px 1fr; gap: 6px; font-size: 13px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.big-number { font-size: 34px; font-weight: 300; }
