:root {
  --bg: #ffffff; --panel: #f7f8fa; --hover: #eef0f4; --active: #e8ebf1;
  --line: #e7e9ee; --line-strong: #d7dae1;
  --ink: #1b1f27; --muted: #5f6673; --subtle: #8d94a1;
  --blue: #2f6bed; --blue-hover: #2259d0; --blue-soft: #e8effe;
  --violet: #7a3fe0; --violet-soft: #f2ebfd;
  --green: #1e9a5b; --green-soft: #e4f6ec;
  --amber: #c98208; --amber-soft: #fdf3dd;
  --red: #d8423a; --red-soft: #fdeaea;
  --event: #dbe7fb; --event-line: #6c9cf0; --event-ink: #24437e;
  --shadow: 0 1px 2px rgba(20, 24, 33, .06), 0 2px 6px rgba(20, 24, 33, .08);
  --pop: 0 12px 40px rgba(20, 24, 33, .22);
  --overlay: rgba(20, 24, 33, .4);
  --hour: 48px;
}
.dark {
  --bg: #15171c; --panel: #1b1e24; --hover: #262a32; --active: #2d323b;
  --line: #2a2e36; --line-strong: #3a3f49;
  --ink: #eceef2; --muted: #a6adb9; --subtle: #767d8a;
  --blue: #5b8cf5; --blue-hover: #7aa2f7; --blue-soft: #1e2c4a;
  --violet: #ae85f3; --violet-soft: #2c2342;
  --green: #4cc587; --green-soft: #15332a;
  --amber: #e6ad45; --amber-soft: #38290f;
  --red: #ef7a72; --red-soft: #3c1e1d;
  --event: #1f3153; --event-line: #5b8cf5; --event-ink: #c5d7fb;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --pop: 0 12px 40px rgba(0, 0, 0, .6); --overlay: rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 13px/1.4 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); height: 100vh; }
.side { display: flex; flex-direction: column; gap: 2px; padding: 12px 10px; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 10px; }
.logo { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; }
.logo i { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: var(--ink); color: var(--bg); font-style: normal; font-size: 12px; font-weight: 700; }
.new { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px; border: 0; border-radius: 7px; background: var(--blue); color: #fff; font-weight: 600; }
.new:hover { background: var(--blue-hover); }
.nav { display: flex; align-items: center; gap: 9px; width: 100%; height: 32px; padding: 0 8px; border: 0; border-radius: 7px; background: none; color: var(--muted); font-weight: 500; text-align: left; }
.nav:hover { background: var(--hover); }
.nav.on { background: var(--active); color: var(--ink); font-weight: 600; }
.nav .n { margin-left: auto; color: var(--subtle); font-size: 12px; font-weight: 500; }
.nav .dot { width: 9px; height: 9px; margin: 0 3px; border-radius: 3px; background: var(--violet); flex: none; }
.side-label { padding: 16px 8px 4px; color: var(--subtle); font-size: 12px; font-weight: 600; }
.side-foot { margin-top: auto; padding-top: 10px; }

.content { min-width: 0; height: 100vh; display: flex; flex-direction: column; }
.bar { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 8px 16px; border-bottom: 1px solid var(--line); flex: none; }
.bar h1 { margin: 0; font-size: 18px; font-weight: 700; }
.bar h1 span { color: var(--subtle); font-weight: 500; }
.bar .sp { flex: 1; }
.tool { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; min-width: 30px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--bg); font-weight: 500; }
.tool:hover { background: var(--hover); }
.tool.ghost { border-color: transparent; background: none; }
.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--hover); }
.seg button { height: 26px; padding: 0 10px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-weight: 500; }
.seg button.on { background: var(--bg); color: var(--ink); box-shadow: var(--shadow); }

.cal { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 256px; }
.grid-wrap { min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.days-head, .days { display: grid; grid-template-columns: 52px repeat(var(--cols), minmax(0, 1fr)); }
.days-head { border-bottom: 1px solid var(--line); padding-right: var(--bar-w, 0); flex: none; }
.day-title { padding: 7px 4px; text-align: center; color: var(--muted); font-weight: 500; }
.day-title b { display: inline-grid; place-items: center; min-width: 24px; height: 24px; margin-left: 3px; border-radius: 7px; color: var(--ink); font-weight: 600; }
.day-title.today b { background: var(--blue); color: #fff; }
.tz { padding: 11px 0 0 8px; color: var(--subtle); font-size: 11px; }
.scroller { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.hours { position: relative; height: calc(var(--hour) * 24); }
.hours span { position: absolute; right: 7px; color: var(--subtle); font-size: 11px; transform: translateY(-50%); }
.day { position: relative; height: calc(var(--hour) * 24); border-left: 1px solid var(--line); background-image: linear-gradient(var(--line) 1px, transparent 1px); background-size: 100% var(--hour); touch-action: pan-y; }
.day .off { position: absolute; left: 0; right: 0; background: var(--panel); opacity: .75; pointer-events: none; }
.now { position: absolute; left: 0; right: 0; z-index: 3; height: 2px; background: var(--red); pointer-events: none; }
.now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }

.block { position: absolute; left: 2px; right: 4px; z-index: 1; display: block; overflow: hidden; padding: 2px 5px 2px 7px; border: 1px solid var(--line-strong); border-left: 3px solid var(--violet); border-radius: 5px; background: var(--bg); box-shadow: var(--shadow); font-size: 11.5px; line-height: 1.25; text-align: left; touch-action: none; user-select: none; }
.block .tt { display: flex; align-items: flex-start; gap: 4px; font-weight: 600; }
.block .ring { width: 10px; height: 10px; margin-top: 2px; border: 1.5px solid var(--subtle); border-radius: 50%; flex: none; }
.block .tm { color: var(--subtle); }
.block.event { border: 0; border-left: 3px solid var(--event-line); background: var(--event); color: var(--event-ink); box-shadow: none; }
.block.event .tm { color: inherit; opacity: .75; }
.block.pri-ASAP { border-left-color: var(--red); }
.block.pri-HIGH { border-left-color: var(--amber); }
.block.pri-LOW { border-left-color: var(--subtle); }
.block.late { background: var(--red-soft); }
.block.risk { background: var(--amber-soft); }
.block.dragging { z-index: 5; opacity: .85; box-shadow: var(--pop); }

.rail { min-height: 0; overflow-y: auto; padding: 12px; border-left: 1px solid var(--line); }
.month-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-weight: 600; }
.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; text-align: center; }
.month span { color: var(--subtle); font-size: 11px; padding: 3px 0; }
.month button { height: 28px; border: 0; border-radius: 6px; background: none; font-size: 12px; }
.month button:hover { background: var(--hover); }
.month button.other { color: var(--subtle); }
.month button.in-week { background: var(--blue-soft); }
.month button.today { background: var(--blue); color: #fff; font-weight: 600; }
.rail h3 { margin: 18px 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.mini { display: flex; align-items: flex-start; gap: 8px; width: 100%; padding: 6px; border: 0; border-radius: 6px; background: none; text-align: left; }
.mini:hover { background: var(--hover); }
.mini b { display: block; font-weight: 500; }
.mini small { color: var(--muted); }
.flag { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--subtle); flex: none; }
.flag.ok { background: var(--green); } .flag.warn { background: var(--amber); } .flag.bad { background: var(--red); }
.quiet { color: var(--subtle); padding: 2px 6px; }

.scroll { flex: 1; min-height: 0; overflow: auto; }
.table { width: 100%; min-width: 760px; border-collapse: collapse; }
.table th { position: sticky; top: 0; z-index: 1; height: 34px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--bg); color: var(--muted); font-weight: 500; text-align: left; }
.table td { height: 38px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.table tbody tr:not(.group):hover { background: var(--hover); }
.group td { height: 36px; background: var(--panel); font-weight: 600; }
.group small { margin-left: 6px; color: var(--subtle); font-weight: 500; }
.name { display: flex; align-items: center; gap: 8px; max-width: 420px; border: 0; padding: 0; background: none; font-weight: 500; text-align: left; }
.round { appearance: none; width: 16px; height: 16px; margin: 0; border: 1.5px solid var(--subtle); border-radius: 50%; background: none; cursor: pointer; flex: none; }
.round:checked { border-color: var(--green); background: var(--green); box-shadow: inset 0 0 0 3px var(--bg); }
tr.done .name { color: var(--subtle); text-decoration: line-through; }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--hover); color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill.ok { background: var(--green-soft); color: var(--green); }
.pill.warn { background: var(--amber-soft); color: var(--amber); }
.pill.bad { background: var(--red-soft); color: var(--red); }
.pill.auto { background: var(--violet-soft); color: var(--violet); }
.empty { padding: 60px 24px; text-align: center; color: var(--muted); }
.empty b { display: block; margin-bottom: 4px; color: var(--ink); font-size: 15px; }

.agenda { width: min(720px, 100%); margin: 0 auto; padding: 20px 16px; }
.agenda h2 { margin: 18px 0 6px; font-size: 13px; color: var(--muted); }
.line { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 6px 10px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; }
.line:hover { background: var(--hover); }
.line time { width: 92px; color: var(--muted); flex: none; }
.line b { font-weight: 500; flex: 1; min-width: 0; }

.settings { width: min(640px, 100%); padding: 20px 16px; }
.settings section { padding: 16px 0; border-bottom: 1px solid var(--line); }
.settings h2 { margin: 0 0 10px; font-size: 14px; }
.hour-row { display: grid; grid-template-columns: 130px 110px 110px; gap: 8px; align-items: center; padding: 3px 0; }
.hour-row label { display: flex; align-items: center; gap: 8px; }
.input { height: 32px; width: 100%; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--bg); }
.input:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.nums label { display: grid; gap: 4px; color: var(--muted); }

dialog { padding: 0; border: 0; border-radius: 12px; background: var(--bg); color: var(--ink); box-shadow: var(--pop); }
dialog::backdrop { background: var(--overlay); }
dialog.task { width: min(860px, calc(100vw - 32px)); }
dialog.small { width: min(420px, calc(100vw - 32px)); }
.sheet { display: grid; grid-template-columns: minmax(0, 1fr) 300px; min-height: 520px; }
.left { display: flex; flex-direction: column; padding: 14px 18px; min-width: 0; }
.left-top { display: flex; align-items: center; justify-content: space-between; min-height: 30px; color: var(--muted); }
.title-in { width: 100%; margin: 6px 0; border: 0; outline: 0; background: none; font-size: 20px; font-weight: 700; }
.desc { flex: 1; min-height: 240px; width: 100%; padding: 4px 0; border: 0; outline: 0; resize: none; background: none; }
.foot { display: flex; align-items: center; gap: 8px; padding-top: 10px; }
.foot .sp { flex: 1; }
.primary { height: 32px; padding: 0 14px; border: 0; border-radius: 7px; background: var(--blue); color: #fff; font-weight: 600; }
.primary:hover { background: var(--blue-hover); }
.right { padding: 0 0 12px; background: var(--panel); border-left: 1px solid var(--line); border-radius: 0 12px 12px 0; }
.banner { display: flex; align-items: center; gap: 8px; padding: 9px 14px; font-weight: 600; border-radius: 0 12px 0 0; }
.banner.ok { background: var(--green-soft); color: var(--green); }
.banner.warn { background: var(--amber-soft); color: var(--amber); }
.banner.bad { background: var(--red-soft); color: var(--red); }
.banner.none { background: var(--hover); color: var(--muted); }
.why { padding: 6px 14px 0; color: var(--muted); font-size: 12px; }
.auto-row { display: flex; align-items: center; gap: 8px; margin: 10px 8px 6px; padding: 7px 8px; border-radius: 7px; background: var(--violet-soft); color: var(--violet); font-weight: 500; }
.prop { display: grid; grid-template-columns: 112px minmax(0, 1fr); align-items: center; gap: 6px; min-height: 34px; padding: 0 14px; color: var(--muted); }
.prop .input { height: 28px; border-color: transparent; background: none; color: var(--ink); }
.prop .input:hover { background: var(--hover); }
.prop select[multiple] { height: 62px; }
.prop input[type=checkbox] { justify-self: start; }
.simple { display: grid; gap: 12px; padding: 18px; }
.simple h2 { margin: 0; font-size: 16px; }
.simple label { display: grid; gap: 4px; color: var(--muted); }
.simple .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.toast { position: fixed; left: 16px; bottom: 16px; z-index: 20; display: flex; gap: 8px; padding: 9px 12px; border-radius: 8px; background: #20242c; color: #fff; box-shadow: var(--pop); }

.toast[hidden] { display: none; }
#auth { display: grid; place-items: center; min-height: 100vh; padding: 16px; background: var(--panel); }
#auth[hidden], .shell[hidden] { display: none; }
.auth-card { display: grid; gap: 12px; width: min(380px, 100%); padding: 24px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); box-shadow: var(--shadow); }
.auth-card h1 { margin: 6px 0 0; font-size: 20px; }
.auth-card label { display: grid; gap: 4px; color: var(--muted); }
.auth-card .primary { height: 36px; }
.auth-error { min-height: 18px; color: var(--red); font-size: 12.5px; }
.auth-error:empty { display: none; }
.side-team { width: 100%; margin: 0 0 6px; padding: 0 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
.side-user { display: flex; align-items: center; gap: 8px; padding: 6px 8px; font-weight: 500; }
.side-user span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--violet-soft); color: var(--violet); font-size: 10px; font-weight: 700; flex: none; }
.person { width: 160px; height: 30px; }
.block.busy { cursor: default; opacity: .8; }
.team-table { min-width: 860px; }
.team-table td, .team-table th { border-right: 1px solid var(--line); }
.team-cell { vertical-align: top; height: 64px !important; padding: 6px 8px !important; min-width: 120px; }
.team-cell small { color: var(--muted); }
.team-task { margin-top: 3px; padding: 1px 5px; overflow: hidden; border-left: 3px solid var(--violet); border-radius: 3px; background: var(--panel); font-size: 11.5px; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; }
.member { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.member-name { flex: 1; min-width: 0; }
.member-name b { display: block; font-weight: 600; }
.member-name small { color: var(--muted); }
.role { width: 150px; }
.invite-row { display: flex; gap: 8px; margin-bottom: 8px; }
.chevrons { display: flex; gap: 3px; padding: 10px 16px; border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; }
.chevron { flex: 1; min-width: 130px; padding: 6px 12px; border-radius: 6px; background: var(--hover); border-top: 3px solid var(--line-strong); }
.chevron.active { background: var(--blue-soft); border-top-color: var(--stage); }
.chevron.done { border-top-color: var(--stage); opacity: .7; }
.chevron.canceled { opacity: .5; text-decoration: line-through; }
.chevron b { display: block; font-weight: 600; }
.chevron small { color: var(--muted); }
.stage-head { display: flex; align-items: center; gap: 8px; }
.stage-head i { width: 10px; height: 10px; border-radius: 3px; }
.stage-head .sp { flex: 1; }
.due { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 400; }
.due .input { width: 130px; height: 26px; }
.timeline { position: relative; min-width: 760px; padding-bottom: 16px; }
.tl-row { display: grid; grid-template-columns: 200px minmax(0, 1fr); align-items: center; min-height: 40px; border-bottom: 1px solid var(--line); }
.tl-row.head { min-height: 32px; color: var(--muted); font-size: 12px; }
.tl-name { padding: 0 16px; border: 0; background: none; font-weight: 500; text-align: left; }
.tl-track { position: relative; height: 100%; min-height: 32px; }
.tl-track > span { position: absolute; top: 8px; white-space: nowrap; }
.bar-stage { position: absolute; top: 8px; height: 24px; overflow: hidden; padding: 0 6px; border: 0; border-radius: 5px; background: var(--stage); color: #fff; font-size: 11.5px; text-align: left; white-space: nowrap; }
.bar-stage.done, .bar-stage.canceled { opacity: .45; }
.bar-stage.pending { opacity: .75; }
.tl-today { position: absolute; top: 0; bottom: 0; left: calc(200px + (100% - 200px) * var(--left) / 100); width: 2px; background: var(--red); pointer-events: none; }
.tpl-list { width: min(720px, 100%); margin: 0 auto; padding: 16px; display: grid; gap: 8px; }
.tpl-card { display: flex; align-items: center; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.tpl-card b { display: block; font-weight: 600; }
.tpl-card small { color: var(--muted); }
.tpl-card .sp { flex: 1; }
.choice { display: flex !important; align-items: center; gap: 8px; color: var(--ink) !important; }
.simple-vars { display: grid; gap: 12px; }
.simple-vars:empty { display: none; }
#template-form { max-height: calc(100vh - 64px); overflow-y: auto; }
.draft-stage { display: grid; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.draft-head { display: grid; grid-template-columns: minmax(0, 1fr) 70px 140px 30px; gap: 6px; }
.draft-task { display: grid; grid-template-columns: minmax(120px, 1fr) 96px 92px 96px 90px 30px; gap: 6px; align-items: center; }
.draft-task label { display: flex; align-items: center; gap: 4px; font-size: 12px; }
.draft-task label .input { padding: 0 4px; }
.hint { margin: 0 0 10px; color: var(--muted); }
.file { position: relative; cursor: pointer; }
.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.chat { width: min(760px, 100%); margin: 0 auto; padding: 20px 16px; display: grid; gap: 12px; }
.turn { line-height: 1.55; font-size: 14px; }
.turn.user { justify-self: end; max-width: 80%; padding: 8px 12px; border-radius: 12px; background: var(--blue-soft); }
.turn.bot { display: grid; gap: 8px; }
.step { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.step.running { color: var(--violet); }
.step.failed { color: var(--red); }
.step svg.i { width: 14px; height: 14px; }
.ai-start { display: grid; justify-items: center; gap: 10px; padding-top: 12vh; text-align: center; }
.ai-start h2 { margin: 0; font-size: 22px; }
.ai-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--violet-soft); color: var(--violet); }
.ai-prompts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.ai-prompts.left { justify-self: start; justify-content: flex-start; }
.ai-prompts .tool { height: auto; min-height: 30px; padding: 5px 10px; white-space: normal; }
.composer { display: flex; align-items: flex-end; gap: 8px; width: min(760px, 100%); margin: 0 auto; padding: 10px 16px 14px; flex: none; }
.composer .input { height: auto; padding: 8px 10px; resize: none; }

.menu { display: none; }
@media (max-width: 1040px) { .cal { grid-template-columns: minmax(0, 1fr); } .rail { display: none; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 10; inset: 0 auto 0 0; width: 232px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .menu { display: inline-flex; }
  .days-head, .days { min-width: 720px; }
  .grid-wrap { overflow-x: auto; }
  .sheet { grid-template-columns: 1fr; min-height: 0; }
  .draft-task { grid-template-columns: 1fr 1fr; }
  .desc { min-height: 80px; }
  .right { border-left: 0; border-top: 1px solid var(--line); border-radius: 0 0 12px 12px; }
  .banner { border-radius: 0; }
  dialog.task { max-height: calc(100vh - 32px); }
}
