/* DataGrid: spreadsheet-style data entry. Theme it by overriding the --dg-* variables on .dg (see style.css) */
.dg {
  --dg-ink: #1c2733;
  --dg-muted: #5d6b7a;
  --dg-line: #d5dde6;
  --dg-soft: #f2f5f8;
  --dg-bg: #ffffff;
  --dg-accent: #1f5fbf;
  --dg-bad: #b42318;
  --dg-bad-bg: #fdecea;
  --dg-warn: #a15c07;
  --dg-warn-bg: #fff5e0;
  --dg-ok: #26734d;
  --dg-mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, Menlo, monospace;
  color: var(--dg-ink);
  margin: 0.4rem 0 0.9rem;
}
.dg-source { display: none !important; }

.dg-bar { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin-bottom: 0.5rem; }
.dg-spacer { flex: 1; }
.dg-btn {
  font: inherit; font-size: 0.85rem; line-height: 1.2;
  padding: 0.42rem 0.75rem; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--dg-line); background: var(--dg-bg); color: var(--dg-ink);
}
.dg-btn:hover { border-color: var(--dg-accent); color: var(--dg-accent); }
.dg-btn:focus-visible { outline: 2px solid var(--dg-accent); outline-offset: 2px; }
.dg-btn.dg-primary { background: var(--dg-accent); border-color: var(--dg-accent); color: #fff; }
.dg-btn.dg-primary:hover { filter: brightness(1.08); color: #fff; }
.dg-btn.dg-quiet { border-color: transparent; background: transparent; color: var(--dg-muted); }
.dg-btn.dg-quiet:hover { color: var(--dg-accent); }
.dg-btn[hidden] { display: none; }

.dg-scroll {
  overflow: auto; max-height: 440px;
  border: 1px solid var(--dg-line); border-radius: 9px; background: var(--dg-bg);
}
.dg-text-mode .dg-scroll { display: none; }
.dg .dg-table { border-collapse: separate; border-spacing: 0; width: auto; min-width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
.dg .dg-table th, .dg .dg-table td {
  padding: 0; text-align: left; border: 0;
  border-right: 1px solid var(--dg-line); border-bottom: 1px solid var(--dg-line);
  font-family: inherit; text-transform: none; letter-spacing: 0; color: inherit;
}
.dg .dg-table tr > :last-child { border-right: 0; }
.dg .dg-table thead th { position: sticky; top: 0; z-index: 2; background: var(--dg-soft); border-bottom: 2px solid var(--dg-line); }
.dg .dg-table tfoot th, .dg .dg-table tfoot td { position: sticky; bottom: 0; z-index: 2; background: var(--dg-soft); border-bottom: 0; border-top: 1px solid var(--dg-line); }
.dg .dg-table .dg-corner, .dg .dg-table .dg-rn {
  position: sticky; left: 0; z-index: 1; background: var(--dg-soft);
  min-width: 2.6rem; padding: 0 0.5rem; text-align: center;
  font-size: 0.72rem; font-weight: 600; color: var(--dg-muted); white-space: nowrap;
}
.dg .dg-table thead .dg-corner, .dg .dg-table tfoot .dg-rn { z-index: 3; }

.dg .dg-headwrap { display: flex; align-items: center; }
.dg .dg-cell, .dg .dg-head {
  display: block; width: 100%; min-width: 7.5rem; box-sizing: border-box; margin: 0;
  border: 0; border-radius: 0; background: transparent; color: inherit; outline: none; box-shadow: none;
  padding: 0.5rem 0.65rem; font-family: inherit; font-size: 0.95rem; font-weight: 400;
}
.dg .dg-cell { font-family: var(--dg-mono); font-size: 0.9rem; }
.dg .dg-cell.dg-text { font-family: inherit; }
.dg .dg-head { font-weight: 650; }
.dg .dg-head::placeholder { color: var(--dg-muted); font-weight: 500; opacity: 0.85; }
.dg .dg-cell:focus, .dg .dg-head:focus { background: var(--dg-bg); border: 0; box-shadow: inset 0 0 0 2px var(--dg-accent); }
.dg .dg-cell.dg-bad { background: var(--dg-bad-bg); color: var(--dg-bad); box-shadow: inset 3px 0 0 var(--dg-bad); }
.dg .dg-half .dg-cell { background: var(--dg-warn-bg); }
.dg .dg-x {
  flex: none; border: 0; background: none; cursor: pointer;
  padding: 0 0.5rem; font-size: 1.05rem; line-height: 1; color: var(--dg-muted);
}
.dg .dg-x:hover { color: var(--dg-bad); }

.dg .dg-table .dg-n { padding: 0.35rem 0.65rem; font-size: 0.76rem; color: var(--dg-muted); white-space: nowrap; }
.dg .dg-table .dg-n.dg-low { color: var(--dg-warn); font-weight: 600; }

.dg .dg-status { margin: 0.5rem 0 0; min-height: 1.3em; font-size: 0.85rem; color: var(--dg-muted); }
.dg .dg-status.dg-err { color: var(--dg-bad); }
.dg .dg-status.dg-ok { color: var(--dg-ok); }

@media (max-width: 560px) {
  .dg .dg-cell, .dg .dg-head { min-width: 6rem; font-size: 1rem; } /* 16px stops iOS zooming on focus */
}
@media print {
  .dg-bar { display: none; }
  .dg-scroll { max-height: none; overflow: visible; }
}
