:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --border: #e3e6ee;
  --text: #1d2233;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; margin: 0 0 .8rem; }
main { max-width: 1400px; margin: 1.2rem auto 4rem; padding: 0 1.2rem; }

/* topbar */
.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: .6rem 1.2rem;
}
.topbar .logo { font-weight: 700; color: var(--text); font-size: 1.05rem; }
.topbar .logo span { color: var(--primary); }
.topbar nav { display: flex; gap: 1rem; flex: 1; }
.topbar nav a { color: var(--muted); font-weight: 500; }
.topbar nav a:hover { color: var(--primary); }
.userbox { display: flex; align-items: center; gap: .6rem; color: var(--muted); }
.userbox form { margin: 0; }

/* messages */
.messages { max-width: 1400px; margin: .8rem auto 0; padding: 0 1.2rem; }
.msg { padding: .6rem .9rem; border-radius: var(--radius); margin-bottom: .4rem; }
.msg-success { background: #dcfce7; color: #14532d; }
.msg-info { background: #dbeafe; color: #1e3a8a; }
.msg-error, .msg-warning { background: #fee2e2; color: #7f1d1d; }

/* cards, toolbar, tables, forms */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.2rem; margin-bottom: 1.2rem;
}
.card.narrow { max-width: 560px; }
.card-link { display: block; color: inherit; transition: box-shadow .15s; }
.card-link:hover { box-shadow: 0 4px 16px rgba(29,34,51,.08); }
.card .cover { width: 100%; height: 120px; object-fit: cover; border-radius: 6px; margin-bottom: .6rem; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.breadcrumb { margin: 0 0 .8rem; }
.empty { padding: 2rem; text-align: center; color: var(--muted); grid-column: 1 / -1; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.hint { background: #fef9c3; color: #713f12; padding: .5rem .8rem; border-radius: 6px; }
.notes { white-space: pre-line; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
.table .actions { white-space: nowrap; }
.table .actions form { display: inline; }

form p { margin: 0 0 .9rem; }
form label { display: block; font-weight: 600; margin-bottom: .25rem; font-size: .88rem; }
input[type=text], input[type=password], input[type=url], input[type=date],
input[type=number], input[type=email], select, textarea {
  width: 100%; max-width: 420px; padding: .5rem .6rem;
  border: 1px solid var(--border); border-radius: 6px; font: inherit;
  background: var(--surface);
}
ul.errorlist { color: var(--danger); margin: .2rem 0; padding-left: 1.1rem; font-size: .85rem; }
.helptext { color: var(--muted); font-size: .8rem; display: block; }

.btn {
  display: inline-block; padding: .45rem .9rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; font-weight: 500; cursor: pointer;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-ghost { border: none; background: none; color: var(--muted); cursor: pointer; }
.btn-sm { padding: .2rem .5rem; font-size: .8rem; }

/* status + progress */
.status { padding: .15rem .6rem; border-radius: 99px; font-size: .8rem; font-weight: 600; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-done, .status-completed { background: #dcfce7; color: #14532d; }
.status-active { background: #dbeafe; color: #1e40af; }
.status-archived { background: #e5e7eb; color: #4b5563; }
.progress { display: block; width: 90px; height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-bar { display: block; height: 100%; background: var(--ok); }

.brand-chip {
  display: inline-block; color: #fff; font-weight: 700; font-size: .72rem;
  padding: .18rem .5rem; border-radius: 5px; letter-spacing: .04em;
  border: 1px solid rgba(29, 34, 51, .15);
}
.preview-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

/* manage section */
.subnav {
  display: flex; gap: .5rem; margin-bottom: 1.2rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .45rem; flex-wrap: wrap;
  box-shadow: 0 1px 3px rgba(29,34,51,.05);
}
.subnav a {
  display: flex; align-items: center; gap: .5rem;
  padding: .55rem 1.2rem; border-radius: 8px;
  color: var(--muted); font-weight: 600; font-size: .95rem;
  border: 1px solid transparent; transition: all .12s;
}
.subnav a:hover { color: var(--primary); background: #eef2ff; }
.subnav a.active {
  background: var(--primary); color: #fff;
  box-shadow: 0 2px 8px rgba(79,70,229,.35);
}
.subnav-icon { font-size: 1.05rem; line-height: 1; }
.team-chip {
  display: inline-block; background: var(--bg); border: 1px solid var(--border);
  border-radius: 99px; padding: .1rem .55rem; font-size: .78rem; margin: 0 .15rem .15rem 0;
}
.color-swatch {
  display: inline-block; width: 14px; height: 14px; border-radius: 3px;
  vertical-align: -2px; border: 1px solid var(--border);
}
input[type=color] { width: 60px; height: 34px; padding: 2px; border: 1px solid var(--border); border-radius: 6px; }
form ul { list-style: none; padding-left: 0; }
form ul li label { font-weight: 400; display: flex; align-items: center; gap: .4rem; }

/* filter bar */
.filterbar {
  display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .6rem .9rem; margin-bottom: 1rem;
}
.filterbar label {
  display: flex; flex-direction: column; gap: .2rem;
  font-size: .78rem; font-weight: 600; color: var(--muted); margin: 0;
}
.filterbar select { width: auto; min-width: 140px; padding: .35rem .5rem; }

/* deliverables panel */
.deliverables { margin-top: 1.2rem; }
.deliverable-list { list-style: none; padding: 0; margin: 0; }
.deliverable-list li {
  display: flex; align-items: center; gap: .6rem;
  padding: .45rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.deliverable-list li:last-child { border-bottom: none; }
.deliverable-list .due { margin-left: auto; font-size: .82rem; color: var(--muted); }
.deliverable-list .due.overdue { color: var(--danger); font-weight: 600; }
.overdue-title { color: var(--danger); font-size: .9rem; margin: .4rem 0; }

/* ---------- calendar ---------- */
.cal-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.cal { min-width: calc(240px + var(--n) * 96px); }
.cal-row {
  display: grid;
  grid-template-columns: 240px repeat(var(--n), minmax(96px, 1fr));
  grid-template-rows: repeat(var(--lanes), minmax(38px, auto));
  border-bottom: 1px solid var(--border);
  position: relative;
}
.cal-row:last-child { border-bottom: none; }
.cal-head { position: sticky; top: 0; background: var(--surface); z-index: 3; }
.cal-launch-head, .cal-week {
  padding: .5rem .6rem; font-size: .8rem; color: var(--muted); font-weight: 600;
}
.cal-week { text-align: center; border-left: 1px solid var(--border); grid-row: 1; }
.cal-week span { display: block; font-weight: 400; font-size: .72rem; }
.cal-week.is-today { background: #eef2ff; color: var(--primary); border-radius: 6px 6px 0 0; }

.cal-launch {
  grid-column: 1; grid-row: 1 / -1;
  display: flex; align-items: stretch; gap: .55rem;
  padding: .45rem .6rem; background: var(--surface);
  position: sticky; left: 0; z-index: 2;
  border-right: 1px solid var(--border);
}
.cal-launch-info {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; justify-content: center; gap: .18rem;
}
.cal-launch-info strong { display: block; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-launch-info small { color: var(--muted); }
.cal-progress { display: flex; align-items: center; gap: .4rem; }
.cal-progress .progress { width: 56px; flex-shrink: 0; }
.preview-full {
  align-self: stretch; width: 54px; min-height: 54px;
  object-fit: cover; border-radius: 8px; border: 1px solid var(--border);
}
.cal-launch-head { grid-column: 1; grid-row: 1; position: sticky; left: 0; z-index: 2; background: var(--surface); }

.cal-cell { grid-row: 1 / -1; border-left: 1px solid var(--border); }
.cal-cell.is-today { background: #eef2ff66; }

.task-chip {
  margin: 3px 4px; padding: .28rem .5rem; z-index: 1;
  border-radius: 6px; font-size: .78rem; font-weight: 600;
  color: var(--text); background: color-mix(in srgb, var(--brand) 18%, white);
  border-left: 3px solid var(--brand);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  align-self: center;
}
.task-chip:hover { outline: 2px solid var(--brand); }
.task-chip.is-done { background: #f0fdf4; border-left-color: var(--ok); color: #14532d; text-decoration: line-through; }
.task-chip.clip-l { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.task-chip.clip-r { border-top-right-radius: 0; border-bottom-right-radius: 0; }

.warn-note { color: #b45309; font-weight: 600; }

/* task actions (complete + delay) */
.task-actions { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.task-actions form { margin: 0; }
.delay-form { display: flex; align-items: center; gap: .6rem; }
.delay-form label { display: flex; align-items: center; gap: .4rem; margin: 0; font-weight: 500; }
.delay-form input[type=number] { width: 64px; }
.delay-form .delay-reason { width: 260px; }
.btn-warn { border-color: #f59e0b; color: #92400e; background: #fef3c7; }
.btn-warn:hover { background: #fde68a; color: #78350f; border-color: #d97706; }

/* task detail */
.task-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
dl.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .6rem; margin: .8rem 0; }
dl.meta dt { font-size: .75rem; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
dl.meta dd { margin: 0; font-weight: 500; }
.attachments, .comments { list-style: none; padding: 0; margin: 0 0 1rem; }
.attachments li, .comments li { padding: .45rem 0; border-bottom: 1px solid var(--border); }
.comments li p { margin: .2rem 0 0; }

/* ---------- interactive gantt editor ---------- */
#gantt-editor { position: relative; user-select: none; }
.ge-row {
  display: flex; align-items: stretch;
  border-bottom: 1px solid var(--border);
}
.ge-row:last-of-type { border-bottom: none; }
.ge-row.ge-moving { opacity: .55; background: #eef2ff; }
.ge-row.ge-drop .ge-track { background-color: #fef9c3; }
.ge-head { border-bottom: 2px solid var(--border); }
.ge-label {
  width: 280px; flex-shrink: 0; display: flex; align-items: center;
  gap: .45rem; padding: .35rem .4rem; min-height: 40px;
}
.ge-drag { cursor: grab; color: var(--muted); font-size: .9rem; padding: 0 .15rem; touch-action: none; }
.ge-drag:active { cursor: grabbing; }
.ge-name { flex: 1; min-width: 0; font-weight: 600; font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ge-role { color: var(--muted); font-size: .74rem; background: var(--bg); border-radius: 99px; padding: .1rem .5rem; }
.ge-actions { display: flex; gap: .2rem; }
.ge-weeks {
  flex: 1; display: grid; grid-template-columns: repeat(var(--n), 1fr);
  text-align: center; font-size: .74rem; color: var(--muted); font-weight: 600;
  align-items: center;
}
.ge-body { position: relative; }
.ge-track {
  flex: 1; position: relative; min-height: 40px; touch-action: none;
  background-image: linear-gradient(to right, var(--border) 1px, transparent 1px);
  background-size: calc(100% / var(--n)) 100%;
}
.ge-bar {
  position: absolute; top: 7px; height: 26px;
  background: var(--primary); border-radius: 6px; cursor: grab;
  display: flex; align-items: center; justify-content: center;
  min-width: 14px; touch-action: none; z-index: 1;
}
.ge-bar:active { cursor: grabbing; }
.ge-bar-text { color: #fff; font-size: .72rem; font-weight: 600; pointer-events: none; white-space: nowrap; overflow: hidden; }
.ge-handle { position: absolute; top: 0; width: 8px; height: 100%; cursor: ew-resize; }
.ge-handle-l { left: 0; border-radius: 6px 0 0 6px; }
.ge-handle-r { right: 0; border-radius: 0 6px 6px 0; }
.ge-handle:hover { background: rgba(255,255,255,.35); }
.ge-dot {
  position: absolute; right: -7px; top: 50%; transform: translateY(-50%);
  width: 13px; height: 13px; border-radius: 50%;
  background: #facc15; border: 2px solid #b45309;
  opacity: 0; cursor: crosshair; z-index: 2; touch-action: none;
}
.ge-bar:hover .ge-dot { opacity: 1; }
.ge-links { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.ge-link { fill: none; stroke: #94a3b8; stroke-width: 1.6; }
.ge-link marker path, .ge-links marker path { fill: #94a3b8; }
.ge-link-temp { stroke: #b45309; stroke-dasharray: 4 3; }
.ge-link-hit { fill: none; stroke: transparent; stroke-width: 11; pointer-events: stroke; cursor: pointer; }
.ge-link-hit:hover + .ge-link, .ge-link-hit:hover { stroke: var(--primary); }
.ge-retargeting .ge-bar { outline: 2px dashed #b45309; outline-offset: 2px; }
.ge-popover {
  position: absolute; z-index: 50; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(29,34,51,.15); padding: .6rem .7rem;
}
.ge-popover-title { font-size: .8rem; font-weight: 600; margin-bottom: .45rem; }
.ge-toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  background: #1d2233; color: #fff; padding: .55rem 1rem; border-radius: 8px;
  font-size: .85rem; opacity: 0; pointer-events: none; transition: opacity .2s;
  z-index: 100; max-width: 90vw;
}
.ge-toast.show { opacity: .95; }
.ge-help { font-size: .8rem; margin-top: -.3rem; }

/* report */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.2rem;
  display: flex; flex-direction: column; gap: .2rem;
}
.tile-value { font-size: 1.9rem; font-weight: 700; }
.tile-label { color: var(--muted); font-size: .82rem; }
.tile-bad { border-color: #fca5a5; background: #fef2f2; }
.tile-bad .tile-value { color: var(--danger); }
.status-ok { background: #dcfce7; color: #14532d; }
.status-delayed { background: #fee2e2; color: #7f1d1d; }
.report-row { cursor: pointer; }
.report-row:hover { background: #f8f9ff; }
.report-overdue-row td { border-top: none; padding-top: 0; }
.overdue-pill {
  display: inline-block; background: #fef2f2; color: #991b1b;
  border: 1px solid #fca5a5; border-radius: 99px;
  padding: .12rem .6rem; font-size: .78rem; margin: 0 .3rem .3rem 0;
}
.overdue-pill:hover { background: #fee2e2; }

/* preview gallery */
.pv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.pv-card {
  margin: 0; border: 1px solid var(--border); border-radius: 10px;
  padding: .6rem; background: var(--surface);
}
.pv-card figcaption { text-align: center; font-weight: 600; font-size: .85rem; margin-top: .45rem; }
.pv-sides { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }
.pv-sides a { position: relative; display: block; }
.pv-sides img {
  width: 96px; height: 96px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg);
}
.pv-side-label {
  position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
  background: rgba(29,34,51,.75); color: #fff; font-size: .62rem;
  padding: .05rem .4rem; border-radius: 99px; white-space: nowrap;
}
.ls-previews .pv-sides img { width: 72px; height: 72px; }

/* launch summary modal */
.launch-modal { max-width: 760px; width: 94vw; max-height: 86vh; overflow-y: auto; }
.cal-launch-click { cursor: pointer; }
.cal-launch-click:hover { background: #eef2ff; }
.ls-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; gap: .6rem; flex-wrap: wrap; }
.ls-follow { display: flex; align-items: center; gap: .4rem; }
.ls-follow form { margin: 0; }
.btn-following { background: #fef3c7; border-color: #f59e0b; color: #92400e; }
.ls-title { font-size: 1.15rem; margin-left: .4rem; }
.ls-banner {
  display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
  background: #fef3c7; color: #78350f; border: 1px solid #f59e0b;
  border-radius: 8px; padding: .6rem .9rem; margin-bottom: .9rem; font-weight: 500;
}
.ls-banner form { margin: 0; }
.ls-grid { display: flex; gap: 1.2rem; align-items: flex-start; margin-bottom: .8rem; flex-wrap: wrap; }
.ls-preview {
  max-width: 260px; max-height: 260px; width: auto; border-radius: 10px;
  border: 1px solid var(--border); object-fit: contain;
}
.ls-grid dl.meta { flex: 1; min-width: 240px; }
.ls-tasks { margin-bottom: 1rem; }
.ls-comments { max-height: 260px; overflow-y: auto; }
.ls-attachments { max-height: 220px; overflow-y: auto; margin-bottom: 1rem; }
.ls-attachments li { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.ls-attachments li > a { max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ls-attachments small { margin-left: auto; color: var(--muted); }
.ls-timeline {
  list-style: none; padding: 0; margin: 0 0 1rem;
  max-height: 280px; overflow-y: auto;
  border-left: 2px solid var(--border); margin-left: .4rem;
}
.ls-timeline li { display: flex; gap: .55rem; padding: .3rem 0 .3rem .6rem; }
.tl-icon { flex-shrink: 0; line-height: 1.4; }
.tl-body { display: flex; flex-direction: column; }
.tl-body small { font-size: .72rem; }
.ls-actions { margin-top: 1rem; text-align: right; }
.assign-multi { min-width: 150px; }

/* dialog (modal) */
dialog {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.2rem 1.4rem; max-width: 560px; width: 92vw;
}
dialog::backdrop { background: rgba(29,34,51,.45); }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .6rem; }

/* mini gantt (template preview) */
.mini-gantt { margin-top: 1.2rem; }
.mini-gantt-head {
  display: grid; grid-template-columns: repeat(var(--n), 1fr);
  margin-left: 180px; font-size: .72rem; color: var(--muted); text-align: center;
}
.mini-gantt-row { display: flex; align-items: center; margin-top: 4px; }
.mini-gantt-label {
  width: 180px; flex-shrink: 0; font-size: .8rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: .5rem;
}
.mini-gantt-cells {
  display: grid; grid-template-columns: repeat(var(--n), 1fr);
  flex: 1; background: repeating-linear-gradient(to right, transparent, transparent calc(100% / var(--n) - 1px), var(--border) calc(100% / var(--n) - 1px), var(--border) calc(100% / var(--n)));
  height: 18px; border-radius: 4px;
}
.mini-gantt-bar { background: var(--primary); border-radius: 4px; opacity: .8; }
