/* =========================================================
   Receipt Scanner — style.css
   ========================================================= */
:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --sidebar: #ffffff;
  --border: #e3e6ee;
  --border-strong: #cfd4df;
  --text: #1d2433;
  --muted: #6b7385;
  --primary: #2453c8;
  --primary-hover: #1c44a8;
  --primary-soft: #e8eefc;
  --success: #2f6b3a;
  --success-soft: #e6f3e8;
  --success-bar: #3c7d46;
  --warn: #8a5a10;
  --warn-soft: #fdf3e1;
  --warn-border: #c9973c;
  --danger: #c62e2e;
  --danger-soft: #fdeaea;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .04);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
.hidden { display: none !important; }
svg.ic { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 280px; flex: none; background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 12px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 17px; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--primary); color: #fff; display: grid; place-items: center; }
.brand .logo svg { width: 18px; height: 18px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; margin-bottom: 4px;
  border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: #f1f3f8; color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.side-sep { border-top: 1px solid var(--border); margin: 12px 0; }
.recent-title { font-weight: 600; font-size: 14px; padding: 4px 12px 8px; }
.recent { flex: 1; overflow-y: auto; padding: 0 4px; }
.recent-item { display: block; padding: 10px 8px; border-radius: 8px; text-decoration: none; color: var(--text); }
.recent-item:hover { background: #f4f6fa; }
.recent-item .co { font-size: 13px; font-weight: 500; text-transform: uppercase; }
.recent-item .nm { font-weight: 600; font-size: 16px; }
.recent-item .dt { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.recent-item .st { font-size: 13px; }
.side-foot { border-top: 1px solid var(--border); padding-top: 10px; }
.side-foot .who { font-size: 12px; color: var(--muted); padding: 0 14px 6px; word-break: break-all; }

.main { flex: 1; min-width: 0; padding: 32px 48px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -.01em; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 9px; border: 1px solid var(--border-strong);
  background: #fff; cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none; color: var(--text);
}
.btn:hover { background: #f5f7fb; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); border-color: #efc4c4; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { border: 0; background: transparent; padding: 8px; border-radius: 8px; cursor: pointer; color: var(--muted); display: inline-grid; place-items: center; }
.icon-btn:hover { background: #eef1f6; color: var(--text); }
.icon-btn.del { color: var(--danger); }

/* ---------- Inputs ---------- */
.field { margin-bottom: 18px; }
.field > label { display: block; color: var(--muted); font-size: 14px; margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: 9px; background: #fff; outline: none;
}
textarea.input { resize: vertical; min-height: 70px; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(36, 83, 200, .12); }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; padding-left: 4px; }
.flag-wrap { position: relative; }
.flag-wrap .flag { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--warn); pointer-events: none; display: none; }
.flag-wrap .flag svg { width: 18px; height: 18px; }
.flagged .input { background: var(--warn-soft); border-color: var(--warn-border); }
.flagged .flag { display: block; }
.flagged .input { padding-right: 36px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.search { position: relative; margin-bottom: 18px; }
.search svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 48px; height: 52px; }

.chips { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.chip { padding: 9px 20px; border-radius: 9px; border: 1px solid var(--border-strong); background: #fff; cursor: pointer; color: var(--muted); display: inline-flex; gap: 8px; align-items: center; }
.chip.on { background: var(--primary-soft); border-color: #c9d6f6; color: var(--primary); }
.chip svg { width: 16px; height: 16px; }

.filters { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 24px; align-items: end; }
.filters .sel { min-width: 220px; }
.filters .sel label { font-size: 13px; color: var(--muted); display: block; margin: 0 0 4px 4px; }
.client-sel { position: relative; min-width: 300px; }
.client-sel svg.ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.client-sel select { padding-left: 44px; height: 50px; }

/* ---------- Cards ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 24px 28px; }
.card + .card { margin-top: 18px; }
.card h3 { margin: 0 0 8px; font-size: 19px; }
.muted { color: var(--muted); }
.green { color: var(--success); }
.amber { color: var(--warn); }
.red { color: var(--danger); }
.empty { padding: 50px 20px; text-align: center; color: var(--muted); }

.task-card { display: flex; align-items: center; justify-content: space-between; padding: 22px 26px; gap: 16px; }
.task-card + .task-card { margin-top: 14px; }
.task-card .t1 { font-weight: 600; font-size: 18px; }
.task-card .t2 { font-weight: 500; font-size: 17px; text-transform: uppercase; margin: 4px 0; }
.task-card .t3 { font-size: 16px; }
.task-card .t4 { color: var(--muted); font-size: 14px; margin-top: 4px; }
.task-card .acts { display: flex; align-items: center; gap: 8px; }

.progress { height: 4px; background: #e6e9f0; border-radius: 4px; overflow: hidden; }
.progress > div { height: 100%; background: var(--success-bar); border-radius: 4px; transition: width .3s; }
.progress.blue > div { background: var(--primary); }

/* menus */
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: 110%; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 28px rgba(20, 30, 60, .12); min-width: 190px; z-index: 30; padding: 6px; }
.menu button { display: flex; width: 100%; gap: 10px; align-items: center; text-align: left; border: 0; background: none; padding: 9px 12px; border-radius: 7px; cursor: pointer; }
.menu button:hover { background: #f3f5f9; }
.menu button.danger { color: var(--danger); }

/* ---------- Table ---------- */
.table-card { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; min-width: 900px; }
.tbl th { text-align: left; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 16px 12px; background: #f6f7fa; border-bottom: 1px solid var(--border); }
.tbl td { padding: 16px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.clickable:hover td { background: #fafbfd; cursor: pointer; }
.tbl .nm { font-weight: 600; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl .sm { color: var(--muted); font-size: 14px; }
.tbl .cl { text-transform: uppercase; color: var(--muted); max-width: 240px; }
.tbl input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--primary); }
.with-ic { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.with-ic svg { width: 18px; height: 18px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; font-size: 14px; font-weight: 500; white-space: nowrap; }
.badge svg { width: 16px; height: 16px; }
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.busy { background: var(--primary-soft); color: var(--primary); }
.badge.err { background: var(--danger-soft); color: var(--danger); }
.badge.grey { background: #eef0f4; color: var(--muted); }

.bulkbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--primary-soft); border-radius: 10px; margin-bottom: 14px; }

/* ---------- Scan page ---------- */
.scan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.with-add { display: flex; gap: 8px; }
.with-add select { flex: 1; }
.scan-grid .card { margin-top: 0; }
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 4px;
  border: 2px dashed #c9d2e6; border-radius: 16px; background: #fff;
  padding: 44px 24px 40px; cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s;
}
.drop:hover { border-color: #9fb3e6; background: #fbfcff; }
.drop.over { border-color: var(--primary); background: #f2f6ff; box-shadow: 0 0 0 4px rgba(36, 83, 200, .08); }
.drop-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; margin-bottom: 10px; }
.drop-icon svg.ic { width: 30px; height: 30px; }
.drop h3 { margin: 0; font-size: 19px; }
.drop .muted { font-size: 14px; }
.drop-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; justify-content: center; }
.file-list-head { display: flex; justify-content: space-between; align-items: center; margin: 18px 2px 8px; }
.file-list { margin-top: 8px; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 9px; background: #fff; margin-bottom: 8px; }
.file-row .fn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .thumb { width: 38px; height: 38px; border-radius: 6px; object-fit: cover; background: #eef0f4; display: grid; place-items: center; color: var(--muted); font-size: 11px; font-weight: 700; }

/* ---------- Task detail ---------- */
.task-actions { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 22px; }
.sec-head { display: flex; align-items: center; gap: 14px; font-size: 19px; font-weight: 600; }
.sec-head svg { width: 26px; height: 26px; }
.collapse-head { display: flex; justify-content: space-between; align-items: center; cursor: pointer; font-size: 19px; font-weight: 600; padding: 22px 28px; }
.doc-line { display: flex; align-items: center; gap: 16px; padding: 14px 28px; border-top: 1px solid var(--border); cursor: pointer; background: #fafafa; }
.doc-line:hover { background: #f3f4f7; }
.doc-line .grow { flex: 1; min-width: 0; }
.doc-line .fn { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-line svg.big { width: 28px; height: 28px; }

/* ---------- Review ---------- */
.review { display: flex; flex-direction: column; height: calc(100vh - 0px); padding: 14px 18px; }
.review-top { display: flex; justify-content: space-between; font-weight: 600; font-size: 15px; margin-bottom: 8px; align-items: center; gap: 10px; }
.review-body { flex: 1; display: grid; grid-template-columns: minmax(0, var(--split-a, 50fr)) 14px minmax(0, var(--split-b, 50fr)); gap: 0; min-height: 0; margin-top: 12px; }
.viewer { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.viewer-tools { display: flex; justify-content: flex-end; padding: 12px; border-bottom: 1px solid var(--border); }
.zoombar { display: flex; align-items: center; gap: 4px; border: 1px solid var(--border); border-radius: 10px; padding: 4px 8px; background: #fff; }
.zoombar .pct { font-family: ui-monospace, Menlo, monospace; min-width: 64px; text-align: center; }
.zoombar .sep { width: 1px; height: 24px; background: var(--border); margin: 0 6px; }
.viewer-canvas { flex: 1; overflow: hidden; background: #f0f1f4; position: relative; min-height: 0; cursor: grab; touch-action: none; overscroll-behavior: contain; user-select: none; -webkit-user-select: none; }
.viewer-canvas.grabbing { cursor: grabbing; }
.viewer-canvas .stage { padding: 0; transform-origin: top left; display: inline-block; position: absolute; top: 0; left: 0; will-change: transform; }
.viewer-canvas img, .viewer-canvas canvas { display: block; max-width: none; }
.viewer-canvas canvas + canvas { margin-top: 10px; }
.divider { align-self: stretch; justify-self: stretch; cursor: col-resize; display: flex; align-items: center; justify-content: center; touch-action: none; border-radius: 6px; }
.divider span { width: 4px; height: 60px; border-radius: 6px; background: var(--border); transition: background .12s, height .12s; }
.divider:hover span, body.col-resizing .divider span { background: var(--primary); height: 120px; }
.form-panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; }
.form-panel h2 { margin: 0; padding: 18px 28px; font-size: 21px; border-bottom: 1px solid var(--border); }
.form-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); padding-right: 20px; }
.form-head h2 { border-bottom: 0; }
.form-head-actions { display: flex; gap: 4px; }
.form-head-actions .icon-btn svg.ic { width: 20px; height: 20px; }
.form-scroll { flex: 1; overflow-y: auto; padding: 18px 28px 10px; }
.form-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 28px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.form-foot .tot { font-size: 22px; font-weight: 600; }
.status-box { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border: 1px solid var(--border); background: #f6f7fa; border-radius: 10px; font-weight: 600; margin-bottom: 22px; }
.status-box svg { width: 28px; height: 28px; }
.status-box.ok svg { color: var(--success); }
.status-box.warn { background: var(--warn-soft); border-color: #f0d7a8; }
.status-box.warn svg { color: var(--warn); }
.status-box ul { margin: 6px 0 0; padding-left: 18px; font-weight: 400; font-size: 14px; }
.form-section { font-size: 19px; font-weight: 600; margin: 8px 0 14px; display: flex; justify-content: space-between; align-items: center; }

.items-wrap { border: 1px solid var(--border); border-radius: 10px; overflow-x: auto; }
table.items { border-collapse: collapse; table-layout: fixed; }
.items th { text-align: left; font-weight: 600; color: var(--muted); padding: 12px 8px; background: #f6f7fa; font-size: 14px; }
.items td { padding: 6px 4px; vertical-align: top; }
.items td:first-child { padding-left: 8px; }
.items .input { padding: 9px 30px 9px 10px; }
.items td.num .input { text-align: right; }
.items textarea.input { min-height: 40px; resize: vertical; }
.items-total { padding: 10px 2px; color: var(--muted); }
.items-total b { color: var(--text); font-weight: 600; margin-left: 8px; font-size: 18px; }

/* ---------- Companies ---------- */
.co-card { padding: 20px 24px; }
.co-card + .co-card { margin-top: 14px; }
.co-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.co-name { font-weight: 700; font-size: 18px; text-transform: uppercase; }
.folders { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.folder { display: inline-flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; border: 1px solid var(--border); border-radius: 10px; background: #fafbfd; }
.folder svg.ic { width: 18px; height: 18px; color: var(--warn); }
.folder .cnt { color: var(--muted); font-size: 13px; }
.folder .kind { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #eef0f4; color: var(--muted); }

/* ---------- Modal / toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15, 20, 35, .45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 480px; padding: 24px 26px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal h3 { margin: 0 0 16px; font-size: 20px; }
.modal .acts { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #1f2533; color: #fff; padding: 12px 20px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); font-size: 14px; max-width: 90vw; }
.toast.err { background: var(--danger); }
.overlay-busy { position: fixed; inset: 0; background: rgba(255, 255, 255, .7); z-index: 150; display: grid; place-items: center; font-weight: 600; }
.spinner { width: 18px; height: 18px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 400px; padding: 32px; }
.login h1 { margin: 0 0 4px; font-size: 26px; }

.notice { padding: 14px 18px; border-radius: 10px; background: var(--warn-soft); border: 1px solid #f0d7a8; color: #6b4a0f; margin-bottom: 18px; font-size: 14px; }
.notice.info { background: var(--primary-soft); border-color: #c9d6f6; color: #1f3f8f; }
code { background: #f1f3f8; padding: 1px 6px; border-radius: 5px; font-size: 13px; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .review-body { grid-template-columns: 1fr; overflow-y: auto; }
  .divider { display: none; }
  .viewer { min-height: 60vh; }
  .review { height: auto; }
}
@media (max-width: 820px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; padding: 10px; }
  .recent, .recent-title, .side-sep { display: none; }
  .nav { display: flex; overflow-x: auto; gap: 4px; }
  .nav a { margin: 0; white-space: nowrap; }
  .main { padding: 20px 16px 40px; }
  .scan-grid, .row2 { grid-template-columns: 1fr; }
  .task-card { flex-direction: column; align-items: stretch; }
  .page-head h1 { font-size: 24px; }
}

/* Additional details (review form) */
.addl { border-top: 1px solid var(--border); margin-top: 22px; padding-top: 18px; }
.addl-head { display: flex; justify-content: space-between; align-items: center; font-size: 19px; font-weight: 600; cursor: pointer; margin-bottom: 14px; }
.addl-head svg.blue { color: var(--primary); }
.input.soft { background: #f4f4f5; }
.custom-box { border: 1px solid var(--border); background: #f8f9fb; border-radius: 10px; padding: 16px 18px; }
.custom-note { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 12px; }
.custom-note svg.ic { width: 18px; height: 18px; }
.custom-row { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; margin-bottom: 10px; }

/* Company logo + settings button */
.brand { flex-direction: column; align-items: stretch; gap: 6px; padding: 6px 8px 18px 12px; }
.brand-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand-logo { width: 150px; max-width: 100%; min-width: 0; flex: 0 1 auto; height: auto; display: block; image-rendering: -webkit-optimize-contrast; }
.settings-link { display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--border); color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; background: #fff; white-space: nowrap; }
.settings-link svg.ic { width: 17px; height: 17px; }
.settings-link:hover { color: var(--text); background: #f4f6fa; }
.settings-link.active { background: var(--primary-soft); color: var(--primary); border-color: #c9d6f6; }
.brand-sub { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .02em; text-transform: uppercase; }
.login-logo { width: 176px; height: auto; display: block; margin-bottom: 18px; }
@media (max-width: 820px) {
  .brand { flex-direction: row; align-items: center; gap: 12px; padding: 4px 6px 10px; }
  .brand-logo { width: 120px; }
}

/* Roles & users */
.role-badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; background: #eef0f4; color: var(--muted); margin-top: 4px; }
.role-badge.manager { background: var(--primary-soft); color: var(--primary); }
.role-badge.admin { background: #fdf0d9; color: #a15c00; }

/* Profile button + panel */
.brand { position: relative; }
.brand-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.brand-actions .settings-link { padding: 6px 9px; font-size: 13px; }
.profile-btn { width: 34px; height: 34px; padding: 0; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); background: none; cursor: pointer; flex: none; overflow: hidden; }
.profile-btn svg, .pf-avatar svg { width: 100%; height: 100%; display: block; }
.profile-btn:hover { box-shadow: 0 0 0 2px var(--primary); }
.profile-pop { position: absolute; top: 52px; right: 6px; z-index: 60; width: 250px; background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 32px rgba(20,30,60,.16); padding: 20px 18px 16px; text-align: center; }
.pf-avatar { width: 76px; height: 76px; margin: 0 auto 10px; border-radius: 50%; overflow: hidden; }
.pf-name { font-weight: 600; font-size: 16px; }
.pf-email { color: var(--muted); font-size: 13px; word-break: break-all; margin: 2px 0 8px; }
.profile-pop .role-badge { font-size: 12px; padding: 3px 12px; }
.pf-help { font-size: 12.5px; color: var(--muted); line-height: 1.45; margin: 10px 0 14px; }
.pf-actions { display: flex; flex-direction: column; gap: 6px; }
.pf-actions .btn { justify-content: center; }
.side-foot .who a { font-size: 12px; }
.cred { border: 1px solid var(--border); border-radius: 10px; background: #f8f9fb; padding: 6px 16px; }
.cred > div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; word-break: break-all; }
.cred > div:last-child { border-bottom: 0; }
.cred b { font-family: ui-monospace, Menlo, monospace; font-weight: 600; text-align: right; }

/* Charges & tax (review form) */
.charges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 14px; align-items: end; }
.charges .field:nth-child(5) { grid-column: span 2; }
.charges .chk { grid-column: span 2; display: flex; gap: 8px; align-items: center; margin-bottom: 18px; font-size: 14px; color: var(--muted); }
.charges .chk input { width: 18px; height: 18px; accent-color: var(--primary); }
@media (max-width: 820px) { .charges { grid-template-columns: 1fr 1fr; } }

/* Totals breakdown (review form) */
.breakdown { border: 1px solid var(--border); border-radius: 10px; padding: 6px 16px; max-width: 460px; margin: 4px 0 8px; background: #fafbfd; }
.breakdown > div { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; font-size: 15px; }
.breakdown > div + div { border-top: 1px dashed var(--border); }
.breakdown b { font-weight: 600; font-variant-numeric: tabular-nums; }
.breakdown .bd-total { border-top: 1px solid var(--border-strong) !important; font-size: 17px; }
.breakdown .bd-check { font-size: 14px; }

/* Sidebar hide / show */
.sidebar { overflow: hidden; }
.recent { min-height: 0; overscroll-behavior: contain; scrollbar-width: thin; }
.recent::-webkit-scrollbar { width: 8px; }
.recent::-webkit-scrollbar-thumb { background: #cfd4df; border-radius: 8px; }
.side-foot, .brand, .nav, .side-sep, .recent-title { flex: none; }
.app { position: relative; }
.collapse-btn { position: fixed; left: 266px; top: 22px; z-index: 20; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border-strong); background: #fff; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; display: grid; place-items: center; box-shadow: 0 1px 4px rgba(20,30,60,.08); padding: 0 0 2px; }
.collapse-btn:hover { color: var(--primary); border-color: var(--primary); }
.expand-btn { display: none; position: fixed; left: 0; top: 22px; z-index: 40; width: 26px; height: 44px; border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 10px 10px 0; background: #fff; color: var(--muted); font-size: 22px; cursor: pointer; box-shadow: 0 1px 4px rgba(20,30,60,.08); padding: 0 0 3px; }
.expand-btn:hover { color: var(--primary); }
body.sb-collapsed .sidebar, body.sb-collapsed .collapse-btn { display: none; }
body.sb-collapsed .expand-btn { display: block; }
body.sb-collapsed .main { padding-left: 44px; }
body.sb-collapsed .review { padding-left: 34px; }
/* With the sidebar hidden, the review screen splits 50 / 50 */
.form-panel, .viewer { min-width: 0; }
@media (max-width: 820px) { .collapse-btn, .expand-btn { display: none !important; } body.sb-collapsed .sidebar { display: flex; } }

/* Settings tabs */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin: -8px 0 22px; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 11px 16px; color: var(--muted); text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab svg.ic { width: 18px; height: 18px; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--primary); border-bottom-color: var(--primary); }
.sub-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }

/* Assign companies dialog */
.assign-tools { display: flex; gap: 8px; margin-bottom: 10px; }
.assign-tools .input { padding: 8px 12px; }
.assign-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 6px; margin-bottom: 14px; }
.assign-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; cursor: pointer; text-transform: uppercase; font-size: 14px; }
.assign-item:hover { background: #f4f6fa; }
.assign-item input { width: 17px; height: 17px; accent-color: var(--primary); }
.modal { max-height: calc(100vh - 32px); overflow-y: auto; }

/* Icon-only Settings / Profile buttons with a hover label */
.brand-actions .settings-link { width: 36px; height: 36px; padding: 0; justify-content: center; border-radius: 50%; border: 0; background: none; color: #7a7f88; }
.brand-actions .settings-link img { width: 28px; height: 28px; display: block; transition: transform .25s; }
.brand-actions .settings-link:hover { background: #eef0f4; }
.brand-actions .settings-link:hover img { transform: rotate(30deg); }
.brand-actions .settings-link.active { background: var(--primary-soft); }
.brand-actions .settings-link svg.ic { width: 22px; height: 22px; }
[data-tip] { position: relative; }
[data-tip]::after { content: attr(data-tip); position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: #1f2430; color: #fff; font-size: 12px; font-weight: 500; padding: 4px 9px; border-radius: 6px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .12s; z-index: 70; }
[data-tip]:hover::after { opacity: 1; }
[data-tip].no-tip::after { opacity: 0 !important; }
.profile-btn { overflow: visible; }
.profile-btn svg { border-radius: 50%; }

/* Task page sections + bin */
.sec-title { display: inline-flex; align-items: center; gap: 12px; }
.sec-title svg.ic { width: 24px; height: 24px; }
.bin-tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; margin-left: 6px; vertical-align: middle; }
.bin-tag.dup { background: #fdf0d9; color: #a15c00; }
.bin-tag.man { background: #eef0f4; color: #5b6170; }
.doc-line .icon-btn.del { margin-left: 4px; }
.folder[data-fopen] { cursor: pointer; transition: border-color .12s, background .12s; }
.folder[data-fopen]:hover { border-color: #c9d6f6; background: var(--primary-soft); }

/* History: extra columns + filters */
.filters2 { margin-top: -6px; }
.filters2 .sel { min-width: 170px; }
.range { display: flex; align-items: center; gap: 6px; }
.range span { color: var(--muted); font-size: 13px; }
.range .input { padding-left: 10px; padding-right: 8px; min-width: 0; }
.table-card { overflow-x: auto; }
.tbl td.nowrap { white-space: nowrap; }
.tbl td.cl { font-size: 13px; line-height: 1.35; max-width: 190px; }
.tbl td.sup { color: var(--text); }
.steps-list { padding-left: 20px; line-height: 1.6; font-size: 14px; }
.steps-list code { background: #f1f3f7; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; word-break: break-all; }
.tbl.hist th, .tbl.hist td { padding-left: 9px; padding-right: 9px; font-size: 14px; }
.tbl.hist th { font-size: 11.5px; }
.tbl.hist td:nth-child(2) { min-width: 150px; }
.tbl.hist td.cl { min-width: 120px; }
.tbl.hist .with-ic svg.ic { display: none; }
.tbl.hist .badge { font-size: 12.5px; padding: 4px 9px; white-space: nowrap; }
.tbl.hist td:last-child { padding-left: 2px; }
.tbl.hist th:last-child, .tbl.hist td:last-child { position: sticky; right: 0; background: #fff; box-shadow: -8px 0 8px -8px rgba(20,30,60,.18); }
.tbl.hist th:last-child { background: #f6f7fa; }
.tbl.hist tr.clickable:hover td:last-child { background: inherit; }
.tbl.hist .nm { max-width: 190px; }

/* Items table: resizable columns */
.items th { position: relative; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.items td .input { width: 100%; box-sizing: border-box; }
.items td.acc .input { padding-right: 10px; }
.col-grip { position: absolute; top: 0; right: 0; width: 9px; height: 100%; cursor: col-resize; z-index: 2; }
.col-grip::after { content: ''; position: absolute; top: 25%; bottom: 25%; right: 3px; width: 2px; border-radius: 2px; background: #d3d8e2; }
.col-grip:hover::after, body.col-resizing .col-grip::after { background: var(--primary); }
body.col-resizing, body.col-resizing * { cursor: col-resize !important; user-select: none; }

/* Calculator + calendar buttons inside a box */
.calc-btn { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.calc-btn:hover { background: var(--primary-soft); color: var(--primary); }
.calc-btn svg.ic { width: 17px; height: 17px; }
.flag-wrap:has(.calc-btn) .input { padding-right: 38px; }
.items td.tot .input { padding-right: 36px; }
.date-pick { position: absolute; right: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; }
.calc-pop { position: fixed; z-index: 90; width: 250px; background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 14px 36px rgba(20,30,60,.2); padding: 12px; }
.calc-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.calc-disp { font-size: 18px; text-align: right; font-variant-numeric: tabular-nums; }
.calc-res { text-align: right; font-size: 14px; min-height: 20px; margin: 4px 2px 8px; }
.calc-short { width: 100%; justify-content: center; margin-bottom: 8px; font-size: 12.5px; }
.calc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
.calc-keys button { height: 38px; border: 1px solid var(--border); border-radius: 9px; background: #f8f9fb; font-size: 16px; cursor: pointer; color: var(--text); }
.calc-keys button:hover { background: #eef1f6; }
.calc-keys button.op { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.calc-use { width: 100%; justify-content: center; }

/* Scrollbar above the History table */
.top-scroll { overflow-x: auto; overflow-y: hidden; height: 16px; margin: 0 2px 6px; scrollbar-color: #c4cad6 #e9ecf2; }
.top-scroll > div { height: 1px; }
.top-scroll::-webkit-scrollbar { height: 12px; }
.top-scroll::-webkit-scrollbar-thumb { background: #c4cad6; border-radius: 8px; border: 2px solid var(--bg, #f5f6f9); }
.top-scroll::-webkit-scrollbar-track { background: #e9ecf2; border-radius: 8px; }

/* Chart of accounts */
.coa-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.coa-tools label.btn { cursor: pointer; }
.coa-list { max-height: 46vh; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.coa-list .tbl th, .coa-list .tbl td { padding: 8px 10px; font-size: 13.5px; }
.coa-list .tbl th { position: sticky; top: 0; z-index: 1; }
.coa-list tr.coa-head td { color: var(--muted); background: #f8f9fb; }
.acc-pop { position: fixed; z-index: 95; max-height: 320px; overflow-y: auto; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 30px rgba(20,30,60,.18); padding: 4px; }
.acc-opt { display: flex; gap: 10px; padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: 13.5px; }
.acc-opt b { flex: none; min-width: 78px; font-weight: 600; font-variant-numeric: tabular-nums; }
.acc-opt span { color: var(--text); }
.acc-opt.on, .acc-opt:hover { background: var(--primary-soft); }
.acc-none { padding: 10px; font-size: 13.5px; }
.items .input.acc-bad { border-color: var(--danger, #d93025); background: #fff6f5; }
.modal:has(.coa-tools), .modal:has(.coa-list) { max-width: 760px; }
.coa-list .tbl { width: 100%; }
.coa-list table.tbl { min-width: 0; }
.acc-add { display: flex; align-items: center; gap: 8px; padding: 9px 10px; margin-top: 2px; border-top: 1px solid var(--border); color: var(--primary); font-weight: 600; font-size: 13.5px; cursor: pointer; border-radius: 0 0 7px 7px; position: sticky; bottom: -4px; background: #fff; }
.acc-add:hover { background: var(--primary-soft); }
.acc-add svg.ic { width: 16px; height: 16px; }
