:root {
  --bg: #F3F6FA; --surface: #FFFFFF; --surface2: #F8FAFD; --hover: #EEF3F9;
  --border: #D7E1EC; --border2: #E7EBEF; --text: #25364B; --muted: #6A7B8E; --faint: #9BAABD;
  --primary: #2563A6; --primary-h: #1D518A; --primary-t: #FFFFFF; --accent: #2F5D7C;
  --sel: #EAF3FE; --zebra: #EDF2F8; --selbar: #3478BB; --danger: #A33B43; --danger-bg: #FBEDEE;
  --today: rgba(214, 74, 86, .10); --today-t: #B33A42; --hard: #7C3037;
  --weekend: rgba(30, 50, 80, .035); --grid: #E7EBEF; --month: #CCD7E3;
  --handle: rgba(20, 30, 45, .35); --lock: #354F68;
  --ok: #2F7D5B; --ok-bg: #E5F3EC; --info: #2563A6; --info-bg: #E6EFF9; --warn: #9A6412; --warn-bg: #FBF0DD; --bad: #B33A42; --bad-bg: #FBE9EA;
  --st-not_started: #A5B2C2; --st-in_progress: #3B82C4; --st-blocked: #D28B36; --st-done: #4F8A70;
  --shadow: 0 10px 32px rgba(16, 32, 56, .16); --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F151C; --surface: #161E27; --surface2: #1A232E; --hover: #202B37;
    --border: #2B3746; --border2: #222D39; --text: #E2E8F0; --muted: #94A3B8; --faint: #64748B;
    --primary: #3B82C4; --primary-h: #4A90D9; --accent: #6B9BC0;
    --sel: #1B2A3B; --zebra: #1E2935; --selbar: #4A90D9; --danger: #E8838B; --danger-bg: #3A2025;
    --today: rgba(240, 110, 120, .13); --today-t: #F08A92; --hard: #E8939A;
    --weekend: rgba(255, 255, 255, .025); --grid: #222D39; --month: #34414F;
    --handle: rgba(0, 0, 0, .35); --lock: #B8CBE0;
    --ok: #6CC49A; --ok-bg: #1B3329; --info: #7DB3E8; --info-bg: #1A2B3E; --warn: #E6B163; --warn-bg: #3A2D16; --bad: #F08A92; --bad-bg: #3A2025;
    --shadow: 0 10px 32px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.4 "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- buttons & inputs */
button {
  border: 1px solid var(--border); background: var(--surface); border-radius: 6px;
  padding: 6px 9px; cursor: pointer; white-space: nowrap; line-height: 1.25;
  transition: background .12s, border-color .12s;
}
button:hover:not(:disabled) { background: var(--hover); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--selbar); outline-offset: 1px; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-t); font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--primary-h); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
button.danger-text { color: var(--danger); }
button.ghost { border-color: transparent; background: transparent; }
button.link { border: 0; background: none; color: var(--accent); padding: 4px 6px; }
button.icon { border: 0; background: none; font-size: 22px; line-height: 1; padding: 2px 8px; color: var(--muted); }
input, select, textarea {
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; min-width: 0;
}
textarea { resize: vertical; width: 100%; }

/* ---------- toolbar */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.tb-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { border-radius: 7px; flex: none; }
.title-input { font-weight: 700; font-size: 15px; width: 170px; border-color: transparent; background: transparent; }
.title-input:hover, .title-input:focus { border-color: var(--border); background: var(--surface); }
.hard { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.hard input { padding: 4px 6px; font-size: 13px; }
.tb-group { display: flex; align-items: center; gap: 4px; }
.tb-group + .tb-group { padding-left: 10px; border-left: 1px solid var(--border2); }
.tb-end { margin-left: auto; }
.tb-break { display: none; }
/* Laptop widths: file actions + PDF/language on row 1, editing tools on row 2. */
@media (max-width: 1560px) {
  .tb-brand { order: 0; } .tb-file { order: 1; } .tb-undo { order: 2; } .tb-end { order: 3; }
  .tb-break { display: block; order: 4; flex-basis: 100%; height: 0; }
  .tb-task { order: 5; padding-left: 0 !important; border-left: 0 !important; } .tb-bars { order: 6; }
  .tb-end { border-left: 0 !important; }
}
@media (max-width: 1240px) { .tb-end { order: 7; } }
.color { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
#color { padding: 5px 6px 5px 24px; background: var(--surface) linear-gradient(var(--swatch), var(--swatch)) 8px 50% / 10px 10px no-repeat; }
#managerBtn.on { color: var(--ok); border-color: var(--ok); font-weight: 600; }
.muted.small { font-size: 12px; }
#dependBtn.on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
#groupPick { padding: 5px 6px; width: 92px; }
.lang { min-width: 72px; }

/* ---------- view bar */
.viewbar {
  display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-between; gap: 6px 16px;
  padding: 8px 16px 6px;
}
.vb-info { display: flex; align-items: center; gap: 6px 10px; min-width: 0; flex: 1; overflow: hidden; }
.vb-info strong { white-space: nowrap; }
.vb-info .summary { flex-wrap: nowrap; white-space: nowrap; }
.vb-info strong { font-size: 15px; }
.summary { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border2); color: var(--muted); }
.chip.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.chip.info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.chip.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.chip.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; font-weight: 600; }
.sel-text { color: var(--accent); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 0 1 auto; }
.vb-controls { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.zoom { display: inline-flex; align-items: center; gap: 3px; }
.zoom span { margin-right: 4px; }
.zoom button { width: 28px; padding: 3px 0; font-weight: 700; }
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.banner { margin: 0 16px 6px; padding: 6px 12px; border-radius: 6px; background: var(--surface2); color: var(--muted); font-size: 12.5px; }
.banner.on { background: var(--info-bg); color: var(--info); font-weight: 600; }

/* ---------- main area */
.main { flex: 1; display: flex; min-height: 0; padding: 0 16px 6px; gap: 12px; }
.chart {
  flex: 1; min-width: 0; overflow: auto; position: relative;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  user-select: none; -webkit-user-select: none; outline: none;
}
.grid { position: relative; }
.bg { position: absolute; bottom: 0; pointer-events: none; z-index: 0; }
.bg i { position: absolute; top: 0; bottom: 0; }
.bg .we { background: var(--weekend); }
.bg .wk { width: 1px; background: var(--grid); }
.bg .mo { width: 1px; background: var(--month); }
.bg .today { background: var(--today); }
.bg .hardline { width: 0; border-left: 2px dashed var(--hard); }
.links { position: absolute; pointer-events: none; z-index: 1; overflow: visible; }
.links path { fill: none; stroke: var(--faint); stroke-width: 1.4; }
.links path.bad { stroke: var(--bad); stroke-dasharray: 4 3; }
.links .ah { fill: var(--faint); stroke: none; }
.links .ah.bad { fill: var(--bad); }

.hdr { position: sticky; top: 0; z-index: 6; display: flex; background: var(--surface2); border-bottom: 1px solid var(--border); }
.hdr-left {
  position: sticky; left: 0; z-index: 7; width: var(--left); flex: none; background: var(--surface2);
  padding: 8px 0 0 16px; border-right: 1px solid var(--border2);
}
.guide { font-size: 11.5px; color: var(--faint); }
.cols { display: flex; align-items: center; margin-top: 10px; font-weight: 700; font-size: 13px; color: var(--muted); }
.c-name { width: calc(var(--name) + 6px); display: flex; align-items: center; justify-content: space-between; padding-right: 16px; }
.add-round {
  width: 22px; height: 22px; padding: 0; border-radius: 50%; border: 0;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 15px; line-height: 22px;
}
.add-round:hover:not(:disabled) { background: var(--primary); }
.hdr-time { position: relative; flex: none; }
.months, .weeks { position: absolute; left: 0; right: 0; }
.months { top: 4px; height: 22px; }
.weeks { top: 32px; height: 26px; border-top: 1px solid var(--border2); }
.mon { position: absolute; top: 0; padding-left: 6px; font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; border-left: 1px solid var(--month); }
.mon b { position: sticky; left: calc(var(--left) + 6px); font-weight: 600; }
.wkl, .day { position: absolute; top: 0; height: 26px; line-height: 26px; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.wkl { padding-left: 5px; border-left: 1px solid var(--grid); }
.day { text-align: center; }
.day.mon1 { font-weight: 700; color: var(--text); border-left: 1px solid var(--grid); }
.day.wkend { color: var(--faint); }
.today-lbl {
  position: absolute; top: 4px; transform: translateX(-50%); z-index: 1;
  font-size: 10.5px; font-weight: 700; color: #fff; background: var(--today-t); border-radius: 4px; padding: 1px 6px;
}
.hard-lbl {
  position: absolute; top: 26px; transform: translateX(-100%); margin-left: -3px; z-index: 1;
  font-size: 10.5px; font-weight: 700; color: var(--hard); background: var(--surface2); white-space: nowrap; padding: 0 3px;
}

.rows { position: relative; z-index: 2; }
.row { display: flex; position: relative; border-bottom: 1px solid var(--border2); }
.row:hover { background: rgba(80, 120, 170, .04); }
.row.sel { background: color-mix(in srgb, var(--sel) 75%, transparent); }
.row.lifted { z-index: 5; box-shadow: var(--shadow); background: var(--surface); }
.left {
  position: sticky; left: 0; z-index: 5; width: var(--left); flex: none;
  display: flex; align-items: center; gap: 6px; padding: 0 10px 0 12px;
  background: var(--surface); border-right: 1px solid var(--border2);
}
.row.sel .left { background: var(--sel); box-shadow: inset 4px 0 0 var(--selbar); }
.name, .owner {
  height: 34px; display: flex; align-items: center; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); overflow: hidden; white-space: nowrap;
}
.name { width: var(--name); gap: 8px; padding: 0 8px; cursor: text; }
.name .txt { overflow: hidden; text-overflow: ellipsis; }
.owner { width: var(--owner); padding: 0; }
.owner:focus-within { border-color: var(--selbar); box-shadow: 0 0 0 2px color-mix(in srgb, var(--selbar) 25%, transparent); }
.owner-input {
  width: 100%; height: 100%; border: 0; border-radius: 6px; padding: 0 8px; background: transparent;
  color: var(--text); cursor: text; user-select: text; -webkit-user-select: text; outline: none; min-width: 0;
}
.owner-input::placeholder { color: var(--faint); font-style: italic; }
.row.sel .name, .row.sel .owner { border-color: var(--selbar); }
.editing { border-color: var(--selbar); box-shadow: 0 0 0 2px color-mix(in srgb, var(--selbar) 25%, transparent); }
.inline-edit { flex: 1; width: 100%; border: 0; padding: 0; background: transparent; outline: none; user-select: text; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--st-not_started); cursor: pointer; display: inline-block; }
.dot:hover { box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 15%, transparent); }
.st-not_started { background: var(--st-not_started); } .st-in_progress { background: var(--st-in_progress); }
.st-blocked { background: var(--st-blocked); } .st-done { background: var(--st-done); }
.row.is-done .name .txt { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }

.lane { position: relative; flex: none; }
.bar {
  position: absolute; border-radius: 5px; background: var(--c); color: #fff;
  display: flex; align-items: center; cursor: grab; touch-action: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .18); z-index: 2;
}
.bar:hover { filter: brightness(1.06); }
.bar.dragging { cursor: grabbing; z-index: 6; box-shadow: var(--shadow); opacity: .92; }
.bar.worst { background: repeating-linear-gradient(135deg, var(--c) 0 8px, color-mix(in srgb, var(--c) 82%, #fff) 8px 12px); }
.bar.late { outline: 2px solid var(--bad); outline-offset: 1px; }
.bar.linked { outline: 1.5px solid var(--accent); outline-offset: 1px; }
.bar.sel { outline: 2.5px solid var(--selbar); outline-offset: 2px; }
.bar.picked { outline: 3px solid var(--primary); outline-offset: 2px; }
.bar.done { opacity: .7; }
.chart.depend .bar { cursor: pointer; }
.chart.depend .bar:not(.picked) { opacity: .75; }
.bar .h { position: absolute; top: 0; bottom: 0; width: min(10px, 25%); cursor: ew-resize; z-index: 1; }
.bar .h::after { content: ""; position: absolute; top: 3px; bottom: 3px; width: 3px; border-radius: 2px; background: var(--handle); }
.bar .hs { left: 0; } .bar .hs::after { left: 2px; }
.bar .he { right: 0; } .bar .he::after { right: 2px; }
.chart.depend .bar .h { cursor: pointer; }
.bar .lbl { flex: 1; text-align: center; font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: clip; padding: 0 10px; text-shadow: 0 1px 1px rgba(0, 0, 0, .25); pointer-events: none; }
.badge {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%); z-index: 2;
  font-size: 9.5px; font-weight: 800; background: var(--accent); color: #fff; border: 1.5px solid #fff;
  border-radius: 99px; padding: 0 5px; line-height: 14px; pointer-events: none;
}
.lockd {
  position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; transform: rotate(45deg);
  background: var(--lock); border: 1.5px solid var(--surface); border-radius: 1px; z-index: 4;
}
.lockd.missed { background: var(--bad); }
.version { font-size: 11px; color: var(--faint); align-self: center; padding-left: 2px; white-space: nowrap; }
.dl { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; transform: rotate(45deg); background: var(--surface); border: 2px solid var(--hard); z-index: 3; }
.overdue { position: absolute; transform: translateY(-50%); display: flex; gap: 6px; align-items: center; font-size: 10.5px; font-weight: 800; color: var(--bad); white-space: nowrap; pointer-events: none; z-index: 3; }
.row-hint { position: absolute; left: 0; z-index: 4; border: 2px solid var(--primary); border-radius: 6px; pointer-events: none; background: color-mix(in srgb, var(--primary) 6%, transparent); }
.addrow { position: sticky; left: 0; width: var(--left); display: flex; align-items: center; gap: 4px; padding: 10px 16px; z-index: 3; }

.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; height: 100%; min-height: 280px; padding: 24px; text-align: center; color: var(--muted); }
.empty img { border-radius: 16px; opacity: .9; }
button.big { padding: 10px 22px; font-size: 15px; }

/* ---------- details panel */
.panel {
  width: 370px; flex: none; display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.panel[hidden] { display: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 6px 16px; border-bottom: 1px solid var(--border2); }
.panel-head h2 { margin: 0; font-size: 15px; display: flex; flex-direction: column; min-width: 0; }
.panel-head h2 small { font-size: 12px; font-weight: 400; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.split { display: inline-flex; }
.split > button:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split > button + button { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 0; padding: 6px 7px; }
.panel-body { overflow: auto; padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); border: 0; padding: 0; margin: 0; min-width: 0; }
.field > input, .field > select, .field > textarea { color: var(--text); font-size: 14px; width: 100%; }
.field.inline { flex-direction: row; align-items: center; justify-content: space-between; margin-top: 8px; }
.field.inline input { width: 90px; }
fieldset.field legend { padding: 0; margin-bottom: 4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.deadline-box { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 6px; background: var(--surface2); border: 1px solid var(--border2); }
.deadline-box span { display: block; font-size: 12px; color: var(--muted); }
.locks-box { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--border2); font-size: 12px; }
.lb-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); }
.lb-head .link { font-size: 12px; padding: 0 4px; }
.lb-head .bad { color: var(--bad); }
.locks-box .muted { margin: 0; }
.lockrow { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.lockrow small { color: var(--muted); margin-right: 2px; }
.lockchip { font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--surface2); border: 1px solid var(--border); color: var(--text); }
.lockchip.missed { background: var(--bad-bg); border-color: transparent; color: var(--bad); }
.deps { max-height: 180px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; padding: 4px; color: var(--text); font-size: 13px; }
.deps label { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 4px; cursor: pointer; }
.deps label:hover { background: var(--hover); }
.panel-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; }
.panel-body h3 { margin: 10px 0 0; font-size: 13px; }
.form-error, .m-error { color: var(--bad); background: var(--bad-bg); border-radius: 6px; padding: 6px 10px; font-size: 13px; }
.form-error[hidden], .m-error[hidden] { display: none; }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th, td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--border2); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }

/* ---------- status bar */
.statusbar { display: flex; justify-content: space-between; gap: 16px; padding: 4px 18px 8px; font-size: 12px; color: var(--muted); }
#status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-state { white-space: nowrap; }
.save-state::before { content: "●"; color: var(--ok); margin-right: 6px; }
.save-state.dirty::before { color: var(--warn); }
.save-state.warn { color: var(--bad); font-weight: 600; white-space: normal; }
.save-state.warn::before { color: var(--bad); }

/* ---------- dialogs, menus, toasts */
dialog {
  border: 1px solid var(--border); border-radius: 12px; padding: 0; width: min(480px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
dialog.wide { width: min(1100px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(15, 25, 40, .4); }
.m-head { padding: 16px 20px 0; }
.m-head h2 { margin: 0; font-size: 17px; }
.m-body { padding: 12px 20px; display: flex; flex-direction: column; gap: 10px; max-height: 65vh; overflow: auto; }
.m-body p { margin: 0; }
.m-error { margin: 0 20px; }
.m-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; }
.m-foot .left { margin-right: auto; }
.lead { font-weight: 600; font-size: 15px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.warning { color: var(--bad); font-size: 13px; }
.table-wrap { overflow: auto; border: 1px solid var(--border2); border-radius: 6px; }
table.preview td.chg { color: var(--primary); font-weight: 700; }
table.preview td.nm { font-weight: 600; }
table.preview th, table.preview td { white-space: nowrap; }
.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.plist li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--border2); border-radius: 8px; }
.pl-info { display: flex; flex-direction: column; min-width: 0; }
.pl-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-info small { color: var(--muted); }
.pl-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.tag { font-size: 12px; color: var(--ok); background: var(--ok-bg); border-radius: 99px; padding: 2px 8px; }
.import-row { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding-top: 6px; border-top: 1px solid var(--border2); }

.menu {
  position: fixed; z-index: 50; min-width: 190px; padding: 4px; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
}
.menu[hidden] { display: none; }
.menu button { border: 0; background: none; text-align: left; padding: 7px 10px; border-radius: 5px; display: flex; align-items: center; gap: 8px; }
.menu button:hover, .menu button:focus { background: var(--hover); outline: none; }
.menu hr { border: 0; border-top: 1px solid var(--border2); margin: 4px 0; }
.menu .mh { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); padding: 4px 10px 2px; }
.menu .ck { width: 12px; color: var(--primary); font-weight: 700; }
.drag-tip { position: fixed; z-index: 60; pointer-events: none; background: var(--text); color: var(--surface); font-size: 12px; font-weight: 600; padding: 4px 8px; border-radius: 5px; white-space: nowrap; }
.drag-tip[hidden] { display: none; }
.toasts { position: fixed; bottom: 36px; left: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.toast { display: flex; align-items: center; gap: 12px; background: var(--text); color: var(--surface); padding: 8px 14px; border-radius: 8px; box-shadow: var(--shadow); font-size: 13px; transition: opacity .4s; }
.toast.out { opacity: 0; }
.toast button { background: transparent; border: 1px solid currentColor; color: inherit; padding: 2px 10px; }

/* ---------- small screens */
@media (max-width: 1100px) {
  .panel { position: fixed; right: 12px; top: 12px; bottom: 12px; z-index: 40; width: min(380px, calc(100vw - 24px)); box-shadow: var(--shadow); }
}
@media (max-width: 760px) {
  .toolbar { padding: 8px 12px; gap: 6px 8px; }
  .tb-group + .tb-group { padding-left: 0; border-left: 0; }
  .tb-group { flex-wrap: wrap; }
  .tb-brand { flex-wrap: wrap; }
  .tb-end { margin-left: 0; }
  .vb-controls { flex: 1 1 100%; gap: 6px 10px; }
  #app { overflow-x: hidden; }
  .title-input { width: 150px; }
  .main { padding: 0 8px 6px; }
  .viewbar { padding: 6px 12px; flex-wrap: wrap; }
  .vb-info { flex-basis: 100%; }
  .banner { margin: 0 8px 6px; }
  .guide { display: none; }
  .sel-text { display: none; }
  button { padding: 6px 9px; }
}

/* ---------- print (Export PDF) */
#print { display: none; }
@media print {
  @page { size: A3 landscape; margin: 10mm; }
  body { background: #fff; color: #1a1f24; }
  #app, dialog, .menu, .toasts, .drag-tip { display: none !important; }
  #print { display: block; }
  .print-chart { width: 100%; height: auto; font-family: "Segoe UI", system-ui, "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif; }
  .print-chart .pt { font-size: 24px; font-weight: 700; fill: #1a1f24; }
  .print-chart .ps { font-size: 12px; fill: #59636e; }
  .print-chart .ph { font-size: 11px; font-weight: 700; fill: #304760; }
  .print-chart .pd { font-size: 9.5px; fill: #59636e; }
  .print-chart .pn { font-size: 11px; fill: #1a1f24; }
  .print-chart .po { font-size: 10.5px; fill: #59636e; }
  .print-chart .pod { font-size: 9px; font-weight: 700; fill: #C73E43; }
  .print-chart .pg { stroke: #DCE2E8; stroke-width: 1; }
  .print-chart .pr { stroke: #E6EAEE; stroke-width: 1; }
  .print-notes { break-before: page; font-size: 11px; }
  .print-notes h1 { font-size: 18px; margin: 0 0 12px; }
  .print-notes article { break-inside: avoid; margin-bottom: 12px; }
  .print-notes h2 { font-size: 13px; margin: 0 0 2px; }
  .print-notes p { margin: 0 0 2px 14px; color: #454d55; }
  .print-notes .h { color: #6a737c; font-size: 10px; }
}

/* ---------- sign-in page */
.auth { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth[hidden], .list-page[hidden], #app[hidden] { display: none; }
.auth-card {
  width: min(400px, 100%); display: flex; flex-direction: column; gap: 12px; padding: 28px 28px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
.auth-logo { align-self: center; border-radius: 14px; }
.auth-card h1 { margin: 0; text-align: center; font-size: 22px; }
.auth-card > p { margin: 0; text-align: center; }
.auth-card .field > input { font-size: 15px; padding: 9px 10px; }
.auth-card button.big { width: 100%; margin-top: 4px; }
.auth-foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--faint); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.check[hidden] { display: none; }

/* ---------- project list */
.list-page { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand-name { font-size: 16px; }
.list-head-end { display: flex; align-items: center; gap: 8px; }
.list-main { width: min(1100px, 100%); margin: 0 auto; padding: 20px 16px 40px; }
.list-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.list-bar h2 { margin: 0 auto 0 0; font-size: 20px; }
.list-bar input[type=search] { width: min(280px, 100%); padding: 7px 10px; }
.list-hint { margin: 8px 0 16px; }
.project-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.project-list > .empty, .project-list > p { border: 0; padding: 24px; }
.prow {
  display: grid; grid-template-columns: minmax(0, 2.4fr) minmax(0, 1.1fr) 70px minmax(0, 1.7fr) 36px;
  align-items: center; gap: 12px; min-height: 44px; padding: 0 8px 0 16px; cursor: pointer;
  border-top: 1px solid var(--border2); font-size: 13.5px;
}
.prow:nth-child(odd) { background: var(--zebra); }          /* alternate shading (row 1 is the header) */
.prow:hover, .prow:focus-visible { background: var(--sel); outline: none; }
.prow.mine { box-shadow: inset 4px 0 0 var(--selbar); }
.prow > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phead { cursor: default; min-height: 36px; border-top: 0; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; background: var(--surface) !important; }
.pr-title { font-weight: 600; }
.pr-owner { font-weight: 600; color: var(--accent); }
.pr-num { text-align: right; font-variant-numeric: tabular-nums; }
.pr-updated { color: var(--muted); }
.pr-del { text-align: right; }
.pr-del .icon:hover { color: var(--danger); }
@media (max-width: 760px) {
  .prow { grid-template-columns: minmax(0, 1fr) auto 36px; gap: 2px 10px; padding: 8px 8px 8px 14px; }
  .prow .pr-owner { grid-column: 1; grid-row: 2; font-size: 12px; }
  .prow .pr-updated { grid-column: 1 / 3; grid-row: 3; font-size: 12px; }
  .prow .pr-num { grid-column: 2; grid-row: 1; }
  .prow .pr-del { grid-column: 3; grid-row: 1; }
  .phead { display: none; }
}

/* ---------- editor header additions */
button.back { display: inline-flex; align-items: center; gap: 8px; border-color: transparent; background: transparent; padding: 2px 8px 2px 2px; font-weight: 600; }
button.back:hover { background: var(--hover); }
.user-btn { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- users dialog */
.users-table td, .users-table th { white-space: nowrap; }
.users-table tr.off td { color: var(--faint); }
.u-actions { display: flex; flex-wrap: wrap; gap: 2px 4px; white-space: normal !important; }
.u-actions .link { font-size: 12.5px; padding: 2px 4px; }
.add-user { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-items: end; }
.add-user .check { grid-column: 1 / -1; }
.users h3 { margin: 6px 0 0; font-size: 14px; }
@media (max-width: 760px) { .add-user { grid-template-columns: 1fr; } .list-head .version { display: none; } }

/* ---------- Drop Dead: a narrow pin at the latest-finish date */
.bar.dd { background: transparent; box-shadow: none; border-radius: 0; z-index: 4; cursor: grab; }
.bar.dd::before { content: ""; position: absolute; left: 50%; top: 6px; bottom: 0; width: 3px; margin-left: -1.5px; border-radius: 2px; background: var(--c); }
.bar.dd::after { content: ""; position: absolute; left: 50%; top: 0; margin-left: -7px; border-left: 7px solid transparent; border-right: 7px solid transparent; border-top: 9px solid var(--c); }
.bar.dd:hover { filter: brightness(1.15); }
.bar.dd.sel, .bar.dd.linked, .bar.dd.picked { outline-offset: 1px; border-radius: 3px; }
.bar.dd.dragging { box-shadow: none; }
