:root {
  --bg: #f8f8f8;
  --bg-card: #fff;
  --bg-subtle: #fafafa;
  --surface: #f2f2f2;
  --divider: #e8e8e8;
  --border: #ddd;
  --border-mid: #ccc;
  --border-sub: #aaa;
  --text: #0a0a0a;
  --text-2: #262626;
  --text-3: #404040;
  --text-4: #374151;
  --text-5: #1f2937;
  --heading: #0a0a0a;
  --accent: #215c5c;
  --accent-hover: #144b4b;
  --danger: #c62828;
  --danger-hover: #b71c1c;
  --mono-bg: #000;
  --mono-fg: #fff;
  --mono-border: #000;
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  margin: 0;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.portal-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 56px;
  padding: 0 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-sizing: border-box;
}
.portal-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}
.portal-header-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.portal-header-toggle:hover { background: var(--surface); }
.portal-header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  text-decoration: none;
  color: var(--text);
}
.portal-header-brand:hover { color: var(--text); }
.portal-header-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}
.portal-header-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text);
  white-space: nowrap;
}
.portal-badge {
  flex-shrink: 0;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--border);
  color: var(--text-3);
  font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.3px;
}
.portal-user-wrap {
  position: relative;
  flex: 0 0 auto;
}
.portal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex: 0 0 auto;
}
.portal-header-bell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  color: var(--text-2);
  text-decoration: none;
}
.portal-header-bell:hover,
.portal-header-bell.is-active {
  background: var(--surface);
  color: var(--text);
}
.portal-user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 4px 10px 4px 4px;
  border-radius: 8px;
  border: 1px solid var(--border-mid);
  background: var(--bg-card);
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.portal-user-btn:hover { background: var(--surface); }
.portal-user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--surface);
}
.portal-user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: 9px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 5px;
  z-index: 200;
}
.portal-header svg {
  display: block;
  flex-shrink: 0;
}

#sidebar {
  z-index: 40;
  transition: transform 0.25s cubic-bezier(.4, 0, .2, 1);
  overflow: hidden;
}
@media (min-width: 901px) {
  #sidebar.collapsed {
    transform: translateX(-100%);
    pointer-events: none;
  }
}
#main-content {
  transition: margin-left 0.25s cubic-bezier(.4, 0, .2, 1);
  min-height: calc(100vh - 56px);
}
#main-content.expanded { margin-left: 0 !important; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 3px; }

.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13.5px;
}
.flash.success { background: var(--border); border: 1px solid var(--border-mid); color: var(--text); }
.flash.error { background: rgba(239, 68, 68, 0.08); border: 1px solid rgba(239, 68, 68, 0.25); color: var(--danger); }

.field-row { margin-bottom: 18px; }
.field-row label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.field-row input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.field-row select,
.field-row textarea,
.form-control {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-mid);
  border-radius: 7px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  height: auto;
  box-shadow: none;
}
.field-row input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):focus,
.field-row select:focus,
.field-row textarea:focus,
.form-control:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(33, 92, 92, 0.12);
}
.field-row textarea,
textarea.form-control { resize: vertical; min-height: 80px; }
.field-row input[type="checkbox"],
.field-row input[type="radio"] {
  width: auto;
  height: auto;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}
.field-row input[type="file"] {
  width: auto;
  max-width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  font-size: 13px;
}
.field-row ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.field-row ul label {
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--text);
  margin: 0;
}
.field-row .errorlist,
.help-block {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  color: var(--danger);
  font-size: 12px;
}

.btn, .form-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border-mid);
}
.btn-ghost:hover { background: var(--divider); color: var(--text); }
.btn-warning { background: #d97706; color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 5px; }
.btn:disabled, .form-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.tbl-check { width: 40px; text-align: center; vertical-align: middle; }
.tbl-check input { width: 15px; height: 15px; margin: 0; accent-color: #215c5c; }
.btn svg, .form-btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px 32px;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.page-title {
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.page-title svg { width: 18px; height: 18px; color: var(--text-4); }
.crumb {
  color: var(--text-4);
  font-size: 12px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.crumb:hover { color: var(--text); }
.crumb svg { width: 12px; height: 12px; }

.search-input {
  background: var(--bg);
  border: 1px solid var(--border-mid);
  border-right: none;
  border-radius: 7px 0 0 7px;
  color: var(--text);
  padding: 7px 12px 7px 30px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.search-input:focus { border-color: var(--border-sub); }
.search-btn {
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-left: none;
  border-radius: 0 7px 7px 0;
  color: var(--text-2);
  padding: 7px 12px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.search-btn:hover { background: var(--divider); color: var(--text); }

.btn-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #215c5c;
  color: #fff;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}
.btn-add:hover { opacity: 0.85; color: #fff; }
.btn-add svg { width: 14px; height: 14px; }

.tbl-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.table-responsive { width: 100%; overflow-x: auto; }
.tbl-card table {
  width: 100%;
  border-collapse: collapse;
}
.tbl-card th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  color: var(--heading);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--divider);
  padding: 10px 14px;
}
.tbl-card th.text-right { text-align: right; }
/* Shrink an actions column to its buttons so spare width goes to data columns. */
.tbl-col-actions { width: 1%; white-space: nowrap; }
.tbl-card td {
  padding: 12px 14px;
  border-top: 1px solid var(--divider);
  color: var(--text-2);
  font-size: 13.5px;
}
.tbl-card tbody tr:hover td { background: var(--divider); }
.sort-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  text-decoration: none;
  letter-spacing: inherit;
  text-transform: inherit;
  font: inherit;
  white-space: nowrap;
}
.sort-link:hover,
.sort-link.is-active { color: var(--text); }
.sort-link.is-asc::after,
.sort-link.is-desc::after,
.js-sortable th.is-asc::after,
.js-sortable th.is-desc::after {
  content: "↑";
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  opacity: 0.75;
}
.sort-link.is-desc::after,
.js-sortable th.is-desc::after { content: "↓"; }
.js-sortable th:not(.no-sort) {
  cursor: pointer;
  user-select: none;
}
.js-sortable th:not(.no-sort):hover { color: var(--text); }
.muted { color: var(--text-4); font-size: 13px; }

.acl-table-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
}
.acl-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}
.acl-table th {
  padding: 11px 14px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--divider);
  color: var(--heading);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-align: center;
  text-transform: uppercase;
}
.acl-table th:first-child { text-align: left; }
.acl-table td {
  padding: 12px 14px;
  border-top: 1px solid var(--divider);
  color: var(--text-2);
  font-size: 13px;
}
.acl-table tbody tr:hover td { background: var(--surface); }
.acl-table td:first-child { color: var(--text); font-weight: 600; }
.acl-check-cell { width: 92px; text-align: center; }
.acl-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border-mid);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
}
.acl-check:hover { border-color: var(--accent); background: var(--surface); }
.acl-check input { position: absolute; opacity: 0; pointer-events: none; }
.acl-check span {
  width: 14px;
  height: 14px;
  border: 1px solid var(--text-4);
  border-radius: 3px;
  background: transparent;
}
.acl-check input:checked + span {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 3px var(--bg-card);
}
.acl-check input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.tbl-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 5px;
  border: 1px solid var(--border-mid);
  color: var(--text-3);
  font-size: 12px;
  text-decoration: none;
  margin-left: 4px;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}
.tbl-action:hover { border-color: var(--border-sub); color: var(--text); }
.tbl-action-del { border-color: rgba(239, 68, 68, 0.2); }
.tbl-action-del:hover { border-color: #c62828; color: var(--danger); }

.status-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
  background: var(--mono-bg);
  color: var(--mono-fg);
  border: 1px solid var(--mono-border);
}
.status-badge-paid { background: var(--accent); border-color: var(--accent); color: #fff; }
.status-badge-overdue { background: var(--danger); border-color: var(--danger); color: #fff; }
.status-badge-void { background: #6b7280; border-color: #6b7280; color: #fff; }
.tbl-card tr.is-void-row td { opacity: 0.65; }
.status-badge-info { background: #3d8a8a; border-color: #3d8a8a; color: #fff; }
.status-badge-warn { background: #d97706; border-color: #d97706; color: #fff; }

.page-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-mid);
  color: var(--text-3);
  text-decoration: none;
  font-size: 12px;
  background: var(--bg-card);
}
.page-btn:hover { border-color: var(--border-sub); color: var(--text); }

.kpi-heading {
  color: var(--text-4);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  margin: 0 0 8px;
}
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  display: block;
}
a.kpi-card:hover { border-color: var(--border-sub); }
.kpi-card.is-warn { border-color: rgba(217, 119, 6, 0.4); }
.kpi-card.is-danger { border-color: rgba(198, 40, 40, 0.35); }
.kpi-card.is-danger .stat-value { color: var(--danger); }
.kpi-card .stat-label {
  color: var(--text-4);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.kpi-card .stat-value {
  color: var(--heading);
  font-size: 22px;
  font-weight: 700;
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}
.stat-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-4);
  line-height: 1.35;
}
.pipeline {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 24px;
}
.pipeline-step {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  display: block;
}
a.pipeline-step:hover { border-color: var(--border-sub); }
.pipeline-step .stat-label {
  color: var(--text-4);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.pipeline-step .stat-value {
  color: var(--heading);
  font-size: 18px;
  font-weight: 700;
  margin: 4px 0 0;
}

.filter-select {
  background: var(--bg);
  border: 1px solid var(--border-mid);
  border-radius: 7px;
  color: var(--text);
  padding: 7px 12px;
  font-size: 13px;
  font-family: inherit;
  height: 34px;
}
.filter-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-3);
  white-space: nowrap;
}
.section-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.section-title svg { width: 14px; height: 14px; color: var(--text-4); }
.muted-note { color: var(--text-4); font-size: 13px; margin: 0 0 16px; line-height: 1.45; }
.delay-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid rgba(217, 119, 6, 0.3);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
  background: rgba(217, 119, 6, 0.06);
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.45;
}
.pager-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--divider);
  font-size: 12px;
  color: var(--text-4);
}
.dash-grid, .detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
.detail-grid { grid-template-columns: 1.3fr 1fr; }
.meta-line { color: var(--text-3); font-size: 13.5px; line-height: 1.55; margin: 0 0 16px; }
.page-kicker {
  margin: 6px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--heading);
}
.page-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 20px;
  overflow: hidden;
}
.facts-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fact {
  padding: 14px 18px;
  border-right: 1px solid var(--divider);
  min-width: 0;
}
.fact:last-child { border-right: none; }
.fact-label {
  color: var(--text-4);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}
.fact-value {
  margin: 5px 0 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
  line-height: 1.4;
}
.fact-sub {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-4);
  overflow-wrap: anywhere;
  line-height: 1.35;
}
.card-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
}
.print-table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.print-table th, .print-table td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  font-size: 13px;
  text-align: left;
}
.print-totals { width: 280px; margin-left: auto; border-collapse: collapse; }
.print-totals th, .print-totals td { padding: 6px 8px; font-size: 13px; }

.umenu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  border-radius: 6px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}
.umenu-item:hover { background: var(--divider); color: var(--text); }
.umenu-item svg { width: 14px; height: 14px; }
.umenu-danger { color: var(--danger); }
.umenu-danger:hover { background: rgba(239, 68, 68, 0.08); color: var(--danger); }

#sidebar-backdrop {
  display: block;
  visibility: hidden;
  position: fixed;
  left: 0;
  right: 0;
  top: 56px;
  bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 55;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
#sidebar-backdrop.visible {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}
body.sidebar-mobile-open {
  overflow: hidden;
}

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
  position: relative;
  padding: 0 0 18px 28px;
  border-left: 2px solid var(--divider);
  margin-left: 8px;
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li .dot {
  position: absolute;
  left: -7px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border-mid);
}
.timeline li.done .dot { background: var(--accent); }
.timeline li.done { border-left-color: var(--accent); }
.timeline li.current { border-left-color: var(--divider); }
.timeline li.current .dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(33, 92, 92, 0.18);
}
.timeline-label { font-size: 14px; line-height: 20px; color: #9aa0a6; }
.timeline li.done .timeline-label { color: var(--text); font-weight: 500; }
.timeline li.current .timeline-label { font-weight: 600; }
.timeline-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: 2px;
  background: rgba(33, 92, 92, 0.12);
  color: var(--accent);
}
.timeline-meta { margin-top: 2px; font-size: 12px; color: var(--text-4); }
.timeline-note { margin-top: 4px; font-size: 13px; color: var(--text-3); line-height: 1.45; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image:
    linear-gradient(rgba(33, 92, 92, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(33, 92, 92, 0.055) 1px, transparent 1px);
  background-size: 28px 28px;
}
.login-wrap {
  width: 100%;
  max-width: 420px;
  margin: 40px auto;
  padding: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.login-brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  margin-bottom: 12px;
}

.invoice-print {
  max-width: 800px;
  margin: 24px auto;
  background: var(--bg-card);
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.invoice-print h1 { margin-top: 0; color: var(--accent); }
.print-page { background: var(--bg); }
.invoice-print .print-cols {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.invoice-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px 56px;
  margin-top: 72px;
  padding-top: 8px;
  page-break-inside: avoid;
}
.invoice-signature {
  min-width: 0;
  align-self: end;
}
.invoice-signature-line {
  border-top: 1px solid var(--text-3);
  margin: 48px 0 6px;
}
.invoice-signature-line.has-image {
  margin-top: 8px;
}
.invoice-signature-image {
  display: block;
  max-height: 56px;
  max-width: 100%;
  width: auto;
  object-fit: contain;
  margin: 0 0 0;
}
.invoice-signature-label {
  color: var(--text-4);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  line-height: 1.3;
}
.invoice-signature-name {
  margin-top: 2px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.signature-pad-wrap {
  border: 1px dashed var(--accent);
  border-radius: 10px;
  background: #fff;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.signature-pad-wrap canvas {
  display: block;
  width: 100%;
  height: 160px;
  touch-action: none;
  cursor: crosshair;
  border-radius: 6px;
  background: #fafafa;
}
.signature-pad-clear {
  align-self: flex-start;
  padding: 4px 10px;
  font-size: 12px;
}
.signature-preview {
  display: block;
  max-height: 72px;
  max-width: 100%;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}
.signature-current {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}
.signature-remove-btn {
  color: var(--danger, #b42318);
}
@media (max-width: 620px) {
  .invoice-signatures { grid-template-columns: 1fr; gap: 28px; }
}
@media print {
  .invoice-signatures {
    margin-top: 64px;
  }
}

.portal-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 80;
  align-items: flex-start;
  justify-content: center;
  padding: 56px 16px 24px;
  background: rgba(10, 10, 10, 0.4);
  overflow-y: auto;
}
.portal-modal.is-open { display: flex; }
body.modal-open { overflow: hidden; }
.portal-modal-panel {
  width: 100%;
  max-width: 520px;
  margin: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
}
.portal-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.portal-modal-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--heading);
}
.portal-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
}
.portal-modal-close:hover { background: var(--surface); color: var(--text); }
.portal-modal-body {
  padding: 18px 20px 8px;
  max-height: min(70vh, 560px);
  overflow-y: auto;
}
.portal-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border);
}
.portal-modal-form { margin: 0; }
.portal-modal-form .field-row:last-of-type { margin-bottom: 8px; }

.doc-dropzone {
  position: relative;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 55%, var(--border));
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 6%, var(--bg-card));
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  margin-bottom: 16px;
  overflow: hidden;
  padding: 8px;
}
.doc-dropzone.is-dragover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-card));
  box-shadow: inset 0 0 0 1px var(--accent);
}
.doc-dropzone.is-uploading {
  pointer-events: none;
}
.doc-dropzone.is-uploading .doc-dropzone-hint {
  opacity: 0.45;
}
.doc-upload-progress {
  margin: 0 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.doc-upload-progress[hidden] {
  display: none !important;
}
.doc-upload-progress-track {
  height: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, var(--border));
  overflow: hidden;
}
.doc-upload-progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.12s ease-out;
}
.doc-upload-progress-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}
.doc-dropzone-hint {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: nowrap;
  padding: 28px 20px 16px;
  color: var(--text-3);
  font-size: 14px;
  text-align: center;
  min-height: 140px;
}
.doc-dropzone-hint svg {
  color: var(--accent);
  flex-shrink: 0;
}
.doc-dropzone-copy {
  margin: 0;
  color: var(--text-3);
  font-size: 14px;
  line-height: 1.4;
}
.doc-dropzone-browse {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  position: relative;
  z-index: 3;
}
.doc-dropzone-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 4px 12px 10px;
  color: var(--text-4);
  font-size: 12px;
}
.doc-dropzone-status {
  width: 100%;
  font-weight: 600;
  color: var(--text-2);
  position: relative;
  z-index: 3;
}
.doc-dropzone-input,
.doc-dropzone-modal .doc-file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
  font-size: 0;
}
.doc-dropzone-modal {
  min-height: 180px;
  margin-bottom: 0;
}
.doc-dropzone-modal .doc-dropzone-hint {
  min-height: 148px;
  pointer-events: none;
}
.doc-dropzone-filename {
  width: 100%;
  font-weight: 600;
  color: var(--text-2) !important;
}
.doc-file-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 8px;
}
.doc-file-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.doc-file-card-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}
.doc-file-card-main svg { color: var(--accent); flex-shrink: 0; }
.doc-file-card-meta { min-width: 0; }
.doc-file-card-name {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
  word-break: break-word;
}
.doc-file-card-sub {
  font-size: 12px;
  margin-top: 2px;
}
.doc-file-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.doc-file-card-actions .tbl-action {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
}
.doc-pdf-frame {
  width: 100%;
  min-height: min(70vh, 640px);
  height: 70vh;
  border: 0;
  border-radius: 8px;
  background: var(--surface);
}
.portal-modal-panel.is-pdf-preview {
  max-width: min(920px, 96vw);
}
.portal-modal-body.is-pdf-preview {
  max-height: none;
  padding-bottom: 16px;
}

@media print {
  .no-print { display: none !important; }
  .invoice-print { margin: 0; border: 0; padding: 0; }
}

@media (max-width: 900px) {
  #sidebar-backdrop.visible {
    left: min(280px, 88vw);
    right: 0;
  }
  body.sidebar-mobile-open #main-content {
    pointer-events: none;
  }
  #sidebar {
    transform: translate3d(-100%, 0, 0);
    visibility: hidden;
    width: min(280px, 88vw) !important;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s, visibility 0s linear 0.25s;
    z-index: 60;
    box-shadow: none;
    pointer-events: none;
    -webkit-overflow-scrolling: touch;
    will-change: transform;
  }
  #sidebar.collapsed {
    width: min(280px, 88vw) !important;
  }
  #sidebar.mobile-open {
    visibility: visible;
    pointer-events: auto;
    transform: translate3d(0, 0, 0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.4);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s, visibility 0s linear 0s;
  }
  #sidebar.sidebar-drawer-instant {
    transition: none !important;
  }
  #main-content, #main-content.expanded {
    margin-left: 0 !important;
    padding: 16px !important;
    position: relative;
    z-index: 0;
  }
  .portal-badge, .portal-user-meta { display: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .pipeline { grid-template-columns: 1fr 1fr 1fr; }
  .dash-grid, .detail-grid { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr 1fr; }
  .fact:nth-child(2n) { border-right: none; }
  .fact:nth-child(-n+2) { border-bottom: 1px solid var(--divider); }
}
@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: 1fr 1fr; }
  .facts { grid-template-columns: 1fr; }
  .fact { border-right: none; border-bottom: 1px solid var(--divider); }
  .fact:last-child { border-bottom: none; }
}

/* Password strength meter (htmx, see StrengthPasswordInput) */
.pw-strength:empty { display: none; }
.pw-strength { margin-top: 8px; }
.pw-strength-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.pw-strength-seg { height: 5px; border-radius: 3px; background: var(--divider); transition: background-color .2s; }
.pw-level-0 .is-filled, .pw-level-1 .is-filled { background: var(--danger); }
.pw-level-2 .is-filled { background: #e08a00; }
.pw-level-3 .is-filled { background: #3f9a5a; }
.pw-level-4 .is-filled { background: var(--accent); }
.pw-strength-text { margin-top: 5px; font-size: 12px; color: var(--text-4); }
.pw-level-0 + .pw-strength-text strong, .pw-level-1 + .pw-strength-text strong { color: var(--danger); }

/* Collapsible supporting-documents section */
.doc-section { margin-bottom: 16px; }
.doc-section-summary {
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.doc-section-summary::-webkit-details-marker { display: none; }
.doc-section:not([open]) > .doc-section-summary { margin-bottom: 0; }
.doc-section-label { display: inline-flex; align-items: center; gap: 7px; }
.doc-section-chevron { transition: transform 0.15s ease; }
.doc-section[open] .doc-section-chevron { transform: rotate(90deg); }
.doc-section-count {
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--border);
  color: var(--text-3);
}

/* Staff profile header: banner, overlapping avatar, dark tab bar */
.profile-shell {
  background: var(--bg-card, #fff);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.profile-hero {
  position: relative;
  min-height: 118px;
  padding: 32px 24px 0 188px;
  background: linear-gradient(120deg, #163a3a 0%, #102a2a 40%, #0e0e0e 100%);
  color: #fff;
}
.profile-avatar {
  position: absolute;
  left: 28px;
  bottom: -64px;
  z-index: 2;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 5px solid #fff;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
.profile-name { margin: 0; font-size: 26px; font-weight: 700; line-height: 1.2; color: #fff; }
.profile-role { margin: 4px 0 0; font-size: 13px; color: rgba(255, 255, 255, 0.7); }
.profile-tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px 0 180px;
  background: #2b2b2b;
  overflow-x: auto;
  scrollbar-width: none;
}
.profile-tabs::-webkit-scrollbar { display: none; }
.profile-tab {
  flex-shrink: 0;
  padding: 15px 22px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
.profile-tab:hover { background: rgba(255, 255, 255, 0.06); }
.profile-tab.is-active { background: #fff; color: var(--accent); }
.profile-tab:focus-visible { outline: 2px solid #fff; outline-offset: -4px; }
.profile-body { padding: 40px 32px 32px; }
.profile-panel { max-width: 640px; }
.profile-panel-title { margin: 0 0 16px; font-size: 15px; font-weight: 700; color: var(--text); }
.profile-panel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; }

@media (max-width: 720px) {
  .profile-hero { min-height: 0; padding: 24px 16px 64px; text-align: center; }
  .profile-avatar { left: 50%; bottom: -48px; width: 96px; height: 96px; margin-left: -48px; font-size: 34px; border-width: 4px; }
  .profile-name { font-size: 22px; }
  .profile-tabs { padding: 56px 8px 0; }
  .profile-tab { padding: 12px 14px; }
  .profile-body { padding: 24px 16px; }
  .profile-panel-grid { grid-template-columns: 1fr; }
}

/* Dashboard card icons */
.kpi-card, .pipeline-step { position: relative; }
.kpi-card .stat-label, .pipeline-step .stat-label { padding-right: 44px; }
.kpi-icon {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(33, 92, 92, 0.1);
  color: var(--accent);
}
.kpi-icon svg { width: 18px; height: 18px; }
.kpi-icon-sm { top: 10px; right: 10px; width: 28px; height: 28px; border-radius: 7px; }
.kpi-icon-sm svg { width: 15px; height: 15px; }
.pipeline-step .stat-label { padding-right: 34px; }
.kpi-card.is-warn .kpi-icon { background: rgba(217, 119, 6, 0.12); color: #d97706; }
.kpi-card.is-danger .kpi-icon { background: rgba(198, 40, 40, 0.1); color: var(--danger); }
