/* Shared editing controls for the source-data tables. */
.sheet-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 22px;
  min-width: 0;
  padding: 16px 18px;
  border: 1px solid #c5dacb;
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  background: #f0f7f0;
}
.sheet-toolbar-copy { display: grid; flex: 1 1 240px; min-width: 0; gap: 4px; }
.sheet-toolbar-copy strong { color: #20543e; font-size: 13px; font-weight: 700; }
.sheet-toolbar-copy small { color: #597362; font-size: 11px; line-height: 1.7; overflow-wrap: anywhere; }
.sheet-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.sheet-actions .btn.small { min-height: 36px; padding: 8px 12px; font-size: 11px; }
.sheet-status { color: #42664c; font-size: 11px; font-weight: 600; overflow-wrap: anywhere; }
.sheet-status:empty { display: none; }
.sheet-status.sheet-error, .sheet-status[data-state="error"], .sheet-error .sheet-status { color: #a83e33; }
.sheet-status[data-state="dirty"] { color: #805c13; }
.sheet-saving { border-color: #b4d0be; background: #eaf4ee; }
.sheet-saving .sheet-status { color: var(--accent); }
.sheet-help { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 14px; min-width: 0; color: #63776a; font-size: 11px; line-height: 1.7; }
.sheet-help kbd { padding: 2px 5px; border: 1px solid #d8e1da; border-bottom-width: 2px; border-radius: 4px; background: #fff; color: #425b4b; font: 10px var(--font-num); white-space: nowrap; }
.sheet-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border: 1px solid #d2e1d4; border-radius: 6px; background: #edf5eb; color: #48644d; font-size: 10px; font-weight: 600; white-space: nowrap; }
.sheet-table th, .sheet-table td { border-right: 1px solid #e8eee8; }
.sheet-table th:last-child, .sheet-table td:last-child { border-right: 0; }
.sheet-table tr.total td { border-right-color: #ffffff24; }
.sheet-table tr.day td { border-right-color: #d7e5d5; }
td.sheet-cell { position: relative; padding: 0; cursor: cell; min-width: 110px; touch-action: manipulation; }
td.sheet-cell.n { min-width: 95px; }
td.sheet-cell[data-key="ten"], td.sheet-cell[data-key="nguoi"] { min-width: 150px; }
td.sheet-cell[data-key="ngay"] { min-width: 125px; }
td.sheet-cell:hover { box-shadow: inset 0 0 0 1px #aac6b0; }
td.sheet-cell:focus, td.sheet-cell:focus-within, td.sheet-cell.sheet-selected { outline: 2px solid #32734e; outline-offset: -2px; z-index: 1; }
td.sheet-cell:focus-visible { outline-width: 3px; }
td.sheet-cell.sheet-selected { background: #eef7ef; }
td.sheet-cell.sheet-dirty, tbody tr:hover td.sheet-cell.sheet-dirty { background: #fff6d9; }
td.sheet-cell.sheet-dirty::after { content: ''; position: absolute; top: 0; right: 0; width: 0; height: 0; border-top: 7px solid #ba892d; border-left: 7px solid transparent; pointer-events: none; }
td.sheet-cell.sheet-editing { padding: 0; background: #fff; cursor: text; }
td.sheet-cell .sheet-editor {
  display: block;
  width: 100%;
  min-width: 90px;
  min-height: 44px;
  margin: 0;
  padding: 10px 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 1.6;
  box-sizing: border-box;
}
td.sheet-cell.n .sheet-editor { min-width: 95px; text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
td.sheet-cell .sheet-editor:focus { outline: 0; box-shadow: none; background: #ffffff80; }
td.sheet-cell .sheet-editor:invalid, td.sheet-cell .sheet-editor[aria-invalid="true"] { box-shadow: inset 0 0 0 2px #b45140; background: #fff8f5; }
td.sheet-cell select.sheet-editor { padding-right: 26px; cursor: pointer; }
td.sheet-cell[data-key="ten"] .sheet-editor, td.sheet-cell[data-key="nguoi"] .sheet-editor { min-width: 150px; }
td.sheet-cell[data-key="ngay"] .sheet-editor { min-width: 125px; }
td.sheet-cell input[type="date"].sheet-editor { min-width: 145px; }
td.sheet-cell textarea.sheet-editor { min-width: 170px; height: 44px; max-height: 160px; resize: vertical; overflow: auto; white-space: pre-wrap; }
td.sheet-cell .sheet-editor:disabled { color: #63776a; background: #f3f6f2; cursor: wait; opacity: .7; }
tbody tr:not(.day):not(.total) td.sheet-formula { background: #f1f7ee; color: #426247; }
tbody tr:not(.day):not(.total):hover td.sheet-formula { background: #e9f2e5; }
tbody tr:not(.day):not(.total) td.sheet-formula.sum { color: #174e39; font-weight: 700; }
tbody tr:not(.day):not(.total) td.sheet-formula.neg { color: #963f32; }
.sheet-row-number { width: 38px; min-width: 38px; padding-inline: 8px; text-align: center; color: #738577; background: #f6f9f4; font: 10px var(--font-num); user-select: none; }
@media (max-width: 700px) {
  .sheet-toolbar { padding: 13px; gap: 11px; }
  .sheet-toolbar-copy { flex-basis: 100%; }
  .sheet-toolbar-copy strong { font-size: 12px; }
  .sheet-toolbar-copy small { font-size: 11px; }
  .sheet-status { flex: 1 1 100%; }
  .sheet-actions { flex: 1 1 100%; }
  .sheet-actions .btn.small { min-height: 42px; }
  td.sheet-cell .sheet-editor { font-size: 16px; min-height: 46px; }
  td.sheet-cell[data-key="ngay"] .sheet-editor { min-width: 135px; }
  td.sheet-cell input[type="date"].sheet-editor { min-width: 160px; }
  td.sheet-cell textarea.sheet-editor { height: 46px; }
  .sheet-help { font-size: 10px; gap: 6px 10px; }
}
.sheet-toolbar { position: sticky; top: var(--sheet-top, 88px); z-index: 19; margin: 12px 34px 0; box-shadow: 0 6px 18px #244b3010; }
@media (max-width: 899px) { .sheet-toolbar { margin-inline: 16px; } }
@media (max-width: 400px) { .sheet-actions { gap: 5px; } .sheet-actions .btn.small { padding-inline: 8px; font-size: 10px; } }
