/* =========================================================
   Acemind CRM — visual system
   Each service line has its own colour, used consistently on
   chips, charts and filters, so staff can scan by service.
   ========================================================= */
:root {
  --ink: #13283a;          /* sidebar */
  --ink-2: #1c3850;
  --primary: #2147c6;
  --primary-soft: #e8edfc;
  --marigold: #f2a900;     /* brand mark */
  --bg: #f3f5f8;
  --card: #ffffff;
  --line: #e3e7ed;
  --text: #1a2533;
  --muted: #6b7787;

  --ok: #1e7e4f;   --ok-bg: #e3f4ea;
  --info: #1f5fbf; --info-bg: #e5effc;
  --warn: #9a6200; --warn-bg: #fdf1d6;
  --bad: #b8322a;  --bad-bg: #fbe6e4;

  --svc-website: #2147c6;
  --svc-seo: #1e8e5a;
  --svc-smo: #c2378a;
  --svc-hosting: #6a4fd3;
  --svc-domain: #0e8fa8;
  --svc-ssl: #c7781a;
  --svc-other: #5c6878;

  --bs-body-font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --bs-body-color: var(--text);
  --bs-body-bg: var(--bg);
  --bs-primary: var(--primary);
  --bs-primary-rgb: 33, 71, 198;
  --bs-link-color: var(--primary);
  --bs-link-color-rgb: 33, 71, 198;
  --bs-border-color: var(--line);
}

body { font-size: 14px; background: var(--bg); color: var(--text); }
h1, h2, h3, h4, h5 { font-weight: 700; letter-spacing: -0.01em; }
a { text-decoration: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex-shrink: 0; background: var(--ink); color: #c9d4df;
  position: fixed; inset: 0 auto 0 0; overflow-y: auto; z-index: 1040;
  transition: transform .2s ease;
}
.main { flex: 1; margin-left: 248px; display: flex; flex-direction: column; min-width: 0; }
.content { padding: 24px 28px; flex: 1; }
.foot { display: flex; justify-content: space-between; padding: 14px 28px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }

.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px; color: #fff; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px 10px 10px 2px; background: var(--marigold); color: var(--ink);
  display: grid; place-items: center; font-weight: 800; font-size: 18px;
}
.brand-logo { display: inline-flex; align-items: center; flex-shrink: 0; min-width: 0; }
.brand-logo img { display: block; width: auto; object-fit: contain; }
.brand-logo-side { background: #fff; border-radius: 9px; padding: 5px 8px; }
.brand-logo-side img { height: 32px; max-width: 150px; }
.brand-logo-plain img { height: 52px; max-width: 220px; }
.auth-logo-mobile { display: none; margin-bottom: 24px; }
@media (max-width: 860px) { .auth-logo-mobile { display: block; } }
.brand-text strong { display: block; font-size: 16px; line-height: 1.1; }
.brand-text small { color: #8ea3b8; font-size: 11.5px; }

.side-nav { padding: 4px 12px 24px; }
.nav-group { font-size: 11.5px; color: #7f94a9; padding: 16px 10px 6px; font-weight: 600; }
.side-nav .nav-link {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px;
  color: #c9d4df; font-weight: 500; margin-bottom: 1px;
}
.side-nav .nav-link i { font-size: 16px; width: 18px; text-align: center; opacity: .85; }
.side-nav .nav-link:hover { background: var(--ink-2); color: #fff; }
.side-nav .nav-link.active { background: #fff; color: var(--ink); font-weight: 700; }
.side-nav .nav-link.active i { color: var(--primary); opacity: 1; }

.topbar {
  height: 64px; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px; padding: 0 28px; position: sticky; top: 0; z-index: 1020;
}
.top-search { position: relative; flex: 1; max-width: 520px; }
.top-search i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.top-search input {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px;
  padding: 9px 12px 9px 38px; font-size: 14px;
}
.top-search input:focus { outline: none; border-color: var(--primary); background: #fff; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.btn-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; color: var(--text); }
.btn-icon:hover { background: var(--bg); }
.dot-count {
  position: absolute; top: 4px; right: 3px; background: var(--bad); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px;
}
.user-btn { display: flex; align-items: center; gap: 10px; border: 0; padding: 4px 8px; border-radius: 10px; }
.user-btn:hover { background: var(--bg); }
.user-btn strong { display: block; font-size: 13px; line-height: 1.2; }
.user-btn small { color: var(--muted); font-size: 11.5px; }

.notif-menu { width: 340px; padding: 0; max-height: 440px; overflow-y: auto; }
.notif-item { display: block; padding: 10px 16px; border-bottom: 1px solid var(--line); color: var(--text); }
.notif-item strong { display: block; font-size: 13px; }
.notif-item span { display: block; font-size: 12.5px; color: var(--muted); }
.notif-item small { font-size: 11px; color: var(--muted); }
.notif-item.unread { background: var(--primary-soft); }

.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .sidebar.open + .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(10, 20, 30, .45); z-index: 1035; }
  .main { margin-left: 0; }
  .content { padding: 18px 16px; }
  .topbar { padding: 0 12px; }
}

/* ---------- Page head ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; margin: 0; }
.page-head p { color: var(--muted); margin: 4px 0 0; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Panels ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 15px; margin: 0; }
.panel-body { padding: 18px; }
.panel-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; }

/* KPI strip — one bordered band divided into cells, not separate cards */
.kpis { display: flex; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 20px; overflow: hidden; }
/* dividers drawn on the left/top edge; the container clips the outer ones, so any count wraps cleanly */
.kpi { flex: 1 1 150px; padding: 16px 18px; box-shadow: -1px 0 0 var(--line), 0 -1px 0 var(--line); }
.kpi span { display: block; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi strong { display: block; font-size: 24px; font-weight: 800; letter-spacing: -0.02em; margin-top: 2px; }
.kpi small { font-size: 12px; color: var(--muted); }
.kpi a { color: inherit; }
.kpi .svc { display: inline-flex; }
.kpi .st, .kpi .exp { display: inline-block; }

/* Invoice summary (currency + year) */
.inv-sum-pick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.inv-sum-pick .form-select { width: auto; min-width: 130px; font-size: 13px; }
.inv-sum-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 14px; }
.inv-sum-card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; color: inherit; }
.inv-sum-card:hover { border-color: var(--primary); color: inherit; }
.inv-sum-card span { display: block; font-size: 14px; font-weight: 600; color: var(--muted); }
.inv-sum-card strong { display: block; font-size: 20px; font-weight: 800; color: var(--primary); margin-top: 4px; }
.inv-sum-card small { font-size: 12px; color: var(--muted); }
.inv-sum-status { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 20px; overflow: hidden; }
.inv-sum-st { padding: 14px 18px; box-shadow: -1px 0 0 var(--line), 0 -1px 0 var(--line); }
.inv-sum-st > span { display: block; font-weight: 600; font-size: 14px; }
.inv-sum-st strong { font-size: 17px; font-weight: 800; color: var(--primary); }
.inv-sum-st a { font-size: 13px; }
.inv-sum-st em { margin-left: auto; font-style: normal; font-size: 13px; color: var(--muted); }
.inv-sum-bar { height: 4px; background: var(--bg); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.inv-sum-bar i { display: block; height: 100%; border-radius: 4px; }

/* Sortable column headers */
th.sortable a, th.js-sortable { color: inherit; text-decoration: none; white-space: nowrap; cursor: pointer; user-select: none; }
th.sortable .bi, th.js-sortable .bi { font-size: 11px; opacity: .35; margin-left: 2px; }
th.sortable:hover .bi, th.js-sortable:hover .bi, th.sorted .bi { opacity: 1; color: var(--primary); }

/* Rows per page + page links under lists */
.pager { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.per-page { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin: 0; }
.per-page .form-select { width: auto; min-width: 72px; }
.filters .per-page .form-select { min-width: 72px; }
.bulk-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 18px; background: var(--warn-bg); border-bottom: 1px solid var(--line); font-size: 13px; }
.bulk-bar[hidden] { display: none; }
.bulk-col { width: 36px; }
.table-top {display: flex; justify-content: flex-end; padding: 8px 18px; border-bottom: 1px solid var(--line); }

/* Foreign payment: live rate + fees */
.pay-calc { background: var(--bg); border-radius: 8px; padding: 8px 10px; color: var(--muted); line-height: 1.5; }
.pay-calc.has-fee { background: var(--warn-bg); color: var(--text); }
.pay-calc.no-fee { background: var(--ok-bg); color: var(--text); }

/* Dashboard: money blurred until "Show amounts" */
.money-private { transition: filter .2s; }
.hide-money .money-private { filter: blur(7px); user-select: none; pointer-events: none; }

/* To-do & notes */
.quick-add .qa-text { resize: none; min-height: 42px; font-size: 15px; }
.quick-add .qa-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.quick-add .qa-client { width: auto; max-width: 260px; }
.quick-add .qa-user { width: auto; max-width: 200px; }
.quick-add .qa-date { width: 150px; }
.quick-add .qa-time { width: 120px; }
.quick-add .qa-row .btn-primary { margin-left: auto; }
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.todo-item:last-child { border-bottom: 0; }
.todo-item.late { background: var(--bad-bg); }
.todo-item form { margin: 0; }
.todo-tick { border: 0; background: none; padding: 0; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; }
.todo-tick:hover, .todo-tick.is-done { color: var(--ok); }
.todo-body { flex: 1; min-width: 0; }
.todo-text { white-space: normal; overflow-wrap: anywhere; }
.todo-item.done .todo-text { text-decoration: line-through; color: var(--muted); }
.todo-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.todo-group-head { padding: 10px 18px 6px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--line); background: #fbfcfd; }
.todo-group-head .count { background: var(--bg); border-radius: 10px; padding: 1px 7px; margin-left: 4px; }
.agenda-list { list-style: none; margin: 0; padding: 0; }
.agenda-list li a { display: flex; gap: 10px; padding: 7px 18px; color: inherit; }
.agenda-list li a:hover { background: var(--bg); }
.agenda-list .bi { color: var(--muted); margin-top: 2px; }
.agenda-list small { display: block; color: var(--muted); font-size: 12px; }
.agenda-list .late small { color: var(--bad); }

/* ---------- Tables ---------- */
.table { margin: 0; --bs-table-bg: transparent; }
.table thead th { font-size: 12px; font-weight: 700; color: var(--muted); background: #f8f9fb; border-bottom: 1px solid var(--line); padding: 10px 14px; white-space: nowrap; }
.table td { padding: 11px 14px; vertical-align: middle; border-color: var(--line); }
.table tbody tr:hover { background: #fafbfd; }
.table .sub { display: block; color: var(--muted); font-size: 12px; }
.t-actions { white-space: nowrap; text-align: right; }
.t-actions .btn { padding: 3px 8px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: #fbfcfd; border-radius: 12px 12px 0 0; }
.filters .form-control, .filters .form-select { width: auto; min-width: 150px; font-size: 13px; }
.tabs-line { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; }
.tabs-line a { padding: 12px 12px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs-line a.active { color: var(--text); border-color: var(--primary); }
.tabs-line a .count { background: var(--bg); border-radius: 10px; padding: 1px 7px; font-size: 11px; margin-left: 4px; }

/* ---------- Badges ---------- */
.st { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 6px; white-space: nowrap; }
.st-ok { background: var(--ok-bg); color: var(--ok); }
.st-info { background: var(--info-bg); color: var(--info); }
.st-warn { background: var(--warn-bg); color: var(--warn); }
.st-bad { background: var(--bad-bg); color: var(--bad); }
.st-bad-soft { background: #fdf0ee; color: #a5463f; }
.st-mute { background: #eef0f3; color: #5c6878; }
.st-new { background: #ede9fe; color: #5b3fc4; }

/* Service chips */
.svc { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 3px 9px 3px 7px; border-radius: 20px; color: var(--c); background: color-mix(in srgb, var(--c) 11%, white); white-space: nowrap; }
.svc i { font-size: 12px; }
.svc-website { --c: var(--svc-website); } .svc-seo { --c: var(--svc-seo); } .svc-smo { --c: var(--svc-smo); }
.svc-hosting { --c: var(--svc-hosting); } .svc-domain { --c: var(--svc-domain); } .svc-ssl { --c: var(--svc-ssl); }
.svc-other { --c: var(--svc-other); }

/* Expiry pills */
.exp { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.exp-ok { color: var(--ok); background: var(--ok-bg); }
.exp-warn { color: var(--warn); background: var(--warn-bg); }
.exp-bad { color: var(--bad); background: var(--bad-bg); }

/* Avatars */
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 800; color: hsl(var(--h), 55%, 28%); background: hsl(var(--h), 65%, 88%); flex-shrink: 0; }
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar.lg { width: 56px; height: 56px; font-size: 18px; }
.avatar.xl { width: 96px; height: 96px; font-size: 30px; }
.avatar-pic { background: #e9edf2; overflow: hidden; }
.avatar-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatars { white-space: nowrap; }
.avatars .avatar { margin-left: -6px; border: 2px solid #fff; }
.avatars .avatar:first-child { margin-left: 0; }

/* Progress */
.prog { height: 6px; background: #eceff3; border-radius: 4px; overflow: hidden; min-width: 80px; }
.prog > div { height: 100%; background: var(--primary); border-radius: 4px; }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.form-control, .form-select { border-color: #d6dce4; border-radius: 8px; font-size: 14px; padding: 8px 11px; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-section { font-size: 13px; font-weight: 700; color: var(--muted); margin: 8px 0 12px; padding-bottom: 6px; border-bottom: 1px dashed var(--line); }
.btn { border-radius: 8px; font-weight: 600; font-size: 14px; }
.btn-primary { --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: #1a3aa6; --bs-btn-hover-border-color: #1a3aa6; }
.btn-light { --bs-btn-bg: #fff; --bs-btn-border-color: var(--line); }
.required::after { content: ' *'; color: var(--bad); }

/* ---------- Detail views ---------- */
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 9px 14px; margin: 0; }
.dl dt { color: var(--muted); font-weight: 600; font-size: 13px; }
.dl dd { margin: 0; word-break: break-word; }
.profile-head { display: flex; align-items: center; gap: 16px; }

/* Timeline (follow-ups, ticket thread, activity) */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 26px; }
.timeline li::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ''; position: absolute; left: 1px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--primary); }
.timeline .meta { font-size: 12px; color: var(--muted); }

.thread-msg { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; background: #fff; }
.thread-msg.internal { background: #fff9e8; border-color: #f2dfa6; }
.thread-msg header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.thread-msg header small { color: var(--muted); }

/* Charts keep a fixed height so they stay readable on phones */
.chart-box { position: relative; height: 300px; }
.chart-box.sm { height: 240px; }

/* Kanban */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.kan-col { background: #e9edf2; border-radius: 12px; padding: 10px; min-height: 300px; }
.kan-col h3 { font-size: 13px; font-weight: 700; padding: 4px 6px 10px; display: flex; justify-content: space-between; margin: 0; }
.kan-col.drag-over { background: #dbe4fb; }
.kan-card { background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 11px 12px; margin-bottom: 8px; cursor: grab; }
.kan-card:active { cursor: grabbing; }
.kan-card .title { font-weight: 700; display: block; margin-bottom: 4px; color: var(--text); }
.kan-card .foot-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 12px; color: var(--muted); }
.kan-card.overdue { border-left: 3px solid var(--bad); }

/* Lead pipeline bar */
.pipeline { display: flex; gap: 6px; overflow-x: auto; }
.pipe-stage { flex: 1; min-width: 110px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--text); }
.pipe-stage.active { border-color: var(--primary); box-shadow: inset 0 -3px 0 var(--primary); }
.pipe-stage span { font-size: 12px; color: var(--muted); font-weight: 600; }
.pipe-stage strong { display: block; font-size: 20px; }
.pipe-stage small { color: var(--muted); font-size: 11.5px; }

/* Rank movement */
.rank-up { color: var(--ok); font-weight: 700; }
.rank-down { color: var(--bad); font-weight: 700; }

/* Empty state */
.empty-state { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty-state i { font-size: 40px; color: #b8c2cf; display: block; margin-bottom: 10px; }
.empty-state h2 { font-size: 18px; color: var(--text); }

/* Login */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side { background: var(--ink); color: #dbe5ee; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h1 { color: #fff; font-size: 34px; line-height: 1.15; max-width: 14ch; }
.auth-side .lines { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.auth-side .svc { background: rgba(255,255,255,.08); color: #fff; }
.auth-form { display: grid; place-items: center; padding: 40px 24px; background: #fff; }
.auth-form form { width: 100%; max-width: 380px; }
@media (max-width: 860px) { .auth-wrap { grid-template-columns: 1fr; } .auth-side { display: none; } }

/* Invoice print */
.invoice-sheet { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 40px; max-width: 900px; margin: 0 auto; }
/* every word on the invoice in capitals for a uniform look (names come in mixed case); email addresses stay as typed */
.invoice-sheet { text-transform: uppercase; }
.invoice-sheet .keep-case { text-transform: none; }
/* Signature block: bottom right; signature with the stamp beside it (never covering the name) */
.inv-sign { margin: 24px 0 0 auto; width: 320px; text-align: center; page-break-inside: avoid; }
.inv-sign-img { display: flex; align-items: center; justify-content: center; height: 104px; margin: 6px 0 4px; }
.inv-sign-img img { position: relative; object-fit: contain; }
.inv-sign-img .sig-img { z-index: 2; max-height: 60px; max-width: 200px; width: auto; height: auto; }   /* not enlarged past its own size */
.inv-sign-img .stamp-img { z-index: 1; height: 100px; max-width: 110px; margin-left: 8px; opacity: .9; }
.inv-sign-img .stamp-img.alone { margin-left: 0; }
.inv-sign-line { border-top: 1px solid var(--text); padding-top: 4px; }
.no-sac .sac-col { display: none; }   /* invoice form while "Show SAC" is off (values are kept) */
.totals { margin-left: auto; max-width: 320px; }   /* invoice form summary */
.totals div { display: flex; justify-content: space-between; padding: 6px 0; }
.totals .grand { border-top: 2px solid var(--text); font-weight: 800; font-size: 17px; margin-top: 4px; padding-top: 10px; }
.stamp { display: inline-block; border: 3px solid currentColor; padding: 4px 14px; border-radius: 6px; font-weight: 800; transform: rotate(-6deg); font-size: 18px; }
/* Classic invoice: clean, teal accents */
/* A4-shaped page: payment details + signature follow the totals with a fixed gap; "Thank you" + website always sit at the very bottom */
.inv-classic { --teal: #1ea7c5; --ic-line: #d8dde3; position: relative; color: #222; font-size: 13px; border-top: 8px solid var(--teal); padding: 40px 44px;
  display: flex; flex-direction: column; min-height: 1123px; }
.inv-classic .ic-bottom { margin-top: 72px; }
.inv-classic .ic-thanks { margin-top: auto !important; }
.inv-classic .ic-terms + .ic-thanks, .inv-classic .ic-bottom + .ic-thanks { padding-top: 16px; }
.ic-foot-gap { height: 40px; flex-shrink: 0; }
.ic-bank { background: #f6fafb; border-left: 3px solid var(--teal); padding: 12px 16px; border-radius: 0 8px 8px 0; min-width: 260px; }
.inv-classic h4 { margin: 0 0 6px; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--teal); font-weight: 700; }
.ic-top { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding-bottom: 18px; border-bottom: 2px solid #222; }
.ic-logo { max-height: 60px; max-width: 240px; object-fit: contain; display: block; }
.ic-co { font-weight: 800; font-size: 16px; margin-top: 8px; }
.ic-small { color: #555; line-height: 1.55; max-width: 420px; font-size: 12.5px; }
.ic-title { text-align: right; margin-left: auto; }
.ic-title h1 { margin: 0; font-size: 26px; font-weight: 800; color: var(--teal); letter-spacing: .06em; }
.ic-title table { margin: 8px 0 0 auto; border-collapse: collapse; }
.ic-title td { padding: 2px 0 2px 16px; text-align: right; }
.ic-title td:first-child { color: #777; }
.ic-parties { border: 1px solid var(--ic-line); margin: 28px 0; padding: 14px 16px; line-height: 1.6; width: 50%; min-width: 300px; }
.ic-name { font-weight: 700; margin-bottom: 2px; }
.ic-items { width: 100%; border-collapse: collapse; border: 1px solid var(--ic-line); }
.ic-items th { background: #eef7fa; border-bottom: 2px solid var(--teal); text-align: left; padding: 9px 10px; font-size: 10.5px; letter-spacing: .06em; font-weight: 700; }
.ic-items td { padding: 10px; border-top: 1px solid #e6e9ed; vertical-align: top; }
.ic-items .num { text-align: right; white-space: nowrap; }
.ic-desc { font-weight: 600; }
.ic-sub { font-size: 11.5px; color: #666; margin-top: 2px; line-height: 1.45; }
.ic-sum { display: grid; grid-template-columns: 1fr 300px; border: 1px solid var(--ic-line); border-top: 0; }
.ic-words { padding: 12px 14px; border-right: 1px solid var(--ic-line); line-height: 1.6; }
.ic-totals div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 14px; border-bottom: 1px solid #eef0f2; }
.ic-totals div:last-child { border-bottom: 0; }
.ic-totals .ic-grand { background: var(--teal); color: #fff; font-weight: 800; font-size: 15px; }
.ic-txns { margin-top: 28px; page-break-inside: avoid; }
.ic-txns table { width: 100%; border-collapse: collapse; }
.ic-txns th { text-align: left; font-size: 10.5px; letter-spacing: .06em; font-weight: 700; color: #555; padding: 6px 10px; border-bottom: 2px solid #222; }
.ic-txns td { padding: 7px 10px; border-bottom: 1px solid #e6e9ed; }
.ic-txns .num { text-align: right; white-space: nowrap; }
.inv-classic .ic-txns + .ic-bottom { margin-top: 48px; }
.ic-bottom { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.ic-bank { line-height: 1.6; }
.ic-bank:empty { display: none; }
.ic-bottom .inv-sign { margin: 0 0 0 auto; }
.ic-terms { margin-top: 24px; padding-top: 12px; border-top: 1px solid var(--ic-line); font-size: 11.5px; color: #666; line-height: 1.6; }
.ic-thanks { text-align: center; margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--ic-line); color: var(--teal); font-weight: 700; letter-spacing: .05em; }
.ic-web { display: block; margin-top: 4px; font-weight: 500; font-size: 12px; letter-spacing: 0; color: #555; text-decoration: none; }
.ic-web:hover { color: var(--teal); text-decoration: underline; }
.inv-stamp { display: table; margin: 16px 0 4px 24px; transform: rotate(-8deg);   /* under "Amount in words", never over text */ border: 3px solid currentColor; padding: 4px 16px; border-radius: 6px; font-weight: 800; letter-spacing: .15em; font-size: 20px; background: rgba(255,255,255,.85); }
.inv-stamp.ok { color: #1e9e5a; } .inv-stamp.bad { color: var(--bad); }
@media (max-width: 640px) { .inv-classic { padding: 24px 18px; min-height: 0; } .inv-classic .ic-bottom { margin-top: 36px; } .ic-parties { width: 100%; min-width: 0; } .ic-sum { grid-template-columns: 1fr; } .ic-words { border-right: 0; border-bottom: 1px solid var(--ic-line); } .ic-title { text-align: left; margin-left: 0; } .ic-title table { margin-left: 0; } }

@media print {
  .sidebar, .topbar, .foot, .no-print, .alert { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0 !important; }
  body { background: #fff; }
  .invoice-sheet { border: 0; padding: 0; }
  /* No page margins = Chrome/Edge have nowhere to print the URL, date and "1/1"; the spacing lives inside the invoice instead */
  @page { size: A4; margin: 0; }
  .inv-classic { border-top: 8px solid #1ea7c5 !important; padding: 14mm 14mm 12mm !important; min-height: 296mm; }   /* one A4 page, footer at its bottom */
  .inv-classic, .inv-classic * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }   /* keep the teal accents when printing / saving as PDF */
  .ic-sum, .ic-bottom, .ic-terms { page-break-inside: avoid; }
  /* tighter spacing on paper so a normal invoice (with its transactions) stays on one A4 page */
  .ic-top { padding-bottom: 12px; } .ic-parties { margin: 16px 0; }
  .ic-items td { padding: 7px 10px; } .ic-txns { margin-top: 18px; }
  .inv-classic .ic-bottom, .inv-classic .ic-txns + .ic-bottom { margin-top: 28px; }
  .ic-foot-gap { height: 14px; } .inv-classic .ic-thanks { padding-top: 10px; }
  .ic-logo { max-height: 48px; } .ic-items td { padding: 5px 10px; } .ic-items th { padding: 7px 10px; } .ic-sub { margin-top: 0; }
  .ic-totals div { padding: 5px 14px; } .ic-words { padding: 8px 14px; } .inv-stamp { margin: 8px 0 0 24px; }
  .ic-txns td { padding: 5px 10px; } .ic-txns th { padding: 4px 10px; }
  .inv-sign-img { height: 82px; } .ic-bank { padding: 8px 14px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Client portal ---------- */
.portal { display: flex; flex-direction: column; min-height: 100vh; }
.portal-top { background: var(--ink); color: #fff; }
.portal-inner { max-width: 1200px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 20px; min-height: 66px; flex-wrap: wrap; }
.portal-links { display: flex; gap: 2px; flex: 1; }
.portal-links a { color: #c9d4df; padding: 8px 11px; border-radius: 8px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.portal-links a:hover { color: #fff; background: var(--ink-2); }
.portal-links a.active { background: #fff; color: var(--ink); }
.portal-user .user-btn:hover { background: var(--ink-2); }
.portal-main { max-width: 1200px; width: 100%; margin: 0 auto; padding: 28px 20px; flex: 1; }
.portal-foot { max-width: 1200px; width: 100%; margin: 0 auto; padding: 18px 20px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }
.portal-welcome { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--marigold); border-radius: 12px; padding: 16px 20px; margin-bottom: 20px; }
@media (max-width: 991.98px) {
  .portal-links { display: none; order: 3; width: 100%; flex-direction: column; padding-bottom: 12px; }
  .portal-links.show { display: flex; }
  .portal-user { order: 2; }
}
.auth-form form { max-width: none; }
.auth-switch { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); text-align: center; }

/* Type-to-confirm dialog */
.tc-icon { width: 40px; height: 40px; border-radius: 50%; background: var(--bad-bg); color: var(--bad); display: grid; place-items: center; font-size: 18px; flex-shrink: 0; }
.tc-impact { background: #fdf6f5; border: 1px solid #f3d9d6; border-radius: 8px; padding: 10px 14px 10px 30px; margin-bottom: 12px; font-size: 13px; }
.tc-impact li { margin: 3px 0; }
