:root {
  --purple: #7b68ee;
  --purple-600: #6a55e8;
  --purple-soft: #f0edff;
  --purple-softer: #f7f5ff;
  --bg: #ffffff;
  --bg-soft: #fbfbfd;
  --bg-sidebar: #fbfbfd;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --border: #e9e9ef;
  --border-strong: #dcdce4;
  --text: #292d34;
  --text-soft: #4d5460;
  --muted: #7c828d;
  --muted-2: #a1a6af;
  --green: #2ecc71;
  --red: #ff5c7c;
  --orange: #ff9f43;
  --blue: #4a90e2;
  --shadow-sm: 0 1px 2px rgba(20, 24, 35, .06);
  --shadow-md: 0 6px 24px rgba(25, 30, 45, .10);
  --shadow-lg: 0 24px 70px rgba(20, 25, 40, .22);
  --radius: 10px;
  --sidebar-w: 252px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #1b1d23;
  --bg-soft: #202329;
  --bg-sidebar: #17191e;
  --surface: #22252c;
  --surface-2: #282c34;
  --border: #2f333c;
  --border-strong: #3a3f4a;
  --text: #e8eaf0;
  --text-soft: #c3c7d1;
  --muted: #8d939f;
  --muted-2: #6d7380;
  --purple-soft: #2b2747;
  --purple-softer: #242233;
  --shadow-md: 0 6px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--purple); text-decoration: none; }
::selection { background: #d9d2ff; color: #241f4d; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d8d8e0; border-radius: 9px; border: 2px solid transparent; background-clip: content-box; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #3d424d; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- Login ---------------- */
.login-wrap { display: flex; min-height: 100vh; }
.login-brand {
  width: 46%;
  background: linear-gradient(150deg, #6a55e8 0%, #7b68ee 42%, #9a8bff 100%);
  color: #fff; padding: 54px 60px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.login-brand::before, .login-brand::after {
  content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,.09);
}
.login-brand::before { width: 460px; height: 460px; right: -160px; top: -120px; }
.login-brand::after { width: 320px; height: 320px; left: -120px; bottom: -130px; background: rgba(255,255,255,.07); }
.brand-row { display: flex; align-items: center; gap: 11px; position: relative; z-index: 1; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; background: #fff; display: grid; place-items: center; color: #6a55e8; font-weight: 800; font-size: 20px; box-shadow: 0 6px 18px rgba(0,0,0,.14); }
.brand-name { font-size: 22px; font-weight: 700; letter-spacing: -.4px; }
.brand-tag { font-size: 13px; opacity: .82; }
.login-hero { position: relative; z-index: 1; max-width: 430px; }
.login-hero h1 { font-size: 42px; line-height: 1.1; margin: 0 0 18px; letter-spacing: -1.4px; font-weight: 700; }
.login-hero p { font-size: 15px; line-height: 1.65; opacity: .88; margin: 0; }
.login-points { display: grid; gap: 13px; margin-top: 32px; }
.login-point { display: flex; gap: 12px; align-items: center; font-size: 13.5px; opacity: .95; }
.login-point span.ic { width: 30px; height: 30px; border-radius: 8px; background: rgba(255,255,255,.16); display: grid; place-items: center; }
.login-foot { position: relative; z-index: 1; font-size: 12px; opacity: .7; }
.login-side { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--bg); }
.login-card { width: 100%; max-width: 368px; }
.login-card h2 { font-size: 26px; margin: 0 0 6px; letter-spacing: -.6px; }
.login-card .sub { color: var(--muted); margin: 0 0 28px; font-size: 13.5px; }
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; color: var(--text-soft); }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--border-strong); background: var(--surface);
  border-radius: 8px; padding: 10px 12px; outline: none; transition: border .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(123,104,238,.14); }
.textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: 8px; padding: 8px 14px;
  font-weight: 600; font-size: 12.5px; background: var(--surface-2); color: var(--text-soft);
  transition: background .15s, color .15s, border .15s, transform .05s; white-space: nowrap;
}
.btn:hover { background: var(--purple-softer); color: var(--purple); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--purple); color: #fff; box-shadow: 0 2px 8px rgba(123,104,238,.3); }
.btn-primary:hover { background: var(--purple-600); color: #fff; }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: #e5484d; }
.btn-danger:hover { background: #ffecec; color: #d33; }
.btn-block { width: 100%; padding: 11px; font-size: 13.5px; }
.btn-sm { padding: 5px 9px; font-size: 12px; border-radius: 6px; }
.btn-icon { padding: 6px; width: 30px; height: 30px; border-radius: 7px; background: transparent; color: var(--muted); }
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.login-error { color: #e5484d; background: #fff0f0; border: 1px solid #ffd6d6; padding: 9px 12px; border-radius: 8px; font-size: 12.5px; margin-bottom: 14px; display: none; }
[data-theme="dark"] .login-error { background: #3a1e24; border-color: #5b2a33; }

/* ---------------- Shell ---------------- */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w); background: var(--bg-sidebar);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; transition: margin .2s ease;
}
.sidebar.hidden { margin-left: calc(-1 * var(--sidebar-w)); }
.ws-head { padding: 12px 12px 8px; display: flex; align-items: center; gap: 9px; }
.ws-avatar { width: 30px; height: 30px; border-radius: 8px; background: var(--purple); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.ws-name { font-weight: 700; font-size: 13.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-head .chev { color: var(--muted); }
.create-btn {
  margin: 8px 12px 8px; padding: 8px 12px; border-radius: 8px; border: none;
  background: var(--purple); color: #fff; font-weight: 600; font-size: 12.5px;
  display: flex; align-items: center; gap: 8px; box-shadow: 0 2px 8px rgba(123,104,238,.28);
}
.create-btn:hover { background: var(--purple-600); }
.side-nav { padding: 2px 8px; display: grid; gap: 1px; }
.side-item {
  display: flex; align-items: center; gap: 9px; padding: 6px 9px; border-radius: 7px;
  color: var(--text-soft); font-weight: 500; font-size: 12.8px; cursor: pointer; user-select: none;
}
.side-item:hover { background: var(--surface-2); color: var(--text); }
.side-item.active { background: var(--purple-soft); color: var(--purple); font-weight: 600; }
.side-item .count { margin-left: auto; font-size: 11px; color: var(--muted); background: var(--surface-2); border-radius: 10px; padding: 1px 6px; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 10px 8px 20px; }
.side-label { display: flex; align-items: center; justify-content: space-between; padding: 7px 9px 5px; color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase; }
.side-label button { background: none; border: none; color: var(--muted); padding: 2px; border-radius: 4px; display: grid; place-items: center; }
.side-label button:hover { background: var(--surface-2); color: var(--purple); }
.space-node { margin-bottom: 2px; }
.space-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px;
  cursor: pointer; font-weight: 600; font-size: 12.8px; color: var(--text-soft);
}
.space-row:hover { background: var(--surface-2); }
.space-row .chev { color: var(--muted-2); transition: transform .15s; flex-shrink: 0; }
.space-row .chev.open { transform: rotate(90deg); }
.space-badge { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 10.5px; flex-shrink: 0; }
.space-row .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.space-row .acts { display: none; gap: 1px; }
.space-row:hover .acts { display: flex; }
.space-children { margin-left: 15px; padding-left: 8px; border-left: 1px solid var(--border); display: none; }
.space-children.open { display: block; }
.tree-row { display: flex; align-items: center; gap: 7px; padding: 5px 7px; border-radius: 6px; cursor: pointer; color: var(--text-soft); font-size: 12.5px; }
.tree-row:hover { background: var(--surface-2); color: var(--text); }
.tree-row.active { background: var(--purple-soft); color: var(--purple); font-weight: 600; }
.tree-row .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.tree-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-row .acts { display: none; }
.tree-row:hover .acts { display: flex; }
.folder-children { margin-left: 10px; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 8px; display: flex; align-items: center; gap: 8px; }
.user-mini { display: flex; align-items: center; gap: 8px; padding: 5px 7px; border-radius: 7px; flex: 1; cursor: pointer; min-width: 0; }
.user-mini:hover { background: var(--surface-2); }
.user-mini .meta { min-width: 0; }
.user-mini .nm { font-weight: 600; font-size: 12.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-mini .em { font-size: 10.8px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.topbar { height: 50px; min-height: 50px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; padding: 0 14px; background: var(--bg); }
.topbar .crumbs { display: flex; align-items: center; gap: 6px; font-size: 12.7px; color: var(--muted); min-width: 0; flex: 1; }
.crumbs .crumb { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 5px; cursor: pointer; white-space: nowrap; }
.crumbs .crumb:hover { background: var(--surface-2); color: var(--text); }
.crumbs .sep { color: var(--muted-2); }
.crumbs .current { color: var(--text); font-weight: 600; cursor: default; }
.topbar-right { display: flex; align-items: center; gap: 5px; }
.top-search { display: flex; align-items: center; gap: 7px; background: var(--surface-2); border: 1px solid transparent; border-radius: 8px; padding: 6px 10px; color: var(--muted); font-size: 12px; min-width: 180px; cursor: pointer; }
.top-search:hover { border-color: var(--border-strong); }
.top-search kbd { margin-left: auto; font-family: inherit; font-size: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 1px 4px; color: var(--muted); }
.new-task-btn { background: var(--purple); color: #fff; border-radius: 8px; padding: 7px 12px; font-size: 12.3px; font-weight: 600; border: none; display: flex; align-items: center; gap: 6px; }
.new-task-btn:hover { background: var(--purple-600); }
.avatar { width: 26px; height: 26px; border-radius: 50%; color: #fff; display: inline-grid; place-items: center; font-size: 10.5px; font-weight: 700; flex-shrink: 0; letter-spacing: .2px; }
.avatar.lg { width: 34px; height: 34px; font-size: 12.5px; }
.avatar.sm { width: 21px; height: 21px; font-size: 9px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid var(--bg); margin-left: -6px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

.view-bar { display: flex; align-items: center; gap: 2px; padding: 0 14px; border-bottom: 1px solid var(--border); min-height: 42px; background: var(--bg); overflow-x: auto; }
.view-tab { display: flex; align-items: center; gap: 6px; padding: 10px 10px; font-size: 12.4px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.view-tab:hover { color: var(--text); }
.view-tab.active { color: var(--purple); border-bottom-color: var(--purple); font-weight: 600; }
.view-bar .spacer { flex: 1; }
.view-bar .tools { display: flex; align-items: center; gap: 2px; }
.tool-btn { display: flex; align-items: center; gap: 5px; background: none; border: none; color: var(--muted); font-size: 12px; padding: 5px 8px; border-radius: 6px; }
.tool-btn:hover { background: var(--surface-2); color: var(--text); }
.content { flex: 1; overflow: auto; position: relative; }
.content-inner { padding: 22px 26px 80px; max-width: 1500px; }

/* ---------------- Home ---------------- */
.home-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; gap: 20px; }
.home-head h1 { margin: 0 0 5px; font-size: 24px; letter-spacing: -.6px; }
.home-head p { margin: 0; color: var(--muted); font-size: 13px; }
.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card { border: 1px solid var(--border); border-radius: 11px; padding: 14px 16px; background: var(--surface); box-shadow: var(--shadow-sm); }
.stat-card .lbl { color: var(--muted); font-size: 11.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat-card .val { font-size: 26px; font-weight: 700; letter-spacing: -.8px; margin-top: 5px; }
.stat-card .val small { font-size: 12px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.stat-card.red .val { color: #e5484d; }
.stat-card.green .val { color: #1fa855; }
.stat-card.purple .val { color: var(--purple); }
.home-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
.panel { border: 1px solid var(--border); border-radius: 11px; background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden; }
.panel-head { padding: 13px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.panel-head h3 { margin: 0; font-size: 13px; font-weight: 600; }
.panel-body { padding: 6px 0; }
.status-bar { display: flex; height: 9px; border-radius: 5px; overflow: hidden; margin: 4px 16px 14px; background: var(--surface-2); }
.status-bar span { height: 100%; }
.status-legend { display: grid; gap: 7px; padding: 0 16px 12px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 12.3px; }
.legend-row .dot { width: 8px; height: 8px; border-radius: 50%; }
.legend-row .nm { flex: 1; color: var(--text-soft); }
.legend-row .ct { color: var(--muted); font-variant-numeric: tabular-nums; }
.recent-row { display: flex; align-items: center; gap: 10px; padding: 9px 16px; cursor: pointer; }
.recent-row:hover { background: var(--purple-softer); }
.recent-row .nm { flex: 1; min-width: 0; font-size: 12.6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-row .meta { font-size: 11px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 34px 18px; font-size: 12.5px; }
.empty .big { font-size: 30px; margin-bottom: 8px; }

/* ---------------- List view ---------------- */
.list-header { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.list-header .list-ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; }
.list-header h1 { font-size: 21px; margin: 0; letter-spacing: -.5px; }
.list-sub { color: var(--muted); font-size: 12.2px; margin: 0 0 16px 40px; }
.list-toolbar { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.list-toolbar .filter-input { width: 210px; }
.list-toolbar .spacer { flex: 1; }
.group { margin-bottom: 8px; border-radius: 9px; }
.group-head { display: flex; align-items: center; gap: 8px; padding: 7px 6px; cursor: pointer; user-select: none; }
.group-head .chev { color: var(--muted-2); transition: transform .15s; }
.group-head.collapsed .chev { transform: rotate(-90deg); }
.status-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 10.6px; font-weight: 700; padding: 3px 8px; border-radius: 4px; letter-spacing: .3px; text-transform: uppercase; white-space: nowrap; }
.group-head .gname { font-weight: 700; font-size: 12px; color: var(--text); text-transform: uppercase; letter-spacing: .35px; }
.group-head .gcount { color: var(--muted); font-size: 11.5px; background: var(--surface-2); border-radius: 9px; padding: 1px 6px; }
.group-head .gadd { margin-left: auto; opacity: 0; color: var(--muted); background: none; border: none; padding: 4px; border-radius: 5px; }
.group:hover .gadd { opacity: 1; }
.group-head .gadd:hover { background: var(--surface-2); color: var(--purple); }
.task-table { border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: var(--surface); }
.task-row { display: flex; align-items: center; gap: 8px; padding: 0 8px; height: 38px; border-bottom: 1px solid var(--border); cursor: pointer; position: relative; }
.task-row:last-child { border-bottom: none; }
.task-row:hover { background: var(--purple-softer); }
.task-row .drag { color: var(--muted-2); opacity: 0; cursor: grab; display: grid; place-items: center; width: 14px; }
.task-row:hover .drag { opacity: 1; }
.task-check { width: 17px; height: 17px; border-radius: 50%; border: 1.6px solid var(--border-strong); display: grid; place-items: center; flex-shrink: 0; color: transparent; background: var(--surface); }
.task-check:hover { border-color: var(--purple); }
.task-check.done { background: var(--green); border-color: var(--green); color: #fff; }
.task-row .tname { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font-size: 12.8px; color: var(--text); }
.task-row .tname .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-row.completed .tname .txt { color: var(--muted); text-decoration: line-through; }
.task-row .tsub { font-size: 10.5px; color: var(--muted); background: var(--surface-2); padding: 1px 5px; border-radius: 4px; display: inline-flex; align-items: center; gap: 3px; }
.row-tags { display: flex; gap: 4px; }
.tag-chip { font-size: 10px; padding: 1px 6px; border-radius: 4px; font-weight: 500; white-space: nowrap; }
.row-meta { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11.3px; flex-shrink: 0; }
.row-meta .due { display: flex; align-items: center; gap: 4px; padding: 2px 5px; border-radius: 4px; white-space: nowrap; }
.row-meta .due.overdue { color: #e5484d; background: #fff0f0; }
.row-meta .due.today { color: #d97706; background: #fff8eb; }
.row-meta .due.none { color: var(--muted-2); }
[data-theme="dark"] .row-meta .due.overdue { background: #3a1e24; }
[data-theme="dark"] .row-meta .due.today { background: #3a2f1e; }
.prio { display: grid; place-items: center; width: 18px; }
.prio.p1 { color: #ff5c7c; }
.prio.p2 { color: #ff9f43; }
.prio.p3 { color: #4a90e2; }
.prio.p4 { color: #a1a6af; }
.row-status { display: none; }
.inline-add { display: flex; align-items: center; gap: 8px; padding: 7px 10px; color: var(--muted); cursor: pointer; font-size: 12.3px; border-top: 1px solid var(--border); }
.inline-add:hover { color: var(--purple); background: var(--purple-softer); }
.inline-add input { border: none; background: transparent; outline: none; flex: 1; font-size: 12.8px; color: var(--text); }

/* ---------------- Board ---------------- */
.board-wrap { display: flex; gap: 12px; align-items: flex-start; overflow-x: auto; padding-bottom: 20px; min-height: 400px; }
.board-col { width: 292px; min-width: 270px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 11px; display: flex; flex-direction: column; max-height: calc(100vh - 200px); }
.board-col-head { display: flex; align-items: center; gap: 8px; padding: 11px 12px; }
.board-col-head .dot { width: 8px; height: 8px; border-radius: 50%; }
.board-col-head .nm { font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; }
.board-col-head .ct { color: var(--muted); font-size: 11px; background: var(--surface); border: 1px solid var(--border); padding: 0 6px; border-radius: 9px; }
.board-col-head .add { margin-left: auto; background: none; border: none; color: var(--muted); padding: 3px; border-radius: 5px; }
.board-col-head .add:hover { background: var(--surface); color: var(--purple); }
.board-col-body { padding: 0 8px 8px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 7px; min-height: 40px; }
.board-col.drag-over { background: var(--purple-softer); border-color: #c9c0ff; }
.task-card { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 10px 11px; cursor: pointer; box-shadow: var(--shadow-sm); transition: box-shadow .15s, border .15s; }
.task-card:hover { box-shadow: var(--shadow-md); border-color: #d5cffa; }
.task-card .nm { font-size: 12.7px; font-weight: 500; line-height: 1.4; margin-bottom: 8px; }
.task-card .card-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.task-card .card-foot { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10.8px; }
.task-card .card-foot .spacer { flex: 1; }
.task-card.done .nm { text-decoration: line-through; color: var(--muted); }
.board-add { color: var(--muted); font-size: 12.2px; padding: 7px 8px; border-radius: 7px; display: flex; align-items: center; gap: 6px; cursor: pointer; }
.board-add:hover { background: var(--surface); color: var(--purple); }

/* ---------------- Calendar ---------------- */
.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.cal-head h2 { margin: 0; font-size: 18px; letter-spacing: -.3px; min-width: 180px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--border); gap: 1px; }
.cal-dow { background: var(--bg-soft); padding: 8px 10px; font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.cal-day { background: var(--surface); min-height: 112px; padding: 5px 6px; font-size: 11.5px; }
.cal-day.other { background: var(--bg-soft); }
.cal-day .dnum { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; color: var(--text-soft); font-weight: 500; margin-bottom: 3px; }
.cal-day.today .dnum { background: var(--purple); color: #fff; font-weight: 700; }
.cal-task { display: flex; align-items: center; gap: 5px; padding: 2px 5px; border-radius: 4px; font-size: 10.8px; margin-bottom: 2px; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cal-task:hover { filter: brightness(.96); }
.cal-task .dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.cal-more { color: var(--muted); font-size: 10.5px; padding: 1px 5px; cursor: pointer; }

/* ---------------- Table ---------------- */
.table-wrap { border: 1px solid var(--border); border-radius: 10px; overflow: auto; background: var(--surface); }
.data-table { width: 100%; border-collapse: collapse; font-size: 12.4px; }
.data-table th { text-align: left; padding: 9px 12px; background: var(--bg-soft); border-bottom: 1px solid var(--border); color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.data-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover { background: var(--purple-softer); }
.data-table .cell-name { max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
.data-table .cell-name .sub { color: var(--muted); font-size: 10.5px; }

/* ---------------- Docs ---------------- */
.docs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.doc-card { border: 1px solid var(--border); border-radius: 11px; padding: 16px; background: var(--surface); cursor: pointer; min-height: 130px; display: flex; flex-direction: column; box-shadow: var(--shadow-sm); }
.doc-card:hover { border-color: #cfc6ff; box-shadow: var(--shadow-md); }
.doc-card .ic { width: 32px; height: 32px; border-radius: 8px; background: var(--purple-soft); color: var(--purple); display: grid; place-items: center; margin-bottom: 10px; }
.doc-card .nm { font-weight: 600; font-size: 13.5px; margin-bottom: 5px; }
.doc-card .ex { color: var(--muted); font-size: 11.8px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.doc-card .dt { margin-top: auto; padding-top: 12px; font-size: 10.8px; color: var(--muted-2); }
.doc-editor { max-width: 820px; }
.doc-editor input.title { border: none; background: none; font-size: 27px; font-weight: 700; outline: none; width: 100%; letter-spacing: -.6px; margin-bottom: 14px; }
.doc-editor textarea { min-height: 420px; border: none; background: var(--bg-soft); border-radius: 10px; padding: 20px; font-size: 13.5px; line-height: 1.7; }
.doc-preview { border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin-top: 14px; line-height: 1.7; font-size: 13.5px; }
.doc-preview h1, .doc-preview h2, .doc-preview h3 { margin-top: 18px; }
.doc-preview code { background: var(--surface-2); padding: 2px 5px; border-radius: 4px; }

/* ---------------- Modal ---------------- */
.overlay { position: fixed; inset: 0; background: rgba(23, 26, 34, .48); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 24px; animation: fade .14s ease; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: .6; } }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: 92vh; display: flex; flex-direction: column; animation: pop .16s ease; border: 1px solid var(--border); }
.modal.wide { max-width: 1040px; height: 88vh; }
.modal.medium { max-width: 780px; max-height: 88vh; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 15px; flex: 1; letter-spacing: -.2px; }
.modal-body { padding: 18px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.task-modal { display: flex; height: 100%; min-height: 0; }
.task-main { flex: 1; min-width: 0; padding: 18px 24px 28px; overflow-y: auto; }
.task-side { width: 310px; min-width: 270px; border-left: 1px solid var(--border); padding: 16px; overflow-y: auto; background: var(--bg-soft); }
.task-title { width: 100%; border: none; background: none; font-size: 21px; font-weight: 700; letter-spacing: -.4px; outline: none; padding: 4px 0 10px; }
.task-desc { width: 100%; min-height: 110px; border: 1px solid transparent; background: var(--bg-soft); border-radius: 8px; padding: 11px 12px; outline: none; resize: vertical; line-height: 1.6; font-size: 13px; color: var(--text-soft); }
.task-desc:focus { border-color: var(--purple); background: var(--surface); }
.task-desc::placeholder { color: var(--muted-2); }
.section-label { font-size: 10.5px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; display: flex; align-items: center; gap: 6px; }
.subtask-row { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-radius: 6px; font-size: 12.6px; cursor: pointer; }
.subtask-row:hover { background: var(--bg-soft); }
.subtask-row .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.subtask-row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta-group { margin-bottom: 13px; }
.meta-label { font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 5px; display: flex; align-items: center; gap: 5px; }
.meta-value { display: flex; align-items: center; gap: 7px; padding: 6px 8px; border-radius: 6px; font-size: 12.3px; cursor: pointer; min-height: 30px; }
.meta-value:hover { background: var(--surface-2); }
.meta-value .spacer { flex: 1; }
.meta-add { color: var(--muted-2); font-size: 12px; padding: 5px 8px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.meta-add:hover { background: var(--surface-2); color: var(--text); }
.comment-list { display: grid; gap: 12px; margin-bottom: 14px; }
.comment { display: flex; gap: 9px; }
.comment .body { background: var(--bg-soft); border-radius: 9px; padding: 8px 11px; font-size: 12.4px; line-height: 1.5; flex: 1; }
.comment .body .hd { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.comment .body .nm { font-weight: 600; font-size: 12px; }
.comment .body .t { color: var(--muted); font-size: 10.5px; }
.comment .body p { margin: 0; color: var(--text-soft); white-space: pre-wrap; }
.comment-composer { display: flex; gap: 9px; align-items: flex-start; }
.comment-composer textarea { flex: 1; min-height: 38px; max-height: 140px; border: 1px solid var(--border-strong); border-radius: 9px; padding: 9px 11px; outline: none; resize: vertical; font-size: 12.5px; }
.comment-composer textarea:focus { border-color: var(--purple); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab { padding: 7px 10px; font-size: 12.3px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; font-weight: 500; }
.tab.active { color: var(--purple); border-color: var(--purple); font-weight: 600; }
.meta-select { position: relative; }
.meta-select .menu { position: absolute; top: calc(100% + 3px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-md); z-index: 10; padding: 4px; max-height: 240px; overflow: auto; }
.menu-item { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 6px; font-size: 12.3px; cursor: pointer; }
.menu-item:hover { background: var(--purple-softer); }
.menu-item .dot { width: 8px; height: 8px; border-radius: 50%; }
.checkbox-list { display: grid; gap: 2px; max-height: 210px; overflow: auto; }
.checkbox-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 12.3px; }
.checkbox-item:hover { background: var(--surface-2); }
.checkbox-item input { accent-color: var(--purple); }
.timer-box { display: flex; align-items: center; gap: 7px; }
.timer-display { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; color: var(--purple); min-width: 64px; }
.timer-running { color: #e5484d; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.attachment-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 7px; font-size: 12.2px; margin-bottom: 5px; }
.attachment-row a { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-soft); }
.attachment-row .size { color: var(--muted); font-size: 10.5px; }
.activity-line { font-size: 11.8px; color: var(--muted); padding: 5px 0; border-bottom: 1px dashed var(--border); }
.activity-line b { color: var(--text-soft); font-weight: 600; }

/* ---------------- Settings ---------------- */
.settings-modal { display: flex; height: 100%; min-height: 0; }
.settings-nav { width: 190px; border-right: 1px solid var(--border); padding: 10px 8px; background: var(--bg-soft); }
.settings-nav .item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 7px; font-size: 12.5px; color: var(--text-soft); cursor: pointer; font-weight: 500; }
.settings-nav .item:hover { background: var(--surface-2); }
.settings-nav .item.active { background: var(--purple-soft); color: var(--purple); font-weight: 600; }
.settings-body { flex: 1; overflow-y: auto; padding: 20px 24px; }
.settings-body h3 { margin: 0 0 4px; font-size: 16px; letter-spacing: -.3px; }
.settings-body .desc { color: var(--muted); font-size: 12.5px; margin: 0 0 18px; line-height: 1.5; }
.integration-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; display: flex; gap: 14px; align-items: flex-start; }
.integration-logo { width: 40px; height: 40px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px; flex-shrink: 0; }
.integration-card .info { flex: 1; min-width: 0; }
.integration-card .nm { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 7px; }
.integration-card .ds { color: var(--muted); font-size: 11.8px; line-height: 1.5; margin-top: 2px; }
.integration-card .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.badge { font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 9px; background: var(--surface-2); color: var(--muted); }
.badge.on { background: #e7f8ee; color: #1a9e50; }
[data-theme="dark"] .badge.on { background: #173a26; color: #58d68d; }
.integration-form { display: grid; gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.integration-form .row { display: flex; gap: 8px; }
.integration-form .row > * { flex: 1; }
.help { font-size: 11.3px; color: var(--muted); line-height: 1.55; background: var(--bg-soft); border-radius: 7px; padding: 8px 10px; }
.help a { font-weight: 500; }
.progress { height: 7px; border-radius: 5px; background: var(--surface-2); overflow: hidden; margin: 8px 0 6px; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, #7b68ee, #a99bff); border-radius: 5px; transition: width .3s; }
.job-log { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10.5px; color: var(--muted); max-height: 130px; overflow: auto; background: var(--bg-soft); border-radius: 7px; padding: 8px 10px; line-height: 1.6; }
.token-box { font-family: ui-monospace, Menlo, monospace; font-size: 11px; background: var(--bg-soft); border: 1px dashed var(--border-strong); padding: 8px 10px; border-radius: 7px; word-break: break-all; margin-top: 8px; }
.members-list { display: grid; gap: 2px; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.member-row .nm { font-weight: 600; font-size: 12.5px; }
.member-row .em { color: var(--muted); font-size: 11px; }
.member-row .role { margin-left: auto; font-size: 11px; color: var(--muted); text-transform: capitalize; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 22px; height: 22px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.swatch.sel { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface) inset; }

/* ---------------- Search / command ---------------- */
.search-modal { position: fixed; inset: 0; background: rgba(22,25,33,.45); z-index: 80; display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; }
.search-panel { width: 600px; max-width: 92vw; background: var(--surface); border-radius: 13px; box-shadow: var(--shadow-lg); overflow: hidden; border: 1px solid var(--border); }
.search-input-wrap { display: flex; align-items: center; gap: 9px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.search-input-wrap input { flex: 1; border: none; outline: none; background: none; font-size: 14px; }
.search-results { max-height: 52vh; overflow: auto; padding: 6px; }
.search-result { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 7px; cursor: pointer; }
.search-result:hover { background: var(--purple-softer); }
.search-result .nm { flex: 1; font-size: 12.7px; }
.search-result .meta { font-size: 10.8px; color: var(--muted); }

/* ---------------- Toast / misc ---------------- */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: grid; gap: 8px; }
.toast { background: #262a33; color: #fff; padding: 10px 14px; border-radius: 9px; font-size: 12.5px; box-shadow: var(--shadow-md); animation: pop .18s ease; max-width: 360px; }
.toast.ok { background: #1f8f4e; }
.toast.err { background: #d13b4f; }
.spinner { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.spinner.dark { border-color: #d8d8e0; border-top-color: var(--purple); }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.center-load { display: grid; place-items: center; height: 60vh; }
.mobile-only { display: none; }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .home-grid { grid-template-columns: 1fr; }
  .task-side { width: 280px; }
}
@media (max-width: 860px) {
  .login-brand { display: none; }
  .sidebar { position: fixed; z-index: 40; height: 100%; box-shadow: var(--shadow-lg); }
  .sidebar:not(.hidden) { margin-left: 0; }
  .sidebar.hidden { margin-left: calc(-1 * var(--sidebar-w)); }
  .mobile-only { display: inline-flex; }
  .top-search { min-width: 0; }
  .top-search .lbl { display: none; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .content-inner { padding: 16px 14px 60px; }
  .task-side { display: none; }
  .settings-nav { width: 145px; }
  .view-bar .tools .tool-btn span { display: none; }
  .row-meta .due span.txt { display: none; }
  .modal { max-height: 94vh; }
}

.side-timer {
  display: flex; align-items: center; gap: 6px; margin: 4px 8px 6px; padding: 7px 8px;
  border-radius: 8px; background: var(--purple-soft); color: var(--purple);
  font-size: 11.3px; font-weight: 500;
}
.side-timer .pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: #e5484d; animation: pulse 1.4s infinite; flex-shrink: 0; }
.side-timer b { font-size: 11px; }
