:root {
  --bg: #f6f7f9; --panel: #fff; --text: #1b1f24; --dim: #5f6b7a; --line: #dfe3e8;
  --accent: #2f6fde; --accent-text: #fff; --good: #1a7f37; --bad: #cf222e; --warn: #9a6700;
  --row: #f9fafb; --code: #f0f2f5;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --panel: #171b21; --text: #e3e7ec; --dim: #8b96a5; --line: #2a313a;
    --accent: #4c8dff; --accent-text: #fff; --good: #3fb950; --bad: #f85149; --warn: #d29922;
    --row: #1b2027; --code: #1f252d;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --panel: #171b21; --text: #e3e7ec; --dim: #8b96a5; --line: #2a313a;
  --accent: #4c8dff; --accent-text: #fff; --good: #3fb950; --bad: #f85149; --warn: #d29922;
  --row: #1b2027; --code: #1f252d;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 15px; margin: 0 0 10px; display: flex; justify-content: space-between; align-items: baseline; }
.dim { color: var(--dim); }
.sub { color: var(--dim); margin: -6px 0 14px; }
main { padding: 20px 24px 60px; max-width: 1600px; margin: 0 auto; }

.top { display: flex; align-items: center; gap: 24px; padding: 10px 24px; background: var(--panel);
       border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; color: var(--text); }
.top nav { display: flex; gap: 4px; flex: 1; }
.top nav a { padding: 6px 12px; border-radius: 6px; color: var(--dim); }
.top nav a.on, .top nav a:hover { background: var(--code); color: var(--text); text-decoration: none; }
.who { display: flex; gap: 10px; align-items: center; color: var(--dim); margin: 0; }

.subnav { display: flex; align-items: center; gap: 4px; padding: 8px 24px; background: var(--panel);
          border-bottom: 1px solid var(--line); position: sticky; top: 45px; z-index: 4; flex-wrap: wrap; }
.subnav a { padding: 5px 11px; border-radius: 6px; color: var(--dim); }
.subnav a.on, .subnav a:hover { background: var(--code); color: var(--text); text-decoration: none; }
.subnav .dbcrumb { color: var(--dim); padding-left: 0; }
.subnav .sep { color: var(--dim); opacity: .6; }
.subnav .dbcur { font-weight: 700; color: var(--text); margin-right: 8px; }

.theme-toggle { flex: none; width: 46px; height: 26px; padding: 0; position: relative; cursor: pointer;
  background: var(--code); border: 1px solid var(--line); border-radius: 999px; }
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle .thumb { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center;
  font-size: 12px; line-height: 1; transition: left .15s ease; }
.theme-toggle .thumb::after { content: "\2600"; }
:root[data-theme="dark"] .theme-toggle .thumb { left: 22px; }
:root[data-theme="dark"] .theme-toggle .thumb::after { content: "\263E"; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .thumb { left: 22px; }
  :root:not([data-theme="light"]) .theme-toggle .thumb::after { content: "\263E"; }
}

button, .btn { font: inherit; padding: 6px 14px; border-radius: 6px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-text); cursor: pointer; display: inline-block; }
button.secondary, .btn.secondary { background: transparent; color: var(--accent); }
button.link { background: none; border: 0; color: var(--accent); padding: 0; }
.btn:hover { text-decoration: none; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
textarea { width: 100%; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; resize: vertical; }
.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 10px 0 14px; }
.bar label { display: flex; gap: 6px; align-items: center; color: var(--dim); }

.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(520px, 1fr)); gap: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.more { font-size: 12px; font-weight: 400; }
h2.section { margin: 22px 0 12px; padding-top: 4px; border-top: 1px solid var(--line); }

.gaugerow { display: flex; gap: 8px; }
.gaugerow .gauge { flex: 1; min-width: 0; }
.gaugerow .gaugeimg { max-width: 200px; }
.gauge { text-align: center; padding: 6px 0 2px; }
.glabel { font-size: 12px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: .04em; }
.gaugeimg { width: 100%; max-width: 260px; height: auto; }
.gtrack { stroke: var(--code); }
.gval { stroke: var(--good); transition: stroke-dashoffset .4s ease; }
.gval.good { stroke: var(--good); }
.gval.warnc { stroke: var(--warn); }
.gval.bad { stroke: var(--bad); }
.gpct { fill: var(--text); font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.gpct.gna { fill: var(--dim); font-size: 22px; }
.gval.ghidden { display: none; }

/* Full-screen SSH terminal page. */
body.sshbody { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.sshbar { display: flex; align-items: center; gap: 14px; padding: 8px 16px; flex: none;
          background: var(--panel); border-bottom: 1px solid var(--line); }
.sshbar .spacer { flex: 1; }
.term { flex: 1; min-height: 0; padding: 6px 4px 4px 8px; background: var(--panel); }
.term .xterm { height: 100%; }
.term .xterm-viewport { overflow-y: auto; }

/* Terminal help overlay */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
         background: rgba(0, 0, 0, .5); padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px;
              max-width: 560px; width: 100%; box-shadow: 0 12px 48px rgba(0, 0, 0, .35); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-head strong { font-size: 15px; }
.modal-head .link { font-size: 16px; line-height: 1; }
.help-table { width: 100%; border-collapse: collapse; }
.help-table th, .help-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
.help-table th { color: var(--dim); font-weight: 600; }
.help-table td:first-child { color: var(--dim); white-space: nowrap; }
.helpnote { font-size: 12px; margin: 12px 0 2px; }
.notes-card { max-width: 640px; }
.notes-text { width: 100%; min-height: 340px; resize: vertical; }
kbd { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; background: var(--code);
      border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; white-space: nowrap; }
.gdetail { color: var(--dim); font-size: 12px; margin-top: -4px; }
.notesbtn { flex: none; padding: 5px 12px; font-size: 13px; }

/* Host panels: each widget row links through to the host's detail page. */
.celllink { display: block; color: inherit; border-radius: 8px; }
.celllink:hover { text-decoration: none; background: var(--row); }

/* Row 2 — storage inventory bars. */
.diskrow { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 9px; }
.diskbar { padding: 2px 4px; }
.dbhead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.dbdev { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.dbkind { font-size: 9.5px; font-weight: 600; color: var(--dim); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; vertical-align: middle; }
.dbtemp { font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }
.dbpct { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dbsub { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; color: var(--dim); font-size: 11.5px; margin-top: 2px; }
.dbmounts { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dbval { flex: none; font-variant-numeric: tabular-nums; }
.dbtrack { margin-top: 5px; height: 8px; background: var(--code); border-radius: 999px; overflow: hidden; }
.dbfill { height: 100%; border-radius: 999px; background: var(--good); transition: width .4s ease; }
.dbfill.warnc { background: var(--warn); }
.dbfill.bad { background: var(--bad); }
.dbunmounted .dbdev, .dbunmounted .dbpct { color: var(--dim); }
.dberror .dbpct { color: var(--bad); font-weight: 700; }

/* Row 3 — NIC throughput cards. */
.netrow { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.netcard { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; background: var(--row); min-width: 0; }
.netdev { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; color: var(--dim); margin-bottom: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.netline { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.netlbl { color: var(--dim); font-size: 11px; }
.netval { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.netval.in { color: var(--good); }
.netval.out { color: var(--accent); }
.spark { display: block; width: 100%; height: 18px; margin: 1px 0 6px; }
.spark-in { stroke: var(--good); stroke-width: 1.5; }
.spark-out { stroke: var(--accent); stroke-width: 1.5; }

/* Per-host detail pages (System / Interfaces / Storage). */
.backlink { margin: 0 0 6px; }
.hosttitle { display: flex; gap: 10px; align-items: baseline; }
.detailgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.dcard { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; min-width: 0; }
.dchead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.drow { display: flex; justify-content: space-between; gap: 16px; padding: 3px 0; border-top: 1px solid var(--line); }
.drow:first-of-type { border-top: 0; }
.drow > span:first-child { color: var(--dim); }
.drow > span:last-child { text-align: right; font-variant-numeric: tabular-nums; word-break: break-word; }
.pill { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--dim); font-variant-numeric: tabular-nums; }
.pill.good { color: var(--good); border-color: var(--good); }
.pill.warnc { color: var(--warn); border-color: var(--warn); }
.pill.bad { color: var(--bad); border-color: var(--bad); }
.hdrbadges { display: flex; gap: 6px; align-items: center; }
.tempcard .tempgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px 24px; margin-top: 10px; }
.tempgname { color: var(--dim); font-weight: 600; font-size: 12px; margin-bottom: 6px; }
.temprow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 2px 0; }
.fstable { width: 100%; border-collapse: collapse; margin-top: 10px; font-variant-numeric: tabular-nums; }
.fstable th, .fstable td { padding: 4px 8px; text-align: left; white-space: nowrap; border-top: 1px solid var(--line); font-size: 13px; }
.fstable th { color: var(--dim); font-weight: 600; font-size: 12px; }
.fstable .num { text-align: right; }
.fstable .good { color: var(--good); } .fstable .warnc { color: var(--warn); } .fstable .bad { color: var(--bad); }
.nofs { margin: 10px 0 0; }

.scroll { overflow: auto; max-height: 75vh; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.panel .scroll { max-height: 360px; }
table.grid { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.grid th, .grid td { padding: 5px 10px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
.grid th { position: sticky; top: 0; background: var(--code); font-weight: 600; font-size: 12px; }
.grid tbody tr:nth-child(even) { background: var(--row); }
.grid .num { text-align: right; }
.grid .null { color: var(--dim); font-style: italic; font-size: 12px; }
.grid .empty { color: var(--dim); text-align: center; padding: 16px; }
.good { color: var(--good); font-weight: 600; }
.bad { color: var(--bad); font-weight: 600; }
.warnc { color: var(--warn); font-weight: 600; }
.meta { color: var(--dim); font-size: 12px; margin: 6px 2px 0; }
.warn { color: var(--warn); }

pre.error { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad);
  border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); padding: 10px 12px; border-radius: 8px; white-space: pre-wrap; }
p.error { color: var(--bad); margin: 0; }
details { margin: 12px 0; }
summary { cursor: pointer; color: var(--dim); }
details pre, code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
details pre { background: var(--code); padding: 10px; border-radius: 8px; overflow: auto; }
.history ul { list-style: none; padding: 0; margin: 8px 0; }
.history li { margin: 4px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { display: flex; gap: 12px; align-items: center; margin-top: 12px; }

.cards { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.cards a { display: flex; flex-direction: column; gap: 4px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px 16px; color: var(--text); height: 100%; }
.cards a:hover { border-color: var(--accent); text-decoration: none; }
.cards span { color: var(--dim); font-size: 13px; }

.login { max-width: 340px; margin: 12vh auto 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 28px; }
.login form { display: flex; flex-direction: column; gap: 14px; }
.login label { display: flex; flex-direction: column; gap: 4px; color: var(--dim); font-size: 13px; }
.login button { margin-top: 6px; padding: 8px; }

@media (max-width: 700px) {
  main { padding: 16px; }
  .top { flex-wrap: wrap; gap: 8px; padding: 10px 16px; }
  .panels { grid-template-columns: 1fr; }
}

.login .ipnote { margin: 16px 0 0; text-align: center; color: var(--dim); font-size: 12px; }
.login .ipnote code { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--text); }

.login .banner { margin: 14px 0 0; padding: 10px 12px; border-radius: 8px; font-size: 11px; line-height: 1.5;
  text-align: left; color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); }
.login .banner strong { color: var(--warn); }

.login .lannote { margin: 0; padding: 8px 10px; border-radius: 8px; font-size: 12px; text-align: center;
  color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--good) 40%, transparent); }

.grid th { cursor: pointer; user-select: none; }
.grid th:hover { background: color-mix(in srgb, var(--accent) 14%, var(--code)); }
.grid th[data-sort] { color: var(--accent); }
.sort-ind { font-size: 10px; opacity: .85; }

/* --- Excel-style per-column sort + filter (the standard) --- */
.th-filter { margin-left: 6px; font-size: 20px; line-height: 1; opacity: .5; cursor: pointer;
             display: inline-block; padding: 2px 4px; border-radius: 4px; vertical-align: middle; }
.th-filter:hover { opacity: 1; background: color-mix(in srgb, var(--accent) 22%, transparent); }
.grid th.filtered { color: var(--accent); }
.grid th.filtered .th-filter { opacity: 1; color: var(--accent); }
/* keep zebra striping correct while a filter hides rows */
.grid.filtering tbody tr:nth-child(even) { background: transparent; }
.grid.filtering tbody tr.odd { background: var(--row); }

.colmenu { position: fixed; z-index: 60; width: 340px; min-width: 240px; max-width: calc(100vw - 16px);
           background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
           box-shadow: 0 8px 28px rgba(0,0,0,.4); padding: 8px; font-size: 13px;
           /* drag the bottom-right corner to resize width + height */
           resize: both; overflow: auto; }
.colmenu .cm-sort { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px;
                    padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.colmenu .cm-sort button { text-align: left; background: none; border: 0; color: var(--text);
                           padding: 5px 7px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.colmenu .cm-sort button:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.colmenu .cm-op { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-bottom: 6px; font-size: 13px; }
.colmenu .cm-op label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.colmenu .cm-op input { margin: 0; }
.colmenu .cm-search { width: 100%; margin-bottom: 6px; font-size: 13px; }
.colmenu .cm-all { display: block; padding: 3px 4px; font-weight: 600; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.colmenu .cm-list { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow: auto; }
/* Wrap long values (e.g. set-aside names) so they're fully readable instead of
   truncated with an ellipsis. */
.colmenu .cm-list li { padding: 2px 4px; white-space: normal; overflow-wrap: anywhere; }
.colmenu .cm-list label { display: flex; align-items: flex-start; gap: 6px; cursor: pointer; }
.colmenu .cm-list label input { margin-top: 3px; flex: none; }
.colmenu .cm-list li:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.colmenu .cm-actions { display: flex; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.colmenu .cm-actions button { flex: 1; padding: 5px; }

.roleform { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin: 0; }
.rolechk { display: inline-flex; gap: 5px; align-items: center; color: var(--text); font-size: 13px; white-space: nowrap; }
.roleform button { padding: 4px 12px; }
button.danger, .link.danger { color: var(--bad); border-color: var(--bad); }
button.link.danger { background: none; border: 0; }

.invitebox { background: color-mix(in srgb, var(--good) 10%, transparent); border: 1px solid color-mix(in srgb, var(--good) 40%, transparent);
  border-radius: 10px; padding: 12px 14px; margin: 0 0 16px; font-size: 13px; }
.invitelink { width: 100%; margin-top: 8px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }

/* Files page */
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; font-size: 14px; }
.crumbs .sep { color: var(--dim); }
.fileactions { gap: 20px; }
.fileform { display: flex; gap: 8px; align-items: center; margin: 0; }
.delform, .renameform { display: inline; margin: 0; }
.rowactions { display: flex; gap: 6px; justify-content: flex-end; }
.rowactions button, .rowactions .btn { padding: 3px 10px; font-size: 13px; }

/* File viewer */
.codeview { background: var(--code); border: 1px solid var(--line); border-radius: 8px;
            padding: 12px 14px; overflow: auto; max-height: 80vh; font-size: 13px; line-height: 1.5;
            font-family: ui-monospace, Menlo, Consolas, monospace; white-space: pre; }
.jsonview .j-key { color: var(--accent); }
.jsonview .j-str { color: var(--good); }
.jsonview .j-num { color: var(--warn); }
.jsonview .j-lit { color: var(--bad); font-weight: 600; }
.hash { color: var(--good); }
.int { color: var(--warn); }
.kw { color: var(--bad); font-weight: 600; }

/* File compare (diff) */
.diff { border: 1px solid var(--line); border-radius: 8px; overflow: auto; max-height: 80vh;
        font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.dl { white-space: pre; padding: 0 10px; }
.dl .dsign { display: inline-block; width: 14px; color: var(--dim); }
.d-add { color: var(--good); }
.d-del { color: var(--bad); }
.dl.d-add { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.dl.d-del { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.dl.d-ctx { color: var(--dim); }
.drawview { max-width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 8px;
            background: #fff; padding: 8px; min-height: 300px; }

/* SFTP page — two-pane (FileZilla-style) transfer tool */
.sftp-wrap { display: flex; flex-direction: column; gap: 10px; }
.sftp-panes { display: flex; gap: 10px; align-items: stretch; }
.sftp-panes .pane { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column;
        border: 1px solid var(--line); border-radius: 8px; background: var(--panel); overflow: hidden; }
.pane-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
             padding: 7px 10px; border-bottom: 1px solid var(--line); background: var(--code); }
.pane-title { font-weight: 600; }
.pane-head .loc { display: flex; gap: 10px; }
.pane-head .loc label { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--dim); }
.pane-head .r-status { margin-left: auto; font-size: 12px; min-width: 60px; text-align: right; }
.r-status.ok { color: var(--good); } .r-status.warn { color: var(--warn); }
.remote-fields { display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
                 padding: 7px 10px; border-bottom: 1px solid var(--line); }
.remote-fields input { font-size: 13px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.remote-fields input.r-host { width: 120px; }
.remote-fields input.r-port { width: 52px; }
.remote-fields input.r-user { width: 90px; }
.remote-fields input.r-pass { width: 110px; }
.remote-fields input.r-key { flex: 1; min-width: 120px; }
.sftp-opts .spacer { flex: 1; }
.pane-path { display: flex; gap: 6px; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.pane-path .p-path { flex: 1; min-width: 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.pane-path .p-up, .pane-path .p-go { padding: 4px 10px; }
.pane-list { list-style: none; margin: 0; padding: 4px; overflow: auto; height: 320px; }
.pane-list li { padding: 3px 8px; border-radius: 5px; cursor: default; font-size: 13px;
                white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pane-list li.d, .pane-list li.f { cursor: pointer; }
.pane-list li.d:hover, .pane-list li.f:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.pane-list li.sel { background: color-mix(in srgb, var(--accent) 24%, transparent); }
.pane-list li.pane-err { color: var(--bad); white-space: normal; cursor: default; }
.pane-list li.pane-hint, .pane-list li.pane-wait { color: var(--dim); cursor: default; }
.sftp-endpoints { display: flex; gap: 10px; }
.sftp-endpoints label.grow { flex: 1; min-width: 0; color: var(--dim); font-size: 13px; }
.sftp-endpoints label.grow input { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.sftp-opts { align-items: center; gap: 14px; }
.sftplog { height: 200px; overflow: auto; margin: 0; padding: 10px 12px; background: var(--code);
           border: 1px solid var(--line); border-radius: 8px; font-size: 13px; line-height: 1.5;
           font-family: ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; }
@media (max-width: 820px) { .sftp-panes, .sftp-endpoints { flex-direction: column; } .pane-list { height: 220px; } }

/* Markdown body */
.mdbody { max-width: 900px; line-height: 1.65; }
.mdbody h1, .mdbody h2, .mdbody h3, .mdbody h4 { margin: 20px 0 8px; line-height: 1.25; }
.mdbody h1 { font-size: 24px; } .mdbody h2 { font-size: 19px; } .mdbody h3 { font-size: 16px; }
.mdbody p, .mdbody ul, .mdbody ol { margin: 0 0 12px; }
.mdbody pre { background: var(--code); border: 1px solid var(--line); padding: 10px 12px; border-radius: 8px; overflow: auto; }
.mdbody code { background: var(--code); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.mdbody pre code { background: none; padding: 0; }
.mdbody table { border-collapse: collapse; margin: 0 0 12px; }
.mdbody th, .mdbody td { border: 1px solid var(--line); padding: 6px 10px; }
.mdbody blockquote { border-left: 3px solid var(--line); margin: 0 0 12px; padding: 2px 14px; color: var(--dim); }
.mdbody img { max-width: 100%; }
.mdbody a { color: var(--accent); }

/* Sam.gov page */
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.bar label.chk { color: var(--dim); }
/* Widen the opportunities table out of the centered `main`, leaving ~1in (96px)
   on each side of the viewport. Only on wide screens — below 1200px it stays
   within main so narrow viewports don't overflow. */
@media (min-width: 1200px) {
  .samwide {
    margin-left: calc(-50vw + 50% + 96px);
    margin-right: calc(-50vw + 50% + 96px);
  }
}

/* All-columns opportunities table: cap each cell so long text (description,
   search_tsv…) ellipsises rather than blowing the row out; hover shows the full
   value (title attr), and the .scroll wrapper scrolls horizontally. */
.samgrid td { max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
.samgrid .idcell { max-width: 110px; }
.samgrid .idcell a { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }

.notice { padding: 10px 12px; border-radius: 8px; margin: 0 0 14px; font-size: 13px; }
.notice.good { color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--good) 40%, transparent); }
.notice.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); }
.notice.warnc { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); }
.notice code { font-family: ui-monospace, Menlo, Consolas, monospace; }

.samedit { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.samedit .opptitle { font-size: 16px; margin: 4px 0 12px; }
.samedit .tag { font-size: 11px; font-weight: 400; text-transform: uppercase; letter-spacing: .04em; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
.kv dt { color: var(--dim); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.desc { margin-top: 12px; }
.desc p { white-space: pre-wrap; margin: 8px 0 0; }
.arcform .stack { display: flex; flex-direction: column; gap: 12px; }
.arcform label { display: flex; flex-direction: column; gap: 4px; color: var(--dim); font-size: 13px; }
.arcform label input, .arcform label textarea { color: var(--text); }
/* Full-width drop-downs so long option names are readable (the opened popup
   shows each option's full text). */
.arcform select, .arcform input { width: 100%; color: var(--text); }
.arcform .actions { display: flex; gap: 10px; margin-top: 4px; }
@media (max-width: 860px) { .samedit { grid-template-columns: 1fr; } }

/* Prompt Mgr: reusable vertical form ("stack"), the add panel, the list's
   prompt cell (long text ellipsised, hover shows full), and the delete zone. */
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label { display: flex; flex-direction: column; gap: 4px; color: var(--dim); font-size: 13px; }
.stack label input, .stack label textarea { width: 100%; color: var(--text); }
.stack textarea { font: inherit; resize: vertical; }
.stack input[readonly] { opacity: .6; cursor: not-allowed; }
.fieldhint { display: block; font-size: 12px; margin-top: 3px; }
.stack .actions { display: flex; gap: 10px; margin-top: 4px; }
/* Multi-column field layout for wide forms (CRM add/edit): labels flow into as
   many columns as fit, each at least ~220px wide. .stack label already styles
   the individual fields. */
.fieldgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.fieldgrid label { color: var(--dim); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.fieldgrid label input { width: 100%; color: var(--text); }
.addprompt { margin: 0 0 18px; }
.addprompt h2 { margin-top: 0; }
.tag { font-size: 11px; font-weight: 400; text-transform: uppercase; letter-spacing: .04em; }
.promptcell { vertical-align: top; }
/* max-width on a <td> is ignored in auto table-layout; constrain a block child
   instead so the long prompt text wraps at a fixed width. */
.promptcell div { max-width: 640px; white-space: normal; overflow-wrap: anywhere; }
.dangerzone { margin-top: 18px; }
.help-card { max-width: 620px; }
.help-card p { margin: 10px 0; line-height: 1.5; }
.help-card code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px;
  background: color-mix(in srgb, var(--text) 10%, transparent); padding: 1px 5px; border-radius: 4px; }
.help-card .helpgrid { width: 100%; margin: 4px 0; }
.help-card .helpgrid td { white-space: normal; max-width: 280px; }

/* Busy overlay shown while a data-busy form submits (Apply / Save). */
.busy-overlay { position: fixed; inset: 0; z-index: 100; display: none; align-items: center;
  justify-content: center; background: color-mix(in srgb, var(--bg) 72%, transparent); }
.busy-overlay.on { display: flex; }
.busy-card { display: flex; align-items: center; gap: 12px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 14px 20px; font-size: 14px;
  color: var(--text); box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.busy-spin { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: busy-spin .7s linear infinite; flex: none; }
@keyframes busy-spin { to { transform: rotate(360deg); } }

/* The Sam.gov count ("Loading……" then "<n> of <m> rows") is a bar pinned to the
   bottom of the viewport. It is rendered before the table (so it paints during
   load) and fixed-positioned (so source order doesn't push it off-screen under
   the long table). main already has bottom padding so content isn't hidden. */
.sambar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; margin: 0;
  padding: 8px 24px; background: var(--bg); border-top: 1px solid var(--line); }
.toploading { font-style: italic; }
/* Admin bulk-edit: large, pushed to the far right end of the filter bar and
   nudged a bit further right into the page gutter. */
.bar .bulk-edit { margin-left: auto; transform: translateX(2in); padding: 10px 22px; font-size: 15px; font-weight: 600; }
.bulklist { list-style: none; margin: 8px 0 0; padding: 0; max-height: 50vh; overflow: auto; }
.bulklist li { padding: 3px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
/* Per-user filter presets */
.preset-group { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.preset-btn { padding: 5px 12px; font-size: 13px; }
.preset-card { max-width: 640px; }
.preset-name { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; font-weight: 600; }
.preset-name-in { flex: 1; }
.preset-hint { font-size: 12px; margin: 0 0 10px; }
.preset-rows { max-height: 55vh; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.preset-row { display: grid; grid-template-columns: minmax(110px, 1fr) auto minmax(0, 1.4fr); gap: 8px; align-items: center; }
.preset-row .preset-col { color: var(--dim); overflow-wrap: anywhere; }
.preset-row select, .preset-row input { font-size: 13px; }
.preset-actions { display: flex; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }

/* Download format chooser. */
#dl-overlay .modal-card { max-width: 420px; }
.dl-formats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.dl-formats .btn { text-align: center; padding: 10px; }
