/* Kế hoạch dự kiến (16/11/2026): tabs, the period chooser, three KPIs and the eight-column table, on the panel's own background. */
#forecast-workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; min-width: 0; }
.forecast-department { font-size: 18px; font-weight: 600; color: var(--ui-accent); white-space: nowrap; }
.forecast-department-select { width: auto; min-width: 9rem; font-weight: 600; color: var(--ui-accent); }

/* Tabs: the open one underlined in dark blue, a thin line under the row. */
.forecast-tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--ui-border); }
.workspace-v2 .forecast-tab { min-height: 44px; padding: 8px 14px; margin-bottom: -1px; background: transparent; border: 0; border-bottom: 3px solid transparent;
  border-radius: 0; box-shadow: none; color: var(--ui-muted); font-size: 16px; font-weight: 500; cursor: pointer; }
.workspace-v2 .forecast-tab[aria-selected="true"] { color: var(--ui-primary); border-bottom-color: var(--ui-primary); font-weight: 700; }
.workspace-v2 .forecast-tab:hover { color: var(--ui-primary); background: transparent; }

.forecast-panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; min-width: 0; }
.forecast-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--ui-border); }

/* ‹ [kỳ đang xem] ›: three boxes the height of an input, 8 px apart; the middle box keeps one width on both tabs. */
.forecast-period { display: flex; align-items: center; gap: 8px; min-width: 0; }
.workspace-v2 .forecast-period .forecast-step { box-sizing: border-box; width: var(--ui-control, 44px); height: var(--ui-control, 44px); min-height: 0; padding: 0;
  display: inline-grid; place-items: center; flex: none; }
.forecast-period-anchor { position: relative; flex: 0 1 17rem; width: 17rem; min-width: 0; }
.workspace-v2 .forecast-period-box { box-sizing: border-box; width: 100%; height: var(--ui-control, 44px);
  min-height: 0; padding: 0 12px; background: var(--ui-input); color: var(--ui-ink); border: 1px solid var(--ui-input-border); border-radius: 6px;
  font-size: 17px; font-weight: 700; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; cursor: pointer; box-shadow: none; }
.workspace-v2 .forecast-period-box:hover { border-color: var(--ui-accent); background: var(--ui-input); }
.forecast-chooser { position: absolute; z-index: 20; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); width: max(100%, 17rem); box-sizing: border-box;
  padding: 10px; background: var(--ui-input); border: 1px solid var(--ui-border); border-radius: 8px; box-shadow: 0 8px 24px var(--ui-shadow); display: grid; gap: 8px; }
.forecast-chooser-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.workspace-v2 .forecast-chooser .forecast-step { width: 36px; height: 36px; min-height: 0; padding: 0; display: inline-grid; place-items: center; }
.forecast-chooser-weeks { display: grid; gap: 4px; }
.forecast-chooser-months { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.workspace-v2 .forecast-choice { min-height: 40px; padding: 6px 8px; background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--ui-ink);
  font-weight: 500; font-variant-numeric: tabular-nums; box-shadow: none; cursor: pointer; }
.workspace-v2 .forecast-choice:hover { background: var(--ui-hover); }
.workspace-v2 .forecast-choice[aria-current="true"] { background: var(--ui-selected); border-color: var(--ui-accent); color: var(--ui-primary); font-weight: 700; }
/* Lưu · Hủy (and Xóa for a saved row) at the top right of the week row while a row is open. */
.forecast-edit-bar { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.workspace-v2 .forecast-edit-bar :is(.forecast-save, .forecast-cancel) { min-height: var(--ui-control, 44px); padding-inline: 18px; font-weight: 600; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; text-align: center; }
.workspace-v2 .forecast-edit-bar .forecast-remove { width: var(--ui-control, 44px); height: var(--ui-control, 44px); min-height: 0; padding: 0; display: inline-grid; place-items: center; }
/* + under the last row, left-aligned, as in Tạo kế hoạch sản xuất. */
.workspace-v2 .forecast-add { justify-self: start; width: 44px; height: 44px; min-height: 0; padding: 0; display: inline-grid; place-items: center; }

/* KPIs: three figures split by thin vertical lines. */
.forecast-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 12px 0; border-bottom: 1px solid var(--ui-border); }
.forecast-kpi { display: grid; gap: 4px; padding: 2px 20px; min-width: 0; }
.forecast-kpi:first-child { padding-left: 8px; }
.forecast-kpi + .forecast-kpi { border-left: 1px solid var(--ui-border); }
.forecast-kpi-label { color: var(--ui-muted); font-size: 15px; }
.forecast-kpi-value { color: var(--ui-primary); font-size: 26px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* The table keeps its frame. */
.forecast-lines { padding-top: 16px; display: grid; gap: 12px; min-width: 0; }
.forecast-table-scroll { max-width: 100%; min-width: 0; overflow-x: auto; }
.forecast-table { width: 100%; min-width: 900px; border-collapse: collapse; table-layout: fixed; }
.forecast-table :is(th, td) { padding: 8px 12px; border: 1px solid var(--ui-border); text-align: left; vertical-align: middle; overflow-wrap: anywhere; }
.forecast-table th { background: var(--ui-surface-muted); color: var(--ui-ink); font-weight: 700; white-space: normal; overflow-wrap: normal; }
.forecast-table :is(th, td):first-child { text-align: center; }
.forecast-table th:nth-child(1) { width: 6%; } .forecast-table th:nth-child(2) { width: 17%; } .forecast-table th:nth-child(3) { width: 16%; }
.forecast-table th:nth-child(4) { width: 11%; } .forecast-table th:nth-child(5) { width: 12%; } .forecast-table th:nth-child(6) { width: 14%; }
.forecast-table th:nth-child(7) { width: 10%; } .forecast-table th:nth-child(8) { width: 14%; }
.forecast-table :is(th, td):nth-child(5) { text-align: right; font-variant-numeric: tabular-nums; }
.forecast-table td:nth-child(4) { font-variant-numeric: tabular-nums; white-space: nowrap; }
.forecast-editable { cursor: pointer; }
.forecast-editable:is(:hover, :focus-visible) { background: var(--ui-hover); }
.forecast-edit-row td { padding: 4px 6px; }
.forecast-edit-row input { box-sizing: border-box; width: 100%; min-width: 0; padding-inline: 8px; }
.forecast-edit-row :is(input, select) { box-sizing: border-box; width: 100%; min-width: 0; }
.forecast-edit-row select { padding-inline: 6px; }
.forecast-edit-row td:nth-child(5) input { text-align: right; }
/* Ngày dự kiến: read-only box that opens the week's calendar. */
.forecast-date-input { cursor: pointer; font-variant-numeric: tabular-nums; }
.forecast-calendar { position: fixed; inset: auto; margin: 0; box-sizing: border-box; width: min(18rem, calc(100vw - 16px)); padding: 10px;
  background: var(--ui-input); color: var(--ui-ink); border: 1px solid var(--ui-border); border-radius: 8px; box-shadow: 0 8px 24px var(--ui-shadow); }
.forecast-calendar-title { display: block; margin-bottom: 8px; text-align: center; font-variant-numeric: tabular-nums; }
.forecast-calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.forecast-calendar-weekday { text-align: center; font-size: 13px; color: var(--ui-muted); }
.workspace-v2 .forecast-calendar-day { min-height: 36px; padding: 0; background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--ui-ink);
  font-weight: 600; font-variant-numeric: tabular-nums; box-shadow: none; cursor: pointer; }
.workspace-v2 .forecast-calendar-day:hover { background: var(--ui-hover); }
.workspace-v2 .forecast-calendar-day.is-today { border-color: var(--ui-border); }
.workspace-v2 .forecast-calendar-day[aria-pressed="true"] { background: var(--ui-primary); color: var(--ui-on-primary); border-color: var(--ui-primary); }
/* Độ sụt: two number boxes with a fixed ± between them. */
.forecast-slump { display: flex; align-items: center; gap: 4px; }
.forecast-slump input { flex: 1 1 0; text-align: center; padding-inline: 4px; }
.forecast-slump-sign { flex: none; font-weight: 600; }
.forecast-empty { text-align: center !important; padding: 16px !important; }

@media (max-width: 720px) {
  .forecast-toolbar { align-items: stretch; }
  .forecast-toolbar .forecast-edit-bar { flex: 1 1 100%; }
  .forecast-toolbar .forecast-edit-bar :is(.forecast-save, .forecast-cancel) { flex: 1 1 0; }
  .workspace-v2 .forecast-period-box { font-size: 15px; padding-inline: 8px; }
  .forecast-kpis { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .forecast-kpi { padding: 8px 0; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; }
  .forecast-kpi:first-child { padding-left: 0; }
  .forecast-kpi + .forecast-kpi { border-left: 0; border-top: 1px solid var(--ui-border); }
  .forecast-kpi-value { font-size: 22px; }
  .workspace-v2 .forecast-tab { flex: 1 1 0; padding-inline: 8px; }
}
/* Phone width: the whole week range fits the middle box. */
@media (max-width: 440px) {
  .workspace-v2 .forecast-period-box { font-size: 14px; padding-inline: 4px; letter-spacing: -0.01em; }
}
