/* ============ Right panel ============ */
.rightbar {
  background: var(--bg);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-height: 0; overflow: hidden;
}
.rb-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.rb-head h3 {
  margin: 0;
  font-size: 14px;
  color: var(--fg);
  font-weight: 600;
}
.rb-head .close {
  width: 28px; height: 28px; border-radius: 5px;
  display: grid; place-items: center; color: var(--fg-3);
}
.rb-head .close:hover { background: var(--bg-hover); color: var(--fg); }

/* Tabs in right sidebar */
.rb-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  flex: none;
  padding: 0 4px;
  gap: 0;
  background: var(--bg);
}
.rb-tab {
  flex: 1;
  padding: 10px 8px 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-3);
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  text-align: center;
  cursor: pointer;
  white-space: nowrap;
}
.rb-tab:hover { color: var(--fg-2); }
.rb-tab.active {
  color: var(--accent);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

/* Collapsible sections for sidebar project detail */
.rb-collapse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 8px;
}
.rb-collapse-header:hover { color: var(--accent); }
.rb-collapse-chevron {
  font-size: 12px;
  color: var(--fg-3);
  transition: transform 0.15s;
}
.rb-collapse-chevron.open { transform: rotate(90deg); }
.rb-collapse-body { margin-bottom: 16px; }

/* Sidebar project detail specifics */
.rb-proj-fin-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  padding: 3px 0;
  color: var(--fg-2);
}
.rb-proj-fin-row.bold { font-weight: 600; color: var(--fg); }
.rb-proj-fin-row .mono { font-family: var(--font-mono); font-size: 11.5px; }
.rb-proj-fin-row .accent { color: var(--accent); }
.rb-proj-fin-row .neg { color: var(--danger); }
.rb-proj-fin-sep { border-top: 1px solid var(--line-soft); margin: 4px 0; }
.rb-proj-net {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: var(--radius);
  text-align: center;
  font-size: 13px;
}
.rb-proj-net.profit { background: oklch(0.96 0.04 145); color: oklch(0.40 0.14 145); }
.rb-proj-net.loss { background: oklch(0.96 0.04 25); color: oklch(0.45 0.18 25); }
.rb-proj-net-val { font-family: var(--font-mono); font-size: 16px; font-weight: 700; margin: 2px 0; }
.rb-proj-net-pct { font-size: 13px; opacity: 0.8; }

.rb-dev-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.rb-dev-table th {
  text-align: left;
  font-weight: 600;
  color: var(--fg-3);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 4px 4px 6px;
  border-bottom: 1px solid var(--line);
}
.rb-dev-table th.r, .rb-dev-table td.r { text-align: right; }
.rb-dev-table td {
  padding: 4px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--fg-2);
}
.rb-dev-table .sub td {
  font-weight: 600;
  color: var(--fg);
  border-top: 1px solid var(--line);
  border-bottom: none;
}

.rb-body { padding: 18px; overflow-y: auto; min-height: 0; flex: 1; }
.rb-section { margin-bottom: 22px; }
.rb-label {
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-3);
  margin-bottom: 8px;
  font-weight: 600;
}
/* Project searchable dropdown */
.proj-search-sel { position: relative; }
.proj-search-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--fg);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s;
}
.proj-search-trigger:hover:not(:disabled) { border-color: var(--fg-3); }
.proj-search-trigger:disabled { opacity: 0.5; cursor: not-allowed; }
.proj-search-name {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.proj-search-drop {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  overflow: hidden;
}
.proj-search-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--fg-3);
}
.proj-search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  color: var(--fg);
}
.proj-search-clear {
  background: none;
  border: none;
  color: var(--fg-3);
  cursor: pointer;
  padding: 2px;
}
.proj-search-list {
  max-height: 240px;
  overflow-y: auto;
  padding: 4px 0;
}
.proj-search-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--fg);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
}
.proj-search-item:hover:not(:disabled) { background: var(--bg-hover); }
.proj-search-item.active { background: color-mix(in oklab, var(--accent) 8%, var(--bg)); font-weight: 500; }
.proj-search-item:disabled { opacity: 0.4; cursor: not-allowed; }
.proj-search-item-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.proj-search-empty {
  padding: 12px 10px;
  font-size: 14px;
  color: var(--fg-3);
  text-align: center;
}

.field {
  display: flex; flex-direction: column; gap: 5px;
  margin-bottom: 10px;
}
.field input[type=text],
.field input[type=number],
.field textarea,
.field select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 11px;
  color: var(--fg);
  font-size: 13px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 14%, transparent);
}

.seg {
  display: flex; background: var(--bg-soft); border-radius: var(--radius); padding: 2px;
}
.seg button {
  flex: 1; padding: 6px 8px; font-size: 14px;
  border-radius: 4px;
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-weight: 500;
}
.seg button.on {
  background: #fff;
  color: var(--fg);
  box-shadow: var(--shadow-1);
}

.kv {
  display: grid; grid-template-columns: 92px 1fr; gap: 8px 10px;
  font-size: 14px;
}
.kv dt { color: var(--fg-3); font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; align-self: center; }
.kv dd { margin: 0; color: var(--fg); }

.log-entry {
  display: flex; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
}
.log-entry:last-child { border-bottom: 0; }
.log-entry .bullet { width: 20px; flex: none; display: grid; place-items: start center; padding-top: 5px; }
.log-entry .bullet .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
}
.log-entry.remove .bullet .dot { background: var(--danger); }
.log-entry.warn .bullet .dot { background: var(--warn); }
.log-entry .body { flex: 1; min-width: 0; }
.log-entry .when { font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-3); margin-top: 3px; }
.log-entry .body b { color: var(--fg); font-weight: 600; }

/* ============ Slot Detail (redesigned, slot-only) ============ */
/* Lives inside .rightbar, so it inherits the desktop column + mobile sheet. */
.rightbar.sd { background: var(--bg); }

.sd-head {
  display: flex; align-items: center; gap: 8px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.sd-head-title {
  font-size: 13px; font-weight: 600; color: var(--fg);
  letter-spacing: -0.01em; margin-right: 2px;
}
.sd-close {
  margin-left: auto; width: 28px; height: 28px; border-radius: 6px;
  display: grid; place-items: center; color: var(--fg-3);
  transition: background .12s, color .12s;
}
.sd-close:hover { background: var(--bg-hover); color: var(--fg); }

.sd-status {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; line-height: 1;
  padding: 4px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--fg-2); background: var(--bg-soft);
  white-space: nowrap;
}
.sd-status .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.sd-status.draft {
  color: oklch(0.47 0.13 58); /* darkened amber → AA on the tint */
  background: color-mix(in oklab, var(--warn) 10%, var(--bg));
  border-color: color-mix(in oklab, var(--warn) 30%, transparent);
}
.sd-status.rej {
  color: oklch(0.47 0.16 27); /* darkened red → AA on the tint */
  background: color-mix(in oklab, var(--danger) 9%, var(--bg));
  border-color: color-mix(in oklab, var(--danger) 30%, transparent);
}
.sd-status.ot {
  color: oklch(0.47 0.15 55); /* darkened orange → AA on the tint */
  background: color-mix(in oklab, oklch(0.62 0.20 55) 11%, var(--bg));
  border-color: color-mix(in oklab, oklch(0.62 0.20 55) 30%, transparent);
}

.sd-body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 20px;
}

/* ── Identity hero ── */
.sd-hero { display: flex; flex-direction: column; gap: 13px; }
.sd-eng { display: flex; align-items: center; gap: 11px; }
.sd-eng .avatar { flex: none; }
.sd-eng-name {
  font-size: 15px; font-weight: 600; color: var(--fg);
  letter-spacing: -0.01em; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sd-eng-role { font-size: 12px; color: var(--fg-3); margin-top: 2px; }
.sd-you { color: var(--accent); font-weight: 600; }

.sd-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sd-fact {
  background: var(--bg-soft); border: 1px solid var(--line-soft);
  border-radius: 8px; padding: 9px 11px;
}
/* zinc-600: muted but AA-compliant (~5.9:1) on the tinted fact tile */
.sd-fact-k { display: flex; align-items: center; gap: 5px; font-size: 11px; color: #52525b; font-weight: 500; }
.sd-fact-k svg { color: var(--fg-3); }
.sd-fact-v { font-size: 14px; color: var(--fg); font-weight: 600; margin-top: 4px; }
.sd-fact-v.mono { font-family: var(--font-mono); }
.sd-fact-v .unit { font-size: 11px; color: var(--fg-3); font-weight: 500; margin-left: 1px; }

/* ── Sections ── */
.sd-sec { display: flex; flex-direction: column; gap: 9px; }
.sd-sec-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--fg-3);
}

/* ── Banners ── */
.sd-banner {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 9px 11px; border-radius: 8px;
  font-size: 12.5px; line-height: 1.45;
}
.sd-banner svg { flex: none; margin-top: 1px; }
.sd-banner b { font-weight: 600; }
.sd-banner.lock { background: var(--bg-soft); border: 1px solid var(--line); color: var(--fg-2); }
.sd-banner.lock svg { color: var(--fg-3); }
.sd-banner.rej {
  background: color-mix(in oklab, var(--danger) 7%, var(--bg));
  border: 1px solid color-mix(in oklab, var(--danger) 25%, transparent);
  color: var(--danger);
}

/* ── Open full project plan ── */
.sd-proj-open {
  display: flex; align-items: center; gap: 7px;
  width: 100%; padding: 9px 12px; border-radius: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--fg);
  background: var(--bg-soft); border: 1px solid var(--line);
  transition: background .12s, border-color .12s;
}
.sd-proj-open:hover { background: var(--bg-hover); border-color: var(--line-strong); }
.sd-proj-open svg { color: var(--fg-3); }

/* ── Duration segmented control ── */
.sd-md {
  display: flex; gap: 4px;
  background: var(--bg-soft); border: 1px solid var(--line-soft);
  border-radius: 9px; padding: 4px;
}
.sd-md button {
  flex: 1; padding: 8px 4px; border-radius: 6px;
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  color: var(--fg-3); transition: background .12s, color .12s;
}
.sd-md button:hover:not(:disabled):not(.on) { color: var(--fg); background: var(--bg-hover); }
.sd-md button.on { background: var(--fg); color: var(--bg); }
.sd-md button:disabled { opacity: .5; cursor: not-allowed; }
.sd-note-hint { font-size: 11.5px; color: var(--fg-3); line-height: 1.5; }

/* ── OT callout ── */
.sd-ot {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px; border-radius: 8px;
  background: color-mix(in oklab, oklch(0.62 0.20 55) 8%, var(--bg));
  border: 1px solid color-mix(in oklab, oklch(0.62 0.20 55) 22%, transparent);
}
.sd-ot .lbl { font-size: 12.5px; color: oklch(0.45 0.15 55); font-weight: 500; line-height: 1.4; }

/* ── Note input ── */
.sd-input {
  width: 100%; background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; color: var(--fg); font-size: 13px;
  font-family: inherit; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.sd-input::placeholder { color: var(--fg-3); }
.sd-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 14%, transparent); }
.sd-input:disabled { background: var(--bg-soft); color: var(--fg-2); cursor: not-allowed; }

/* ── Metadata ── */
.sd-meta { display: flex; flex-direction: column; gap: 8px; }
.sd-meta-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--fg-2); }
.sd-meta-row .k { color: var(--fg-3); width: 74px; flex: none; }
.sd-meta-row .mono { font-family: var(--font-mono); font-size: 11.5px; word-break: break-all; }
.sd-meta-row .avatar { flex: none; }

/* ── Footer actions ── */
.sd-foot {
  flex: none; border-top: 1px solid var(--line);
  padding: 11px 12px; background: var(--bg);
  display: flex; flex-direction: column; gap: 8px;
}
.sd-foot-tools { display: flex; gap: 6px; }
.sd-tool {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 8px 6px; border-radius: 7px;
  font-size: 12px; font-weight: 500; color: var(--fg-2);
  background: var(--bg-soft); border: 1px solid var(--line-soft);
  transition: background .12s, color .12s;
}
.sd-tool:hover { background: var(--bg-hover); color: var(--fg); }
.sd-tool.ot { color: oklch(0.48 0.16 55); }
.sd-tool.ot:hover { color: oklch(0.43 0.16 55); }
.sd-del {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px; border-radius: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--danger);
  background: transparent;
  border: 1px solid color-mix(in oklab, var(--danger) 22%, var(--line));
  transition: background .12s;
}
.sd-del:hover { background: color-mix(in oklab, var(--danger) 7%, var(--bg)); }

/* ── Keyboard focus — matches the app convention (2px accent ring) ── */
.sd-close:focus-visible,
.sd-proj-open:focus-visible,
.sd-md button:focus-visible,
.sd-tool:focus-visible,
.sd-del:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}
.sd-input:focus-visible { outline: none; } /* keeps its border + ring treatment */

/* ── "Saved" flash on slot edits ── */
.sd-saved {
  margin-left: auto; /* push to the right, next to the close button */
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; color: oklch(0.50 0.13 150);
  white-space: nowrap;
  animation: sdSavedIn .14s ease-out;
}
.sd-saved + .sd-close { margin-left: 0; }
.sd-saved svg { color: currentColor; }
@keyframes sdSavedIn { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .sd-close, .sd-proj-open, .sd-md button, .sd-input, .sd-tool, .sd-del { transition: none; }
  .sd-saved { animation: none; }
}

