/* =========================================================================
   ForensiQL — styles
   Dark, information-dense UI inspired by VS Code / DB Browser / DataGrip.
   ========================================================================= */

:root {
  --bg-0: #0e1116;   /* app background */
  --bg-1: #12161d;   /* panels */
  --bg-2: #171c25;   /* headers / rows */
  --bg-3: #1e2530;   /* hover / inputs */
  --bg-4: #2a3340;   /* borders-ish surfaces */
  --line: #232a35;   /* borders */
  --line-2: #303a48;
  --txt-0: #e6edf3;  /* primary text */
  --txt-1: #b6c2cf;  /* secondary */
  --txt-2: #7d8b9a;  /* muted */
  --accent: #4ea1ff; /* primary accent */
  --accent-2: #7c5cff;
  --ok: #3fb950;
  --warn: #d29922;
  --err: #f85149;
  --susp: #ff6b6b;   /* suspicious highlight */
  --pk: #d2a8ff;     /* primary-key column */
  --sel: #17385f;    /* cell selection */
  --sel-line: #2f6fb3;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 6px;
  --h-top: 42px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--txt-0);
  background: var(--bg-0);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.scroll { overflow: auto; }
.pad { padding: 12px 14px; }
code { font-family: var(--mono); background: var(--bg-3); padding: 1px 5px; border-radius: 4px; color: var(--txt-1); }

/* scrollbars */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2c3644; border-radius: 6px; border: 2px solid var(--bg-0); }
::-webkit-scrollbar-thumb:hover { background: #3a4757; }

/* ---------- buttons / inputs ---------- */
.btn {
  font-family: var(--sans); font-size: 12px;
  color: var(--txt-1); background: var(--bg-3);
  border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: 5px 10px; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--bg-4); color: var(--txt-0); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #04121f; border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { background: #6bb2ff; }
.btn-lg { padding: 9px 18px; font-size: 14px; }
.btn.small { padding: 3px 7px; font-size: 11px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.mini-input, input[type=search], input[type=text], select, textarea {
  font-family: var(--sans); font-size: 12px; color: var(--txt-0);
  background: var(--bg-3); border: 1px solid var(--line-2);
  border-radius: 5px; padding: 4px 8px; outline: none;
}
.mini-input:focus, input:focus, select:focus, textarea:focus { border-color: var(--accent); }
select { cursor: pointer; }
label { color: var(--txt-1); }

/* ---------- top bar ---------- */
#topbar {
  height: var(--h-top); display: flex; align-items: center; gap: 12px;
  padding: 0 12px; background: var(--bg-1); border-bottom: 1px solid var(--line);
  position: relative; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { color: var(--accent); font-size: 18px; cursor: pointer; }
.brand-name { font-weight: 600; letter-spacing: .2px; cursor: pointer; }
.brand-mark:hover, .brand-name:hover { color: #6bb2ff; }
.brand-badge {
  font-size: 10px; letter-spacing: .5px; color: var(--ok);
  border: 1px solid #1e5b2d; background: #0f2417; padding: 2px 7px; border-radius: 20px;
}
.topbar-tabs { display: flex; gap: 4px; margin-left: 8px; flex: 1; overflow-x: auto; }
.topbar-tabs::-webkit-scrollbar { height: 0; }
.db-tab {
  display: flex; align-items: center; gap: 7px; padding: 4px 9px; border-radius: 6px 6px 0 0;
  background: var(--bg-2); border: 1px solid var(--line); border-bottom: none;
  cursor: pointer; font-size: 12px; color: var(--txt-1); max-width: 220px;
}
.db-tab .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-tab.active { background: var(--bg-3); color: var(--txt-0); border-color: var(--line-2); }
.db-tab .close { color: var(--txt-2); border-radius: 4px; padding: 0 3px; }
.db-tab .close:hover { background: var(--err); color: #fff; }
.topbar-actions { display: flex; gap: 6px; }

/* ---------- workspace / panels ---------- */
#workspace { display: flex; height: calc(100vh - var(--h-top)); width: 100vw; }
.panel { background: var(--bg-1); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#panel-left { width: 280px; flex: 0 0 auto; border-right: 1px solid var(--line); }
#panel-center { flex: 1 1 auto; min-width: 200px; border-right: 1px solid var(--line); }
#panel-right { width: 460px; flex: 0 0 auto; display: flex; flex-direction: column; }

.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; background: var(--bg-2); border-bottom: 1px solid var(--line);
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--txt-2);
  flex: 0 0 auto;
}
.panel-head-actions { display: flex; gap: 6px; align-items: center; }
.panel-head-actions .mini-input { width: 130px; }
.panel-body { flex: 1 1 auto; min-height: 0; }

/* splitters */
.splitter { flex: 0 0 5px; background: transparent; position: relative; z-index: 5; }
.splitter-v { cursor: col-resize; }
.splitter-h { cursor: row-resize; flex: 0 0 5px; }
.splitter::after { content:""; position:absolute; inset:0; }
.splitter:hover::after, .splitter.dragging::after { background: var(--accent); opacity:.5; }
.splitter-v::after { left:1px; right:1px; }
.splitter-h::after { top:1px; bottom:1px; }

/* ---------- explorer tree ---------- */
#explorer { font-size: 13px; padding: 4px 0 12px; }
.tree-group { user-select: none; }
.tree-node {
  display: flex; align-items: center; gap: 7px; padding: 4px 8px 4px 8px;
  cursor: pointer; white-space: nowrap; color: var(--txt-1); border-radius: 6px;
  margin: 1px 6px; position: relative; transition: background .1s;
}
.tree-node:hover { background: var(--bg-3); color: var(--txt-0); }
.tree-node.active {
  background: linear-gradient(90deg, rgba(78,161,255,.16), rgba(78,161,255,.05));
  color: var(--txt-0); font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent);
}
.tree-node.active .tree-ico { color: var(--accent); opacity: 1; }
.tree-node.empty { color: var(--txt-2); }
.tree-node.empty .tree-ico { opacity: .4; }
.tree-caret { width: 12px; flex: 0 0 auto; display: inline-block; color: var(--txt-2); transition: transform .12s; text-align: center; }
.tree-caret.open { transform: rotate(90deg); }
.tree-ico { width: 16px; flex: 0 0 auto; text-align: center; opacity: .8; color: var(--txt-1); }
.tree-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* friendly label yields space to the table name first (shrinks 200x faster) */
.tree-friendly {
  flex: 0 200 auto; min-width: 0; max-width: 55%; overflow: hidden; text-overflow: ellipsis;
  color: var(--accent); font-size: 10.5px; opacity: .8; font-weight: 400;
}
.tree-count {
  margin-left: auto; flex: 0 0 auto; color: var(--txt-1); font-size: 10.5px;
  font-family: var(--mono); background: var(--bg-3); border: 1px solid var(--line);
  padding: 0 6px; border-radius: 20px; min-width: 20px; text-align: center;
}
.tree-node:hover .tree-count { border-color: var(--line-2); }
.tree-node.active .tree-count { background: rgba(78,161,255,.18); border-color: transparent; color: #cfe6ff; }
.tree-count.zero { opacity: .45; }
.tree-children { margin-left: 15px; padding-left: 3px; border-left: 1px solid var(--line); }

/* group header rows (Tables / Views / Indexes / Triggers) */
.grp-header { color: var(--txt-2); text-transform: uppercase; letter-spacing: .5px; font-size: 11px; font-weight: 700; margin-top: 6px; }
.grp-header:first-of-type { margin-top: 2px; }
.grp-header:hover { background: transparent; color: var(--txt-0); }
.grp-header .tree-ico { opacity: .6; }
.grp-count { background: transparent; border: none; color: var(--txt-2); }

/* detected-browser badge row */
.detected-row { display: flex; align-items: center; gap: 8px; padding: 8px 12px 4px; }
.detected-label { font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: var(--txt-2); }
.detected-badge {
  font-size: 11px; font-weight: 600; color: var(--accent);
  background: rgba(78,161,255,.1); border: 1px solid rgba(78,161,255,.28);
  padding: 1px 9px; border-radius: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* expandable column list under a table (DB Browser structure tree) */
.tree-cols { margin: 1px 0 3px 26px; border-left: 1px solid var(--line); }
.tree-col {
  display: flex; align-items: center; gap: 6px; padding: 2px 8px 2px 10px;
  font-size: 12px; color: var(--txt-1); cursor: default; white-space: nowrap;
}
.tree-col:hover { background: var(--bg-2); }
.tree-col .cico { width: 13px; text-align: center; font-size: 11px; }
.tree-col .cname { overflow: hidden; text-overflow: ellipsis; }
.tree-col .ctype { color: var(--txt-2); font-size: 10px; margin-left: auto; padding-left: 8px; }
.tree-col .cbadge { font-size: 9px; padding: 0 4px; border-radius: 3px; }
.tree-col .cbadge.pk { color: var(--pk); border: 1px solid #4a3a63; }
.tree-col .cbadge.fk { color: #7ee0c0; border: 1px solid #2e5a4d; }
.tree-col .cbadge.ix { color: var(--accent); border: 1px solid #274a6b; }
.tree-col .cbadge.nn { color: var(--warn); border: 1px solid #5a4a1e; }
.tree-section {
  padding: 6px 12px 3px; font-size: 10px; text-transform: uppercase;
  letter-spacing: .6px; color: var(--txt-2); display:flex; justify-content:space-between;
}

/* ---------- persistent cell preview panel ---------- */
.cell-preview { flex: 0 0 auto; display: flex; flex-direction: column; border-top: 1px solid var(--line); background: var(--bg-1); }
.cp-resize { height: 6px; cursor: row-resize; background: transparent; position: relative; flex: 0 0 auto; }
.cp-resize::after { content: ""; position: absolute; left: 50%; top: 1px; width: 40px; height: 3px; transform: translateX(-50%); background: var(--line-2); border-radius: 3px; }
.cp-resize:hover::after, .cp-resize.dragging::after { background: var(--accent); }
.cell-preview.collapsed .cp-resize { display: none; }
.cp-head { display: flex; align-items: center; gap: 8px; padding: 4px 10px; background: var(--bg-2); border-bottom: 1px solid var(--line); font-size: 11px; cursor: pointer; }
.cell-preview.collapsed .cp-head { border-bottom: none; }
.cp-title { text-transform: uppercase; letter-spacing: .5px; color: var(--txt-2); }
.cp-meta { color: var(--txt-1); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; }
.cp-meta b { color: var(--txt-0); }
.cp-spacer { flex: 1; }
.cp-toggle { background: transparent; border: none; color: var(--txt-2); cursor: pointer; font-size: 13px; padding: 0 4px; }
.cp-toggle:hover { color: var(--txt-0); }
.cp-body { height: 130px; overflow: auto; padding: 8px 10px; display: flex; gap: 14px; align-items: flex-start; }
.cell-preview.collapsed .cp-body { display: none; }
.cp-body .cp-text { font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-word; color: var(--txt-0); flex: 1; min-width: 0; }
.cp-body img.cp-img { max-height: 114px; max-width: 200px; border-radius: 4px; box-shadow: 0 0 0 1px var(--line);
  background-image: linear-gradient(45deg,#1a1f28 25%,transparent 25%),linear-gradient(-45deg,#1a1f28 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#1a1f28 75%),linear-gradient(-45deg,transparent 75%,#1a1f28 75%);
  background-size: 14px 14px; background-position: 0 0,0 7px,7px -7px,-7px 0; padding: 3px; }
.cp-extras { margin-top: 8px; }

/* ---------- tabs (center + results) ---------- */
.tabbar, .results-tabs { display: flex; gap: 2px; background: var(--bg-2); border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.tab, .rtab {
  background: transparent; border: none; border-bottom: 2px solid transparent;
  color: var(--txt-2); padding: 8px 14px; cursor: pointer; font-size: 12px;
}
.tab:hover, .rtab:hover { color: var(--txt-0); }
.tab.active, .rtab.active { color: var(--txt-0); border-bottom-color: var(--accent); }
.view-host, .results-host { flex: 1 1 auto; min-height: 0; position: relative; }
.view, .rview { position: absolute; inset: 0; display: none; }
.view.active, .rview.active { display: block; }
.view > div, .rview > div { height: 100%; }

/* ---------- SQL editor ---------- */
#editor-host { flex: 0 0 auto; height: 200px; min-height: 80px; border-bottom: 1px solid var(--line); overflow: hidden; }
.CodeMirror { height: 100% !important; font-family: var(--mono) !important; font-size: 13px; background: var(--bg-0) !important; }
.CodeMirror-gutters { background: var(--bg-1) !important; border-right: 1px solid var(--line) !important; }
.results-head {
  display:flex; align-items:center; justify-content:space-between;
  background: var(--bg-2); border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.results-status { font-size: 11px; color: var(--txt-2); padding: 0 12px; white-space: nowrap; }
.results-status .ok { color: var(--ok); }
.results-status .err { color: var(--err); }

/* ---------- data grid ---------- */
.grid-wrap { display:flex; flex-direction:column; height:100%; }
.grid-toolbar {
  display:flex; align-items:center; gap:6px; padding:6px 8px; background: var(--bg-2);
  border-bottom:1px solid var(--line); flex:0 0 auto; flex-wrap: wrap;
}
.grid-toolbar .spacer { flex:1; }
.grid-toolbar .title { font-weight:600; color: var(--txt-0); margin-right: 4px; }
.grid-toolbar .friendly { color: var(--accent); font-size:11px; }
.grid-search { width: 200px; }
.grid-scroll { flex:1 1 auto; overflow:auto; position:relative; }
table.grid { border-collapse: separate; border-spacing: 0; font-family: var(--mono); font-size: 11px; width: max-content; min-width: 100%; table-layout: fixed; }
table.grid th, table.grid td {
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 3px 8px; text-align: left; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; vertical-align: top;
}
/* density variants */
table.grid.compact { font-size: 10px; }
table.grid.compact th, table.grid.compact td { padding: 1px 6px; }
table.grid.roomy { font-size: 12px; }
table.grid.roomy th, table.grid.roomy td { padding: 5px 10px; }
/* wrap mode: show long values in full across multiple lines */
table.grid.wrap td { white-space: normal; word-break: break-word; overflow: visible; text-overflow: clip; max-width: 680px; }
table.grid thead th {
  position: sticky; top: 0; z-index: 3; background: var(--bg-2); color: var(--txt-0);
  cursor: pointer; user-select: none; font-weight: 700; font-size: 12.5px;
}
/* keep header labels a touch larger than cell data so columns stay identifiable */
table.grid.compact thead th { font-size: 11px; }
table.grid.roomy thead th { font-size: 13.5px; }
table.grid thead th .th-inner > span:first-child { letter-spacing: .2px; }
table.grid thead th:hover { background: var(--bg-3); }
table.grid thead th .th-inner { display:flex; align-items:center; gap:6px; }
table.grid thead th .col-type { color: var(--txt-2); font-weight: 400; font-size: 10px; }
table.grid thead th .col-pk { color: var(--pk); }
table.grid thead th .sort-ind { color: var(--accent); margin-left:auto; }
table.grid thead th .col-menu { color: var(--txt-2); opacity:0; margin-left:4px; }
table.grid thead th:hover .col-menu { opacity:1; }
table.grid tbody tr:nth-child(even) td { background: rgba(255,255,255,.012); }
table.grid tbody tr:hover td { background: var(--bg-2); }
table.grid td.rownum, table.grid th.rownum {
  position: sticky; left: 0; z-index: 2; background: var(--bg-1); color: var(--txt-2);
  text-align: right; user-select: none; width: 52px; min-width: 52px;
}
table.grid thead th.rownum { z-index: 4; }
table.grid td.sel { background: var(--sel) !important; outline: 1px solid var(--sel-line); outline-offset: -1px; }
table.grid td.null { color: var(--txt-2); font-style: italic; }
table.grid td.blob { color: var(--warn); cursor: pointer; }
table.grid td.blob:hover { text-decoration: underline; }
table.grid td.blob img.cell-thumb {
  height: 20px; width: auto; max-width: 96px; vertical-align: middle; border-radius: 3px;
  image-rendering: auto; background: #fff2; padding: 1px; box-shadow: 0 0 0 1px var(--line);
}
table.grid.compact td.blob img.cell-thumb { height: 16px; }
table.grid.roomy td.blob img.cell-thumb { height: 28px; }
table.grid td.blob .thumb-cap { color: var(--txt-2); font-size: 10px; margin-left: 6px; }
table.grid td.num { color: #a5d6a7; }
table.grid td.suspicious { color: var(--susp); }
table.grid td .ts-conv { color: var(--accent); display:block; font-size:11px; opacity:.85; }
.col-frozen { position: sticky; z-index: 2; background: var(--bg-1) !important; box-shadow: 1px 0 0 var(--line-2); }
thead .col-frozen { z-index: 4; }

.resizer { position:absolute; top:0; right:-3px; width:6px; height:100%; cursor:col-resize; z-index:5; }

/* inline per-column filter row (DB Browser style) */
table.grid thead th .th-filter { margin-top: 4px; }
table.grid thead th .th-filter input {
  width: 100%; box-sizing: border-box; font-family: var(--mono); font-size: 10px;
  padding: 2px 5px; background: var(--bg-0); border: 1px solid var(--line-2);
  border-radius: 4px; color: var(--txt-0); font-weight: 400;
}
table.grid thead th .th-filter input::placeholder { color: var(--txt-2); }
table.grid thead th .th-filter input.active { border-color: var(--accent); background: #12233a; }

.grid-footer {
  display:flex; align-items:center; gap:10px; padding:5px 10px; background: var(--bg-2);
  border-top:1px solid var(--line); flex:0 0 auto; font-size:11px; color: var(--txt-2);
}
.grid-footer .pager { display:flex; align-items:center; gap:4px; }
.grid-footer .spacer { flex:1; }

/* ---------- empty / message states ---------- */
.empty-msg { color: var(--txt-2); padding: 30px; text-align:center; font-size: 13px; }
.err-box { color: var(--err); background: #2a1416; border:1px solid #5a2327; border-radius:6px; padding:10px 12px; margin:10px; font-family: var(--mono); font-size:12px; white-space: pre-wrap; }

/* ---------- schema / info / stats views ---------- */
.section-title { font-size: 13px; font-weight: 600; color: var(--txt-0); margin: 16px 0 8px; display:flex; align-items:center; gap:8px; }
.section-title:first-child { margin-top: 0; }
.kv { display:grid; grid-template-columns: minmax(0, 200px) minmax(0, 1fr); gap:4px 12px; font-size:12px; }
.kv .v { word-break: break-word; }
.kv .k { color: var(--txt-2); }
.kv .v { color: var(--txt-0); font-family: var(--mono); }
pre.sql { background: var(--bg-0); border:1px solid var(--line); border-radius:6px; padding:12px; overflow:auto; font-family: var(--mono); font-size:12px; color:#cfe3ff; white-space: pre; }
table.meta { border-collapse: collapse; font-size:12px; width:100%; margin: 6px 0; }
table.meta th, table.meta td { border:1px solid var(--line); padding:5px 8px; text-align:left; }
table.meta th { background: var(--bg-2); color: var(--txt-1); }
table.meta td { font-family: var(--mono); color: var(--txt-1); }
.chip { display:inline-block; background: var(--bg-3); border:1px solid var(--line-2); border-radius: 20px; padding:1px 9px; font-size:11px; color: var(--txt-1); margin: 0 4px 4px 0; }
.chip.pk { color: var(--pk); border-color:#4a3a63; }
.chip.fk { color: #7ee0c0; border-color:#2e5a4d; }
.chip.idx { color: var(--accent); border-color:#274a6b; }

/* stats cards */
.stat-card { border:1px solid var(--line); border-radius:8px; margin-bottom:10px; overflow:hidden; }
.stat-card > .h { background: var(--bg-2); padding:7px 10px; display:flex; justify-content:space-between; align-items:center; }
.stat-card > .h .name { font-family: var(--mono); color: var(--txt-0); }
.stat-card > .h .type { color: var(--txt-2); font-size:11px; }
.stat-card > .b { padding: 8px 10px; }
.stat-row { display:flex; gap:16px; flex-wrap:wrap; font-size:12px; margin-bottom:6px; }
.stat-row .m { color: var(--txt-2); }
.stat-row .m b { color: var(--txt-0); font-family: var(--mono); font-weight:600; }
.bar { height: 6px; background: var(--bg-3); border-radius: 4px; overflow:hidden; }
.bar > i { display:block; height:100%; background: var(--accent); }
.topvals { margin-top:6px; }
.topvals .tv { display:flex; align-items:center; gap:8px; font-size:11px; margin:3px 0; }
.topvals .tv .val { font-family: var(--mono); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width: 55%; color: var(--txt-1); }
.topvals .tv .barwrap { flex:1; }
.topvals .tv .cnt { color: var(--txt-2); min-width:60px; text-align:right; }

/* ---------- built-in / saved / history lists ---------- */
.q-item {
  border:1px solid var(--line); border-radius:6px; padding:8px 10px; margin-bottom:8px;
  background: var(--bg-1); cursor:pointer;
}
.q-item:hover { border-color: var(--line-2); background: var(--bg-2); }
.q-item .q-title { font-weight:600; color: var(--txt-0); display:flex; justify-content:space-between; gap:8px; }
.q-item .q-desc { color: var(--txt-2); font-size:11px; margin-top:2px; }
.q-item .q-sql { font-family: var(--mono); font-size:11px; color: var(--txt-2); margin-top:5px; white-space:pre-wrap; max-height: 3.2em; overflow:hidden; }
.q-cat { font-size:10px; text-transform:uppercase; letter-spacing:.5px; color: var(--txt-2); margin: 12px 0 6px; }
.q-cat:first-child { margin-top: 0; }
.q-actions { display:flex; gap:6px; }

/* ---------- dropzone / empty ---------- */
.dropzone { position: fixed; inset: 0; background: rgba(8,10,14,.86); backdrop-filter: blur(3px); display:flex; align-items:center; justify-content:center; z-index: 50; }
.dropzone.dragover .dz-card { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(78,161,255,.25); }
.dz-card { text-align:center; background: var(--bg-1); border:2px dashed var(--line-2); border-radius: 14px; padding: 40px 46px; max-width: 620px; }
.dz-icon { font-size: 46px; }
.dz-card h1 { font-size: 22px; margin: 10px 0 4px; }
.dz-tag { color: var(--txt-1); font-size: 13px; line-height: 1.6; margin: 4px auto 16px; max-width: 500px; }
.dz-sub { color: var(--txt-2); margin: 0 0 18px; font-size: 12px; }
.dz-error { color: var(--err); background: #2a1416; border: 1px solid #5a2327; border-radius: 8px; padding: 10px 14px; margin: 16px auto 0; max-width: 500px; font-size: 12.5px; line-height: 1.5; text-align: left; }
.dz-error b { color: #ff9a9a; }
.dz-formats { color: var(--txt-2); font-size: 11px; margin-top: 22px; line-height: 1.7; }
.dz-privacy { color: var(--ok); font-size: 11px; margin-top: 12px; }
.dz-tip { color: var(--txt-2); font-size: 11px; margin-top: 8px; line-height: 1.6; max-width: 520px; margin-left: auto; margin-right: auto; }
.dz-tip b { color: var(--txt-1); }

/* ---------- modal ---------- */
.modal-host { position: fixed; inset:0; background: rgba(4,6,10,.6); display:flex; align-items:center; justify-content:center; z-index: 60; }
.modal { background: var(--bg-1); border:1px solid var(--line-2); border-radius: 10px; width: min(760px, 92vw); max-height: 86vh; display:flex; flex-direction:column; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal-head { display:flex; align-items:center; justify-content:space-between; padding: 12px 16px; border-bottom:1px solid var(--line); }
.modal-head h3 { margin:0; font-size:15px; }
.modal-body { padding: 14px 16px; overflow:auto; }
.modal-foot { padding: 10px 16px; border-top:1px solid var(--line); display:flex; justify-content:flex-end; gap:8px; }
.modal .close-x { cursor:pointer; color: var(--txt-2); font-size: 18px; }
.modal .close-x:hover { color: var(--txt-0); }
.form-row { display:flex; gap:10px; align-items:center; margin-bottom:10px; flex-wrap:wrap; }
.form-row > label { min-width: 120px; color: var(--txt-1); }
.form-row select, .form-row input { min-width: 160px; }
.hexview { font-family: var(--mono); font-size:12px; white-space: pre; background: var(--bg-0); border:1px solid var(--line); border-radius:6px; padding:10px; overflow:auto; line-height:1.5; color: var(--txt-1); }
.hexview .off { color: var(--txt-2); }
.hexview .asc { color: var(--accent); }
/* cell inspector */
.inspect-meta { color: var(--txt-2); font-size: 11px; margin-bottom: 8px; }
.inspect-meta b { color: var(--txt-1); }
.inspect-text { font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-word;
  background: var(--bg-0); border: 1px solid var(--line); border-radius: 6px; padding: 10px; max-height: 52vh; overflow: auto; color: var(--txt-0); }
.inspect-img-wrap { text-align: center; background: var(--bg-0); border: 1px solid var(--line); border-radius: 6px; padding: 14px;
  background-image: linear-gradient(45deg,#1a1f28 25%,transparent 25%),linear-gradient(-45deg,#1a1f28 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#1a1f28 75%),linear-gradient(-45deg,transparent 75%,#1a1f28 75%);
  background-size: 16px 16px; background-position: 0 0,0 8px,8px -8px,-8px 0; }
.inspect-img { max-width: 100%; max-height: 52vh; image-rendering: auto; }

/* ---------- context menu ---------- */
.ctxmenu { position: fixed; z-index: 100; background: var(--bg-2); border:1px solid var(--line-2); border-radius:8px; padding:5px; min-width: 200px; box-shadow: 0 12px 34px rgba(0,0,0,.5); }
.ctxmenu .mi { padding:6px 10px; border-radius:5px; cursor:pointer; font-size:12px; color: var(--txt-1); display:flex; justify-content:space-between; gap:16px; }
.ctxmenu .mi:hover { background: var(--accent); color:#04121f; }
.ctxmenu .mi.disabled { color: var(--txt-2); pointer-events:none; }
.ctxmenu .sep { height:1px; background: var(--line); margin:4px 2px; }
.ctxmenu .mi .kbd { color: var(--txt-2); font-size:10px; }
.ctxmenu .mi:hover .kbd { color:#04121f; }
.ctxmenu .grp { padding:4px 10px 2px; font-size:10px; text-transform:uppercase; color: var(--txt-2); letter-spacing:.5px; }

/* ---------- toast ---------- */
#toast-host { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 200; display:flex; flex-direction:column; gap:8px; align-items:center; }
.toast { background: var(--bg-2); border:1px solid var(--line-2); border-left: 3px solid var(--accent); border-radius:6px; padding:9px 14px; font-size:12px; color: var(--txt-0); box-shadow: 0 8px 24px rgba(0,0,0,.4); animation: toastin .18s ease; max-width: 60vw; }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast.warn { border-left-color: var(--warn); }
@keyframes toastin { from { opacity:0; transform: translateY(8px);} to {opacity:1;transform:none;} }

/* ---------- loader ---------- */
.loader { position: fixed; inset:0; background: rgba(6,8,12,.55); display:flex; flex-direction:column; align-items:center; justify-content:center; gap:14px; z-index: 300; }
.spinner { width: 38px; height:38px; border:3px solid var(--line-2); border-top-color: var(--accent); border-radius:50%; animation: spin .8s linear infinite; }
#loader-text { color: var(--txt-1); font-size:13px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* IOC / search result tables reuse .meta */
.mono { font-family: var(--mono); }
.muted { color: var(--txt-2); }
.hl { background: #4a3d0e; color: #ffe08a; border-radius:2px; }
a.link { color: var(--accent); text-decoration:none; cursor:pointer; }
a.link:hover { text-decoration:underline; }

/* responsive */
@media (max-width: 1200px) {
  #panel-right { width: 360px; }
  #panel-left { width: 220px; }
}
@media (max-width: 900px) {
  #panel-right { width: 300px; }
  #panel-left { width: 190px; }
  #panel-center { min-width: 150px; }
  /* stack key/value pairs so values never get clipped in a cramped panel */
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv .k { margin-top: 7px; }
  .kv .v { margin-bottom: 2px; }
}
