/* ============================================================
   Databases, dashboards and charts
   Builds on the tokens in app.css. Colours for series and tags are
   the validated categorical palette, stepped separately for light and
   dark surfaces (see the dataviz notes in docs/FEATURES.md).
   ============================================================ */

:root {
  /* chart series: blue, orange, aqua, yellow, magenta, green, violet, red */
  --viz-0: #3987e5; --viz-1: #d95926; --viz-2: #199e70; --viz-3: #c98500;
  --viz-4: #d55181; --viz-5: #1f9d1f; --viz-6: #9085e9; --viz-7: #e66767;
  --viz-other: #6b7488;
  --viz-grid: #232838;
  --viz-axis: #3a4258;
  --good-text: #4cc24c;
  --bad-text: #f08a8a;
  --warn: #fab219;
  --crit: #e5484d;

  --tg-blue-bg: #3987e533;   --tg-blue-fg: #9cc4f7;
  --tg-orange-bg: #d9592633; --tg-orange-fg: #f4ab87;
  --tg-teal-bg: #199e7033;   --tg-teal-fg: #74d6b5;
  --tg-yellow-bg: #c9850033; --tg-yellow-fg: #f2c978;
  --tg-pink-bg: #d5518133;   --tg-pink-fg: #f4a9c6;
  --tg-green-bg: #1f9d1f33;  --tg-green-fg: #83d983;
  --tg-violet-bg: #9085e933; --tg-violet-fg: #c3bdf6;
  --tg-red-bg: #e6676733;    --tg-red-fg: #f6aaaa;
  --tg-gray-bg: #8a92a42b;   --tg-gray-fg: #b7bdcc;

  --dbt-bg: var(--surface);
  --dbt-hover: var(--surface-3);
  --dbt-line: color-mix(in srgb, var(--border) 70%, transparent);
}

[data-theme="light"] {
  --viz-0: #2a78d6; --viz-1: #eb6834; --viz-2: #1baf7a; --viz-3: #eda100;
  --viz-4: #e87ba4; --viz-5: #008300; --viz-6: #4a3aa7; --viz-7: #e34948;
  --viz-other: #898781;
  --viz-grid: #e6e9f0;
  --viz-axis: #c9cfdc;
  --good-text: #006300;
  --bad-text: #b02a29;
  --warn: #f59e0b;
  --crit: #d03b3b;

  --tg-blue-bg: #2a78d62b;   --tg-blue-fg: #1c5cab;
  --tg-orange-bg: #eb683433; --tg-orange-fg: #a8400f;
  --tg-teal-bg: #1baf7a2b;   --tg-teal-fg: #0b7350;
  --tg-yellow-bg: #eda10038; --tg-yellow-fg: #835600;
  --tg-pink-bg: #e87ba42e;   --tg-pink-fg: #a8346a;
  --tg-green-bg: #00830026;  --tg-green-fg: #006300;
  --tg-violet-bg: #4a3aa724; --tg-violet-fg: #3a2d8a;
  --tg-red-bg: #e3494826;    --tg-red-fg: #a52625;
  --tg-gray-bg: #89878133;   --tg-gray-fg: #52514e;

  --dbt-bg: #ffffff;
  --dbt-hover: #f3f5f9;
}

/* ---------------- tags and dots ---------------- */

.tg {
  display: inline-block; max-width: 100%;
  padding: 1px 8px; border-radius: 6px;
  font-size: 12.5px; line-height: 1.55; font-weight: 540;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  vertical-align: middle;
}
.tg-blue { background: var(--tg-blue-bg); color: var(--tg-blue-fg); }
.tg-orange { background: var(--tg-orange-bg); color: var(--tg-orange-fg); }
.tg-teal { background: var(--tg-teal-bg); color: var(--tg-teal-fg); }
.tg-yellow { background: var(--tg-yellow-bg); color: var(--tg-yellow-fg); }
.tg-pink { background: var(--tg-pink-bg); color: var(--tg-pink-fg); }
.tg-green { background: var(--tg-green-bg); color: var(--tg-green-fg); }
.tg-violet { background: var(--tg-violet-bg); color: var(--tg-violet-fg); }
.tg-red { background: var(--tg-red-bg); color: var(--tg-red-fg); }
.tg-gray { background: var(--tg-gray-bg); color: var(--tg-gray-fg); }

.cdot { display: inline-block; width: 14px; height: 14px; border-radius: 4px; flex: none; }
.cdot-blue { background: var(--viz-0); } .cdot-orange { background: var(--viz-1); } .cdot-teal { background: var(--viz-2); }
.cdot-yellow { background: var(--viz-3); } .cdot-pink { background: var(--viz-4); } .cdot-green { background: var(--viz-5); }
.cdot-violet { background: var(--viz-6); } .cdot-red { background: var(--viz-7); } .cdot-gray { background: var(--viz-other); }

/* ---------------- toast actions ---------------- */

.toast-action {
  border: 0; background: none; cursor: pointer; color: var(--accent-text);
  font: inherit; font-weight: 650; padding: 0 4px;
}
.toast-action:hover { text-decoration: underline; }

/* ---------------- the database page ---------------- */

.dbp { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.dbp-head { display: flex; align-items: center; gap: 10px; padding: 18px 22px 8px; flex: none; }
.dbp-link {
  display: flex; align-items: center; gap: 12px; flex: none; margin: 2px 22px 8px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2);
}
.dbp-link[hidden] { display: none; }
.dbp-link-ico { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); color: var(--accent, var(--text-dim)); }
.dbp-link-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.dbp-link-text b { font-size: 13.5px; }
.dbp-link-text span { font-size: 12.5px; color: var(--text-dim); line-height: 1.35; }
.dbp-icon {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center;
  border: 0; border-radius: var(--r-md); background: none; cursor: pointer;
  font-size: 26px; line-height: 1; color: var(--text-dim);
}
.dbp-icon:hover { background: var(--surface-3); }
.dbp-title {
  flex: 1; min-width: 0; border: 0; background: none; color: var(--text);
  font: inherit; font-size: 28px; font-weight: 700; letter-spacing: -.02em; padding: 2px 4px; border-radius: var(--r-sm);
}
.dbp-title:focus { outline: none; background: var(--surface-3); }
.dbp-title::placeholder { color: var(--text-faint); }

.dbp-bar {
  display: flex; align-items: center; gap: 12px; flex: none;
  padding: 0 16px; border-bottom: 1px solid var(--border);
}
.dbp-tabs { display: flex; align-items: stretch; gap: 2px; min-width: 0; flex: 1 1 auto; overflow-x: auto; scrollbar-width: none; }
.dbp-tabs::-webkit-scrollbar { display: none; }
.dbp-tab { display: flex; flex: none; }
.dbp-tab-main {
  display: flex; align-items: center; gap: 6px; padding: 9px 10px;
  border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer;
  color: var(--text-dim); font: inherit; font-size: 13px; font-weight: 540; white-space: nowrap;
}
.dbp-tab-main:hover { color: var(--text); background: var(--surface-3); border-radius: var(--r-sm) var(--r-sm) 0 0; }
.dbp-tab.active .dbp-tab-main { color: var(--text); border-bottom-color: var(--accent); font-weight: 640; }
.dbp-tab-caret { display: inline-flex; transform: rotate(90deg); opacity: .6; margin-left: 2px; }
.dbp-tab-add {
  align-self: center; width: 28px; height: 28px; flex: none; display: grid; place-items: center;
  border: 0; border-radius: var(--r-sm); background: none; color: var(--text-faint); cursor: pointer;
}
.dbp-tab-add:hover { background: var(--surface-3); color: var(--text); }

.dbp-tools { display: flex; align-items: center; gap: 4px; flex: none; padding: 5px 0; }
.dbp-tool { background: transparent; border-color: transparent; color: var(--text-dim); padding: 0 8px; }
.dbp-tool-label { display: none; }
@media (min-width: 1700px) { .dbp-tool-label { display: inline; } }
.dbp-tool:hover:not(:disabled) { background: var(--surface-3); color: var(--text); border-color: transparent; }
.dbp-tool.on { color: var(--accent-text); }
.dbp-badge {
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px;
  background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 700; display: inline-grid; place-items: center;
}
.dbp-search {
  width: 150px; height: 28px; padding: 0 9px; margin-left: 4px;
  border: 1px solid transparent; border-radius: var(--r-md); background: var(--surface-3);
  color: var(--text); font: inherit; font-size: 12.5px;
}
.dbp-search:focus { outline: none; border-color: var(--accent); background: var(--bg); width: 210px; }
.dbp-search::placeholder { color: var(--text-faint); }
.dbp-new { margin-left: 4px; }

.dbp-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 22px 0; flex: none; }
.dbp-chips[hidden] { display: none; }
.dbp-chip {
  display: inline-flex; align-items: center; border-radius: 99px; background: var(--accent-soft);
  color: var(--accent-text); font-size: 12px; font-weight: 560; max-width: 100%;
}
.dbp-chip-main {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 4px 3px 10px; border: 0; background: none;
  color: inherit; font: inherit; cursor: pointer; min-width: 0;
}
.dbp-chip-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dbp-chip-x { border: 0; background: none; color: inherit; cursor: pointer; padding: 3px 8px 3px 2px; display: grid; place-items: center; opacity: .7; }
.dbp-chip-x:hover { opacity: 1; }

.dbp-body { flex: 1; min-height: 0; overflow: hidden; position: relative; margin-top: 8px; background: var(--dbt-bg); border-top: 1px solid var(--border); }
.dbp-number { padding: 28px; max-width: 520px; }

/* ---------------- the table ---------------- */

.dbt { height: 100%; overflow: auto; outline: none; position: relative; background: var(--dbt-bg); }
.dbt-inner { display: block; --cols: 38px 280px 52px; padding-bottom: 120px; }
.dbt.compact .dbt-inner { padding-bottom: 0; }
.dbt-row {
  display: grid; grid-template-columns: var(--cols); min-height: 36px;
  border-bottom: 1px solid var(--dbt-line); background: var(--dbt-bg);
}
.dbt:not(.compact) .dbt-row[data-row]:hover { background: var(--dbt-hover); }
.dbt-row.checked { background: var(--accent-soft) !important; }

.dbt-head { position: sticky; top: 0; z-index: 5; min-height: 34px; border-bottom: 1px solid var(--border); }
.dbt-th {
  display: flex; align-items: center; gap: 6px; min-width: 0; padding: 0 10px; height: 34px;
  font-size: 12px; font-weight: 600; color: var(--text-dim); cursor: pointer; position: relative;
  border-right: 1px solid var(--dbt-line); user-select: none; background: var(--dbt-bg);
}
.dbt-th:hover { background: var(--dbt-hover); color: var(--text); }
.th-ico { display: inline-flex; color: var(--text-faint); }
.th-name { flex: 1; min-width: 0; }
.dbt-th.num { justify-content: flex-end; }
.dbt-th.num .th-name { flex: 0 1 auto; }
.th-sort { color: var(--accent-text); display: inline-flex; }
.dbt-gut.dbt-th, .dbt-th.dbt-addcol { cursor: default; }
.dbt-addcol { border-right: 0; justify-content: center; padding: 0; }
.resizer { position: absolute; right: -3px; top: 0; bottom: 0; width: 7px; cursor: col-resize; z-index: 2; }
.resizer:hover, .resizer:active { background: var(--accent); opacity: .5; }

.dbt-gut { display: flex; align-items: center; justify-content: center; position: sticky; left: 0; z-index: 3; background: inherit; }
.dbt-row:not(.dbt-head) > .dbt-gut { background: inherit; }
.dbt-check {
  width: 16px; height: 16px; border: 1.5px solid var(--border-strong); border-radius: 4px; background: var(--dbt-bg);
  display: grid; place-items: center; cursor: pointer; padding: 0; color: #fff; opacity: 0;
}
.dbt-row:hover .dbt-check, .dbt-row.checked .dbt-check, .dbt:focus-within .dbt-row.checked .dbt-check { opacity: 1; }
.dbt-row.checked .dbt-check { background: var(--accent); border-color: var(--accent); }

.dbt-cell {
  display: flex; align-items: center; min-width: 0; padding: 6px 10px; position: relative;
  font-size: 13.5px; border-right: 1px solid var(--dbt-line); background: inherit; cursor: default; overflow: hidden;
  scroll-margin-top: 40px; scroll-margin-left: 340px;
}
.dbt-cell.title { position: sticky; left: 38px; z-index: 2; font-weight: 540; background: inherit; }
.dbt-head .dbt-th:nth-child(2) { position: sticky; left: 38px; z-index: 6; }
.dbt-head .dbt-gut { z-index: 7; }
.dbt-cell.spacer { border-right: 0; }
.dbt-cell.num { justify-content: flex-end; font-variant-numeric: tabular-nums; }
.dbt-cell.computed { color: var(--text-dim); }
.dbt-cell.sel { outline: 2px solid var(--accent); outline-offset: -2px; z-index: 4; }
.dbt-cell.editing { outline: 2px solid var(--accent); outline-offset: -2px; z-index: 4; background: var(--surface-2); overflow: visible; }
.dbt.wrap .dbt-cell { align-items: flex-start; }
.dbt.wrap .cv { white-space: normal; word-break: break-word; }
.dbt.readonly .dbt-cell { cursor: default; }

.dbt-input {
  position: absolute; inset: 0; width: 100%; height: 100%; padding: 0 10px; border: 0; outline: none;
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 13.5px;
}
.dbt-cell.num .dbt-input { text-align: right; }
.dbt-input.bad { background: var(--red-soft); }

.dbt-cell .open-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: none; align-items: center; gap: 4px; padding: 2px 8px; border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); background: var(--surface-2); color: var(--text-dim); font: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer;
}
.dbt-row:hover .open-btn { display: inline-flex; }
.open-btn:hover { color: var(--text); background: var(--surface-3); }

.dbt-gh {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; user-select: none;
  background: var(--dbt-bg); border-bottom: 1px solid var(--dbt-line); position: sticky; left: 0; font-weight: 640; font-size: 13px;
}
.dbt-gh:hover { background: var(--dbt-hover); }
.dbt-gh .tree-toggle { display: inline-flex; transition: transform var(--fast); color: var(--text-faint); }
.dbt-gh .tree-toggle.open { transform: rotate(90deg); }
.gh-count { color: var(--text-faint); font-weight: 600; font-size: 12px; }
.gh-add { margin-left: auto; opacity: 0; }
.dbt-gh:hover .gh-add { opacity: 1; }

.dbt-add .dbt-cell.title { color: var(--text-faint); gap: 6px; cursor: pointer; font-weight: 500; }
.dbt-add:hover { background: var(--dbt-hover); }
.dbt-add:hover .dbt-cell.title { color: var(--text); }
.dbt-foot { background: var(--dbt-bg); }
.dbt-foot .dbt-cell.foot { font-size: 12px; color: var(--text-dim); justify-content: flex-end; gap: 6px; cursor: pointer; font-variant-numeric: tabular-nums; }
.dbt-foot .dbt-cell.foot:first-of-type { justify-content: flex-start; }
.foot-fn { color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; font-size: 10.5px; font-weight: 700; }
.foot-val { font-weight: 640; color: var(--text); }
.foot-hint { opacity: 0; color: var(--text-faint); }
.dbt-foot:hover .foot-hint { opacity: 1; }
.dbt-foot .dbt-cell.foot:hover { background: var(--dbt-hover); }

.dbt-more { display: block; width: 100%; padding: 9px; border: 0; border-bottom: 1px solid var(--dbt-line); background: var(--dbt-bg); color: var(--accent-text); font: inherit; font-size: 12.5px; cursor: pointer; }
.dbt-more:hover { background: var(--dbt-hover); }
.dbt-empty { padding: 28px; text-align: center; color: var(--text-faint); font-size: 13.5px; }
.dbt-bulk {
  position: sticky; top: 0; z-index: 8; display: flex; align-items: center; gap: 10px; padding: 7px 14px;
  background: var(--accent-soft); border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--accent-text);
}
.dbt-bulk + .dbt-head { top: 43px; }

/* compact tables (dashboard widgets) */
.dbt.compact { height: auto; max-height: 440px; overflow: auto; background: transparent; }
.dbt.compact .dbt-row { min-height: 34px; background: transparent; border-bottom-color: var(--dbt-line); }
.dbt.compact .dbt-row[data-row] { cursor: pointer; }
.dbt.compact .dbt-row[data-row]:hover { background: var(--dbt-hover); }
.dbt.compact .dbt-head { position: static; border-bottom: 1px solid var(--border); min-height: 30px; }
.dbt.compact .dbt-th { height: 30px; background: transparent; cursor: default; border-right: 0; padding: 0 8px; }
.dbt.compact .dbt-th:hover { background: transparent; color: var(--text-dim); }
.dbt.compact .dbt-cell { border-right: 0; padding: 4px 8px; position: static; background: transparent; scroll-margin: 0; }
.dbt.compact .dbt-cell.title { position: static; }
.dbt.compact .dbt-gut { display: none; }
.dbt.compact .dbt-head .dbt-th:nth-child(2) { position: static; }

/* ---------------- cell values ---------------- */

.cv { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-title { font-weight: 560; }
.cv-empty::before { content: ''; }
.cv-tags { display: flex; gap: 4px; flex-wrap: nowrap; overflow: hidden; }
.cv-date { color: var(--text); }
.cv-link { color: var(--accent-text); text-decoration: none; }
.cv-link:hover { text-decoration: underline; }
.cv-check {
  display: inline-grid; place-items: center; width: 17px; height: 17px; border: 1.5px solid var(--border-strong); border-radius: 5px; color: #fff; flex: none;
}
.cv-check.on { background: var(--accent); border-color: var(--accent); }
.cv-people { display: flex; gap: 8px; overflow: hidden; }
.cv-person { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; white-space: nowrap; }
.cv-rels { display: flex; gap: 4px; overflow: hidden; }
.rel-chip {
  display: inline-block; max-width: 100%; padding: 1px 8px; border-radius: 6px; background: var(--surface-3);
  border: 1px solid var(--border); color: var(--text); font-size: 12.5px; line-height: 1.5; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rel-chip:hover { border-color: var(--accent); color: var(--accent-text); }
.cv-meter { display: flex; align-items: center; gap: 8px; width: 100%; }
.meter-track { flex: 1; min-width: 36px; height: 6px; border-radius: 99px; background: color-mix(in srgb, var(--viz-0) 16%, transparent); overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: 99px; background: var(--viz-0); }
.meter-fill.warn { background: var(--warn); }
.meter-fill.over { background: var(--crit); }
.meter-text { font-size: 12px; font-variant-numeric: tabular-nums; min-width: 38px; text-align: right; display: inline-flex; align-items: center; justify-content: flex-end; gap: 3px; }
.meter-fill.over ~ .meter-text, .cv-meter:has(.over) .meter-text { color: var(--bad-text); font-weight: 650; }

/* ---------------- popovers ---------------- */

.pop {
  position: fixed; z-index: 86; max-height: min(600px, 82vh); overflow: auto;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); animation: menuIn var(--fast);
}
.pop.sheet {
  left: 0 !important; right: 0; bottom: 0; top: auto !important; width: 100% !important; max-height: 78vh;
  border-radius: var(--r-xl) var(--r-xl) 0 0; padding-bottom: env(safe-area-inset-bottom); animation: modalIn var(--med);
}
.pop-scrim { position: fixed; inset: 0; z-index: 85; background: rgba(3, 5, 10, .45); }
.pe { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.pe-head { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-faint); }
.pe-head-ico { display: inline-flex; color: var(--text-dim); }
.pe-foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; padding-top: 4px; }
.pe-foot.split { justify-content: space-between; }
.pe-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pe-sec { display: flex; flex-direction: column; gap: 10px; }
.pe-note { font-size: 12.5px; color: var(--text-dim); background: var(--surface-3); padding: 9px 11px; border-radius: var(--r-md); line-height: 1.5; }
.pe-static { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--r-md); background: var(--surface-3); font-size: 13.5px; }
.pe-preview { font-size: 12.5px; color: var(--text-dim); padding: 2px 2px 0; }
.pe-sep { height: 1px; background: var(--border); margin: 2px 0; }
.pe-check { font-size: 13px; }
.danger-text { color: var(--bad-text); }
.pf { display: flex; flex-direction: column; gap: 5px; }
.pf-label { font-size: 12px; font-weight: 600; color: var(--text-dim); }
.pf-hint { font-size: 12px; color: var(--text-faint); }
.pf-select { padding: 7px 30px 7px 10px; font-size: 13.5px; }
.pe .input, .pe .textarea { font-size: 13.5px; padding: 7px 10px; }

.seg { display: inline-flex; padding: 2px; border-radius: var(--r-md); background: var(--surface-3); gap: 2px; align-self: flex-start; flex-wrap: wrap; }
.seg-item { border: 0; background: none; padding: 5px 11px; border-radius: 8px; font: inherit; font-size: 12.5px; font-weight: 560; color: var(--text-dim); cursor: pointer; }
.seg-item:hover { color: var(--text); }
.seg-item.active { background: var(--surface-2); color: var(--text); box-shadow: var(--shadow-sm); }
[data-theme="light"] .seg-item.active { background: #fff; }

/* pickers */
.pk { display: flex; flex-direction: column; }
.pk-search {
  width: 100%; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--border); background: transparent;
  color: var(--text); font: inherit; font-size: 13.5px; outline: none; border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.pk-search::placeholder { color: var(--text-faint); }
.pk-search.bad { background: var(--red-soft); }
.pk-list { padding: 4px; display: flex; flex-direction: column; gap: 1px; max-height: 300px; overflow: auto; }
.pk-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--text); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer; min-width: 0;
}
.pk-item:hover, .pk-item.active { background: var(--surface-3); }
.pk-check { width: 16px; flex: none; display: inline-flex; color: var(--accent-text); }
.pk-create { color: var(--text-dim); }
.pk-clear { color: var(--text-dim); border-top: 1px solid var(--border); border-radius: 0 0 var(--r-sm) var(--r-sm); margin-top: 3px; }
.pk-empty { padding: 14px; color: var(--text-faint); font-size: 13px; text-align: center; }
.pk .pe-head { padding: 12px 14px 6px; }

/* date picker */
.dp { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.dp-input { border: 1px solid var(--border) !important; border-radius: var(--r-md) !important; padding: 7px 10px !important; background: var(--bg) !important; }
.dp-head { display: flex; align-items: center; justify-content: space-between; }
.dp-title { font-size: 13.5px; font-weight: 650; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-dow { text-align: center; font-size: 11px; font-weight: 650; color: var(--text-faint); padding: 3px 0; }
.dp-day { aspect-ratio: 1; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer; }
.dp-day:hover { background: var(--surface-3); }
.dp-day.out { color: var(--text-faint); }
.dp-day.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.dp-day.sel { background: var(--accent); color: #fff; box-shadow: none; }
.dp-foot { display: flex; align-items: center; }

/* filter / sort rows */
.fe-filter { display: flex; flex-direction: column; gap: 8px; }
.fl-row { display: grid; grid-template-columns: 54px minmax(90px, 1fr) minmax(100px, 1fr) minmax(110px, 1.3fr) 28px; gap: 6px; align-items: center; }
.fl-where { font-size: 12px; color: var(--text-faint); text-align: right; padding-right: 2px; }
.fl-row .select, .fl-row .input, .fl-row .fl-pick { min-width: 0; width: 100%; }
.fl-pick { justify-content: flex-start; overflow: hidden; text-overflow: ellipsis; height: 34px; }
.fl-mode { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }
.fl-mode .select { width: auto; padding-top: 4px; padding-bottom: 4px; }
.fl-empty { font-size: 13px; color: var(--text-faint); padding: 2px 0; }
.fl-add { align-self: flex-start; }

/* properties list */
.prop-list { display: flex; flex-direction: column; gap: 1px; }
.prop-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 8px; border: 0; border-radius: var(--r-sm); background: none; color: var(--text); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer; }
.prop-item:hover:not(:disabled) { background: var(--surface-3); }
.prop-item:disabled { cursor: default; opacity: .7; }
.prop-ico { color: var(--text-faint); display: inline-flex; }
.prop-eye { color: var(--text-dim); display: inline-flex; }

/* property editor */
.pe-name { font-weight: 600; }
.pe-types { display: flex; flex-direction: column; gap: 2px; max-height: 360px; overflow: auto; }
.pe-type { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border: 0; border-radius: var(--r-sm); background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.pe-type:hover, .pe-type.on { background: var(--surface-3); }
.pe-type-ico { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-3); color: var(--text-dim); flex: none; }
.pe-type.on .pe-type-ico { background: var(--accent-soft); color: var(--accent-text); }
.pe-type-text { display: flex; flex-direction: column; }
.pe-type-text b { font-size: 13.5px; font-weight: 600; }
.pe-type-text small { font-size: 12px; color: var(--text-faint); }
.pop-pe .pe > .pk-search { border: 1px solid var(--border); border-radius: var(--r-md); }
.opt-list { display: flex; flex-direction: column; gap: 2px; }
.opt-row { display: flex; align-items: center; gap: 2px; }
.opt-color { border: 0; background: none; padding: 6px; cursor: pointer; border-radius: var(--r-sm); display: grid; place-items: center; }
.opt-color:hover { background: var(--surface-3); }
.opt-name, .opt-add { flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; color: var(--text); font: inherit; font-size: 13.5px; }
.opt-name:hover, .opt-add:hover { background: var(--surface-3); }
.opt-name:focus, .opt-add:focus { outline: none; border-color: var(--accent); background: var(--bg); }
.opt-add { border: 1px dashed var(--border-strong); }
.cgrid { padding: 6px; display: flex; flex-direction: column; }
.cswatch { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border: 0; border-radius: var(--r-sm); background: none; color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.cswatch:hover, .cswatch.on { background: var(--surface-3); }
.pe-filter { max-width: 100%; }

.fx-input { font-family: var(--mono); font-size: 13px !important; line-height: 1.5; min-height: 84px; resize: vertical; }
.fx-status { font-size: 12.5px; min-height: 18px; color: var(--text-faint); }
.fx-status.ok { color: var(--good-text); }
.fx-status.bad { color: var(--bad-text); }
.fx-preview { font-size: 13px; color: var(--text-dim); }
.fx-preview b { color: var(--text); }
.fx-tools { display: flex; align-items: center; gap: 8px; }
.fx-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.fx-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface-3); color: var(--text); font: inherit; font-size: 12px; cursor: pointer; }
.fx-chip:hover { border-color: var(--accent); color: var(--accent-text); }
.fx-help { display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.fx-help[hidden] { display: none; }
.fx-fns { max-height: 220px; overflow: auto; padding: 0 4px 4px; display: flex; flex-direction: column; }
.fx-fn { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 6px 8px; border: 0; border-radius: var(--r-sm); background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.fx-fn:hover { background: var(--surface-3); }
.fx-fn code { font-family: var(--mono); font-size: 12.5px; color: var(--accent-text); }
.fx-fn span { font-size: 12px; color: var(--text-dim); }

.dsh-range { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; }

/* ---------------- the board ---------------- */

.dbb { display: flex; gap: 12px; padding: 14px; height: 100%; overflow-x: auto; align-items: stretch; background: var(--bg); }
.dbb-col { display: flex; flex-direction: column; width: 290px; flex: none; min-height: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.dbb-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; flex: none; }
.dbb-none { font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.dbb-count { color: var(--text-faint); font-size: 12px; font-weight: 600; }
.dbb-body { flex: 1; min-height: 80px; padding: 4px 8px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; }
.dbb-col.drop-target { border-color: var(--accent); }
.dbb-col.drop-target .dbb-body { background: var(--accent-soft); }
.dbb-card {
  padding: 10px 11px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2);
  cursor: pointer; touch-action: manipulation; transition: border-color var(--fast), box-shadow var(--fast);
}
.dbb-card:hover, .dbb-card:focus-visible { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.dbb-card.dragging { opacity: .4; }
.dbb-card.lifted { position: fixed; z-index: 90; pointer-events: none; box-shadow: var(--shadow-lg); transform: rotate(1.5deg); }
.dbb-title { font-size: 13.5px; font-weight: 560; line-height: 1.4; word-break: break-word; }
.dbb-props { display: flex; flex-direction: column; gap: 5px; margin-top: 8px; }
.dbb-prop { font-size: 12.5px; color: var(--text-dim); min-width: 0; }
.dbb-addcol { width: 190px; flex: none; justify-content: flex-start; align-self: flex-start; }

/* ---------------- the calendar ---------------- */

.dbc { height: 100%; overflow: auto; padding: 14px 16px 24px; background: var(--dbt-bg); }
.dbc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.dbc-title { font-size: 17px; font-weight: 680; letter-spacing: -.01em; }
.dbc-nav { display: flex; gap: 4px; }
.dbc-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.dbc-dow { padding: 6px 8px; font-size: 11.5px; font-weight: 650; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.dbc-day { min-height: 104px; padding: 4px 5px 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.dbc-day.out { background: color-mix(in srgb, var(--bg) 55%, transparent); }
.dbc-day.out .dbc-daynum { color: var(--text-faint); }
.dbc-daynum { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 600; color: var(--text-dim); padding: 0 3px; min-height: 22px; }
.dbc-day.today .dbc-daynum span { background: var(--accent); color: #fff; border-radius: 99px; min-width: 22px; height: 22px; display: inline-grid; place-items: center; }
.dbc-add { border: 0; background: none; color: var(--text-faint); cursor: pointer; opacity: 0; width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; }
.dbc-day:hover .dbc-add, .dbc-add:focus-visible { opacity: 1; }
.dbc-add:hover { background: var(--surface-3); color: var(--text); }
.dbc-item {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; padding: 2px 6px; border: 0; border-radius: 5px;
  background: var(--accent-soft); color: var(--text); font: inherit; font-size: 12px; text-align: left; cursor: pointer; min-width: 0;
}
.dbc-item:hover { background: color-mix(in srgb, var(--accent) 28%, transparent); }
.dbc-item-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.dbc-item-extra { flex: none; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.dbc-more { border: 0; background: none; color: var(--text-dim); font: inherit; font-size: 11.5px; text-align: left; padding: 0 6px; cursor: pointer; }
.dbc-more:hover { color: var(--accent-text); }
.dbc-daylist { padding: 4px 10px 12px; display: flex; flex-direction: column; gap: 4px; }

/* ---------------- charts ---------------- */

.vz { position: relative; padding: 4px 0 2px; min-width: 0; }
.dbp-body > .vz { padding: 16px 22px 24px; height: 100%; overflow: auto; max-width: 1000px; }
.vz-head { display: flex; align-items: center; gap: 12px; min-height: 28px; margin-bottom: 4px; }
.vz-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; flex: 1; min-width: 0; }
.vz-key { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-dim); }
.vz-keybox { width: 10px; height: 10px; border-radius: 3px; flex: none; background: var(--viz-0); }
.vz-keyline { width: 14px; height: 3px; border-radius: 2px; flex: none; background: var(--viz-0); }
.vz-toggle { opacity: .7; margin-left: auto; }
.vz-head.solo { min-height: 22px; margin: 0 0 2px; justify-content: flex-end; }
.vz:hover .vz-toggle { opacity: 1; }
.vz-plot { position: relative; }
.vz-svg { display: block; max-width: 100%; overflow: visible; }
.vz-svg text { font-family: var(--font); fill: var(--text-faint); }
.vz-grid { stroke: var(--viz-grid); stroke-width: 1; }
.vz-axis { stroke: var(--viz-axis); stroke-width: 1; }
.vz-tick { font-size: 11px; fill: var(--text-faint); font-variant-numeric: tabular-nums; }
.vz-cat { font-size: 12.5px; fill: var(--text-dim) !important; }
.vz-value { font-size: 12px; font-weight: 650; fill: var(--text) !important; font-variant-numeric: tabular-nums; }
.vz-cross { stroke: var(--viz-axis); stroke-width: 1; pointer-events: none; }
.vz-hit { fill: transparent; outline: none; cursor: default; }
.vz-hit:focus-visible { fill: var(--accent-soft); }
.vz-bar { transition: opacity var(--fast); }
.vz-bar.dim { opacity: .55; }
.vz-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.vz-area { stroke: none; opacity: .1; }
.vz-dot { stroke: var(--surface); stroke-width: 2; }

.vz-s0 { fill: var(--viz-0); stroke: none; } .vz-s1 { fill: var(--viz-1); stroke: none; } .vz-s2 { fill: var(--viz-2); stroke: none; } .vz-s3 { fill: var(--viz-3); stroke: none; }
.vz-s4 { fill: var(--viz-4); stroke: none; } .vz-s5 { fill: var(--viz-5); stroke: none; } .vz-s6 { fill: var(--viz-6); stroke: none; } .vz-s7 { fill: var(--viz-7); stroke: none; } .vz-sx { fill: var(--viz-other); stroke: none; }
.vz-line.vz-s0 { stroke: var(--viz-0); fill: none; } .vz-line.vz-s1 { stroke: var(--viz-1); fill: none; } .vz-line.vz-s2 { stroke: var(--viz-2); fill: none; } .vz-line.vz-s3 { stroke: var(--viz-3); fill: none; }
.vz-line.vz-s4 { stroke: var(--viz-4); fill: none; } .vz-line.vz-s5 { stroke: var(--viz-5); fill: none; } .vz-line.vz-s6 { stroke: var(--viz-6); fill: none; } .vz-line.vz-s7 { stroke: var(--viz-7); fill: none; } .vz-line.vz-sx { stroke: var(--viz-other); fill: none; }
.vz-dot.vz-s0, .vz-dot.vz-s1, .vz-dot.vz-s2, .vz-dot.vz-s3, .vz-dot.vz-s4, .vz-dot.vz-s5, .vz-dot.vz-s6, .vz-dot.vz-s7, .vz-dot.vz-sx { stroke: var(--surface); stroke-width: 2; }
.vz-keybox.vz-s0, .vz-keyline.vz-s0 { background: var(--viz-0); } .vz-keybox.vz-s1, .vz-keyline.vz-s1 { background: var(--viz-1); } .vz-keybox.vz-s2, .vz-keyline.vz-s2 { background: var(--viz-2); }
.vz-keybox.vz-s3, .vz-keyline.vz-s3 { background: var(--viz-3); } .vz-keybox.vz-s4, .vz-keyline.vz-s4 { background: var(--viz-4); } .vz-keybox.vz-s5, .vz-keyline.vz-s5 { background: var(--viz-5); }
.vz-keybox.vz-s6, .vz-keyline.vz-s6 { background: var(--viz-6); } .vz-keybox.vz-s7, .vz-keyline.vz-s7 { background: var(--viz-7); } .vz-keybox.vz-sx, .vz-keyline.vz-sx { background: var(--viz-other); }
.vz-keybox, .vz-keyline { fill: none; }

.vz-donut { margin: 0 auto; }
.vz-slice { stroke: var(--surface) !important; stroke-width: 2 !important; transition: opacity var(--fast); outline: none; cursor: default; }
.vz-slice.dim { opacity: .5; }
.vz-center-val { font-size: 20px; font-weight: 700; fill: var(--text) !important; }
.vz-center-label { font-size: 11.5px; fill: var(--text-faint) !important; }
.vz-plot:has(.vz-donut) { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 28px; }
.vz-donut-legend { display: flex; flex-direction: column; gap: 6px; min-width: 190px; flex: 1 1 190px; max-width: 320px; }
.vz-donut-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 38px; align-items: center; gap: 8px; font-size: 13px; }
.vz-donut-name { color: var(--text); }
.vz-donut-val { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.vz-donut-pct { color: var(--text-faint); font-variant-numeric: tabular-nums; text-align: right; }

.vz-tip {
  position: absolute; z-index: 20; pointer-events: none; min-width: 130px; max-width: 280px; padding: 8px 10px;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r-md); box-shadow: var(--shadow-md); font-size: 12.5px;
}
.vz-tip[hidden] { display: none; }
.vz-tip-title { font-size: 11.5px; color: var(--text-faint); font-weight: 600; margin-bottom: 4px; }
.vz-tip-row { display: flex; align-items: center; gap: 8px; padding: 1px 0; }
.vz-tip-val { font-variant-numeric: tabular-nums; font-size: 13.5px; }
.vz-tip-label { color: var(--text-dim); }
.vz-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 36px 16px; color: var(--text-faint); text-align: center; font-size: 13.5px; }
.vz-tablewrap { overflow: auto; max-height: 420px; }
.vz-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.vz-table th, .vz-table td { padding: 7px 10px; border-bottom: 1px solid var(--dbt-line); text-align: left; }
.vz-table th { font-size: 12px; color: var(--text-dim); position: sticky; top: 0; background: var(--surface); }
.vz-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------- number tiles ---------------- */

.stat { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat-label { font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.stat-value { font-size: 30px; font-weight: 680; letter-spacing: -.02em; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* A tile's figure scales to the tile, so £14,044.50 never gets cut off on a narrow screen. */
@container (max-width: 250px) { .stat-value { font-size: clamp(19px, 11.5cqw, 30px); } }
.stat-delta { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.stat-delta.good { color: var(--good-text); }
.stat-delta.bad { color: var(--bad-text); }
.stat-vs { color: var(--text-faint); font-weight: 500; }
.stat-flat { display: inline-block; width: 12px; text-align: center; }

/* ---------------- the row page ---------------- */

.rp-scrim { position: fixed; inset: 0; z-index: 60; background: rgba(3, 5, 10, 0); transition: background var(--med); }
.rp-scrim.on { background: rgba(3, 5, 10, .38); }
.rp {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61; width: min(720px, 100vw);
  display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg); transform: translateX(24px); opacity: 0; transition: transform var(--med), opacity var(--med);
}
.rp.on { transform: none; opacity: 1; }
.rp-head { display: flex; align-items: center; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--border); flex: none; padding-top: max(10px, env(safe-area-inset-top)); }
.rp-crumb { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-dim); min-width: 0; padding: 0 6px; }
.rp-scroll { flex: 1; overflow: auto; padding: 22px 32px 60px; }
.rp-loading { flex: 1; display: grid; place-items: center; }
.rp-title {
  width: 100%; border: 0; background: none; resize: none; color: var(--text); font: inherit; font-size: 30px; font-weight: 700;
  letter-spacing: -.02em; line-height: 1.2; padding: 0; margin-bottom: 14px; overflow: hidden; outline: none; display: block;
}
.rp-title::placeholder { color: var(--text-faint); }
.rp-props { display: flex; flex-direction: column; border-top: 1px solid var(--border); padding-top: 8px; }
.rp-field { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px; align-items: center; min-height: 34px; padding: 1px 0; }
.rp-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); min-width: 0; }
.rp-label svg { flex: none; color: var(--text-faint); }
.rp-value { min-width: 0; }
.fe { min-height: 30px; padding: 4px 8px; border-radius: var(--r-sm); display: flex; align-items: center; cursor: pointer; min-width: 0; font-size: 13.5px; position: relative; }
.fe:hover, .fe:focus-visible { background: var(--surface-3); outline: none; }
.fe.ro { cursor: default; }
.fe.ro:hover { background: none; }
.fe .cv { white-space: normal; }
.fe .cv-tags, .fe .cv-rels, .fe .cv-people { flex-wrap: wrap; }
.fe-ph { color: var(--text-faint); }
.fe .dbt-input { position: static; height: 30px; margin: -4px -8px; width: calc(100% + 16px); border-radius: var(--r-sm); outline: 2px solid var(--accent); }
.rp-notes-head { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 6px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-faint); }
.rp-notes { min-height: 160px; padding: 4px 0 20px; }
.rp-meta { display: flex; align-items: center; gap: 10px; color: var(--text-faint); font-size: 12px; padding-top: 12px; }
.rp-meta-who { display: inline-flex; align-items: center; gap: 6px; }

/* quick add */
.qa { display: flex; flex-direction: column; gap: 12px; }
.qa-row { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 10px; align-items: center; }
.qa-label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.qa-title { font-size: 15px; font-weight: 560; }
.qa .fe { border: 1px solid var(--border); background: var(--bg); min-height: 36px; }
.qa .fe:hover { border-color: var(--border-strong); background: var(--bg); }
.qa .fe:focus-visible, .qa .fe:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.qa-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.qa-chip { border: 1.5px solid transparent; background: none; padding: 2px; border-radius: 8px; cursor: pointer; opacity: .55; }
.qa-chip .tg { font-size: 13.5px; padding: 3px 12px; }
.qa-chip:hover { opacity: .85; }
.qa-chip.on { opacity: 1; border-color: var(--accent); }
.qa-keep { margin-right: auto; font-size: 13px; color: var(--text-dim); }

/* ---------------- dashboards ---------------- */

.dsh { padding: 0 0 60px; max-width: 1280px; margin: 0 auto; }
.dsh-controls { display: flex; align-items: center; gap: 8px; padding: 6px 22px 14px; flex-wrap: wrap; }
.dsh-periodbox { display: inline-flex; align-items: center; gap: 4px; }
.dsh-period { gap: 8px; min-width: 150px; justify-content: space-between; font-weight: 600; }
.dsh-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; padding: 0 22px; }
.dsh-card {
  grid-column: span 6; min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px;
}
.dsh-card.tile { cursor: pointer; padding: 16px 18px; container-type: inline-size; }
.dsh-card.tile:hover { border-color: var(--border-strong); }
.dsh-card.span-3 { grid-column: span 3; } .dsh-card.span-4 { grid-column: span 4; } .dsh-card.span-6 { grid-column: span 6; }
.dsh-card.span-8 { grid-column: span 8; } .dsh-card.span-12 { grid-column: span 12; }
.dsh-card.editing { border-style: dashed; border-color: var(--border-strong); }
.dsh-card-head { display: flex; align-items: center; gap: 8px; min-height: 28px; }
.dsh-card-head.tile-head { position: absolute; right: 8px; top: 8px; }
.dsh-card.tile { position: relative; }
.dsh-card-title { font-size: 14px; font-weight: 650; letter-spacing: -.005em; }
.dsh-open { opacity: 0; color: var(--text-faint); }
.dsh-card:hover .dsh-open { opacity: 1; }
.dsh-card-body { min-width: 0; }
.dsh-stat { padding: 2px 0; }
.dsh-add {
  grid-column: span 12; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 22px;
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg); background: none; color: var(--text-dim); font: inherit; font-weight: 600; cursor: pointer;
}
.dsh-add:hover { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
.dsh-empty { grid-column: span 12; }

/* ---------------- databases home & the new-database dialog ---------------- */

.dbh { max-width: 980px; margin: 0 auto; padding: 28px 24px 80px; }
.dbh-hero { padding: 8px 0 18px; }
.dbh-hero h2 { font-size: 26px; letter-spacing: -.02em; margin-bottom: 8px; }
.dbh-hero p { max-width: 640px; color: var(--text-dim); font-size: 14.5px; line-height: 1.6; }
.dbh-h { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-faint); margin: 22px 0 10px; }
.dbh-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.dbh-card { display: flex; align-items: flex-start; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; min-width: 0; }
.dbh-card:hover { border-color: var(--accent); background: var(--surface-2); }
.dbh-ico { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--surface-3); font-size: 20px; color: var(--text-dim); }
.dbh-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.dbh-text .small { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.4; }
.dbh-text b { font-size: 14px; }

.nd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.nd-card { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 14px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface-2); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.nd-card:hover { border-color: var(--accent); }
.nd-card b { font-size: 14.5px; }
.nd-card span:last-child { font-size: 12.5px; color: var(--text-dim); line-height: 1.45; }
.nd-ico { font-size: 26px; line-height: 1; height: 30px; display: flex; align-items: center; }
.nd-card.blank { border-style: dashed; }
.nd-config { display: flex; flex-direction: column; gap: 12px; }
.nd-head { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.nd-ico-sm { font-size: 22px; }
.nd-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

/* ---------------- import ---------------- */

.imp { display: flex; flex-direction: column; gap: 14px; }
.imp-map { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow: auto; padding-right: 4px; }
.imp-row { display: grid; grid-template-columns: minmax(0, 1fr) 20px minmax(0, 1.5fr); gap: 8px; align-items: center; }
.imp-src { min-width: 0; display: flex; flex-direction: column; }
.imp-sample { font-size: 12px; color: var(--text-faint); }
.imp-arrow { color: var(--text-faint); display: grid; place-items: center; }
.imp-dest { display: flex; gap: 6px; min-width: 0; flex-wrap: wrap; }
.imp-dest .select, .imp-dest .input { flex: 1 1 130px; min-width: 0; padding: 7px 10px; font-size: 13px; }
.imp-options { display: flex; flex-direction: column; gap: 8px; }
.imp-opt { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.imp-opt .select { width: auto; padding: 5px 30px 5px 9px; }
.imp-preview { overflow: auto; border: 1px solid var(--border); border-radius: var(--r-md); padding: 8px; }
.imp-table { border-collapse: collapse; font-size: 12.5px; width: 100%; margin-bottom: 6px; }
.imp-table th, .imp-table td { padding: 5px 9px; text-align: left; border-bottom: 1px solid var(--dbt-line); white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.imp-table th { color: var(--text-dim); font-weight: 600; }
.imp-table td.bad { color: var(--bad-text); background: var(--red-soft); }

/* ---------------- small screens ---------------- */

@media (max-width: 760px) {
  .dbp-head { padding: 12px 14px 6px; }
  .dbp-link { margin: 0 14px 8px; flex-wrap: wrap; }
  .dbp-link-text { flex-basis: calc(100% - 50px); }
  .dbp-title { font-size: 22px; }
  .dbp-bar { flex-wrap: wrap; padding: 0 8px; gap: 0; }
  .dbp-tabs { flex-basis: 100%; }
  .dbp-tools { flex-basis: 100%; overflow-x: auto; padding: 4px 0 6px; }
  
  .dbp-search { width: 110px; flex: none; }
  .dbp-search:focus { width: 150px; }
  .dbp-chips { padding: 8px 14px 0; }
  .fl-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 28px; }
  .fl-where { grid-column: 1 / -1; text-align: left; }
  .fl-value { grid-column: 1 / -2; }
  .rp-scroll { padding: 16px 16px 60px; }
  .rp-field { grid-template-columns: 1fr; gap: 0; padding-bottom: 6px; }
  .qa-row { grid-template-columns: 1fr; gap: 4px; }
  .dsh-controls { padding: 4px 14px 12px; }
  .dsh-grid { padding: 0 14px; gap: 10px; }
  .dsh-card.span-3 { grid-column: span 6; }
  .dsh-card.span-4, .dsh-card.span-6, .dsh-card.span-8 { grid-column: span 12; }
  .dbh { padding: 18px 14px 80px; }
  .dbc-day { min-height: 70px; }
  .dbb-col { width: 82vw; }
  .imp-row { grid-template-columns: 1fr; }
  .imp-arrow { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .rp, .rp-scrim { transition: none; }
}
