/* Petro-Logistics platform — modern design system (no build step). */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1b2733;
  --muted: #5b6b7b;
  --border: #e3e8ee;
  --brand: #0b5cab;
  --brand-dark: #084a8a;
  --accent: #0a8f5b;
  --danger: #c0392b;
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.06);
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text); background: var(--bg);
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout: topbar + sidebar + content */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  height: 56px; padding: 0 20px;
  background: var(--brand); color: #fff; box-shadow: var(--shadow);
}
.topbar .brand { font-weight: 700; letter-spacing: .2px; color: #fff; }
.topbar .brand:hover { text-decoration: none; }
.topbar .spacer { flex: 1; }
.topbar .user { color: #dbe7f5; font-size: 14px; }
.topbar .user a { color: #fff; text-decoration: underline; }
/* Sign out is a POST form (a cross-site link must not end a session); it
   reads like the link it replaced. */
.topbar .user form { display: inline; }
.topbar .user .linkbtn { color: #fff; text-decoration: underline; }

.shell { display: flex; min-height: calc(100vh - 56px); }
.sidebar {
  width: 232px; flex: none; background: var(--surface);
  border-right: 1px solid var(--border); padding: 16px 12px;
}
.sidebar a {
  display: block; padding: 9px 12px; border-radius: 8px;
  color: var(--text); font-weight: 500; margin-bottom: 2px;
}
.sidebar a:hover { background: #eef3f9; text-decoration: none; }
.sidebar a.active { background: var(--brand); color: #fff; }
.sidebar .group { font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); margin: 14px 12px 6px; }
.sidebar .navgrp { margin-bottom: 2px; }
.sidebar .navgrp > summary { cursor: pointer; list-style: none; padding: 9px 12px;
  border-radius: 8px; font-weight: 600; color: var(--text); user-select: none; }
.sidebar .navgrp > summary::-webkit-details-marker { display: none; }
.sidebar .navgrp > summary::after { content: "▸"; float: right; color: var(--muted);
  transition: transform .12s; }
.sidebar .navgrp[open] > summary::after { transform: rotate(90deg); }
.sidebar .navgrp > summary:hover { background: #eef3f9; }
.sidebar .navgrp > a { margin-left: 12px; padding: 7px 12px; font-weight: 400; }
.content { flex: 1; padding: 24px 28px; max-width: 1200px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 22px 0 10px; }
.sub { color: var(--muted); margin: 0 0 18px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }

/* Alerts */
.alert { padding: 10px 14px; border-radius: 8px; margin: 0 0 16px; }
.alert.ok { background: #e7f6ee; color: #0a6e44; border: 1px solid #b8e6cd; }
.alert.err { background: #fdecea; color: #a52a1f; border: 1px solid #f5c7c1; }
.alert.info { background: #eef6ff; color: #16324f; border: 1px solid #cfe0f5; }

/* Buttons */
.btn, button, input[type=submit] {
  display: inline-block; cursor: pointer; font: inherit; font-weight: 600;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--brand);
  background: var(--brand); color: #fff; transition: background .12s, border-color .12s;
}
.btn:hover, button:hover { background: var(--brand-dark); text-decoration: none; }
.btn:focus-visible, button:focus-visible { outline: 2px solid #bcd6f0; outline-offset: 1px; }
.btn.secondary, button.secondary { background: #fff; color: var(--brand); }
.btn.secondary:hover, button.secondary:hover { background: #eef3f9; }
.btn.danger, button.danger { background: var(--danger); border-color: var(--danger); }
.btn.danger:hover, button.danger:hover { background: #a13125; border-color: #a13125; }
.btn.sm, button.sm { padding: 4px 9px; font-size: 13px; }

/* Forms */
label { display: inline-block; font-weight: 600; color: var(--muted); font-size: 13px; }
input, select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; color: var(--text); margin-top: 4px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd6f0; border-color: var(--brand); }
textarea { width: 100%; min-height: 90px; }
.form-row { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 14px; }
.form-row > label { display: flex; flex-direction: column; }
.form-row input.w-sm { width: 140px; }
/* .msel-filter excluded: it sits inside a pick/msel panel and must size to the
   panel, not to the generic form-control minimum (which overflows it) */
.form-row input:not(.w-sm):not([type=checkbox]):not(.msel-filter), .form-row select { min-width: 240px; }
.form-row > label.check { flex-direction: row; align-items: center; gap: 6px; align-self: flex-end; padding-bottom: 10px; }
.formfoot { margin-top: 6px; }
td.changes .chg { display: inline-block; background: #f1f5f9; border-radius: 6px;
  padding: 2px 8px; margin: 1px 4px 1px 0; font-size: 12px; }
td.nowrap { white-space: nowrap; }

.testform { display: flex; gap: 6px; align-items: center; }
.testform input[type=email] { width: 190px; margin-top: 0; padding: 5px 8px; font-size: 13px; }

/* Single-select picker (select[data-combo] / input[data-lookup]): the
   client-area msel skin (toggle + panel + filter) driven by initPick, so both
   portals' dropdowns are literally one component. The native field stays in
   the DOM (hidden) and is what submits. */
.pick { position: relative; display: block; margin-top: 4px; }
/* Visually hidden but still focusable: a required native select must be able to
   anchor the browser's validation bubble (display:none makes reportValidity()
   fail silently and the submit button looks dead). */
.pick > .pick-native { position: absolute; left: 0; bottom: 0; width: 100%; height: 1px;
  opacity: 0; pointer-events: none; margin: 0; border: 0; padding: 0; }
.form-row .pick { min-width: 240px; }
.pick .msel-filter { margin-top: 0; }
.msel-opt.sel { background: #eef3f9; }
.msel-confirm { margin-top: 4px; font-size: 12px; }
.msel-confirm-list { margin: 2px 0 0; padding-left: 18px; }
.msel-confirm-list li { margin: 0; }
.msel-opt.active { background: var(--brand); color: #fff; }

/* Permission picker (staff team editor) */
.permgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 10px; margin-bottom: 16px; }
.permgrid .perm { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
  font-weight: 400; color: var(--text); background: #fff; }
.permgrid .perm:hover { border-color: var(--brand); }
.permgrid .perm.on { background: #eef6ff; border-color: var(--brand); }
.permgrid .perm.warn.on { background: #fef6ec; border-color: #d97706; }
.permgrid .perm input { margin-top: 3px; }
.permgrid .perm strong { display: block; font-size: 14px; }
.permgrid .perm small { display: block; color: var(--muted); line-height: 1.35; }

/* Tables */
table.data { width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.data th, table.data td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); }
table.data th { background: #f0f4f8; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted);
  cursor: default; }
table.data tbody tr:nth-child(even) { background: #fafcfe; }
table.data tbody tr:hover { background: #f1f6fc; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr:last-child td { border-bottom: 0; }
/* section-header rows in a grouped table (tr[data-group], e.g. templates by list) —
   styled like the thead so they read as headers; td background also masks the
   striping and hover tints, which key off the tr */
table.data tr.tgroup td { background: #f4f4f4; color: #5c5c5c; font-weight: 600;
  font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
table.data tr.tgroup td .muted { text-transform: none; font-weight: 400; }
/* sortable headers (AJAX grid + static data-sortable tables) */
th .arrow { opacity: .55; font-size: 11px; }
table[data-sortable] th:not([data-nosort]):hover { color: var(--text); }

/* Grid (DataTables-equivalent) controls */
.grid-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.grid-toolbar input.search { min-width: 240px; }
.grid-toolbar .spacer { flex: 1; }
.grid-info { color: var(--muted); font-size: 13px; }
.grid th[data-sort] { cursor: pointer; user-select: none; }
.grid th[data-sort]:hover { color: var(--text); }
.grid th .arrow { opacity: .5; font-size: 11px; }
.pager { display: flex; gap: 6px; align-items: center; margin-top: 12px; }
.pager button { background: #fff; color: var(--brand); padding: 5px 11px; }
.pager button[disabled] { opacity: .4; cursor: default; }

.login-wrap { max-width: 380px; margin: 8vh auto; }
.login-wrap .card { padding: 28px; }
.muted { color: var(--muted); }
/* large checkbox sets: scrollable multi-column grid with filter + all/none */
.checkgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 2px 16px;
  max-height: 340px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; background: #fbfcfe; }
.checkgrid label.flag { display: flex; align-items: center; gap: 7px; font-weight: 400; color: var(--text);
  font-size: 14px; padding: 2px 4px; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.checkgrid label.flag:hover { background: #eef3f9; }
.checkgrid input { margin: 0; width: auto; flex: none; }
.checkgrid-bar { display: flex; align-items: center; gap: 12px; margin: 0 0 8px; }
.checkgrid-bar input.search { min-width: 220px; }
.checkgrid-bar .count { color: var(--muted); font-size: 13px; }
.checkgrid-bar button.linkish { background: none; border: 0; color: var(--brand); padding: 0; font-weight: 500; font-size: 13px; cursor: pointer; }
.checkgrid-bar button.linkish:hover { text-decoration: underline; background: none; }

/* include-folder tree picker */
.foldertree { max-height: 420px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; background: #fbfcfe; font-size: 14px; }
.foldertree ul { list-style: none; margin: 0; padding-left: 22px; }
.foldertree > ul { padding-left: 0; }
.foldertree .ft-row { display: flex; align-items: center; gap: 4px; padding: 1px 4px; border-radius: 5px; }
.foldertree .ft-row:hover { background: #eef3f9; }
.foldertree .ft-row label { display: flex; align-items: center; gap: 6px; font-weight: 400; color: var(--text); cursor: pointer; }
.foldertree input { margin: 0; width: auto; }
.foldertree input:disabled + * , .foldertree .ft-row label:has(input:disabled) { opacity: .6; }
.ft-toggle { background: none; border: 0; padding: 0; width: 18px; flex: none; color: var(--muted);
  cursor: pointer; font-size: 11px; line-height: 1; }
.ft-toggle.ft-leaf { cursor: default; opacity: .35; }
.ft-name { background: none; border: 0; padding: 1px 4px; font: inherit; color: var(--text);
  cursor: pointer; border-radius: 5px; text-align: left; }
.ft-name:hover { background: #e3edf8; }
.ft-name.picked { background: var(--brand); color: #fff; }
.ft-name.ft-plain { cursor: default; color: var(--muted); }
.ft-name.ft-plain:hover { background: none; }

details > summary { cursor: pointer; }
details { margin-bottom: 12px; }
details pre { background: #f7fafc; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; overflow-x: auto; font-size: 13px; }
code { background: #eef3f9; padding: 2px 6px; border-radius: 5px; font-size: 13px; }
ul.links { list-style: none; padding: 0; }
ul.links li { margin: 6px 0; }

/* ---- Sea Movements filter panel + multi-select + autocomplete ---- */
.filters .form-row { gap: 14px 18px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 10px; }
.filters .form-row:last-child { margin-bottom: 0; }
.filters label.chk { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; }
.filters label.chk input { width: auto; }
.msel-row { align-items: flex-start; }
.msel { position: relative; display: flex; flex-direction: column; gap: 4px; min-width: 210px; flex: 1 1 210px; }
.msel > label { font-size: 12px; font-weight: 600; color: var(--muted); }
/* toggle button looks like a <select> and shows the current selection */
.msel-toggle { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 38px;
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; background: #fff;
  cursor: pointer; font: inherit; text-align: left; }
.msel-toggle:hover { border-color: var(--brand); }
.msel-summary { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.msel-summary.on { color: var(--text); font-weight: 500; }
.msel-caret { color: var(--muted); font-size: 12px; }
.msel-panel { position: absolute; top: 100%; left: 0; right: 0; z-index: 30; margin-top: 2px;
  background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 6px; min-width: 220px; }
.msel-filter { width: 100%; margin-bottom: 6px; }
.msel-list { max-height: 260px; overflow: auto; }
.msel-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 14px; white-space: nowrap; }
.msel-item:hover { background: #eef3f9; }
.msel-item input { width: auto; }
.msel-empty { padding: 8px; color: var(--muted); font-size: 13px; }
.msel-section { padding: 6px 8px 2px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.msel-section:not(:first-child) { border-top: 1px solid var(--border, #e3e8ef); margin-top: 4px; }
.msel-group { padding: 7px 10px 3px; color: var(--brand-deep); font-size: 11px;
  text-transform: uppercase; letter-spacing: .4px; }
/* autocomplete dropdown (tanker/customer/supplier/middleman) */
.filters label.ac { position: relative; }
.msel-drop { position: absolute; top: 100%; left: 0; right: 0; z-index: 30; max-height: 240px; overflow: auto;
  background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); margin-top: 2px; }
.msel-opt { padding: 7px 10px; cursor: pointer; font-size: 14px; }
.msel-opt:hover { background: #eef3f9; }
.cols-menu { position: absolute; z-index: 40; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow); padding: 8px 12px; max-height: 320px; overflow: auto; margin-top: 4px; }
.cols-menu label { display: block; font-size: 13px; padding: 3px 0; white-space: nowrap; }
.cols-menu input { width: auto; margin-right: 6px; }
.data.grid { display: block; overflow-x: auto; }
.data tr.totals td { border-top: 2px solid var(--border); background: #f3f6fa; }
/* admin dashboard */
.stat-row { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
.stat-row .stat { flex: 1 1 120px; margin-bottom: 0; text-align: center; padding: 16px 12px; }
.stat-num { font-size: 28px; font-weight: 700; color: var(--brand); line-height: 1.1; }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-top: 4px; }
.dash-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .dash-cols { grid-template-columns: 1fr; } }
.pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #eef3f9; color: var(--muted); }
.pill.ok { background: #e7f6ee; color: #0a6e44; }
.pill.warn { background: #fdf3e1; color: #9a6210; }
.pill.bad { background: #fdecea; color: #a52a1f; }
.pill.on { background: #e7f6ee; color: #0a6e44; }
.pill.off { background: #f1f5f9; color: #9aa7b4; }
.pill.h-engaged { background: #e7f6ee; color: #0a6e44; }
.pill.h-at_risk { background: #fdf3e1; color: #9a6210; }
.pill.h-dormant { background: #f1f0f4; color: #6b5b8a; }
.pill.h-none { background: #f1f5f9; color: #9aa7b4; }

/* CRM account hub */
.crm-logform, .crm-taskform { border-bottom: 1px solid var(--border); padding-bottom: 12px; margin-bottom: 12px; }
.note-tmpls { font-size: 12px; color: var(--muted); margin: 0 0 8px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.crm-preview { background: #eef6ff; border-radius: 8px; padding: 8px 12px; display: inline-block; }
.contract-row { padding: 8px 0; border-bottom: 1px solid #eef2f6; }
.addlines { display: flex; flex-direction: column; gap: 6px; }
.addline { margin: 0; align-items: flex-end; }
.contract-row:last-child { border-bottom: none; }
.recon { list-style: none; margin: 4px 0 0; padding: 0; }
.recon > li { padding: 4px 0; }
.recon-ok { color: #0a6e44; font-weight: 600; }
.ti-files { margin-top: 4px; }
.filechip { display: inline-block; background: #eef3f9; border: 1px solid var(--border);
  border-radius: 6px; padding: 2px 8px; margin: 2px 4px 2px 0; font-size: 12px; text-decoration: none; }
.filechip:hover { background: #dde7f3; }
.timeline, .tasklist, .worklist { list-style: none; margin: 0; padding: 0; }
.worklist > li { padding: 5px 0; border-bottom: 1px solid #eef2f6; }
.worklist > li:last-child { border-bottom: none; }
.worklist > li.overdue { color: #a52a1f; }
.timeline > li { padding: 8px 0; border-bottom: 1px solid #eef2f6; }
.timeline > li:last-child, .tasklist > li:last-child { border-bottom: none; }
.tasklist > li { padding: 6px 0; border-bottom: 1px solid #eef2f6; }
.tasklist > li.overdue { color: #a52a1f; }
.te-kind { text-transform: uppercase; font-size: 10px; letter-spacing: .4px; }
.te-api .te-kind { background: #e6eefb; color: #2b5fa8; }
.te-login .te-kind, .te-email_out .te-kind { background: #e7f6ee; color: #0a6e44; }
.te-loginfail .te-kind { background: #fdecea; color: #a52a1f; }
.te-impersonation .te-kind { background: #f1f0f4; color: #6b5b8a; }
.te-expiry .te-kind { background: #fdf3e1; color: #9a6210; }
.ti-body { margin: 3px 0 0; white-space: pre-wrap; }
.ti-meta { font-size: 12px; margin-top: 3px; }
tr.overdue td { background: #fdf6f5; }
.linkbtn { background: none; border: none; color: var(--brand); cursor: pointer; padding: 0; font: inherit; }
.linkbtn.ok { color: #0a6e44; font-weight: 700; }
.linkbtn:hover { text-decoration: underline; }

/* client home news feed */
.news-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.news-item:last-child { border-bottom: 0; padding-bottom: 0; }
.news-item:first-of-type { padding-top: 0; }
.news-head { font-weight: 600; color: var(--text); }
.news-date { font-weight: 400; font-size: 12px; color: var(--muted); margin-left: 6px; }
.news-body { white-space: pre-wrap; color: var(--muted); font-size: 14px; margin-top: 3px; }

/* received-email view (client mail archive) */
.card.mailview { padding: 0; overflow: hidden; }
.mailframe { display: block; width: 100%; height: 70vh; border: 0; background: #fff; }

/* report-downloads file browser */
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; font-size: 14px; }
.breadcrumb .sep { color: var(--muted); }
.breadcrumb a { padding: 2px 4px; border-radius: 5px; }
.breadcrumb a:hover { background: #eef3f9; }
.filelist td.fname { display: flex; align-items: center; gap: 8px; }
.filelist .ic { font-size: 16px; line-height: 1; }
.filelist tbody tr:hover { background: #f7fafc; }

/* mail compose — rich-text editor, TinyMCE or Quill (vendored, served from /assets) */
/* The editor must NOT be wrapped in a <label>: clicking the contenteditable pane
   would forward to the label's first button and fire a token insert. Use .field. */
.field-label { display: inline-block; font-weight: 600; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.wysiwyg { margin-top: 4px; }
/* accumulating multi-file picker (add-to / remove-individually list) */
.filelist .btn.sm { margin-bottom: 6px; }
.filelist-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.filelist-items li { display: flex; align-items: center; gap: 8px; background: #f7fafc; border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-size: 13px; }
.filelist-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filelist-rm { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px; }
.filelist-rm:hover { color: #b91c1c; }

/* review-before-send modal (mail compose) */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal { background: #fff; border-radius: 10px; max-width: 720px; width: 100%; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 12px 48px rgba(0,0,0,.3); }
.modal-hd { padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 16px; }
.modal-bd { padding: 18px; overflow-y: auto; }
.modal-meta { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.modal-meta strong { color: var(--text); }
.modal-subject { font-weight: 600; font-size: 15px; margin: 6px 0 10px; }
.modal-email { border: 1px solid var(--border); border-radius: 8px; padding: 14px; font-size: 14px; line-height: 1.5; max-height: 360px; overflow-y: auto; }
.modal-email img { max-width: 100%; height: auto; }
.modal-files { font-size: 13px; color: var(--muted); margin-top: 12px; }
.modal-files .lbl { font-weight: 600; color: var(--text); }
.modal-ft { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.compose-actions { display: flex; gap: 10px; margin-top: 10px; align-items: center; }

/* client FAQ (accordion) */
.faq { border-bottom: 1px solid var(--border); padding: 10px 0; }
.faq:last-child { border-bottom: 0; padding-bottom: 0; }
.faq summary { cursor: pointer; font-weight: 600; color: var(--text); }
.faq-a { margin-top: 6px; color: var(--muted); white-space: pre-wrap; }
.wysiwyg-tokens { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.wysiwyg-btn { font-size: 12px; padding: 3px 8px; border: 1px solid var(--border); background: #fff; border-radius: 5px; cursor: pointer; color: var(--text); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.wysiwyg-btn:hover { background: #eef3f9; }
/* engine toggle sits apart from the token buttons, in the UI font */
.wysiwyg-swap { margin-left: auto; font-family: inherit; color: var(--muted); }
.wysiwyg-swap:disabled { opacity: .5; cursor: default; }
/* TinyMCE mounts after the hidden textarea (sibling of .wysiwyg) */
.field .tox-tinymce { border: 1px solid var(--border); border-radius: 8px; }
.wysiwyg .ql-toolbar { border-top-left-radius: 8px; border-top-right-radius: 8px; background: #f7fafc; }
.wysiwyg .ql-container { border-bottom-left-radius: 8px; border-bottom-right-radius: 8px; font-size: 14px; }
.wysiwyg .ql-editor { min-height: 240px; max-height: 480px; }
.wysiwyg .ql-editor img { max-width: 100%; height: auto; }
/* fallback if the editor can't load: show the raw textarea */
textarea[hidden] { display: none; }
.wysiwyg + textarea:not([hidden]) { display: block; width: 100%; min-height: 240px; margin-top: 6px; }

/* ---- analytics (admin) -------------------------------------------------- */
.subnav { display: flex; gap: 4px; margin: 0 0 14px; border-bottom: 1px solid #dde5ee; }
.subnav a { padding: 7px 14px; border-radius: 8px 8px 0 0; color: #4a5a6d; text-decoration: none; font-size: 14px; }
.subnav a:hover { background: #eef3f9; }
.subnav a.on { background: #fff; border: 1px solid #dde5ee; border-bottom-color: #fff; margin-bottom: -1px; color: #16324f; font-weight: 600; }
.kpis { display: flex; gap: 12px; flex-wrap: wrap; margin: 0 0 14px; }
.kpi { flex: 1; min-width: 150px; background: #fff; border: 1px solid #dde5ee; border-radius: 10px; padding: 14px 16px; }
.kpi-n { display: block; font-size: 26px; font-weight: 700; color: #16324f; font-variant-numeric: tabular-nums; }
.kpi-l { display: block; font-size: 12px; color: #6b7b8d; margin-top: 2px; }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart .ch-grid { stroke: #e6ecf3; stroke-width: 1; }
svg.chart .ch-lab { fill: #6b7b8d; font-size: 11px; font-family: inherit; }
svg.chart .ch-empty { fill: #9aa7b4; font-size: 13px; }
svg.chart .ch-line { fill: none; stroke-width: 2; stroke-linejoin: round; }
svg.chart .ch-bar { fill: #2563eb; opacity: .85; rx: 2; }
.meter { height: 8px; background: #e6ecf3; border-radius: 999px; overflow: hidden; }
.meter span { display: block; height: 100%; background: #2563eb; border-radius: 999px; }
ol.audit { list-style: none; margin: .5em 0 0; padding: 0; }
ol.audit > li { padding: 8px 0 8px 16px; border-left: 2px solid #dde5ee; position: relative; }
ol.audit > li::before { content: ''; position: absolute; left: -5px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: #2563eb; }
ol.audit ul { margin: 4px 0 0 0; padding-left: 1.2em; font-size: 13px; color: #4a5a6d; }
a.pill { text-decoration: none; }
a.pill:hover { background: #dde7f3; }
.impbanner { background: #7c2d12; color: #fff; text-align: center; padding: 6px 12px; font-size: 13px; }
.impbanner a { color: #fde68a; }

/* ============================================================================
   BRAND SKIN — matches petro-logistics.com (2026-07 client-area redesign).
   Palette lifted from the website: navy #1f2434, orange #f15a22 (hover
   #eb4a0f, deep #c53e0c, tint #fef1ec), greys #f5f5f5/#dbdbdb/#5c5c5c/#363636.
   Montserrat is self-hosted from /assets (single variable-weight file).
   Applies to BOTH portals; layout below is scoped to the client area.
   ========================================================================== */

@font-face {
  font-family: "Montserrat";
  src: url(/assets/montserrat-latin.woff2) format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --text: #363636;
  --muted: #6a6b6d;
  --border: #dbdbdb;
  --navy: #1f2434;
  --brand: #f15a22;
  --brand-dark: #eb4a0f;
  --brand-deep: #c53e0c;
  --brand-tint: #fef1ec;
  --shadow: 0 1px 3px rgba(31,36,52,.08), 0 1px 2px rgba(31,36,52,.06);
  --radius: 6px;
}

body {
  font: 14px/1.55 Montserrat, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  color: var(--text); background: var(--bg);
}

/* Text links use the deeper orange for contrast; chrome stays #f15a22. */
a { color: var(--brand-deep); }
a:hover { color: var(--brand-dark); }

h1, h2 { color: var(--navy); font-weight: 700; }
h1 { letter-spacing: -.2px; }

/* Topbar: flat website navy with the white ship logo. */
.topbar { background: var(--navy); box-shadow: none; }
.topbar .brand {
  display: block; width: 122px; height: 41px; overflow: hidden;
  background: url(/assets/logo.svg) no-repeat left center / contain;
  font-size: 0; color: transparent;
}
.topbar .user { color: #c9cdd8; }

/* Sidebar: quiet greys, orange active state (matches the site CTA). */
.sidebar a { border-radius: 4px; color: var(--navy); }
.sidebar a:hover { background: #f2f2f2; }
.sidebar a.active { background: var(--brand); color: #fff; }
.sidebar .navgrp > summary { border-radius: 4px; color: var(--navy); }
.sidebar .navgrp > summary:hover { background: #f2f2f2; }

/* Buttons: website CTA orange, square-ish Bulma radius. */
.btn, button, input[type=submit] {
  border-radius: 4px; border-color: var(--brand); background: var(--brand);
}
.btn:hover, button:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
/* Link-buttons: the a:hover text-link color above must not beat .btn's white
   text (orange-on-orange = invisible). Secondary keeps its own text color. */
a.btn:hover { color: #fff; }
a.btn.secondary:hover { color: var(--brand-deep); }
.btn:focus-visible, button:focus-visible { outline: 2px solid #f8c5ab; }
.btn.secondary, button.secondary { background: #fff; color: var(--brand-deep); }
.btn.secondary:hover, button.secondary:hover { background: var(--brand-tint); }
.pager button { background: #fff; color: var(--brand-deep); }

/* Forms */
input, select, textarea { border-radius: 4px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #f8c5ab; border-color: var(--brand); }

/* Tables: neutral grey heads, warm orange row hover. */
table.data th { background: #f5f5f5; color: #5c5c5c; }
table.data tbody tr:nth-child(even) { background: #fafafa; }
table.data tbody tr:hover { background: var(--brand-tint); }
.data tr.totals td { background: #f4f4f4; }
.filelist tbody tr:hover { background: var(--brand-tint); }

/* Menus, pickers, hovers: neutral grey instead of the old blue tints. */
.msel-toggle { border-radius: 4px; }
.msel-panel, .msel-drop, .cols-menu { border-radius: 4px; }
.msel-item:hover, .msel-opt:hover, .msel-opt.sel,
.breadcrumb a:hover, .checkgrid label.flag:hover, .foldertree .ft-row:hover,
.wysiwyg-btn:hover, .subnav a:hover { background: #f2f2f2; }
.msel-opt.active { background: var(--brand); color: #fff; }
.ft-name:hover { background: #f2f2f2; }
.ft-name.picked { background: var(--brand); }
code { background: #f4f4f4; }
.filechip { background: #f4f4f4; }
.filechip:hover { background: #e8e8e8; }
.crm-preview, .permgrid .perm.on { background: var(--brand-tint); }
.alert.info { background: #eef0f5; color: var(--navy); border-color: #d6d9e2; }

/* Login: full-bleed website navy, card floating like the site hero. */
body:has(.login-wrap) { background: var(--navy); }
body:has(.login-wrap) .topbar { border-bottom: 1px solid rgba(255,255,255,.08); }
.login-wrap .card { border: 0; box-shadow: 0 18px 48px rgba(0,0,0,.35); padding: 32px; }
.login-wrap h1 { font-size: 24px; }

/* ============================================================================
   CLIENT-AREA LAYOUT (scoped by body.area-client; the admin portal keeps
   its sidebar — its nav has collapsible groups). Horizontal navigation at
   every width: the navy topbar keeps brand + user; the nav is a single-line
   pill bar beneath it with ONE overflow behaviour everywhere — it either
   fits, or it scrolls sideways with scroll-shadow edge hints; it never
   wraps. Content column is centered.
   ========================================================================== */

.area-client .shell { display: block; min-height: 0; }
.area-client .sidebar {
  width: auto; display: flex; gap: 6px; align-items: center;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 10px clamp(12px, 3vw, 28px); border-right: 0;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 56px; z-index: 9;
  background-color: var(--surface);
  background-image:
    linear-gradient(90deg, var(--surface) 40%, rgba(255,255,255,0)),
    linear-gradient(270deg, var(--surface) 40%, rgba(255,255,255,0)),
    radial-gradient(farthest-side at 0 50%, rgba(31,36,52,.28), transparent),
    radial-gradient(farthest-side at 100% 50%, rgba(31,36,52,.28), transparent);
  background-position: left center, right center, left center, right center;
  background-size: 44px 100%, 44px 100%, 16px 100%, 16px 100%;
  background-repeat: no-repeat;
  background-attachment: local, local, scroll, scroll;
}
.area-client .sidebar::-webkit-scrollbar { display: none; }
.area-client .sidebar a {
  flex: none; white-space: nowrap; margin-bottom: 0;
  padding: 7px 14px; border-radius: 999px; font-size: 14px;
}
.area-client .content { max-width: 1200px; margin: 0 auto; padding: 24px clamp(14px, 3vw, 28px); }

@media (max-width: 900px) {
  .content { max-width: none; padding: 18px 16px; }
  /* Non-grid tables (saved queries, pivots, files) scroll like the grid does. */
  table.data { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .dash-cols { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .topbar { padding: 0 12px; gap: 10px; height: 52px; }
  .topbar .brand { width: 106px; height: 36px; }
  /* Show just "Sign out" — the name text is dropped, not the link. */
  .topbar .user { font-size: 0; }
  .topbar .user a { font-size: 13px; }
  /* Same single-line bar, just tighter — and re-pinned under the 52px topbar. */
  .area-client .sidebar { gap: 4px; padding: 8px 10px; top: 52px; }
  .area-client .sidebar a { padding: 6px 11px; font-size: 13px; }
  .content { padding: 14px 10px; }
  h1 { font-size: 20px; }
  .card { padding: 14px; }
  .form-row { gap: 10px; }
  /* Stack every field full-width; keep checkboxes inline on one line. */
  .form-row > label { width: 100%; }
  .form-row > label.chk, .filters label.chk { width: auto; }
  .form-row input:not([type=checkbox]), .form-row select { min-width: 0; width: 100%; }
  .msel { min-width: 0; flex-basis: 100%; }
  .grid-toolbar { flex-wrap: wrap; gap: 8px; }
  .grid-toolbar input.search { min-width: 0; flex: 1 1 100%; }
  .login-wrap { margin: 6vh auto; padding: 0 14px; }
  .login-wrap .card { padding: 22px; }
  .stat-row .stat { flex-basis: 40%; }
}

/* ============================================================================
   WIDTH layer — use the screen we have.
   Pages are fluid to a 1680px comfort cap; pages carrying genuinely wide
   data (the movements grid, or a generated summary pivot) drop the cap
   entirely, so the table takes the full viewport before it falls back to
   horizontal scrolling inside its card.
   ========================================================================== */
.content { max-width: 1680px; }
.content:has(table.grid), .content:has(tr.totals) { max-width: none; }
/* Filter pickers stay tidy when the page goes full-bleed. */
.msel { max-width: 380px; }
/* Flexible at every width: no table may ever force page-level horizontal
   scroll. Every data table becomes its own scroll container (as the
   movements grid always was) — it hugs its content up to the available
   width, then scrolls in place. min-width:0 lets the flex column shrink. */
.content { min-width: 0; }
table.data { display: block; width: fit-content; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ============================================================================
   CLIENT-AREA UX REFINEMENTS (client feedback, 2026-07-12).
   ========================================================================== */

/* Rows-per-page lives in the grid footer, sharing the line with the pager
   (the pager is inserted by app.js directly after the table). */
.grid-foot { display: flex; justify-content: flex-end; align-items: center; margin-top: -37px; min-height: 32px; pointer-events: none; }
.grid-foot label { display: flex; align-items: center; gap: 8px; pointer-events: auto; }
.grid-foot select { margin-top: 0; min-width: 0; }

/* Columns menu: sticky action header + two-column checkbox list. */
.cols-menu { padding: 0; width: 480px; max-width: min(480px, calc(100vw - 40px)); max-height: 420px; }
.cols-head {
  position: sticky; top: 0; z-index: 1; background: var(--surface);
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.cols-count { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.cols-list { columns: 2; column-gap: 18px; padding: 8px 12px 10px; }
.cols-list label { break-inside: avoid; }

/* Divider instead of pushing the save group to the far edge. */
.filters .vr { width: 1px; align-self: stretch; background: var(--border); margin: 0 10px; }

/* Summaries: From/To with "to most recent" tucked beneath; compact controls
   so the whole first row (through Units) fits on one line on big screens. */
.dategrp { display: flex; flex-wrap: wrap; gap: 12px 18px; }
/* "To most recent" sits directly under the To date it modifies. */
.tocol { display: flex; flex-direction: column; }
.tocol > label:not(.chk) { display: flex; flex-direction: column; }
.tocol .chk { margin-top: 6px; }
.filters .form-row:has(.dategrp) { align-items: flex-start; }
#sum-filters .form-row select { min-width: 0; }
#sum-filters input[type=date] { min-width: 0; width: 160px; }
.dategrp > label:not(.chk) { display: flex; flex-direction: column; }
.cols-menu { margin-top: 0; }
/* Disabled fields read as clearly off (e.g. To date under "to most recent"). */
input:disabled, select:disabled { background: #f2f2f2; color: #9a9a9a; cursor: not-allowed; }
/* All Data: the row also holds Date-by and the transfers checkbox — keep the
   lone checkbox level with the input line, not the row top. */
.form-row:has(.dategrp) > label.chk { align-self: flex-start; margin-top: 31px; }

/* ============================================================================
   QUERY-IN-FLIGHT FEEDBACK (client feedback, 2026-07-27).
   Big movements/summary queries gave no sign anything was happening. app.js
   veils the results while a query runs: the AJAX grid covers its .grid-box;
   full-page queries (form[data-busy], a[data-busy-link]) veil the
   [data-busy-mask] card and put a spinner in the clicked button.
   ========================================================================== */
.spinner { display: inline-block; width: 14px; height: 14px; flex: none;
  border: 2px solid rgba(11,92,171,.25); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
button .spinner, .btn .spinner { border-color: rgba(255,255,255,.4);
  border-top-color: #fff; margin-right: 8px; vertical-align: -2px; }
button.secondary .spinner, .btn.secondary .spinner {
  border-color: rgba(11,92,171,.25); border-top-color: var(--brand); }
.busy { opacity: .8; pointer-events: none; }
.grid-box, [data-busy-mask] { position: relative; }
.busy-overlay { position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: flex-start; justify-content: center;
  background: rgba(255,255,255,.55); border-radius: inherit; }
/* display:flex above would otherwise beat the UA's [hidden]{display:none}. */
.busy-overlay[hidden] { display: none; }
.busy-overlay .busy-box { position: sticky; top: 35vh; margin: 18px 0;
  display: flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 16px; box-shadow: var(--shadow);
  color: var(--muted); font-size: 14px; font-weight: 600; }
