:root {
  --paper: #f1ede5;
  --surface: #fffdf9;
  --surface-2: #f8f3eb;
  --ink: #28231f;
  --muted: #766d62;
  --line: #dfd3c3;
  --accent: #be6842;
  --accent-deep: #914428;
  --accent-soft: #f2dfd3;
  --olive: #7d8061;
  --olive-soft: #e7e7d8;
  --over-budget: #a9412d;
  --over-budget-deep: #8f3628;
  --over-budget-soft: #f7e2da;
  --shadow: 0 18px 44px rgba(70, 48, 30, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
[data-app-view][hidden] { display: none !important; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 78% -12%, rgba(190, 104, 66, .18), transparent 34rem),
    linear-gradient(90deg, rgba(100, 84, 66, .035) 1px, transparent 1px),
    var(--paper);
  background-size: auto, 32px 100%, auto;
  font-family: "Zen Kaku Gothic New", sans-serif;
}
button, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 226px minmax(0, 1fr); }
.app-shell.has-collapsible-sidebar { grid-template-columns: 30px minmax(0, 1fr); }
.app-shell.has-collapsible-sidebar .sidebar {
  width: 226px;
  padding: 22px 16px;
  overflow: hidden;
  z-index: 20;
  transform: translateX(-196px);
  box-shadow: 5px 0 16px rgba(70,48,30,.05);
  transition: transform .18s ease, box-shadow .18s ease;
  will-change: transform;
}
.app-shell.has-collapsible-sidebar .sidebar::after {
  position: absolute;
  z-index: 2;
  top: 0;
  right: 0;
  bottom: 0;
  display: grid;
  width: 30px;
  padding-top: 24px;
  place-items: start center;
  color: var(--accent-deep);
  background: rgba(255,253,249,.94);
  content: "メニュー";
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  transition: opacity .1s ease;
  writing-mode: vertical-rl;
}
.app-shell.has-collapsible-sidebar .sidebar > * {
  width: auto;
}
.app-shell.has-collapsible-sidebar .sidebar:hover,
.app-shell.has-collapsible-sidebar .sidebar:focus-within {
  transform: translateX(0);
  box-shadow: 12px 0 32px rgba(70,48,30,.16);
}
.app-shell.has-collapsible-sidebar .sidebar:hover::after,
.app-shell.has-collapsible-sidebar .sidebar:focus-within::after { opacity: 0; pointer-events: none; }
.app-shell.has-collapsible-sidebar main { padding-inline: clamp(16px, 2.5vw, 38px); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 16px; border-right: 1px solid var(--line); background: rgba(255,253,249,.7); backdrop-filter: blur(14px); display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 10px 8px 28px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; color: #fff; background: var(--accent); border-radius: 11px 11px 2px 11px; font-family: "DM Mono", monospace; font-weight: 500; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; line-height: 1.2; letter-spacing: -.02em; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 11px; }
nav { display: grid; gap: 4px; }
.nav-group { display: grid; gap: 2px; }
.nav-children { position: relative; display: grid; gap: 2px; margin: 0 0 3px 15px; padding-left: 12px; }
.nav-children::before { position: absolute; top: 3px; bottom: 3px; left: 0; width: 1px; background: var(--line); content: ""; }
.nav-link { padding: 11px 12px; color: var(--muted); border-radius: 9px; font-size: 13px; font-weight: 700; text-decoration: none; transition: background .15s, color .15s; }
.nav-link:hover, .nav-link.active { color: var(--accent-deep); background: var(--accent-soft); }
.nav-child { position: relative; padding: 8px 10px; font-size: 12px; font-weight: 500; }
.nav-child::before { position: absolute; top: 50%; left: -12px; width: 8px; height: 1px; background: var(--line); content: ""; }
.nav-group.has-active-child > .nav-parent { color: var(--accent-deep); }
.sidebar-source-mode { display: grid; gap: 7px; margin-top: 18px; padding: 14px 8px 0; border-top: 1px solid var(--line); }
.sidebar-source-label { color: var(--muted); font-size: 11px; font-weight: 700; }
.sidebar-source-options { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); }
.sidebar-source-options button { min-width: 0; min-height: 32px; padding: 5px 4px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: 10px; font-weight: 700; line-height: 1.25; }
.sidebar-source-options button:hover { color: var(--accent-deep); background: rgba(190, 104, 66, .1); }
.sidebar-source-options button.is-active { color: var(--accent-deep); background: var(--surface); box-shadow: 0 2px 7px rgba(70,48,30,.09); }
.sidebar-note { margin-top: auto; padding: 14px 12px; color: var(--muted); border-top: 1px solid var(--line); font-size: 12px; }
.live-dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--olive); }
main { min-width: 0; padding: 34px clamp(20px, 4vw, 62px) 72px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding-bottom: 30px; }
.eyebrow { margin: 0 0 7px; color: var(--accent-deep); font-family: "DM Mono", monospace; font-size: 10px; letter-spacing: .12em; }
h1, h2 { margin: 0; font-family: "Zen Kaku Gothic New", sans-serif; letter-spacing: -.04em; }
h1 { font-size: clamp(29px, 3.2vw, 47px); line-height: 1.12; }
h2 { font-size: 24px; line-height: 1.25; }
.topbar-actions { display: flex; align-items: end; gap: 10px; }
.period-field { display: grid; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 700; }
select, .outline-btn, .solid-btn { min-height: 40px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }
select { min-width: 124px; }
.outline-btn { color: var(--accent-deep); font-weight: 700; }
.outline-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.solid-btn { border-color: var(--accent); background: var(--accent); color: #fffaf7; font-weight: 700; }
.solid-btn:hover { background: var(--accent-deep); }
.method-card { display: flex; align-items: center; gap: 18px; padding: 14px 18px; border: 1px solid var(--line); background: rgba(255,253,249,.72); box-shadow: 0 7px 24px rgba(70,48,30,.04); }
.method-card p { margin: 0; flex: 1; color: var(--muted); font-size: 13px; line-height: 1.65; }
.method-card strong { color: var(--ink); }
.method-index { color: var(--accent); font-family: "Zen Kaku Gothic New", sans-serif; font-size: 30px; font-weight: 700; }
.source-badge { padding: 5px 9px; color: var(--olive); background: var(--olive-soft); border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
.metric-card { min-height: 138px; padding: 20px; border: 1px solid var(--line); background: var(--surface); box-shadow: 0 7px 24px rgba(70,48,30,.04); }
.metric-card p, .metric-card small { margin: 0; color: var(--muted); font-size: 12px; }
.metric-card strong { display: block; margin: 8px 0 11px; font-family: "Zen Kaku Gothic New", sans-serif; font-size: clamp(24px, 2.4vw, 36px); letter-spacing: -.05em; }
.accent-card { color: #fffaf5; border-color: var(--accent-deep); background: linear-gradient(135deg, var(--accent-deep), var(--accent)); }
.accent-card p, .accent-card small { color: rgba(255,250,245,.78); }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, .9fr); gap: 18px; }
.panel { padding: clamp(20px, 3vw, 30px); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.panel-hint { padding-top: 4px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.title-budget-list { display: grid; gap: 10px; }
.title-row { padding: 17px; border: 1px solid var(--line); background: var(--surface-2); transition: border-color .15s, transform .15s; }
.title-row:hover { border-color: var(--accent); transform: translateY(-1px); }
.title-row summary { display: grid; grid-template-columns: minmax(170px, 1fr) auto; gap: 8px 18px; cursor: pointer; list-style: none; }
.title-row summary::-webkit-details-marker { display: none; }
.title-name { font-size: 15px; font-weight: 700; }
.title-formal { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.title-percent { color: var(--accent-deep); font-family: "DM Mono", monospace; font-size: 15px; font-weight: 700; text-align: right; }
.bar { grid-column: 1 / -1; height: 9px; overflow: hidden; background: #e8e0d4; border-radius: 99px; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #dfaa8d); border-radius: inherit; }
.title-meta { display: flex; justify-content: space-between; gap: 10px; grid-column: 1 / -1; color: var(--muted); font-size: 11px; }
.allocation-detail { display: grid; gap: 8px; margin-top: 15px; padding-top: 14px; border-top: 1px dashed var(--line); }
.allocation-detail div { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; color: var(--muted); font-size: 12px; }
.allocation-detail strong { color: var(--ink); }
.formula { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: center; gap: 8px; padding: 22px 14px; background: var(--surface-2); color: var(--muted); font-size: 12px; text-align: center; }
.formula b { color: var(--accent); font-family: "Zen Kaku Gothic New", sans-serif; font-size: 25px; }
.formula strong { color: var(--accent-deep); }
.assumption-list { margin: 22px 0 0; }
.assumption-list div { display: flex; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.assumption-list dt { color: var(--muted); }
.assumption-list dd { margin: 0; font-weight: 700; text-align: right; }
.member-panel { margin-top: 18px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; }
th { color: var(--muted); background: var(--surface-2); font-size: 11px; letter-spacing: .04em; white-space: nowrap; }
td.num { font-family: "DM Mono", monospace; text-align: right; white-space: nowrap; }
.share-cell { min-width: 150px; }
.share-track { display: inline-block; width: 72px; height: 6px; margin-right: 7px; overflow: hidden; background: #e8e0d4; border-radius: 99px; vertical-align: middle; }
.share-track span { display: block; height: 100%; background: var(--olive); border-radius: inherit; }
dialog { width: min(940px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); background: var(--surface); box-shadow: 0 28px 90px rgba(42,35,31,.25); }
dialog::backdrop { background: rgba(42,35,31,.36); backdrop-filter: blur(3px); }
.dialog-card { padding: 24px; }
.dialog-head, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.dialog-note { color: var(--muted); font-size: 13px; }
.icon-btn, .text-btn { padding: 8px; border: 0; color: var(--muted); background: transparent; font-size: 19px; }
.text-btn { color: var(--accent-deep); font-size: 13px; font-weight: 700; }
textarea { width: 100%; min-height: min(52vh, 560px); padding: 14px; resize: vertical; border: 1px solid var(--line); background: #28231f; color: #f8eee6; font: 12px/1.6 "DM Mono", monospace; }
.dialog-actions { margin-top: 14px; }
#editor-error { margin-left: auto; color: #a9412d; font-size: 12px; }
@media (max-width: 1040px) { .summary-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } .content-grid { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .app-shell { display: block; } .sidebar { position: static; width: 100%; height: auto; padding: 12px; flex-direction: row; align-items: center; gap: 10px; } .brand { padding: 5px; flex: 1; } .sidebar nav, .sidebar-note { display: none; } .sidebar-source-mode { width: min(250px, 48vw); margin: 0; padding: 0; border: 0; } .sidebar-source-label { display: none; } main { padding: 24px 14px 48px; } .topbar, .topbar-actions, .method-card { align-items: stretch; flex-direction: column; } .topbar-actions { gap: 8px; } .outline-btn, select { width: 100%; } .summary-grid { grid-template-columns: 1fr 1fr; gap: 8px; } .metric-card { min-height: 120px; padding: 15px; } .metric-card strong { font-size: 25px; } .method-card { gap: 8px; } .formula { grid-template-columns: 1fr; } .formula b { transform: rotate(90deg); } .source-badge { align-self: flex-start; }
  .app-shell.has-collapsible-sidebar { display: block; }
  .app-shell.has-collapsible-sidebar .sidebar,
  .app-shell.has-collapsible-sidebar .sidebar:hover,
  .app-shell.has-collapsible-sidebar .sidebar:focus-within { position: static; width: 100%; height: auto; padding: 12px; overflow: visible; transform: none; box-shadow: none; transition: none; will-change: auto; }
  .app-shell.has-collapsible-sidebar .sidebar::after { display: none; }
  .app-shell.has-collapsible-sidebar .sidebar > * { width: auto; opacity: 1; pointer-events: auto; }
}/* Inline mock-data editor */
.data-editor-panel { display: flex; flex-direction: column; min-height: 0; }
.editor-note { margin: -8px 0 16px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.editor-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.editor-tab { min-height: 34px; padding: 6px 8px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; }
.editor-tab:hover { color: var(--accent-deep); background: var(--accent-soft); }
.editor-tab.active { color: var(--accent-deep); background: var(--surface); box-shadow: 0 2px 8px rgba(70,48,30,.08); }
.mock-data-table { margin-top: 14px; min-height: 257px; }
.editor-table { width: 100%; border-collapse: collapse; }
.editor-table th, .editor-table td { padding: 9px 7px; border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; vertical-align: middle; }
.editor-table th { color: var(--muted); background: transparent; font-size: 10px; letter-spacing: .04em; }
.editor-table td strong, .editor-table td small { display: block; }
.editor-table td small { margin-top: 2px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.number-field { display: flex; align-items: center; justify-content: flex-end; gap: 5px; color: var(--muted); font-family: "DM Mono", monospace; font-size: 10px; }
.number-field input { width: 102px; min-height: 32px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); font-family: "DM Mono", monospace; text-align: right; }
.number-field input:focus { outline: 2px solid rgba(190,104,66,.24); border-color: var(--accent); }
.editor-table-note, .empty-editor { margin: 0 0 10px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.editor-table-scroll { max-height: 279px; overflow: auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.work-editor-table th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); }
.work-editor-table th, .work-editor-table td { white-space: nowrap; }
.invoice-import-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.invoice-import-box strong, .invoice-import-box small { display: block; }
.invoice-import-box small { margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.invoice-file-picker {
  max-width: 180px;
  min-height: 40px;
  padding: 9px 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--accent-deep);
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.invoice-file-picker:hover { border-color: var(--accent); background: var(--accent-soft); }
.invoice-file-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.invoice-filter-bar { display: grid; grid-template-columns: minmax(150px, 1fr) auto; gap: 8px; margin-top: 10px; }
.invoice-filter-bar input {
  min-width: 0;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.invoice-filter-bar input:focus { outline: 2px solid rgba(190,104,66,.2); border-color: var(--accent); }
.invoice-load-error { padding: 12px; color: #9f3827; background: #f8e4dc; font-size: 11px; line-height: 1.5; }
.invoice-load-error small { display: block; margin-top: 3px; color: #7b5e53; }
.invoice-stage { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.invoice-stage > header { display: flex; align-items: flex-start; gap: 9px; }
.invoice-stage > header > span {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fffaf7;
  background: var(--accent);
  font: 500 11px "DM Mono", monospace;
}
.invoice-stage > header strong, .invoice-stage > header small { display: block; }
.invoice-stage > header strong { font-size: 12px; }
.invoice-stage > header small { margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.invoice-mapping-board {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr);
  gap: 14px;
  margin-top: 12px;
}
.invoice-mapping-column {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}
.invoice-mapping-column > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.invoice-mapping-column > header strong,
.invoice-mapping-column > header small { display: block; }
.invoice-mapping-column > header strong { font-size: 12px; }
.invoice-mapping-column > header small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.invoice-source-list,
.invoice-master-list {
  display: grid;
  align-content: start;
  gap: 7px;
  max-height: 560px;
  margin-top: 10px;
  padding-right: 3px;
  overflow-y: auto;
}
.invoice-source-card,
.invoice-master-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  transition: border-color .14s ease, background-color .14s ease, box-shadow .14s ease, opacity .14s ease;
}
.invoice-source-card { padding: 10px; cursor: pointer; }
.invoice-source-card:hover,
.invoice-source-card.is-selected { border-color: var(--accent); background: #fffaf6; }
.invoice-source-card.is-selected { box-shadow: 0 0 0 2px rgba(190,104,66,.13); }
.invoice-source-card.is-drag-over { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.invoice-source-card > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.invoice-source-card > header strong,
.invoice-source-card > header small { display: block; }
.invoice-source-card > header strong { font-size: 11px; line-height: 1.4; }
.invoice-source-card > header small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.invoice-source-card > header > span {
  flex: none;
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 8px;
}
.invoice-source-card.is-mapped > header > span { color: var(--olive); background: var(--olive-soft); }
.invoice-current-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding: 6px 7px 6px 9px;
  border-radius: 7px;
  color: var(--accent-deep);
  background: var(--accent-soft);
  font-size: 10px;
  font-weight: 700;
}
.invoice-current-title button {
  width: 22px;
  height: 22px;
  flex: none;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  font-size: 15px;
}
.invoice-current-title button:hover { color: var(--accent-deep); background: rgba(255,255,255,.68); }
.invoice-current-title > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invoice-current-title > span > small { display: block; margin-bottom: 1px; color: var(--muted); font-size: 8px; font-weight: 500; }
.invoice-detail-name {
  overflow: hidden;
  margin: 7px 0 0;
  color: var(--ink);
  font-size: 10px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.invoice-drop-guide {
  margin: 8px 0 0;
  padding: 8px;
  border: 1px dashed var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 9px;
  text-align: center;
}
.invoice-title-candidates { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 8px; }
.invoice-title-candidates > span { color: var(--muted); font-size: 8px; }
.invoice-title-candidates button {
  min-height: 25px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--surface);
  font-size: 9px;
}
.invoice-title-candidates button:hover { border-color: var(--accent); color: var(--accent-deep); background: var(--accent-soft); }
.invoice-master-card {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 0 6px;
  padding: 8px 9px;
  cursor: grab;
}
.invoice-master-card:hover { border-color: var(--accent); background: #fffaf6; }
.invoice-master-card:active { cursor: grabbing; }
.invoice-master-card.is-dragging { opacity: .42; }
.invoice-master-drag { grid-row: 1 / 3; color: var(--muted); font-size: 15px; }
.invoice-master-card strong { overflow: hidden; font-size: 10px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.invoice-master-card small { color: var(--muted); font-size: 8px; }
.solid-btn:disabled, .outline-btn:disabled { cursor: default; opacity: .45; }
.editor-actions { display: flex; align-items: center; gap: 10px; margin-top: auto; padding-top: 15px; }
.editor-save-status { display: block; min-height: 18px; margin-top: 10px; color: var(--accent-deep); font-size: 11px; text-align: right; }
@media (max-width: 720px) {
  .mock-data-table { min-height: 0; }
  .editor-actions { flex-wrap: wrap; }
  .editor-tabs { grid-template-columns: repeat(2, 1fr); }
  .invoice-import-box, .invoice-filter-bar { grid-template-columns: 1fr; }
  .invoice-file-picker { max-width: none; }
  .invoice-mapping-board { grid-template-columns: 1fr; }
  .invoice-source-list,
  .invoice-master-list { max-height: 380px; }
}
.editor-table { min-width: 0; }
.work-editor-table { min-width: 620px; }

.fetched-data-actions { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.fetched-data-status { color: var(--muted); font-size: 11px; }
.fetched-title-list { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.fetched-work-heading { margin: 18px 0 8px; font-size: 13px; }
.fetched-work-empty { color: var(--muted); font-size: 12px; line-height: 1.6; }


.budget-editor-list { display: grid; gap: 14px; }
.budget-title-editor { padding: 12px; border: 1px solid var(--line); background: var(--surface-2); }
.budget-title-editor > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.budget-title-editor > header strong, .budget-title-editor > header small { display: block; }
.budget-title-editor > header small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.budget-category-add { min-height: 34px; padding: 6px 10px; font-size: 11px; }
.budget-category-card { display: grid; gap: 8px; margin-top: 8px; padding: 10px; border: 1px solid var(--line); background: var(--surface); }
.budget-category-fields { display: grid; grid-template-columns: minmax(150px, 1fr) auto 30px; align-items: center; gap: 8px; }
.budget-category-name { min-width: 0; min-height: 32px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); font-weight: 700; }
.budget-category-name:focus { outline: 2px solid rgba(190,104,66,.24); border-color: var(--accent); }
.budget-category-remove { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--muted); font-size: 17px; }
.budget-category-remove:hover { border-color: var(--accent); color: var(--accent-deep); background: var(--accent-soft); }
.budget-category-tasks { display: flex; flex-wrap: wrap; gap: 5px; }
.budget-task-chip { display: inline-flex; align-items: center; gap: 5px; min-height: 28px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--ink); font-size: 11px; }
.budget-task-chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.budget-task-chip span { color: var(--accent-deep); font-size: 14px; }
.budget-category-empty { color: var(--muted); font-size: 11px; }
.budget-task-select { width: min(280px, 100%); min-height: 32px; padding: 5px 9px; font-size: 11px; }
.budget-title-editor > footer { display: grid; grid-template-columns: auto 1fr; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 10px; }
.budget-title-editor > footer strong { color: var(--ink); font-weight: 500; }
.budget-title-empty { margin: 8px 0; color: var(--muted); font-size: 11px; }
.allocation-category { display: grid !important; grid-template-columns: 1fr !important; gap: 4px !important; }
.allocation-category-summary { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; }
.allocation-category small { color: var(--muted); font-size: 10px; }
@media (max-width: 720px) {
  .budget-title-editor > header { align-items: stretch; flex-direction: column; }
  .budget-category-fields { grid-template-columns: 1fr auto; }
  .budget-category-fields .number-field { justify-content: flex-start; }
  .budget-category-remove { grid-column: 2; grid-row: 1; }
}


/* Selected-title monthly budget view */
.content-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, .9fr);
  align-items: start;
}
button:disabled,
select:disabled {
  cursor: default;
  opacity: .46;
}
.title-panel-head {
  align-items: flex-end;
}
.title-controls {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 8px;
}
.title-controls label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}
.title-refresh-control {
  display: grid;
  gap: 4px;
}
.title-refresh-control button {
  min-height: 39px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-deep);
  background: var(--surface);
  font-size: 11px;
  font-weight: 700;
}
.title-refresh-control button:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.title-refresh-control small {
  min-height: 14px;
  color: var(--muted);
  font-size: 9px;
  text-align: right;
}
.title-controls [hidden] {
  display: none !important;
}
.title-controls select {
  width: auto;
  min-width: 148px;
  max-width: 260px;
}
.title-controls label:first-child select {
  min-width: 220px;
}
.result-view-tabs {
  display: inline-grid;
  grid-template-columns: repeat(3, auto);
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}
.result-view-tab {
  min-height: 34px;
  padding: 6px 14px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}
.result-view-tab:hover {
  color: var(--accent-deep);
  background: var(--accent-soft);
}
.result-view-tab.active {
  color: #fffaf7;
  background: var(--accent);
}
.title-budget-list.is-matrix-view {
  display: block;
}
.title-budget-list.is-schedule-view { display: block; }
.budget-matrix-wrap {
  width: 100%;
  overflow: auto;
  padding: 2px;
  background: transparent;
  scrollbar-color: #c9b8a6 transparent;
  scrollbar-width: thin;
}
.budget-matrix {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 6px 7px;
  table-layout: fixed;
}
.budget-matrix th,
.budget-matrix td {
  border: 0;
}
.budget-matrix thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  width: 84px;
  min-width: 84px;
  padding: 10px 6px;
  border-radius: 8px;
  color: var(--ink);
  background: #f3ece2;
  font-family: "Zen Kaku Gothic New", sans-serif;
  font-size: 11px;
  text-align: center;
}
.budget-matrix .budget-matrix-corner,
.budget-matrix .budget-matrix-role {
  position: sticky;
  left: 0;
  z-index: 3;
  width: 220px;
  min-width: 220px;
  max-width: 220px;
  text-align: left;
}
.budget-matrix .budget-matrix-corner {
  z-index: 4;
  color: var(--muted);
  font-family: "Zen Kaku Gothic New", sans-serif;
  font-size: 13px;
  letter-spacing: .04em;
}
.budget-matrix-role {
  padding: 15px 14px;
  border-radius: 8px;
  background: var(--surface-2);
  vertical-align: top;
}
.budget-matrix-role strong,
.budget-matrix-role small {
  display: block;
}
.budget-matrix-role strong {
  color: var(--ink);
  font-size: 15px;
}
.budget-matrix-role small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}
.budget-matrix-total-row .budget-matrix-role strong {
  color: var(--accent-deep);
}
.budget-matrix-member-row > * {
  background: #fffdf9;
}
.budget-matrix .budget-matrix-member {
  position: sticky;
  padding-left: 29px;
  clip-path: inset(0 0 0 20px round 5px);
  background: #fbf7f0;
}
.budget-matrix-member strong {
  font-size: 14px;
  font-weight: 700;
}
.budget-matrix-member small {
  color: #9b8d7e;
  font-size: 11px;
}
.budget-matrix-values > * {
  display: block;
  min-height: 20px;
  line-height: 20px;
}
.budget-matrix-cell {
  width: 84px;
  min-width: 84px;
  padding: 10px 6px;
  border-radius: 8px;
  background: var(--surface);
  vertical-align: top;
}
.budget-matrix-cell.is-member {
  background: #fffdf9;
}
.budget-matrix-values {
  display: grid;
  gap: 0;
  text-align: right;
}
.budget-matrix-values > * {
  color: var(--ink);
  font-family: "Zen Kaku Gothic New", sans-serif;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: normal;
  white-space: nowrap;
}
.budget-matrix-cell.is-member .budget-matrix-values > * {
  color: #655d55;
}
.budget-matrix-values strong {
  color: var(--accent-deep);
  font-size: 14px;
  font-weight: 400;
}
.budget-matrix-track {
  display: block;
  height: 5px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #e8e0d4;
}
.budget-matrix-track > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #dfaa8d);
}
.budget-matrix-placeholder { visibility: hidden; }
.budget-matrix-cell.is-over-budget {
  background: var(--over-budget-soft);
}
.budget-matrix-cell.is-over-budget .budget-matrix-values strong {
  color: var(--over-budget);
}
.budget-matrix-cell.is-over-budget .budget-matrix-track > span {
  background: var(--over-budget);
}
.budget-matrix-cell.is-unassigned .budget-matrix-values > * {
  color: #a9412d;
}
.schedule-budget-guide {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 14px;
  min-height: 33px;
  margin: 0 2px 10px;
  color: var(--muted);
  font-size: 10px;
}
.schedule-budget-guide > span { font-weight: 700; }
.schedule-budget-guide > small { margin-left: auto; font-size: 10px; }
.schedule-heat-key { display: inline-flex; align-items: center; gap: 5px; }
.schedule-heat-key i { width: 18px; height: 8px; border-radius: 99px; background: #dfe8d8; }
.schedule-heat-key.is-over i { width: 34px; background: linear-gradient(90deg, var(--over-budget-soft), var(--over-budget)); }
.schedule-value-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.schedule-value-toggle > span { padding: 0 6px; font-size: 9px; font-weight: 700; }
.schedule-value-toggle button {
  min-height: 27px;
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 9px;
  font-weight: 700;
}
.schedule-value-toggle button:hover { color: var(--accent-deep); background: var(--accent-soft); }
.schedule-value-toggle button.is-active { color: #fffaf5; background: var(--accent); }
.schedule-budget-wrap { overflow: clip; padding-inline: 0; }
.schedule-budget-table {
  width: 100%;
  min-width: 0;
  border-spacing: 2px 4px;
  table-layout: fixed;
}
.schedule-budget-table thead th:not(.budget-matrix-corner),
.schedule-budget-table .schedule-budget-cell {
  width: auto;
  min-width: 0;
}
.schedule-budget-table thead th:not(.budget-matrix-corner) {
  height: 30px;
  padding-inline: 1px;
  padding-block: 2px 4px;
  overflow: hidden;
  border-radius: 3px;
  line-height: 1;
}
.schedule-budget-table thead th small,
.schedule-budget-table thead th strong { display: block; font-family: "DM Mono", monospace; line-height: 1; }
.schedule-budget-table thead th small { min-height: 9px; color: var(--muted); font-size: 9px; font-weight: 400; }
.schedule-budget-table thead th strong { margin-top: 2px; font-size: 11px; }
.schedule-budget-table .budget-matrix-corner,
.schedule-budget-table .schedule-budget-role {
  width: 170px;
  min-width: 170px;
  max-width: 170px;
}
.schedule-budget-table thead th.is-current { color: var(--accent-deep); background: var(--accent-soft); }
.schedule-budget-role { min-height: 82px; padding: 8px 9px; border-radius: 5px; }
.schedule-budget-role strong {
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  white-space: normal;
}
.schedule-budget-role small { margin-top: 2px; font-size: 10px; }
.schedule-budget-role .schedule-budget-period { color: var(--accent-deep); font-family: "DM Mono", monospace; font-weight: 600; }
.schedule-budget-cell { height: 82px; overflow: hidden; padding: 8px 4px; border-radius: 3px; vertical-align: middle; }
.schedule-budget-cell .budget-matrix-track { height: 4px; margin: 5px 1px 0; }
.schedule-budget-cell.is-scheduled { background: var(--surface-2); }
.schedule-budget-cell.is-scheduled .budget-matrix-track > span { background: #71805d; }
.schedule-budget-cell.is-scheduled.is-over-budget { background: var(--over-budget-soft); }
.schedule-budget-cell.is-scheduled.is-over-budget .budget-matrix-values strong { color: var(--over-budget); }
.schedule-budget-cell.is-scheduled.is-over-budget .budget-matrix-track > span { background: var(--over-budget); }
.schedule-budget-table.is-visual-mode .schedule-budget-cell.is-scheduled {
  background: #dfe8d8;
}
.schedule-budget-table.is-visual-mode .schedule-budget-cell.is-over-budget {
  background: color-mix(in srgb, var(--over-budget) var(--schedule-over-heat), var(--over-budget-soft));
}
.schedule-budget-table.is-visual-mode .schedule-budget-cell.has-unplanned-consumption { background: var(--over-budget); }
.schedule-budget-table.is-visual-mode .schedule-budget-cell .budget-matrix-values { display: none; }
.schedule-budget-table.is-visual-mode .schedule-budget-cell .budget-matrix-track { height: 8px; margin: 0 3px; background: rgba(255,255,255,.62); }
.schedule-budget-table.is-visual-mode .schedule-budget-cell.is-over-budget .budget-matrix-track > span { background: var(--over-budget); }
.schedule-budget-cell.is-outside-schedule { background: #f6f2ec; }
.schedule-budget-cell.is-empty { background: transparent; }
.schedule-budget-cell.has-unplanned-consumption { background: var(--over-budget-soft); }
.schedule-budget-cell.has-unplanned-consumption .budget-matrix-values > * { color: var(--over-budget); }
.schedule-budget-cell[data-schedule-tooltip],
.schedule-budget-table thead th[data-schedule-tooltip] { transition: filter .12s ease; }
.schedule-budget-cell[data-schedule-tooltip]:hover,
.schedule-budget-table thead th[data-schedule-tooltip]:hover { filter: brightness(.9) saturate(1.08); }
.schedule-budget-cell[data-schedule-item-id] { cursor: pointer; }
.schedule-budget-cell[data-schedule-item-id]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.schedule-budget-tooltip {
  position: fixed;
  z-index: 1000;
  max-width: min(280px, calc(100vw - 16px));
  padding: 8px 10px;
  border: 1px solid #d8b69f;
  border-radius: 7px;
  color: #fffaf5;
  background: #7f4934;
  box-shadow: 0 9px 28px rgba(68, 42, 29, .2);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.55;
  white-space: pre-line;
  pointer-events: none;
}
.schedule-budget-tooltip[hidden] { display: none; }
.schedule-budget-empty {
  display: block;
  color: #c7bbae;
  font: 500 13px "DM Mono", monospace;
  text-align: center;
}
.schedule-budget-empty-state {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}
.schedule-budget-empty-state p { margin: 0; color: var(--muted); }
.schedule-breakdown-dialog { width: min(860px, calc(100vw - 32px)); border-radius: 16px; }
.schedule-breakdown-head { align-items: flex-start; }
.schedule-breakdown-head .icon-btn { flex: none; }
.schedule-breakdown-meta { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.schedule-breakdown-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 20px;
}
.schedule-breakdown-summary > div {
  min-width: 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-2);
}
.schedule-breakdown-summary span,
.schedule-breakdown-summary strong { display: block; }
.schedule-breakdown-summary span { color: var(--muted); font-size: 10px; }
.schedule-breakdown-summary strong { margin-top: 3px; font: 500 18px "DM Mono", monospace; }
.schedule-breakdown-summary .is-over strong { color: var(--over-budget); }
.schedule-breakdown-section { margin-top: 22px; }
.schedule-breakdown-section > header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.schedule-breakdown-section h3 { margin: 0; font-size: 14px; }
.schedule-breakdown-section > header strong { color: var(--accent-deep); font: 500 13px "DM Mono", monospace; }
.schedule-breakdown-table-wrap { overflow-x: auto; }
.schedule-breakdown-table { width: 100%; border-collapse: collapse; }
.schedule-breakdown-table th { padding: 8px 10px; font-size: 10px; }
.schedule-breakdown-table td { padding: 10px; border-top: 1px solid var(--line); font-size: 12px; vertical-align: top; }
.schedule-breakdown-table td.num { font-size: 12px; }
.schedule-breakdown-empty { margin: 0; padding: 14px; color: var(--muted); background: var(--surface-2); border-radius: 9px; font-size: 12px; }
@media (max-width: 620px) {
  .schedule-breakdown-summary { grid-template-columns: 1fr; }
  .schedule-breakdown-dialog .dialog-card { padding: 18px; }
}
.month-result-card {
  padding: 18px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.month-result-card > header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 11px;
}
.month-result-card > header strong,
.month-result-card > header small {
  display: block;
}
.month-result-card > header > div > strong {
  font-family: "Zen Kaku Gothic New", sans-serif;
  font-size: 18px;
}
.month-result-card > header small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}
.month-result-percent {
  color: var(--accent-deep);
  font: 700 14px "DM Mono", monospace;
  white-space: nowrap;
}
.month-result-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 16px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}
.monthly-role-list {
  display: grid;
  gap: 0;
  margin-top: 15px;
  border-top: 1px dashed var(--line);
}
.monthly-role-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(223, 211, 195, .72);
  font-size: 12px;
}
.monthly-role-row > div strong,
.monthly-role-row > div small {
  display: block;
}
.monthly-role-row > div small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}
.monthly-role-row > span {
  color: var(--muted);
  font-family: "DM Mono", monospace;
  white-space: nowrap;
}
.monthly-role-utilization {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-width: 0;
  gap: 10px;
}
.role-rate-metric {
  display: grid;
  min-width: 0;
  gap: 4px;
}
.role-rate-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.role-rate-head span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}
.role-rate-head strong {
  color: var(--accent-deep);
  font: 700 12px "DM Mono", monospace;
  white-space: nowrap;
}
.role-rate-metric > small,
.monthly-role-utilization.is-unassigned-rate small {
  margin: 0;
  color: var(--muted);
  font: 10px "DM Mono", monospace;
  white-space: nowrap;
}
.monthly-role-track {
  display: block;
  height: 6px;
  overflow: hidden;
  background: #e8e0d4;
  border-radius: 99px;
}
.monthly-role-track > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #dfaa8d);
  border-radius: inherit;
}
.role-rate-metric.is-over-budget .monthly-role-track > span {
  background: var(--over-budget);
}
.role-rate-metric.is-over-budget .role-rate-head strong,
.monthly-role-row.is-unassigned > div:first-child strong {
  color: var(--over-budget);
}
.monthly-role-utilization.is-unassigned-rate {
  grid-template-columns: 1fr auto;
  color: #a9412d;
}
.role-cumulative-summary {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid #e3cdbc;
  background: #fff8f2;
}
.role-summary-heading,
.role-summary-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.role-summary-heading span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}
.role-summary-heading strong {
  color: var(--accent-deep);
  font: 700 16px "DM Mono", monospace;
}
.role-summary-meta {
  color: var(--muted);
  font: 10px "DM Mono", monospace;
}
.role-cumulative-summary.is-over-budget .role-summary-heading strong {
  color: var(--over-budget);
}
.role-cumulative-summary.is-over-budget .monthly-role-track > span {
  background: var(--over-budget);
}
.role-month-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.role-month-block {
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.role-month-block > header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}
.role-month-block > header strong {
  font-family: "Zen Kaku Gothic New", sans-serif;
  font-size: 15px;
}
.role-month-block > header small {
  margin-left: 8px;
  color: var(--muted);
  font: 10px "DM Mono", monospace;
}
.role-month-metric {
  display: grid;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
}
.role-month-metric > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.role-month-metric > div span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}
.role-month-metric > div strong {
  color: var(--accent-deep);
  font: 700 13px "DM Mono", monospace;
}
.role-month-metric > small {
  color: var(--muted);
  font: 10px "DM Mono", monospace;
}
.role-month-metric.is-over-budget > div strong {
  color: var(--over-budget);
}
.role-month-metric.is-over-budget .monthly-role-track > span {
  background: var(--over-budget);
}
.role-month-metric.is-unassigned-rate {
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  color: #a9412d;
}
.role-member-list {
  display: grid;
  gap: 0;
  margin-top: 10px;
}
.role-member-list h5 {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 10px;
}
.role-member-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(110px, .42fr);
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid rgba(223, 211, 195, .7);
}
.role-member-row > div:first-child strong,
.role-member-row > div:first-child small {
  display: block;
}
.role-member-row > div:first-child strong {
  font-size: 11px;
}
.role-member-row > div:first-child small {
  margin-top: 1px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.role-member-row > span {
  color: var(--muted);
  font: 10px "DM Mono", monospace;
  white-space: nowrap;
}
.role-member-cost {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 5px;
}
.role-member-cost strong {
  font: 700 11px "DM Mono", monospace;
  text-align: right;
}
.role-member-cost small {
  color: var(--muted);
  font: 9px "DM Mono", monospace;
}
.role-member-track {
  grid-column: 1 / -1;
  display: block;
  height: 4px;
  overflow: hidden;
  background: #e8e0d4;
  border-radius: 99px;
}
.role-member-track > span {
  display: block;
  height: 100%;
  background: var(--olive);
  border-radius: inherit;
}
.month-empty {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.table-subtext {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
}

.assignment-filter-note {
  margin: 10px 0 0;
  color: var(--accent-deep);
  font-size: 10px;
}
.assignment-work-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.assignment-member-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.assignment-title-episode {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
}
.assignment-title-episode span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.assignment-title-episode strong {
  flex: 0 0 auto;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 10px;
}
.assignment-member-role {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}
.assignment-task-exclusions {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.assignment-task-exclusions summary {
  width: max-content;
  cursor: pointer;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.assignment-task-exclusions > div {
  display: grid;
  gap: 3px;
  margin-top: 8px;
}
.assignment-task-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
}
.assignment-task-row:hover {
  background: var(--surface);
}
.assignment-task-row small {
  color: var(--muted);
  font: 500 10px "DM Mono", monospace;
}
.assignment-task-row.is-excluded span,
.assignment-task-row.is-excluded small {
  color: var(--muted);
  text-decoration: line-through;
}
.assignment-work-row {
  display: grid;
  gap: 8px;
  padding: 11px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.assignment-work-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.assignment-work-meta strong {
  font-size: 12px;
}
.assignment-work-meta span {
  color: var(--muted);
  font: 500 10px "DM Mono", monospace;
  white-space: nowrap;
}
.assignment-work-row > p {
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
}
.assignment-work-row label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}
.assignment-work-row select {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 6px 9px;
  font-size: 11px;
}
.assignment-work-row select:focus,
.title-controls select:focus {
  outline: 2px solid rgba(190, 104, 66, .2);
  border-color: var(--accent);
}
.assignment-empty {
  padding: 18px;
  border: 1px dashed var(--line);
  background: var(--surface-2);
}
.assignment-empty strong {
  display: block;
  font-size: 13px;
}
.assignment-empty p {
  margin: 6px 0 14px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}
.inline-link {
  display: inline-flex;
  align-items: center;
  width: auto;
  min-height: 34px;
  padding: 6px 10px;
  font-size: 11px;
  text-decoration: none;
}
.fetched-report-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.fetched-report-head strong {
  font-size: 13px;
}
.fetched-report-head small {
  color: var(--muted);
  font: 500 9px "DM Mono", monospace;
}
.data-editor-panel .mock-data-table {
  min-height: 0;
}
.member-panel table {
  min-width: 900px;
}

@media (max-width: 1180px) {
  .title-panel-head {
    align-items: stretch;
    flex-direction: column;
  }
  .title-controls {
    justify-content: flex-start;
  }
}
@media (max-width: 1040px) {
  .content-grid {
    grid-template-columns: 1fr;
  }
  .title-panel-head {
    flex-direction: row;
    align-items: flex-end;
  }
}
@media (max-width: 720px) {
  .title-panel-head {
    align-items: stretch;
    flex-direction: column;
  }
  .title-controls {
    display: grid;
    grid-template-columns: 1fr;
  }
  .title-controls select,
  .title-controls label:first-child select {
    width: 100%;
    min-width: 0;
    max-width: none;
  }
  .title-refresh-control button {
    width: 100%;
  }
  .title-refresh-control small {
    text-align: left;
  }
  .result-view-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }
  .budget-matrix thead th,
  .budget-matrix-cell {
    width: 84px;
    min-width: 84px;
  }
  .budget-matrix .budget-matrix-corner,
  .budget-matrix .budget-matrix-role {
    width: 180px;
    min-width: 180px;
    max-width: 180px;
  }
  .monthly-role-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .monthly-role-row > span:nth-of-type(2) {
    grid-column: 1 / -1;
    text-align: right;
  }
  .monthly-role-utilization {
    grid-column: 1 / -1;
  }
  .role-member-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .role-member-cost {
    grid-column: 1 / -1;
  }
  .month-result-meta {
    display: grid;
    grid-template-columns: 1fr;
  }
}

.month-result-card > .bar { display: block; width: 100%; }


/* Hierarchical work-to-budget-role assignment */
.content-grid { grid-template-columns: minmax(0, 1fr); }
.title-panel-head { flex-wrap: wrap; }
.title-panel-head > div:first-child { min-width: 180px; }
.title-controls { flex-wrap: wrap; }
.assignment-board-note {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}
.mock-data-table { container-type: inline-size; }
.assignment-board {
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
  gap: 10px;
}
.assignment-source-pane,
.assignment-role-pane {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.assignment-source-pane > header,
.assignment-role-pane > header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.assignment-source-pane > header strong,
.assignment-role-pane > header strong { font-size: 12px; }
.assignment-source-pane > header small,
.assignment-role-pane > header small { color: var(--muted); font-size: 9px; }
.assignment-source-list,
.assignment-role-list {
  max-height: 620px;
  overflow: auto;
  padding: 8px;
}
.assignment-person-group + .assignment-person-group {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.assignment-source-children {
  display: grid;
  gap: 4px;
  margin-left: 11px;
  padding-left: 8px;
  border-left: 1px solid var(--line);
}
.assignment-source-branch { display: grid; gap: 4px; }
.assignment-source-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 3px;
  min-width: 0;
}
.assignment-source {
  width: 100%;
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}
.assignment-source:hover,
.assignment-source.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.assignment-source.is-dragging { opacity: .42; }
.assignment-source-grip { color: #b9ad9f; font-size: 15px; line-height: 1; }
.assignment-source-copy { min-width: 0; }
.assignment-source-copy strong,
.assignment-source-copy small { display: block; }
.assignment-source-copy strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.assignment-source-copy small { margin-top: 1px; color: var(--muted); font-size: 8px; }
.assignment-source-role {
  max-width: 76px;
  overflow: hidden;
  padding: 2px 5px;
  border-radius: 999px;
  color: var(--accent-deep);
  background: var(--accent-soft);
  font-size: 8px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.assignment-source-clear {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  font-size: 16px;
  line-height: 1;
}
.assignment-source-clear:hover {
  color: var(--accent-deep);
  background: var(--accent-soft);
}
.assignment-role-section + .assignment-role-section { margin-top: 12px; }
.assignment-role-section h4 {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .06em;
}
.assignment-role-dropzone {
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  transition: border-color .15s, background .15s, transform .15s;
}
.assignment-role-dropzone + .assignment-role-dropzone { margin-top: 6px; }
.assignment-role-dropzone:hover,
.assignment-role-dropzone:focus-visible,
.assignment-role-dropzone.is-drag-over {
  outline: 0;
  border-color: var(--accent);
  background: #fff8f2;
}
.assignment-role-dropzone.is-drag-over { transform: translateY(-1px); }
.assignment-role-dropzone > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 7px;
}
.assignment-role-dropzone > header strong,
.assignment-role-dropzone > header small { display: block; }
.assignment-role-dropzone > header strong { font-size: 11px; }
.assignment-role-dropzone > header small { margin-top: 1px; color: var(--muted); font-size: 8px; }
.assignment-role-dropzone > header > span {
  color: var(--muted);
  font: 8px "DM Mono", monospace;
  white-space: nowrap;
}
.assigned-task-list { display: grid; gap: 4px; margin-top: 7px; }
.assigned-task-chip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 5px 5px 5px 7px;
  border: 1px solid #ead8cb;
  border-radius: 6px;
  background: var(--accent-soft);
}
.assigned-task-chip > span { min-width: 0; }
.assigned-task-chip strong,
.assigned-task-chip small { display: block; }
.assigned-task-chip strong { font-size: 9px; }
.assigned-task-chip small {
  overflow: hidden;
  margin-top: 1px;
  color: var(--muted);
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.assigned-task-chip button {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  font-size: 15px;
}
.assigned-task-chip button:hover { color: var(--accent-deep); background: var(--surface); }
.assignment-role-empty {
  margin: 0;
  padding: 8px;
  border: 1px dashed var(--line);
  color: #a79c90;
  font-size: 9px;
  text-align: center;
}
@container (max-width: 620px) {
  .assignment-board { grid-template-columns: 1fr; }
  .assignment-source-list,
  .assignment-role-list { max-height: 460px; }
}

/* All-title portfolio */
.portfolio-main { max-width: none; padding-inline: clamp(14px, 2.2vw, 34px); }
.portfolio-topbar { padding-bottom: 20px; }
.portfolio-updated-at { align-self: center; color: var(--muted); font-size: 11px; white-space: nowrap; }
.portfolio-panel { min-width: 0; padding: 20px 18px 0; overflow: clip; }
.portfolio-panel-head { align-items: flex-end; margin-bottom: 14px; }
.portfolio-panel-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 9px 14px; }
.portfolio-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; color: var(--muted); font-size: 11px; }
.portfolio-legend span { display: inline-flex; align-items: center; gap: 4px; }
.portfolio-legend i { width: 9px; height: 9px; border-radius: 2px; }
.portfolio-legend .is-normal { background: var(--surface-2); border: 1px solid var(--line); }
.portfolio-legend .is-warning { background: #e8c9a9; }
.portfolio-legend .is-over { background: var(--over-budget); }
.portfolio-status { min-height: 24px; color: var(--muted); font-size: 11px; }
.portfolio-table-wrap { width: 100%; overflow-x: clip; }
.portfolio-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 2px 4px;
}
.portfolio-table th,
.portfolio-table td { padding: 0; border: 0; }
.portfolio-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
}
.portfolio-table thead .portfolio-corner { z-index: 6; }
.portfolio-corner {
  width: 170px;
  min-width: 170px;
  max-width: 170px;
  padding: 10px 6px !important;
  background: #f3ece2 !important;
  font-size: 11px;
}
.portfolio-month-head {
  height: 30px;
  overflow: hidden;
  padding: 2px 1px 4px !important;
  border-radius: 3px;
  background: #f3ece2 !important;
  text-align: center;
  vertical-align: bottom;
}
.portfolio-month-head small,
.portfolio-month-head strong { display: block; line-height: 1; }
.portfolio-month-head small { min-height: 9px; color: var(--muted); font: 400 9px "DM Mono", monospace; }
.portfolio-month-head strong { margin-top: 2px; color: var(--ink); font: 500 11px "DM Mono", monospace; }
.portfolio-title-cell {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 170px;
  min-width: 170px;
  max-width: 170px;
  padding: 8px 10px !important;
  background: var(--surface-2) !important;
  vertical-align: middle;
}
.portfolio-title-cell a { display: block; min-width: 0; color: var(--ink); text-decoration: none; }
.portfolio-title-cell a:hover strong { color: var(--accent-deep); }
.portfolio-title-cell a strong { display: -webkit-box; overflow: hidden; font-size: 13px; line-height: 1.35; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.portfolio-title-meta { display: grid; justify-items: start; gap: 2px; margin-top: 5px; }
.portfolio-title-cell small { color: var(--muted); font: 400 10px "DM Mono", monospace; }
.portfolio-title-meta > span { padding: 2px 5px; border-radius: 999px; font-size: 10px; }
.portfolio-title-over { color: var(--over-budget-deep); background: var(--over-budget-soft); }
.portfolio-title-remaining { color: #65704f; background: var(--olive-soft); }
.portfolio-title-unbudgeted { color: var(--muted); background: #ebe5dc; }
.portfolio-title-loading { color: var(--accent-deep); background: var(--accent-soft); }
.portfolio-title-error { color: #9f3827; background: #f8e4dc; }
.portfolio-month-cell {
  height: 82px;
  overflow: hidden;
  padding: 8px 4px !important;
  border-radius: 3px;
  background: #f3eee6;
  text-align: center;
  vertical-align: middle;
}
.portfolio-month-cell .budget-matrix-track { height: 4px; margin: 5px 1px 0; }
.portfolio-month-cell.is-normal .budget-matrix-track > span,
.portfolio-month-cell.is-future .budget-matrix-track > span { background: #71805d; }
.portfolio-month-cell.is-warning .budget-matrix-track > span { background: var(--accent); }
.portfolio-month-cell.is-over .budget-matrix-track > span { background: var(--over-budget); }
.portfolio-month-cell.is-empty { background: transparent; }
.portfolio-month-cell.is-loading { background: #f7f4ef; }
.portfolio-month-cell.is-future { background: #fffaf4; }
.portfolio-month-cell.is-normal { background: var(--surface-2); }
.portfolio-month-cell.is-unbudgeted { background: #f2eee7; color: var(--muted); }
.portfolio-month-cell.is-unbudgeted .budget-matrix-values > * { color: var(--muted); }
.portfolio-month-cell.is-warning { background: #e8c9a9; }
.portfolio-month-cell.is-over { background: var(--over-budget-soft); }
.portfolio-month-cell.is-over .budget-matrix-values > * { color: var(--over-budget); }
.portfolio-month-cell[data-portfolio-tooltip] { transition: filter .12s ease; }
.portfolio-month-cell[data-portfolio-tooltip]:hover { filter: brightness(.9) saturate(1.08); }
.portfolio-month-cell[data-portfolio-breakdown-row] { cursor: pointer; }
.portfolio-month-cell[data-portfolio-breakdown-row]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.portfolio-breakdown-cause { color: var(--over-budget); }
.portfolio-breakdown-cause strong { color: inherit; }
.portfolio-breakdown-shortage { color: var(--accent-deep); }
.portfolio-breakdown-shortage strong { color: inherit; }
.schedule-breakdown-summary .is-under strong { color: var(--accent-deep); }
.portfolio-table.is-band-layout { border-spacing: 2px 2px; }
.portfolio-table.is-band-layout .portfolio-month-cell { height: 82px; }
.portfolio-title-band-row th {
  padding: 12px 12px 5px !important;
  background: var(--surface-2) padding-box !important;
}
.portfolio-title-band-row:not(:first-child) th { border-top: 14px solid transparent; }
.portfolio-title-band {
  display: grid;
  grid-template-columns: minmax(150px, .8fr) minmax(260px, 1.2fr) minmax(220px, 1fr);
  align-items: center;
  gap: 14px 24px;
  text-align: left;
}
.portfolio-title-band a { min-width: 0; color: var(--ink); text-decoration: none; }
.portfolio-title-band a:hover { color: var(--accent-deep); }
.portfolio-title-band a > strong { display: block; overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.portfolio-band-totals { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.portfolio-band-totals > span { color: var(--muted); font-size: 10px; }
.portfolio-band-totals > span > strong { margin-left: 3px; color: var(--ink); font: 500 11px "DM Mono", monospace; }
.portfolio-band-totals > .portfolio-title-over,
.portfolio-band-totals > .portfolio-title-remaining,
.portfolio-band-totals > .portfolio-title-unbudgeted,
.portfolio-band-totals > .portfolio-title-loading,
.portfolio-band-totals > .portfolio-title-error { padding: 2px 6px; border-radius: 999px; }
.portfolio-total-rate { display: grid; gap: 5px; min-width: 0; }
.portfolio-total-rate > div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.portfolio-total-rate > div span { color: var(--muted); font-size: 10px; }
.portfolio-total-rate > div strong { color: var(--accent-deep); font: 500 12px "DM Mono", monospace; }
.portfolio-total-track { display: block; height: 7px; overflow: hidden; border-radius: 999px; background: #e7e1d6; }
.portfolio-total-track > span { display: block; height: 100%; border-radius: inherit; background: #71805d; }
.portfolio-title-band:has(.portfolio-title-over) .portfolio-total-track > span { background: var(--over-budget); }

@media (max-width: 1200px) {
  .portfolio-month-cell strong,
  .portfolio-month-cell small { display: none; }
  .portfolio-month-cell { height: 48px; }
  .portfolio-title-band { grid-template-columns: minmax(130px, .7fr) minmax(220px, 1fr) minmax(180px, 1fr); gap: 10px 16px; }
}
@media (max-width: 720px) {
  .portfolio-panel { padding-inline: 10px; }
  .portfolio-panel-head { align-items: stretch; flex-direction: column; }
  .portfolio-panel-actions { align-items: flex-start; justify-content: flex-start; }
  .portfolio-legend { justify-content: flex-start; }
  .portfolio-title-cell { padding-inline: 6px !important; }
  .portfolio-title-cell small { display: none; }
  .portfolio-title-band { grid-template-columns: 1fr; gap: 7px; }
}
