/* =====================================================================
   Custom database page (database.html)
   Everything is inside the box with id="dbx", so these styles never
   change other Picrezo pages. The tool boxes keep light colors in dark mode.
   ===================================================================== */
.wrap.wide { max-width: 1900px; }
.wrap.wide > .info { max-width: 820px; margin-top: 32px; }

/* ===== Colors and basic controls ===== */
#dbx { --blue:#2563eb; --line:#d6dbe3; --text:#1d2430; --muted:#5f6b7a; --red:#c62828; color:var(--text); }
#dbx * { box-sizing:border-box; }
#dbx .card { background:#fff; border:1px solid var(--line); border-radius:10px; padding:14px; margin-bottom:14px; color:var(--text); }
#dbx .h2 { font-size:17px; margin:0 0 8px; }
#dbx label { font-size:13px; color:var(--muted); display:block; margin:6px 0 4px; }
#dbx input, #dbx select, #dbx textarea { font:inherit; font-size:14px; padding:6px 8px; border:1px solid var(--line); border-radius:6px; background:#fff; color:var(--text); width:100%; }
#dbx button { font:inherit; font-size:14px; padding:7px 12px; border:1px solid var(--blue); background:var(--blue); color:#fff; border-radius:6px; cursor:pointer; white-space:nowrap; }
#dbx button.ghost { background:#fff; color:var(--blue); }
#dbx button.small { padding:4px 9px; font-size:13px; }
#dbx button.danger { border-color:var(--red); background:#fff; color:var(--red); }
#dbx button:disabled { opacity:.45; cursor:default; }
#dbx .filebtn { display:inline-block; margin:0; padding:7px 12px; border:1px solid var(--blue); border-radius:6px; color:var(--blue); background:#fff; cursor:pointer; font-size:14px; }
#dbx .filebtn.small { padding:4px 9px; font-size:13px; }
#dbx .btns { display:flex; gap:6px; flex-wrap:wrap; align-items:center; }
#dbx .grow { flex:1 1 auto; }
#dbx .mt8 { margin-top:8px; } #dbx .mt10 { margin-top:10px; }
#dbx .note { font-size:13px; color:var(--muted); margin:6px 0; }
#dbx .note.err { color:var(--red); font-weight:600; }
#dbx .toprow { display:flex; gap:12px; flex-wrap:wrap; align-items:flex-end; }
#dbx .toprow .grow { min-width:240px; }
#dbx .toprow label { margin-top:0; }

/* ===== Table tabs ===== */
#dbx .tabs { display:flex; gap:4px; flex-wrap:wrap; margin-top:10px; border-bottom:2px solid var(--line); }
#dbx .tab { border:1px solid var(--line); border-bottom:none; background:#f4f6f9; color:var(--text); border-radius:8px 8px 0 0; padding:6px 12px; font-size:14px; }
#dbx .tab.on { background:var(--blue); color:#fff; border-color:var(--blue); }
#dbx .tab.add { background:#fff; color:var(--blue); border-style:dashed; }

/* ===== Tool row, filters, views ===== */
#dbx .tools { display:flex; gap:6px; flex-wrap:wrap; align-items:center; }
#dbx .tools .search { width:200px; padding:4px 8px; font-size:13px; }
#dbx .tools .sel { width:auto; padding:4px 6px; font-size:13px; }
#dbx .tools .lab { font-size:13px; color:var(--muted); margin-left:6px; }
#dbx #views button { margin-right:4px; }
#dbx #views button.on { background:var(--blue); color:#fff; }
#dbx .vx { margin-left:-2px; padding:4px 6px !important; }
#dbx .frow { display:flex; gap:6px; align-items:center; flex-wrap:wrap; margin-top:6px; font-size:13px; }
#dbx .frow select, #dbx .frow input { width:auto; padding:4px 6px; font-size:13px; }
#dbx .frow input { width:160px; }

/* ===== The data grid ===== */
#dbx .tablewrap { overflow-x:auto; margin-top:6px; }
#dbx table { border-collapse:collapse; table-layout:fixed; font-size:13px; }
#dbx th, #dbx td { border:1px solid var(--line); padding:2px; vertical-align:middle; }
#dbx th { background:#eef2f7; font-weight:600; text-align:left; position:relative; padding:5px 6px; }
#dbx th .hname { cursor:pointer; display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; padding-right:26px; }
#dbx th .htype { display:block; font-weight:400; font-size:11px; color:var(--muted); }
#dbx th .hedit { position:absolute; right:8px; top:5px; padding:1px 5px; font-size:12px; }
#dbx th.rn, #dbx td.rn { text-align:center; color:var(--muted); width:46px; }
#dbx td.rn button { padding:1px 6px; font-size:12px; }
#dbx td input, #dbx td select { border-color:transparent; padding:5px 6px; font-size:13px; }
#dbx td input:focus, #dbx td select:focus { border-color:var(--blue); outline:none; }
#dbx td input[type=checkbox] { width:auto; margin:0 auto; display:block; }
#dbx td.num input, #dbx td.fx { text-align:right; }
#dbx td.fx { color:#0d47a1; font-weight:600; padding-right:8px; background:#f7faff; }
#dbx td.del { text-align:center; width:34px; }
#dbx td.del button { padding:1px 6px; font-size:12px; }
#dbx tr.grp td { background:#e8eef7; font-weight:700; }
#dbx tr.grp td.gl { padding:5px 8px; }
#dbx tr.tot td { background:#f1f5f9; font-weight:700; text-align:right; padding:4px 8px; }
#dbx tr.tot td select { font-size:11px; padding:2px; width:auto; border-color:var(--line); }
#dbx .money { color:var(--muted); font-size:11px; margin-left:3px; }
#dbx .colgrip { position:absolute; top:0; right:0; width:7px; height:100%; cursor:col-resize; z-index:3; touch-action:none; }
#dbx .colgrip:hover { background:rgba(37,99,235,.35); }
#dbx th.sorted .hname { color:var(--blue); }

/* ===== Dialogs (column editor, record form) ===== */
#dbx .dlg { position:fixed; inset:0; background:rgba(15,23,42,.45); z-index:40; display:flex; align-items:flex-start; justify-content:center; padding:5vh 12px; overflow:auto; }
#dbx .dlg[hidden] { display:none; }
#dbx .dlgbox { background:#fff; border-radius:12px; padding:18px; width:min(560px,100%); box-shadow:0 10px 30px rgba(0,0,0,.25); }
#dbx .chips { display:flex; gap:4px; flex-wrap:wrap; }
#dbx .chips button { padding:2px 8px; font-size:12px; }
#dbx #formFields .ff { margin-bottom:4px; }
#dbx #formFields .ffx { font-size:14px; color:#0d47a1; font-weight:600; padding:6px 0; }

/* ===== Short message at the bottom ===== */
#dbx #msg { position:fixed; bottom:16px; left:50%; transform:translateX(-50%); background:#222; color:#fff; padding:8px 14px; border-radius:6px; font-size:14px; display:none; z-index:60; }

/* ===== Calculated cells that hold text (values from a linked record) ===== */
#dbx td.fx.fxt { text-align:left; color:#334155; font-weight:400; }
#dbx .tools button.on { background:var(--blue); color:#fff; }

/* ===== Chart ===== */
#dbx .chartbox { border:1px solid var(--line); border-radius:8px; padding:8px; margin:8px 0; background:#fff; }
#dbx #chartArea { position:relative; overflow-x:auto; margin-top:6px; }
#dbx #chartArea svg { display:block; }
#dbx .chtip { position:absolute; background:#1d2430; color:#fff; font-size:12px; padding:4px 8px; border-radius:5px; pointer-events:none; white-space:nowrap; z-index:5; }
#dbx .chtip[hidden] { display:none; }
#dbx #chAgg[hidden] { display:none; }

/* ===== Print / PDF: only the clean report is printed ===== */
@media screen { #printArea { display:none; } }
@media print {
  @page { margin:12mm; }
  body > *:not(#printArea) { display:none !important; }
  #printArea { display:block; font-family:Arial, sans-serif; color:#000; }
  #printArea h1 { font-size:18px; margin:0 0 4px; }
  #printArea .pinfo { font-size:11px; color:#444; margin:0 0 10px; }
  #printArea .pchart { display:block; max-width:100%; height:auto; margin:0 0 12px; }
  #printArea table { border-collapse:collapse; width:100%; font-size:10px; }
  #printArea th, #printArea td { border:1px solid #999; padding:3px 5px; text-align:left; vertical-align:top; }
  #printArea th { background:#e8eef7; }
  #printArea thead { display:table-header-group; }
  #printArea tr { break-inside:avoid; }
  #printArea td.n { text-align:right; white-space:nowrap; }
  #printArea tr.pg td { background:#eef2f7; font-weight:bold; }
  #printArea tr.pt td { background:#dde3ec; font-weight:bold; }
  #printArea th, #printArea tr.pg td, #printArea tr.pt td { -webkit-print-color-adjust:exact; print-color-adjust:exact; }
}

/* ===== Color rules: soft backgrounds so the text stays easy to read ===== */
#dbx td input, #dbx td select { background:transparent; }
#dbx .rulesbox { border:1px dashed var(--line); border-radius:8px; padding:6px 8px; margin-top:8px; }
#dbx .frow input.short { width:70px; }
#dbx .tip { font-size:12px; }
#dbx tr.rc-red td, #dbx td.rc-red, #printArea .rc-red, #dbx select.c-red { background:#fde2e1; }
#dbx tr.rc-orange td, #dbx td.rc-orange, #printArea .rc-orange, #dbx select.c-orange { background:#ffe8cc; }
#dbx tr.rc-yellow td, #dbx td.rc-yellow, #printArea .rc-yellow, #dbx select.c-yellow { background:#fff6bf; }
#dbx tr.rc-green td, #dbx td.rc-green, #printArea .rc-green, #dbx select.c-green { background:#dcf5e3; }
#dbx tr.rc-blue td, #dbx td.rc-blue, #printArea .rc-blue, #dbx select.c-blue { background:#dbeafe; }
#dbx tr.rc-grey td, #dbx td.rc-grey, #printArea .rc-grey, #dbx select.c-grey { background:#e9edf1; }
#printArea tr[class^=rc-] td, #printArea td[class*=rc-] { -webkit-print-color-adjust:exact; print-color-adjust:exact; }
#printArea tr.rc-red td { background:#fde2e1; } #printArea tr.rc-orange td { background:#ffe8cc; } #printArea tr.rc-yellow td { background:#fff6bf; }
#printArea tr.rc-green td { background:#dcf5e3; } #printArea tr.rc-blue td { background:#dbeafe; } #printArea tr.rc-grey td { background:#e9edf1; }

/* ===== Pivot table ===== */
#dbx #pivotArea { overflow-x:auto; margin-top:6px; }
#dbx table.pivot { table-layout:auto; }
#dbx table.pivot th, #dbx table.pivot td { padding:4px 10px; white-space:nowrap; }
#dbx table.pivot td.n, #dbx table.pivot th.n { text-align:right; }
#dbx table.pivot .tot, #dbx table.pivot tr.ptot td, #dbx table.pivot tr.ptot th { background:#eef2f7; font-weight:700; }
#dbx #pvAgg[hidden] { display:none; }
@media print {
  #printArea table.ppivot { width:auto; margin-bottom:12px; }
  #printArea table.ppivot th { text-align:left; }
  #printArea table.ppivot td { text-align:right; }
  #printArea table.ppivot tr.ptot td, #printArea table.ppivot tr.ptot th, #printArea table.ppivot .tot { background:#dde3ec; font-weight:bold; -webkit-print-color-adjust:exact; print-color-adjust:exact; }
}

/* ===== Checkbox settings in the column editor ===== */
#dbx label.chk { display:flex; align-items:center; gap:6px; color:var(--text); margin-top:10px; }
#dbx label.chk input { width:auto; margin:0; }
#dbx .dlgbox.wide { width:min(900px,100%); }

/* ===== Row selection, duplicate, required ===== */
#dbx td input.rsel, #dbx th input.rsel { width:auto; margin:0 3px 0 0; vertical-align:middle; display:inline-block; }
#dbx td.rn { white-space:nowrap; }
#dbx td.del { white-space:nowrap; width:58px; }
#dbx td.del button { margin:0 1px; }
#dbx tr.picked td { box-shadow:inset 0 0 0 9999px rgba(37,99,235,.08); }
#dbx td.missing { box-shadow:inset 0 0 0 2px #e57373; }
#dbx #formFields .ff.missing input, #dbx #formFields .ff.missing select, #dbx #formFields .ff.missing textarea { border-color:var(--red); }
#dbx .bulk { display:flex; gap:6px; align-items:center; flex-wrap:wrap; background:#eef4ff; border:1px solid #c7d7f5; border-radius:8px; padding:6px 8px; margin-top:8px; font-size:13px; }
#dbx .bulk select, #dbx .bulk input { width:auto; padding:4px 6px; font-size:13px; }
#dbx .bulk .bval input[type=text] { width:160px; }

/* ===== Long text ===== */
#dbx td textarea { border-color:transparent; padding:5px 6px; font-size:13px; resize:vertical; min-height:30px; display:block; line-height:1.35; background:transparent; }
#dbx td textarea:focus { border-color:var(--blue); outline:none; }
#dbx #formFields textarea { min-height:70px; }

/* ===== Photos / files ===== */
#dbx .files { display:flex; gap:3px; flex-wrap:wrap; align-items:center; padding:2px; }
#dbx .files .thumb { padding:0; border:1px solid var(--line); background:#fff; color:var(--text); width:34px; height:34px; border-radius:4px; overflow:hidden; font-size:10px; display:flex; align-items:center; justify-content:center; }
#dbx .files .thumb:not(:has(img)) { width:auto; padding:0 4px; }
#dbx .files .thumb img { width:100%; height:100%; object-fit:cover; display:block; }
#dbx .files .addf { margin:0; width:28px; height:28px; border:1px dashed var(--blue); color:var(--blue); border-radius:4px; display:flex; align-items:center; justify-content:center; cursor:pointer; font-size:16px; }
#dbx #fvBody { text-align:center; }
#dbx .fvimg { max-width:100%; max-height:70vh; border-radius:6px; }

/* ===== Calendar ===== */
#dbx .calm { min-width:150px; text-align:center; }
#dbx .cal { display:grid; grid-template-columns:repeat(7, minmax(0,1fr)); gap:3px; margin-top:8px; }
#dbx .calh { font-size:12px; color:var(--muted); text-align:center; padding:2px; }
#dbx .calday { border:1px solid var(--line); border-radius:6px; min-height:96px; padding:3px; background:#fff; display:flex; flex-direction:column; gap:2px; min-width:0; }
#dbx .calday.out { background:#f7f8fa; } #dbx .calday.out .calnum { color:#aab2bd; }
#dbx .calday.today { border-color:var(--blue); box-shadow:inset 0 0 0 1px var(--blue); }
#dbx .calnum { font-size:12px; font-weight:600; display:flex; justify-content:space-between; align-items:center; }
#dbx .calplus { padding:0 5px !important; font-size:12px !important; opacity:0; }
#dbx .calday:hover .calplus, #dbx .calplus:focus { opacity:1; }
#dbx .chip { font-size:12px; background:#eef4ff; border-radius:4px; padding:2px 5px; cursor:pointer; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; user-select:none; touch-action:none; }
#dbx .chip b { font-weight:600; }

/* ===== Board ===== */
#dbx .board { display:flex; gap:10px; overflow-x:auto; align-items:flex-start; padding:8px 0; }
#dbx .lane { flex:0 0 250px; background:#f4f6f9; border-radius:8px; padding:6px; min-height:120px; display:flex; flex-direction:column; gap:6px; }
#dbx .laneh { display:flex; align-items:center; gap:4px; padding:2px 4px; }
#dbx .laneh b { flex:1 1 auto; }
#dbx .card2 { background:#fff; border:1px solid var(--line); border-radius:6px; padding:6px 8px; cursor:pointer; font-size:13px; display:flex; flex-direction:column; gap:2px; user-select:none; touch-action:none; }
#dbx .card2 .cf { font-size:12px; color:var(--muted); }
#dbx .card2.rc-red, #dbx .chip.rc-red { background:#fde2e1; } #dbx .card2.rc-orange, #dbx .chip.rc-orange { background:#ffe8cc; }
#dbx .card2.rc-yellow, #dbx .chip.rc-yellow { background:#fff6bf; } #dbx .card2.rc-green, #dbx .chip.rc-green { background:#dcf5e3; }
#dbx .card2.rc-blue, #dbx .chip.rc-blue { background:#dbeafe; } #dbx .card2.rc-grey, #dbx .chip.rc-grey { background:#e9edf1; }

/* ===== Dragging ===== */
#dbx .dragghost { position:fixed; z-index:80; pointer-events:none; opacity:.9; box-shadow:0 6px 18px rgba(0,0,0,.25); }
#dbx .dragging { opacity:.35; }
#dbx .dropon { outline:2px dashed var(--blue); outline-offset:-2px; }
@media (max-width:700px) { #dbx .calday { min-height:64px; } #dbx .chip { font-size:10px; padding:1px 3px; } #dbx .calh { font-size:10px; } }
@media print { #printArea img.pthumb { width:40px; height:40px; object-fit:cover; margin:1px; } }
