/* Donna — dark surface, rounded cards, coloured blocks on a time grid. */

:root {
  --bg: #0e1016;
  --surface: #161a23;
  --surface-2: #1d2230;
  --surface-3: #242a3a;
  --line: #262c3b;
  --text: #e9ecf5;
  --muted: #8b93a7;
  --faint: #5d6479;
  --accent: #4f7dfb;
  --danger: #f2565a;

  --deep: #6e7bff;
  --physical: #2fbf71;
  --admin: #f2a93b;
  --rest: #f2589b;

  --ppm: 0.95;          /* pixels per minute of the day */
  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

/* The views are grids and flex boxes; without this their display rule wins
   over the hidden attribute and a hidden view still renders. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }

.app { display: flex; flex-direction: column; min-height: 100%; }

/* --- top bar ---------------------------------------------------------- */

.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 14px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -0.01em; }
.mark {
  width: 28px; height: 28px; border-radius: 9px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700;
}
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 999px; }
.tab {
  border: 0; background: transparent; color: var(--muted);
  padding: 7px 18px; border-radius: 999px; font-weight: 550;
}
.tab.is-active { background: var(--accent); color: #fff; }
.topbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.ghost {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
  padding: 7px 14px; border-radius: 999px; font-weight: 550;
}
.ghost:hover { color: var(--text); border-color: var(--surface-3); }
.ghost.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.lock::before { content: "🔒 "; }
.lock.is-open::before { content: "🔓 "; }

/* --- layout ----------------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr) 320px;
  gap: 18px; padding: 18px; align-items: start;
}
.rail { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 76px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card.wide { width: 100%; }

.eyebrow {
  font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--faint); font-weight: 650; margin-bottom: 10px;
}
.sub { color: var(--muted); margin: 0 0 12px; font-size: 13px; }

.dayline { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 620; }
.dot { width: 4px; height: 4px; border-radius: 50%; background: var(--faint); }

/* --- segmented profile control (ref: Tickets / Holidays / Planner) ----- */

.segmented { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.seg {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); background: var(--surface-2);
  border-radius: var(--radius-sm); padding: 10px 12px; text-align: left;
}
.seg .seg-name { font-weight: 600; text-transform: capitalize; }
.seg .seg-score { margin-left: auto; color: var(--faint); font-variant-numeric: tabular-nums; font-size: 12px; }
.seg .swatch { width: 8px; height: 26px; border-radius: 4px; background: var(--accent); }
.seg.is-active { border-color: var(--accent); background: #1a2136; }
.seg.is-edited .seg-name::after { content: " ·edited"; color: var(--admin); font-weight: 500; font-size: 11px; }

/* --- breakdown bars (ref: Calmendar time breakdown) -------------------- */

.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 64px 1fr 44px; align-items: center; gap: 8px; font-size: 12px; }
.bar-track { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; }
.bar-val { color: var(--faint); text-align: right; font-variant-numeric: tabular-nums; }

/* --- chips ------------------------------------------------------------ */

.legend { display: flex; flex-wrap: wrap; gap: 6px; }
.legend-buffers { margin-top: 8px; }
.chip {
  font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  border: 1px solid transparent;
}
.energy-deep { background: color-mix(in srgb, var(--deep) 20%, transparent); color: var(--deep); }
.energy-physical { background: color-mix(in srgb, var(--physical) 20%, transparent); color: var(--physical); }
.energy-admin { background: color-mix(in srgb, var(--admin) 20%, transparent); color: var(--admin); }
.energy-rest { background: color-mix(in srgb, var(--rest) 20%, transparent); color: var(--rest); }
.chip.buffer { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--line); }

/* --- board ------------------------------------------------------------ */

.board-head h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -0.02em; }
.board-head { margin-bottom: 14px; }

.gridwrap {
  display: grid; grid-template-columns: 52px minmax(0, 1fr);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 14px 14px 0;
}
.gutter { position: relative; }
.gutter .hour {
  position: absolute; right: 10px; font-size: 11px; color: var(--faint);
  transform: translateY(-6px); font-variant-numeric: tabular-nums;
}
.lanes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }

.lane { display: flex; flex-direction: column; min-width: 0; }
.lane-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; padding: 0 2px; }
.lane-name { font-weight: 620; text-transform: capitalize; font-size: 13px; }
.lane-score { color: var(--faint); font-size: 11px; margin-left: auto; font-variant-numeric: tabular-nums; }
.lane-why { color: var(--muted); font-size: 11px; line-height: 1.4; margin: 0 2px 8px; min-height: 30px; }

.track {
  position: relative; border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.track .rule { position: absolute; left: 0; right: 0; height: 1px; background: var(--line); opacity: 0.55; }

/* --- blocks ----------------------------------------------------------- */

.block {
  position: absolute; left: 5px; right: 5px;
  border-radius: 9px; padding: 6px 9px;
  overflow: hidden; touch-action: none; user-select: none;
  border-left: 3px solid var(--accent);
  background: var(--surface-3);
  transition: box-shadow .12s ease, transform .12s ease;
}
.block.is-short { padding: 1px 8px; display: flex; align-items: center; }
.block.is-short .b-title { font-size: 10.5px; line-height: 1.1; }
.block .b-title { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.block .b-meta { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.block.is-demand { cursor: grab; }
.block.is-demand:hover { box-shadow: 0 0 0 1px var(--surface-3), 0 6px 18px rgba(0,0,0,.35); }
.block.is-selected { box-shadow: 0 0 0 2px var(--accent); }
.block.is-dragging { cursor: grabbing; z-index: 20; box-shadow: 0 12px 30px rgba(0,0,0,.5); }
.block.is-fixed { cursor: not-allowed; }
.block.is-fixed .b-title::after { content: " 📌"; }

.block.k-deep { background: color-mix(in srgb, var(--deep) 22%, var(--surface-2)); border-left-color: var(--deep); }
.block.k-physical { background: color-mix(in srgb, var(--physical) 22%, var(--surface-2)); border-left-color: var(--physical); }
.block.k-admin { background: color-mix(in srgb, var(--admin) 22%, var(--surface-2)); border-left-color: var(--admin); }
.block.k-rest { background: color-mix(in srgb, var(--rest) 22%, var(--surface-2)); border-left-color: var(--rest); }

/* buffers read as present but not yours */
.block.is-buffer { background: transparent; border: 1px dashed var(--line); border-left: 1px dashed var(--line); opacity: .82; }
.block.is-buffer .b-title { font-weight: 500; color: var(--muted); font-size: 11px; }
.block.k-travel { background: repeating-linear-gradient(135deg, transparent, transparent 6px, rgba(255,255,255,.025) 6px, rgba(255,255,255,.025) 12px); }
.block.k-slack { border-style: dotted; }

.handle {
  position: absolute; left: 0; right: 0; bottom: 0; height: 10px;
  cursor: ns-resize;
}
.handle::after {
  content: ""; position: absolute; left: 50%; bottom: 3px; width: 22px; height: 2px;
  transform: translateX(-50%); border-radius: 2px; background: rgba(255,255,255,.25);
}
.block.is-bounced { animation: bounce .34s ease; }
@keyframes bounce {
  0% { transform: translateX(0); } 20% { transform: translateX(-6px); }
  45% { transform: translateX(5px); } 70% { transform: translateX(-3px); } 100% { transform: translateX(0); }
}

/* --- right rail ------------------------------------------------------- */

.detail-head { display: flex; align-items: center; }
.detail-head .eyebrow { margin: 0; }
.x { margin-left: auto; background: transparent; border: 0; color: var(--faint); font-size: 18px; line-height: 1; }
.empty { color: var(--faint); font-size: 13px; }

.field {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text); border-radius: var(--radius-sm); padding: 11px 12px; margin-bottom: 10px;
}
.field:focus { outline: none; border-color: var(--accent); }
select.field { appearance: none; }

.kv { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12.5px; margin: 6px 0; }
.kv b { color: var(--text); font-weight: 600; }

.notice { display: flex; gap: 9px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.notice:first-child { border-top: 0; }
.notice .badge {
  flex: none; width: 20px; height: 20px; border-radius: 7px; display: grid; place-items: center;
  font-size: 11px; background: var(--surface-3);
}
.notice.warn .badge { background: color-mix(in srgb, var(--admin) 30%, transparent); color: var(--admin); }
.notice.drop .badge { background: color-mix(in srgb, var(--danger) 26%, transparent); color: var(--danger); }
.notice.assume .badge { background: var(--surface-3); color: var(--faint); }

.cta {
  width: 100%; border: 0; border-radius: 13px; padding: 14px;
  background: var(--accent); color: #fff; font-weight: 650;
}
.cta:hover { filter: brightness(1.08); }
.cta:disabled { background: var(--surface-3); color: var(--faint); cursor: not-allowed; }
.cta.small { width: auto; padding: 10px 18px; border-radius: 10px; }
.ratify-note { color: var(--faint); font-size: 11.5px; text-align: center; }

/* --- places view ------------------------------------------------------ */

.places-view { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th { text-align: left; color: var(--faint); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .07em; padding: 6px 8px; }
table.grid td { padding: 4px 8px; border-top: 1px solid var(--line); }
table.grid input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text); border-radius: 8px; padding: 7px 9px; font: inherit;
}
table.grid input:focus { outline: none; border-color: var(--accent); }
.row-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; }


/* --- people view ------------------------------------------------------ */

.people-view { grid-template-columns: 248px minmax(0, 1fr) 340px; }

.capacity { display: flex; align-items: center; gap: 5px; margin: 10px 0 12px; }
.pip { width: 18px; height: 6px; border-radius: 999px; background: var(--surface-3); }
.pip.is-on { background: var(--accent); }
.cap-text { margin-left: 6px; color: var(--muted); font-size: 12px; }

.agenda-list { display: flex; flex-direction: column; gap: 6px; }
.agenda-row {
  text-align: left; border: 1px solid var(--line); background: var(--surface-2);
  border-radius: var(--radius-sm); padding: 9px 10px;
}
.agenda-row:hover { border-color: var(--surface-3); }
.agenda-row.is-selected { border-color: var(--accent); background: #1a2136; }
.agenda-top { display: flex; align-items: center; gap: 7px; }
.agenda-top b { font-weight: 600; font-size: 13px; }
.agenda-top .tag { margin-left: auto; }
.agenda-why { color: var(--muted); font-size: 12px; margin-top: 3px; line-height: 1.35; }

.load { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 4px; margin-top: 10px; }
.load-day { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.load-bar { display: flex; flex-direction: column-reverse; gap: 2px; width: 100%; }
.load-cell { height: 7px; border-radius: 2px; background: var(--surface-3); }
.load-cell.is-on { background: color-mix(in srgb, var(--accent) 75%, transparent); }
.load-label { color: var(--faint); font-size: 10px; }
.load-day.is-today .load-label { color: var(--text); font-weight: 650; }
.overflow { margin-top: 10px; font-size: 12px; color: var(--admin); line-height: 1.4; }

.prio { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--faint); }
.prio-high { background: var(--rest); }
.prio-normal { background: var(--accent); }
.prio-low { background: var(--surface-3); }

.tag {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; background: var(--surface-3); color: var(--muted); white-space: nowrap;
}
.tag.late { background: color-mix(in srgb, var(--danger) 22%, transparent); color: var(--danger); }
.tag.today { background: color-mix(in srgb, var(--accent) 26%, transparent); color: #9db6ff; }
.tag.soon { background: color-mix(in srgb, var(--admin) 20%, transparent); color: var(--admin); }
.tag.quiet { background: transparent; color: var(--faint); padding-left: 0; font-weight: 500; }
.tag.opp { background: color-mix(in srgb, var(--physical) 18%, transparent); color: var(--physical); }
.tag.cold { background: color-mix(in srgb, var(--deep) 18%, transparent); color: var(--deep); }

.kanban { display: grid; grid-template-columns: repeat(5, minmax(128px, 1fr)); gap: 10px; align-items: start; overflow-x: auto; padding-bottom: 6px; }
.kcol { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-width: 0; }
.kcol-head { display: flex; align-items: baseline; gap: 8px; padding: 12px 12px 8px; }
.kcol-name { font-weight: 620; font-size: 13px; }
.kcol-count { margin-left: auto; color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.kcol-body { display: flex; flex-direction: column; gap: 8px; padding: 0 8px 10px; min-height: 120px; border-radius: 0 0 var(--radius) var(--radius); transition: background .12s ease; }
.kcol-body.is-over { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.kcol-empty { color: var(--faint); font-size: 11.5px; padding: 10px 6px; line-height: 1.4; border: 1px dashed var(--line); border-radius: var(--radius-sm); }
.stage-idea .kcol-head { box-shadow: inset 0 2px 0 var(--faint); border-radius: var(--radius) var(--radius) 0 0; }
.stage-follow_up .kcol-head { box-shadow: inset 0 2px 0 var(--accent); border-radius: var(--radius) var(--radius) 0 0; }
.stage-discussion .kcol-head { box-shadow: inset 0 2px 0 var(--admin); border-radius: var(--radius) var(--radius) 0 0; }
.stage-collaborate .kcol-head { box-shadow: inset 0 2px 0 var(--physical); border-radius: var(--radius) var(--radius) 0 0; }
.stage-parked .kcol-head { box-shadow: inset 0 2px 0 var(--surface-3); border-radius: var(--radius) var(--radius) 0 0; }

.pcard {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 10px; cursor: grab; outline: none;
}
.pcard:hover, .pcard:focus-visible { border-color: var(--surface-3); box-shadow: 0 6px 18px rgba(0,0,0,.3); }
.pcard.is-selected { border-color: var(--accent); }
.pcard.is-dragging { opacity: .45; cursor: grabbing; }
.pcard.is-cold { opacity: .8; }
.pcard-top { display: flex; align-items: baseline; gap: 7px; }
.pcard-top .prio { transform: translateY(-1px); }
.pcard-name { font-size: 13px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.pcard-sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard-meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }

.person .phead h2 { margin: 8px 0 2px; font-size: 19px; letter-spacing: -0.01em; }
.person .phead .sub { margin: 0; }
.pmet { color: var(--faint); font-size: 12px; margin-top: 4px; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 14px 0 6px; }
.fact { background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 9px; display: flex; flex-direction: column; gap: 2px; }
.fact span { color: var(--faint); font-size: 10.5px; }
.fact b { font-size: 13px; font-weight: 620; }
.person .kv .field { margin: 0; }

.psec { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; }
.fu-line { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.fu-reason { font-size: 13px; }
.hint { color: var(--faint); font-size: 11.5px; margin-bottom: 8px; }
.field.compact { padding: 8px 10px; margin-bottom: 8px; font-size: 13px; }
.field.draft { font: 13px/1.5 inherit; resize: vertical; min-height: 96px; }
textarea.field { font: inherit; resize: vertical; }
.row-actions.tight { margin-top: 2px; gap: 8px; flex-wrap: wrap; }
.ghost.ok:hover { color: var(--physical); border-color: color-mix(in srgb, var(--physical) 45%, var(--line)); }
.ghost.danger:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.snooze { display: flex; align-items: center; gap: 5px; margin-top: 10px; }
.snooze .hint { margin: 0 4px 0 0; }
.chipbtn { border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); padding: 3px 10px; border-radius: 999px; font-size: 12px; }
.chipbtn:hover { color: var(--text); }

.timeline { display: flex; flex-direction: column; gap: 7px; margin: 6px 0 10px; max-height: 240px; overflow-y: auto; }
.tl-row { display: grid; grid-template-columns: 52px 62px minmax(0, 1fr); gap: 6px; font-size: 12.5px; align-items: baseline; }
.tl-date { color: var(--faint); font-variant-numeric: tabular-nums; }
.tl-kind { color: var(--muted); font-size: 11px; text-transform: capitalize; }
.tl-kind.k-met { color: var(--accent); }
.tl-text { line-height: 1.4; overflow-wrap: anywhere; }

.inline-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: flex-start; }
.inline-form .field { width: auto; }
.inline-form .grow { flex: 1 1 140px; }
.inline-form .ghost { padding: 7px 12px; }

.opp-row { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; padding: 6px 0; font-size: 13px; }
.opp-title { flex: 1 1 auto; min-width: 0; }
.opp-note { flex: 1 1 100%; color: var(--muted); font-size: 12px; }
.x.small { font-size: 15px; margin-left: 0; }

.tg-code {
  font: 600 26px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .22em; text-align: center; padding: 14px 0 16px; color: var(--text);
}
.wide-modal { width: min(560px, 100%); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 10px; margin-top: 10px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 11.5px; }
.form-grid label.span { grid-column: 1 / -1; }
.form-grid label.check { flex-direction: row; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text); padding-top: 18px; }
.compact-grid { gap: 0 8px; }

/* --- modal, toast ----------------------------------------------------- */

.scrim {
  position: fixed; inset: 0; background: rgba(6,8,12,.78); backdrop-filter: blur(6px);
  display: grid; place-items: center; z-index: 60; padding: 20px;
}
.scrim[hidden] { display: none; }
.modal { width: min(380px, 100%); }
.modal h2 { margin: 4px 0 6px; font-size: 19px; letter-spacing: -0.01em; }
.wide-btn { width: 100%; margin-top: 8px; }
.err { color: var(--danger); font-size: 12.5px; min-height: 18px; margin-bottom: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--surface-3); border: 1px solid var(--line);
  padding: 12px 18px; border-radius: 12px; max-width: min(520px, 90vw);
  opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; z-index: 70;
  font-size: 13px; box-shadow: 0 18px 40px rgba(0,0,0,.5);
}
.toast.is-up { opacity: 1; transform: translate(-50%, 0); }
.toast.is-bad { border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }
.toast.is-warn { border-color: color-mix(in srgb, var(--admin) 55%, var(--line)); }

/* --- narrow ----------------------------------------------------------- */

@media (max-width: 1180px) {
  .shell, .people-view { grid-template-columns: 232px minmax(0, 1fr); }
  .rail-right { grid-column: 1 / -1; position: static; flex-direction: row; flex-wrap: wrap; }
  .rail-right .card { flex: 1 1 260px; }
  .rail-right .cta { flex: 1 1 100%; }
}
@media (max-width: 860px) {
  .shell, .places-view, .people-view { grid-template-columns: minmax(0, 1fr); }
  .kanban { display: flex; scroll-snap-type: x mandatory; }
  .kcol { flex: 0 0 78vw; scroll-snap-align: start; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; }
  .lanes { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 12px; }
  .lane { flex: 0 0 78vw; scroll-snap-align: start; }
  .topbar { padding: 10px 12px; gap: 8px; }
  .brand > span:last-child { display: none; }
  .tab { padding: 7px 12px; }
  .ghost { padding: 6px 10px; }
  #redactBtn { display: none; }
}
