:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --line: #d9dde3;
  --text: #1f2429;
  --muted: #6b7480;
  --accent: #2f6fdb;
  --today: #fff8dc;
  --recent: #f0f1f3;
  --future: #f7f3fb;
  --none: #2e9e5b;
  --partial: #e8912d;
  --required: #d9433b;
  --link: #5b6472;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
header h1 { font-size: 18px; margin: 0; }
.legend { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; flex: 1; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 10px; border-left: 4px solid; background: #fafafa; }
.chip.hint { border: 0; color: var(--muted); }
.ops-none { border-color: var(--none); }
.ops-partial { border-color: var(--partial); }
.ops-required { border-color: var(--required); }
.who { display: flex; gap: 12px; align-items: center; }
.status { color: var(--required); font-size: 12px; }
.weekend { color: var(--muted); font-size: 12px; }
button {
  font: inherit;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
button:hover { background: #f0f3f8; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { background: #2559b3; }
button.danger { color: var(--required); }

#boardWrap { flex: 1; overflow: auto; padding: 12px; }
.board {
  display: grid;
  position: relative;
  gap: 0;
  width: 100%;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.corner, .colhead, .rowhead, .cell { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.colhead { padding: 8px 10px; text-align: center; background: #fafbfc; }
.colhead .lbl { font-weight: 600; }
.colhead .sub { font-size: 12px; color: var(--muted); }
.colhead.today { background: var(--today); }
.colhead.recent { background: var(--recent); }
.colhead.future { background: var(--future); }
.rowhead {
  padding: 10px;
  font-weight: 600;
  background: #fafbfc;
  display: flex;
  align-items: center;
  position: sticky;
  left: 0;
  z-index: 2;
}
.cell {
  min-width: 0;
  min-height: 84px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: cell;
}
.cell.today { background: var(--today); }
.cell.recent { background: var(--recent); }
.cell.future { background: var(--future); }
.cell:hover { outline: 2px dashed #c7cfdb; outline-offset: -3px; }

.release {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 6px solid var(--none);
  border-radius: 6px;
  padding: 6px 22px 6px 8px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  user-select: none;
  touch-action: none;
}
.release:hover { box-shadow: 0 2px 6px rgba(0,0,0,.14); }
.release.ops-none { border-left-color: var(--none); background: #f3fbf6; }
.release.ops-partial { border-left-color: var(--partial); background: #fff7ec; }
.release.ops-required { border-left-color: var(--required); background: #fdf0ef; }
.release .title { font-weight: 600; overflow-wrap: anywhere; }
.release .body { font-size: 12px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 4.2em; overflow: hidden; }
.release .date { font-size: 11px; color: var(--accent); margin-top: 3px; }
.release .handle {
  position: absolute;
  right: 5px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border-radius: 50%;
  background: #cfd4db;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #c3c9d1;
  cursor: crosshair;
  touch-action: none;
}
.release .handle:hover { background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.release.drop-target { outline: 3px solid var(--accent); }
.release.drag-source { opacity: .7; }
.release.moving { opacity: .35; }
.release.ghost {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0,0,0,.3);
  transform: rotate(-1deg);
}
.cell.drop-ok { outline: 2px dashed var(--accent); outline-offset: -3px; background-color: #eaf1fd; }
.cell.drop-here { background-color: #d6e4fb; }

#links { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; z-index: 3; }
#links path.link { fill: none; stroke: var(--link); stroke-width: 2; marker-end: url(#arrow); pointer-events: none; }
#links path.hit { fill: none; stroke: transparent; stroke-width: 12; pointer-events: stroke; cursor: pointer; }
#links path.hit:hover + path.link, #links path.link.hot { stroke: var(--required); }
#links path.temp { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 4; }

dialog {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
  min-width: 420px;
  max-width: 92vw;
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(20,24,30,.45); }
dialog h2 { margin: 0 0 12px; font-size: 16px; }
#editForm .row { display: flex; gap: 16px; }
#editForm label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); flex: 1; }
#editForm select, #editForm input, #editForm textarea {
  font: inherit; font-size: 14px; color: var(--text);
  padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
.dateRow { display: flex; gap: 6px; }
.dateRow input { flex: 1; }
.opsPick { border: 1px solid var(--line); border-radius: 6px; margin: 12px 0; padding: 6px 10px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.opsPick label:has(input:disabled) { opacity: .45; cursor: not-allowed; }
.opsNote { font-size: 12px; color: var(--muted); flex-basis: 100%; }
.opsNote:empty { display: none; }
.opsPick legend { font-size: 12px; color: var(--muted); padding: 0 4px; }
.opsPick label { flex-direction: row !important; align-items: center; color: var(--text) !important; font-size: 14px !important; padding-left: 6px; border-left: 4px solid; }
.textLbl textarea { width: 100%; resize: vertical; }
.depList { margin-top: 10px; font-size: 13px; }
.depList h3 { font-size: 12px; color: var(--muted); margin: 8px 0 4px; font-weight: 600; }
.depList div { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 2px 0; }
.depList button { padding: 1px 8px; font-size: 12px; }
.meta { font-size: 11px; color: var(--muted); margin-top: 10px; }
menu { display: flex; gap: 8px; margin: 16px 0 0; padding: 0; }
menu .spacer { flex: 1; }

#logDlg { width: min(900px, 92vw); }
.dlgHead { display: flex; justify-content: space-between; align-items: center; }
.tabs { display: flex; gap: 4px; margin: 10px 0; border-bottom: 1px solid var(--line); }
.tab { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; }
.tab.active { border-bottom-color: var(--accent); color: var(--accent); }
.pane { max-height: 60vh; overflow: auto; }
#logTable { width: 100%; border-collapse: collapse; font-size: 13px; }
#logTable th, #logTable td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
#logTable th { position: sticky; top: 0; background: #fff; color: var(--muted); font-weight: 600; font-size: 12px; }
#logTable td.when { white-space: nowrap; color: var(--muted); }
#logTable td.action { text-transform: capitalize; }
#archiveList { list-style: none; padding: 0; margin: 0; }
#archiveList li { display: flex; gap: 10px; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--line); }
#archiveList .d { color: var(--muted); font-size: 12px; min-width: 100px; }
.hint { color: var(--muted); font-size: 12px; }
