:root {
  --bg: #f4f7f9;
  --surface: #ffffff;
  --surface-2: #eef4f6;
  --ink: #13202b;
  --muted: #667684;
  --line: #d9e1e7;
  --teal: #0b6f7f;
  --teal-dark: #084f5b;
  --teal-soft: #e3f3f5;
  --blue: #1769aa;
  --amber: #b7791f;
  --red: #b42318;
  --green: #137333;
  --shadow: 0 16px 36px rgba(26, 45, 58, 0.08);
  --control-height: 38px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Thai", Arial, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  transition: grid-template-columns .16s ease;
}
.app-shell.sidebar-collapsed {
  grid-template-columns: 64px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  background: #0f202b;
  color: white;
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 100vh;
  padding: 16px 10px;
  overflow: hidden;
}
.brand {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e9f7f9;
  color: var(--teal-dark);
  font-weight: 800;
  letter-spacing: .02em;
}
.brand-copy {
  min-width: 0;
}
.brand strong { display: block; font-size: 14px; white-space: nowrap; }
.brand span { display: block; font-size: 11px; color: #a7b7c4; margin-top: 2px; white-space: nowrap; }
.sidebar-toggle {
  margin-left: auto;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 6px;
  background: rgba(255,255,255,.06);
  color: #dce8ee;
  font-weight: 800;
  line-height: 1;
}
.sidebar-toggle:hover {
  background: rgba(255,255,255,.12);
}
.nav-list {
  flex: 1 1 auto;
  display: grid;
  align-content: start;
  gap: 4px;
  padding-top: 16px;
  overflow-y: auto;
  min-height: 0;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  color: #c9d5de;
  border: 0;
  background: transparent;
  border-radius: 6px;
  padding: 10px 11px;
  text-align: left;
}
.nav-item svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-item.active {
  background: #163241;
  color: white;
}
.sidebar-foot {
  flex: 0 0 auto;
  margin-top: auto;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  padding: 12px;
  color: #b8c7d1;
  font-size: 12px;
}
.sidebar-foot strong { display: block; color: white; margin-top: 4px; }
.sidebar-collapsed .sidebar {
  padding-inline: 9px;
}
.sidebar-collapsed .brand {
  justify-content: center;
  padding-inline: 0;
}
.sidebar-collapsed .brand-mark {
  display: none;
}
.sidebar-collapsed .brand-copy,
.sidebar-collapsed .nav-item span,
.sidebar-collapsed .sidebar-foot {
  display: none;
}
.sidebar-collapsed .sidebar-toggle {
  margin-left: 0;
}
.sidebar-collapsed .nav-list {
  padding-top: 14px;
}
.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 11px 0;
}
.sidebar-collapsed .nav-item svg {
  width: 19px;
  height: 19px;
}

.workspace {
  min-width: 0;
  padding: 20px 22px 28px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.topbar h1 { font-size: 24px; margin: 0; letter-spacing: 0; }
.topbar p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.toolbar {
  display: flex;
  align-items: end;
  gap: 10px;
}
label span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}
input, select {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  min-height: var(--control-height);
  padding: 7px 9px;
  color: var(--ink);
}
input[type="number"] { width: 88px; }
input:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 2px solid rgba(11, 111, 127, .22);
  outline-offset: 2px;
}
.segmented {
  display: flex;
  border: 1px solid var(--line);
  background: white;
  border-radius: 7px;
  padding: 3px;
}
.segmented button {
  border: 0;
  background: transparent;
  border-radius: 5px;
  padding: 7px 11px;
  color: var(--muted);
  min-height: 30px;
}
.segmented button.selected {
  background: var(--teal);
  color: white;
}

.month-menu {
  position: relative;
}
.month-menu::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 8px;
}
.month-menu-button {
  border: 1px solid var(--line);
  background: white;
  border-radius: 7px;
  min-height: var(--control-height);
  padding: 7px 12px;
  color: var(--ink);
  min-width: 138px;
  text-align: left;
}
.month-popover {
  position: absolute;
  right: 0;
  top: 100%;
  width: 238px;
  padding: 10px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transform: translateY(0);
  transition: opacity .12s ease, transform .12s ease;
}
.month-menu:hover .month-popover,
.month-menu.open .month-popover,
.month-menu:focus-within .month-popover {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(4px);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.month-actions {
  display: flex;
  gap: 6px;
  margin-top: 9px;
}
.month-actions button {
  border: 0;
  background: var(--surface-2);
  color: var(--teal-dark);
  border-radius: 5px;
  padding: 6px 8px;
  font-size: 11px;
}
.month-checkboxes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.month-chip {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  background: #fbfcfd;
  font-size: 11px;
  user-select: none;
  cursor: pointer;
}
.month-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.month-chip.checked {
  background: var(--teal-soft);
  border-color: #8bcbd3;
  color: var(--teal-dark);
  font-weight: 800;
}
.kpi {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 6px 18px rgba(26,45,58,.04);
}
.kpi span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 9px; }
.kpi strong { display: block; font-size: 22px; line-height: 1.1; }
.kpi.actual strong { color: var(--teal-dark); }
.kpi.balance strong { color: var(--green); }

.content-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
}
.panel-title h2 { margin: 0; font-size: 16px; }
.panel-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.monitor-title {
  justify-content: center;
  text-align: center;
}
.monitor-title h2 {
  font-size: 17px;
}
.soft-button, .primary-button {
  border: 0;
  border-radius: 6px;
  min-height: var(--control-height);
  padding: 8px 12px;
}
.soft-button { background: var(--surface-2); color: var(--teal-dark); }
.primary-button { background: var(--teal); color: white; }
.soft-button:hover { background: #e3edf1; }
.primary-button:hover { background: var(--teal-dark); }

.report-menu-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
  max-width: 100%;
  overflow-x: clip;
}
.report-menu-bar label,
.menu-group {
  display: grid;
  gap: 5px;
  min-width: 0;
}
.report-menu-bar label span,
.menu-group > span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  margin-bottom: 0;
}
.report-menu-bar input,
.report-menu-bar select,
.report-menu-bar .month-menu-button,
.report-menu-bar .soft-button,
.report-menu-bar .segmented {
  height: var(--control-height);
}
.report-menu-bar input[type="number"] {
  width: 88px;
  text-align: center;
}
.scale-control {
  min-width: 150px;
}
.scale-control span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.scale-control b {
  color: var(--teal-dark);
}
.report-menu-bar .scale-control input[type="range"] {
  width: 150px;
  min-height: var(--control-height);
  height: var(--control-height);
  padding: 0;
  accent-color: var(--teal);
}
.column-menu {
  position: relative;
}
.column-menu::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 8px;
}
.column-menu-button {
  display: flex;
  align-items: center;
  width: 164px;
  min-width: 164px;
  max-width: 164px;
  height: var(--control-height);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--ink);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.column-menu-button::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-right: 1.7px solid currentColor;
  border-bottom: 1.7px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  opacity: .7;
  flex: 0 0 auto;
}
.column-popover {
  position: absolute;
  left: 0;
  top: 100%;
  width: 218px;
  padding: 8px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 32;
  opacity: 0;
  pointer-events: none;
  transform: translateY(0);
  transition: opacity .12s ease, transform .12s ease;
}
.column-menu:hover .column-popover,
.column-menu.open .column-popover,
.column-menu:focus-within .column-popover {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(4px);
}
.column-choice {
  min-height: 30px;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
.column-choice span {
  display: block;
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
  font-size: inherit;
  line-height: 1.2;
}
.column-choice:hover {
  background: #f3f8fa;
}
.column-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.column-choice::before {
  content: "";
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border: 1px solid #b9c7d1;
  border-radius: 4px;
  color: white;
  background: white;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  flex: 0 0 auto;
}
.column-choice.checked::before {
  content: "✓";
  background: var(--teal);
  border-color: var(--teal);
}
.report-menu-bar .segmented {
  align-items: center;
  padding: 3px;
  min-width: 0;
}
.report-menu-bar .segmented button {
  min-width: 64px;
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
}
.report-menu-bar .month-menu-button {
  display: flex;
  align-items: center;
  width: 158px;
  min-width: 158px;
  max-width: 158px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}
.report-menu-bar .column-menu-button {
  height: var(--control-height);
}
.report-menu-bar .month-menu-button::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-right: 1.7px solid currentColor;
  border-bottom: 1.7px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  opacity: .7;
  flex: 0 0 auto;
}
.report-menu-bar .soft-button {
  border: 1px solid var(--line);
  background: white;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
  padding: 0 13px;
}
.menu-action {
  margin-left: auto;
}
.workday-rate {
  display: grid;
  gap: 5px;
  flex: 1 1 300px;
  min-width: min(300px, 100%);
  max-width: 100%;
}
.workday-rate > span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}
.rate-chips {
  display: flex;
  flex-wrap: wrap;
  height: var(--control-height);
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  padding: 4px 6px;
}
.rate-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  height: 28px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 800;
}
.rate-chip.safe { background: #e7f5ed; color: var(--green); }
.rate-chip.watch { background: #fff4df; color: var(--amber); }
.rate-chip.danger { background: #fdebea; color: var(--red); }

.table-wrap { overflow: auto; max-width: 100%; }
table {
  width: auto;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}
.monitor-table {
  width: max-content;
  table-layout: fixed;
  font-size: calc(12px * var(--table-scale, 1));
}
th {
  position: sticky;
  top: 0;
  background: #eef4f6;
  color: #40515f;
  z-index: 1;
  text-align: right;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid #dfe7ed;
  padding: 9px 8px;
  white-space: nowrap;
  user-select: none;
}
.monitor-table th {
  text-align: center;
  padding: calc(9px * var(--table-scale, 1)) calc(8px * var(--table-scale, 1));
}
.monitor-table th span {
  display: block;
  margin-top: 2px;
  color: #667684;
  font-size: calc(10px * var(--table-scale, 1));
  font-weight: 600;
}
.monitor-table th,
.monitor-table td {
  position: relative;
}
.monitor-table .hidden-col,
.hidden-col {
  display: none !important;
}
.monitor-table .fixed-col {
  position: sticky;
  background: white;
  background-clip: padding-box;
  z-index: 3;
}
.monitor-table th.fixed-col {
  background: #eef4f6;
  z-index: 5;
}
.monitor-table .col-group { z-index: 10; }
.monitor-table .col-sequence { z-index: 9; }
.monitor-table .col-code { z-index: 8; }
.monitor-table .col-doc { z-index: 7; }
.monitor-table .col-item { z-index: 6; }
.monitor-table .col-annualBudget { z-index: 5; }
.monitor-table .col-monthlyBudget { z-index: 4; }
.monitor-table .col-actual { z-index: 3; }
.monitor-table .col-variance { z-index: 3; }
.monitor-table .col-usedPct { z-index: 3; }
.monitor-table .col-status { z-index: 3; }
.monitor-table th.col-group,
.monitor-table th.col-sequence,
.monitor-table th.col-code,
.monitor-table th.col-doc,
.monitor-table th.col-item,
.monitor-table th.col-annualBudget,
.monitor-table th.col-monthlyBudget,
.monitor-table th.col-actual,
.monitor-table th.col-variance,
.monitor-table th.col-usedPct,
.monitor-table th.col-status {
  z-index: 20;
}
.monitor-table .col-group { left: 0; }
.monitor-table .col-sequence { left: var(--sticky-1, 160px); }
.monitor-table .col-code { left: var(--sticky-2, 212px); }
.monitor-table .col-doc { left: var(--sticky-3, 324px); }
.monitor-table .col-item { left: var(--sticky-4, 398px); }
.monitor-table .col-annualBudget { left: var(--sticky-5, 588px); }
.monitor-table .col-monthlyBudget { left: var(--sticky-6, 718px); }
.monitor-table .col-actual { left: var(--sticky-7, 836px); }
.monitor-table .col-variance { left: var(--sticky-8, 946px); }
.monitor-table .col-usedPct { left: var(--sticky-9, 1058px); }
.monitor-table .col-status {
  left: var(--sticky-10, 1150px);
  box-shadow: 8px 0 12px rgba(26,45,58,.06);
}
.monitor-table .col-group,
.monitor-table .col-sequence,
.monitor-table .col-code,
.monitor-table .col-doc,
.monitor-table .col-item,
.monitor-table .col-annualBudget,
.monitor-table .col-monthlyBudget,
.monitor-table .col-actual,
.monitor-table .col-variance,
.monitor-table .col-usedPct,
.monitor-table .col-status {
  border-right-color: #8fa3b1;
  box-shadow: inset -1px 0 #8fa3b1;
}
td {
  border-bottom: 1px solid #edf1f4;
  border-right: 1px solid #edf1f4;
  padding: 8px;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.data-row td {
  padding: calc(5px * var(--table-scale, 1)) calc(6px * var(--table-scale, 1));
  line-height: 1.15;
}
.category-label {
  display: inline-block;
  vertical-align: middle;
}
.sum-button {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: right;
  font: inherit;
  line-height: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: #93a8b6;
  text-underline-offset: 2px;
}
.sum-button:hover {
  color: var(--teal-dark);
  text-decoration-color: var(--teal-dark);
}
.sum-button:focus-visible {
  outline-offset: 1px;
}
.monitor-table .col-item,
.monitor-table .col-code {
  text-align: left;
}
.monitor-table .col-group,
.monitor-table .col-sequence,
.monitor-table .col-doc {
  text-align: center;
}
.monitor-table th.col-group,
.monitor-table th.col-sequence,
.monitor-table th.col-code,
.monitor-table th.col-doc,
.monitor-table th.col-item {
  text-align: center;
}
.monitor-table td.col-annualBudget,
.monitor-table td.col-monthlyBudget,
.monitor-table td.col-actual,
.monitor-table td.col-variance {
  text-align: right;
}
.monitor-table .col-usedPct,
.monitor-table .col-status {
  text-align: center;
}
.group-cell {
  color: var(--teal-dark);
  font-weight: 800;
  vertical-align: middle;
  text-align: center;
  border-right: 1px solid #edf1f4;
  line-height: 1.25;
}
.data-row.group-start > .col-group,
.data-row.group-start > .col-sequence,
.data-row.group-start > .col-code,
.data-row.group-start > .col-doc,
.data-row.group-start > .col-item,
.data-row.group-start > .col-annualBudget,
.data-row.group-start > .col-monthlyBudget,
.data-row.group-start > .col-actual,
.data-row.group-start > .col-variance,
.data-row.group-start > .col-usedPct,
.data-row.group-start > .col-status {
  border-top: 1px solid #8fa3b1;
}
.data-row.group-end > .col-sequence,
.data-row.group-end > .col-code,
.data-row.group-end > .col-doc,
.data-row.group-end > .col-item,
.data-row.group-end > .col-annualBudget,
.data-row.group-end > .col-monthlyBudget,
.data-row.group-end > .col-actual,
.data-row.group-end > .col-variance,
.data-row.group-end > .col-usedPct,
.data-row.group-end > .col-status {
  border-bottom: 1px solid #8fa3b1;
}
.data-row.group-start > .group-cell {
  border-bottom: 1px solid #8fa3b1;
}
.section-spacer-row td {
  height: 18px;
  padding: 0;
  border: 0;
  background: var(--surface);
}
.section-row td {
  background: #f8fafb;
  color: var(--teal-dark);
  font-weight: 800;
  text-align: left;
  padding-top: 13px;
}
.monitor-table .section-row td:first-child,
.monitor-table .subtotal-row td:first-child,
.monitor-table .empty-row td:first-child {
  position: sticky;
  left: 0;
  z-index: 4;
}
.subtotal-row td {
  background: #e2f1f4;
  color: var(--teal-dark);
  font-weight: 800;
  border-top: 2px solid #8fb5bf;
  border-bottom: 2px solid #8fb5bf;
  padding: 8px;
  line-height: 1.25;
}
.sub-row td {
  background: #fbfcfd;
  color: #425362;
  font-size: 11px;
  padding: 4px 6px;
  line-height: 1.15;
}
.sub-row:hover td { background: #f7fbfc; }
.data-row td.col-group,
.data-row td.col-sequence,
.data-row td.col-code,
.data-row td.col-doc,
.data-row td.col-item { background: #f8fafc; }
.data-row td.col-annualBudget,
.data-row td.col-monthlyBudget { background: #fff8e8; }
.data-row td.col-actual { background: #eef8f4; }
.data-row td.col-variance,
.data-row td.col-usedPct,
.data-row td.col-status { background: #f7f9fc; }
.data-row:hover td.col-group,
.data-row:hover td.col-sequence,
.data-row:hover td.col-code,
.data-row:hover td.col-doc,
.data-row:hover td.col-item { background: #eef5f8; }
.data-row:hover td.col-annualBudget,
.data-row:hover td.col-monthlyBudget { background: #fff2d2; }
.data-row:hover td.col-actual { background: #e2f3ec; }
.data-row:hover td.col-variance,
.data-row:hover td.col-usedPct,
.data-row:hover td.col-status { background: #eef3f7; }
.subtotal-row td.fixed-col { background: #edf6f8; }
.sub-row td.fixed-col { background: #fbfcfd; }
.sub-row:hover td.fixed-col { background: #f7fbfc; }
.monitor-table .col-status {
  border-right: 1px solid #cfdbe3;
}
.sub-indent {
  display: inline-flex;
  align-items: center;
  padding-left: 28px;
  color: #425362;
}
.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 24px;
}
.data-row:hover td { background: #fbfdfe; }
.expand-button,
.expand-spacer {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  margin-right: 5px;
}
.expand-button {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: white;
  color: var(--teal-dark);
}
.expand-button::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.8px solid currentColor;
  border-bottom: 1.8px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .15s ease;
}
.expand-button.open::before {
  transform: rotate(45deg);
}
.link-button {
  border: 0;
  color: var(--teal-dark);
  background: transparent;
  padding: 0;
  font-weight: 700;
}
.col-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  z-index: 2;
}
.col-resizer:hover {
  background: rgba(11, 111, 127, .18);
}
.negative { color: var(--red); font-weight: 700; }
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
}
.monitor-table .pill {
  min-width: calc(60px * var(--table-scale, 1));
  padding: calc(3px * var(--table-scale, 1)) calc(8px * var(--table-scale, 1));
  font-size: calc(11px * var(--table-scale, 1));
}
.pill.ok { background: #e7f5ed; color: var(--green); }
.pill.watch { background: #fff4df; color: var(--amber); }
.pill.danger { background: #fdebea; color: var(--red); }
.pill.no-budget { background: #eef1f3; color: var(--muted); }

.import-panel { padding-bottom: 16px; }
.import-drop {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 18px 16px;
}
.import-drop input {
  min-height: 42px;
  border-style: dashed;
  flex: 1;
}
.import-result {
  margin: 0 16px 16px;
  border: 1px solid var(--line);
  background: #fbfcfd;
  border-radius: 8px;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
}
.import-result.blocked {
  border-color: #efb5af;
  background: #fff5f4;
  color: var(--red);
  font-weight: 800;
}
.issues { margin: 0 16px 16px; border: 1px solid var(--line); border-radius: 8px; }

.budget-auth {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}
.budget-input {
  width: 130px;
  text-align: right;
}
.budget-input:disabled {
  color: var(--muted);
  background: #f4f6f8;
}
.budget-confirm-bar {
  display: flex;
  justify-content: flex-end;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: #fbfcfd;
}
.budget-confirm-bar .primary-button {
  min-width: 245px;
  font-weight: 800;
}

.present-panel {
  background: #f7fafb;
}
.present-title {
  background: white;
}
.present-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.present-actions a {
  text-decoration: none;
}
.file-button {
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}
.present-menu-bar {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.template-status {
  display: grid;
  grid-template-columns: minmax(190px, 1.3fr) minmax(160px, .9fr) minmax(170px, .9fr) minmax(260px, 1.5fr);
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fbfc;
}
.template-status span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}
.template-status strong {
  display: block;
  margin-top: 3px;
  font-size: 13px;
}
.template-status p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.present-deck {
  display: grid;
  gap: 14px;
  padding: 16px;
}
.present-hero,
.present-section {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.present-hero {
  display: grid;
  grid-template-columns: 1fr 1.8fr;
  gap: 18px;
  padding: 18px;
  align-items: center;
}
.present-hero span,
.present-section-head span,
.present-risk-row span {
  color: var(--muted);
  font-size: 12px;
}
.present-hero h3 {
  margin: 6px 0;
  font-size: 26px;
}
.present-hero p {
  margin: 0;
  color: var(--muted);
}
.present-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.present-kpi-grid article {
  border: 1px solid #dbe6eb;
  border-radius: 7px;
  padding: 12px;
  background: #fbfdfe;
}
.present-kpi-grid span,
.present-kpi-grid strong {
  display: block;
}
.present-kpi-grid strong {
  margin-top: 7px;
  font-size: 18px;
}
.present-section {
  padding: 14px;
}
.present-section-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: baseline;
  margin-bottom: 10px;
}
.present-section-head h3 {
  margin: 0;
  font-size: 15px;
}
.present-summary-table {
  display: grid;
  border: 1px solid #dbe6eb;
  border-radius: 7px;
  overflow: hidden;
}
.present-summary-header,
.present-summary-row {
  display: grid;
  grid-template-columns: 1.35fr repeat(5, minmax(86px, 1fr)) 78px;
  gap: 0;
}
.present-summary-header span,
.present-summary-row span,
.present-summary-row strong {
  padding: 9px 10px;
  border-right: 1px solid #e4ebef;
  text-align: right;
}
.present-summary-header span:first-child,
.present-summary-row span:first-child {
  text-align: left;
}
.present-summary-header {
  background: #eef4f6;
  color: #40515f;
  font-weight: 800;
  font-size: 12px;
}
.present-summary-row {
  border-top: 1px solid #edf1f4;
  background: white;
}
.present-summary-row.total {
  background: #e2f1f4;
  color: var(--teal-dark);
  font-weight: 800;
}
.present-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.present-rate-card {
  min-height: 120px;
  display: grid;
  gap: 10px;
  align-content: center;
  padding: 14px;
  border: 1px solid #edf1f4;
  border-radius: 7px;
  background: #fbfdfe;
}
.present-rate-card .workday-rate {
  width: 100%;
}
.present-rate-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.present-bars,
.present-risk-list {
  display: grid;
  gap: 7px;
}
.present-bar-row {
  display: grid;
  grid-template-columns: 38px 1fr 82px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}
.present-bar-row div {
  height: 9px;
  border-radius: 999px;
  background: #edf2f5;
  overflow: hidden;
}
.present-bar-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}
.present-bar-row b {
  text-align: right;
  font-weight: 700;
}
.present-risk-row {
  display: grid;
  grid-template-columns: 1fr 62px 78px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid #edf1f4;
  border-radius: 7px;
  background: #fbfdfe;
}
.present-risk-row strong,
.present-risk-row span {
  display: block;
}
.present-risk-row b {
  text-align: right;
}
.present-empty {
  border: 1px dashed var(--line);
  border-radius: 7px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(460px, 96vw);
  height: 100vh;
  background: white;
  border-left: 1px solid var(--line);
  box-shadow: -16px 0 38px rgba(18,32,43,.16);
  z-index: 20;
  display: flex;
  flex-direction: column;
}
.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h2 { margin: 0; font-size: 17px; }
.drawer-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.icon-button {
  border: 1px solid var(--line);
  background: white;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  font-size: 22px;
  line-height: 1;
}
.drawer-section {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  overflow: auto;
}
.drawer-section h3 { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.drill-row, .transaction-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid #edf1f4;
}
.drill-row span { color: var(--ink); }
.transaction-row div {
  min-width: 0;
}
.transaction-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 270px;
  font-size: 12px;
}
.transaction-row span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 3px;
}
.transaction-row b { white-space: nowrap; }
.muted { color: var(--muted); }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    min-height: auto;
    overflow: visible;
  }
  .nav-list { grid-template-columns: repeat(3, 1fr); }
  .topbar { align-items: stretch; flex-direction: column; }
  .toolbar { flex-wrap: wrap; }
  .menu-action { margin-left: 0; }
  .kpi-grid, .present-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .month-popover { left: 0; right: auto; }
}

@media (max-width: 760px) {
  .report-menu-bar {
    align-items: stretch;
    gap: 10px;
  }
  .report-menu-bar label,
  .report-menu-bar .menu-group,
  .report-menu-bar .workday-rate,
  .report-menu-bar .menu-action {
    flex: 1 1 180px;
  }
  .report-menu-bar .segmented {
    width: 100%;
  }
  .report-menu-bar .segmented button {
    flex: 1 1 0;
    min-width: 0;
    padding-inline: 6px;
  }
  .report-menu-bar .month-menu,
  .report-menu-bar .month-menu-button,
  .report-menu-bar .soft-button {
    width: 100%;
    max-width: none;
  }
  .report-menu-bar .scale-control input[type="range"] {
    width: 100%;
  }
  .rate-chips {
    height: auto;
    min-height: var(--control-height);
  }
  .rate-chip {
    flex: 1 1 86px;
    min-width: 0;
  }
}

@media (max-width: 620px) {
  .workspace { padding: 14px; }
  .kpi-grid, .present-grid { grid-template-columns: 1fr; }
  .nav-list { grid-template-columns: 1fr 1fr; }
  .month-checkboxes { grid-template-columns: repeat(3, 1fr); }
}
