:root {
  color-scheme: light;
  --ink: #1f2328;
  --muted: #68727d;
  --line: #d9dee5;
  --paper: #ffffff;
  --wash: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #fbfcfd;
  --surface-muted: #f8fafb;
  --field: #ffffff;
  --accent-soft: #fffaf1;
  --accent-line: #ead6b4;
  --gold: #c79235;
  --gold-dark: #9d6d21;
  --green: #1f7a4d;
  --blue: #215f9a;
  --shadow: 0 16px 40px rgba(33, 39, 45, 0.08);
}

@font-face {
  font-family: "Ingella Khmer";
  src: local("Noto Sans Khmer UI"), local("Khmer Sangam MN"), local("Khmer OS");
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  color: var(--ink);
  background: var(--wash);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* The sidebar is position:fixed (out of flow), so keep main content in the
   second grid track instead of collapsing into the empty 280px column. */
body > main {
  grid-column: 2;
  min-width: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.button {
  border: 0;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  max-width: 100%;
  text-align: center;
}

.ghost,
.chip {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}

.chip {
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 7px;
  text-decoration: none;
}

.chip.active {
  border-color: var(--gold);
  color: var(--gold-dark);
  background: var(--accent-soft);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100vh;
  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 22px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 24px;
  z-index: 30;
}

.mobile-menu-toggle,
.mobile-menu-close {
  display: none;
}

.mobile-menu-backdrop {
  display: none;
}

.brand img {
  width: 100%;
  max-width: 220px;
  display: block;
}

.brand span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

nav {
  display: grid;
  gap: 10px;
}

.nav-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 6px;
  align-items: start;
  border-radius: 14px;
  cursor: grab;
}

.nav-item.dragging {
  opacity: 0.55;
  transform: scale(0.99);
  cursor: grabbing;
}

.nav-drag-handle {
  min-height: 42px;
  width: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #b4bec8;
  cursor: grab;
  user-select: none;
  font-size: 13px;
  letter-spacing: -4px;
}

.nav-item:active .nav-drag-handle {
  cursor: grabbing;
}

nav a,
.nav-dropdown-toggle {
  min-height: 42px;
  border-radius: 12px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  padding: 11px 14px;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

nav a.active,
.nav-dropdown-toggle.active {
  background: linear-gradient(135deg, #fff7e8, #f7efe2);
  color: #7c541a;
  border: 1px solid #ead6b4;
  box-shadow: inset 0 0 0 1px rgba(199, 146, 53, 0.08);
}

.nav-item > a:hover,
.nav-dropdown-toggle:hover,
.nav-submenu a:hover {
  background: #f8fafb;
}

.nav-group {
  display: grid;
  gap: 8px;
  border-radius: 16px;
}

.nav-dropdown-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  text-align: left;
  font-weight: 700;
}

.nav-dropdown-toggle.active {
  border: 1px solid #ead6b4;
}

.nav-caret {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(199, 146, 53, 0.12);
  color: var(--gold-dark);
  font-size: 12px;
  transition: transform 160ms ease;
}

.nav-group.open .nav-caret {
  transform: rotate(180deg);
}

.nav-submenu {
  display: none;
  position: relative;
  gap: 5px;
  margin-left: 14px;
  padding: 4px 0 4px 14px;
}

.nav-submenu::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 0;
  width: 2px;
  border-radius: 999px;
  background: #ead6b4;
}

.nav-group.open .nav-submenu {
  display: grid;
}

.nav-submenu a {
  position: relative;
  min-height: 34px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
}

.nav-submenu-label {
  margin: 8px 0 2px;
  padding-left: 12px;
  color: #9aa3ad;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-submenu-label:first-child {
  margin-top: 0;
}

.nav-submenu a::before {
  content: "";
  position: absolute;
  left: -18px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #ead6b4;
  transform: translateY(-50%);
}

.nav-submenu a.active {
  color: var(--gold-dark);
  background: #fffaf1;
  border-color: #ead6b4;
  font-weight: 700;
}

.nav-submenu a.active::before {
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(199, 146, 53, 0.14);
}

.nav-reset {
  min-height: 30px;
  justify-content: flex-start;
  padding: 0 0 0 24px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.nav-reset:hover {
  color: var(--ink);
}

.template-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafbfc;
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.template-note strong {
  color: var(--ink);
}

main {
  min-width: 0;
  padding: 26px;
}

.panel-head,
.accounting-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.table-filter-input {
  flex: 0 0 auto;
  min-height: 34px;
  min-width: 200px;
  max-width: 320px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-size: 13px;
}

.topbar {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.topbar-main,
.topbar-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-controls {
  align-items: stretch;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.top-actions,
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}

.compact-actions {
  margin-top: 12px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fff;
  font-size: 13px;
  font-weight: 700;
}

.notification-menu {
  position: relative;
}

.notification-bell {
  position: relative;
}

.notification-bell.has-alerts {
  border-color: #fecaca;
  color: #b91c1c;
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.12), 0 0 18px rgba(239, 68, 68, 0.22);
}

.notification-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  display: grid;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  place-items: center;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.65);
}

.notification-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 90;
  width: min(360px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(31, 35, 40, 0.22);
  overflow: hidden;
}

.notification-popover header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.notification-popover header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.notification-list {
  display: grid;
  max-height: 360px;
  overflow: auto;
}

.notification-item {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}

.notification-item.is-overdue,
.notification-item.is-due-now {
  background: #fff5f5;
  box-shadow: inset 4px 0 #ef4444;
}

.notification-item.is-due-soon {
  background: #fff8ed;
  box-shadow: inset 4px 0 #f97316;
}

.notification-item span,
.notification-item small {
  color: var(--muted);
  font-size: 12px;
}

.notification-footer {
  display: block;
  padding: 10px 12px;
  color: var(--ink);
  font-weight: 900;
  text-align: center;
  text-decoration: none;
  background: var(--surface-soft);
}

.login-body {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 1fr;
  background: linear-gradient(135deg, #f7f8fb, #fff7ec);
}

.login-shell {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  position: relative;
  display: grid;
  gap: 18px;
  width: min(440px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(31, 35, 40, 0.12);
}

.login-brand {
  display: grid;
  gap: 10px;
  justify-items: center;
  text-align: center;
}

.login-brand img {
  width: 150px;
  height: auto;
}

.icon-button {
  width: 40px;
  min-width: 40px;
  padding: 0;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.num-sensitive-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--ink);
}

.num-sensitive {
  transition: filter 0.25s;
  color: var(--ink);
}

.num-sensitive.num-blurred {
  filter: blur(12px);
  opacity: 0.4;
  user-select: none;
  pointer-events: none;
}

.num-eye-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 0.15s, color 0.15s;
}

.num-eye-btn:hover {
  opacity: 1;
}

.num-eye-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
}

.num-eye-btn.peeking {
  color: var(--gold);
  opacity: 1;
  animation: peek-pulse 3s linear forwards;
}

@keyframes peek-pulse {
  0%   { opacity: 1; }
  80%  { opacity: 1; }
  100% { opacity: 0.4; }
}

.vat-toggle {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.vat-toggle-opt {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  transition: background 160ms ease, color 160ms ease;
}

.vat-toggle-opt svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.vat-toggle-opt.active {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 4px 10px rgba(31, 35, 40, 0.18);
}

.subnav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.metric,
.panel {
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
  border-radius: 16px;
}

.metric span,
.panel-head span,
.accounting-head p,
.meta,
.empty {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.split,
.ledger-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 14px;
}

/* Only one ledger panel renders at a time (VAT or non-VAT), so let a lone
   panel use the full width instead of being squeezed into one grid column. */
.ledger-grid > .panel:only-child {
  grid-column: 1 / -1;
}

/* Highlight invoices with an outstanding balance (not fully paid). */
tr.unpaid-row > td {
  background: #fdeaea;
}

/* Clickable ledger rows open the invoice's print page. */
tr.ledger-row:hover > td {
  background: color-mix(in srgb, var(--gold) 12%, var(--surface));
}
tr.ledger-row.unpaid-row:hover > td {
  background: color-mix(in srgb, #fdeaea 80%, var(--gold));
}

.expense-layout {
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: start;
}

.expense-layout .panel {
  padding: 12px;
}

.expense-layout .panel-head {
  padding-bottom: 8px;
}

.expense-layout .form-panel {
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.expense-layout .form-panel > .panel-head,
.expense-layout .form-panel > .expense-items-editor,
.expense-layout .form-panel > .expense-cogs-header,
.expense-layout .form-panel > .expense-accounting-details,
.expense-layout .form-panel > .form-actions,
.expense-layout .form-panel > label:has(textarea),
.expense-layout .form-panel > .supplier-switch-block {
  grid-column: span 2;
}

.expense-layout input,
.expense-layout select,
.expense-layout textarea {
  padding: 8px;
}

.expense-layout label {
  gap: 4px;
}

.expense-layout [hidden] {
  display: none !important;
}

.expense-layout textarea {
  min-height: 72px;
}

.accounting-entry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
}

.accounting-form,
.accounting-start {
  max-width: 760px;
}

.ledger-grid > *,
.expense-form-stack,
.accounting-form,
.table-panel {
  min-width: 0;
}

.accounting-shortcuts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.accounting-guide {
  margin-bottom: 14px;
}

.flow-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.flow-steps a {
  display: grid;
  gap: 6px;
  padding: 14px;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(244, 238, 225, 0.6));
}

.flow-steps a:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.flow-steps span {
  color: var(--muted);
  font-size: 13px;
}

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.panel {
  padding: 16px;
}

.form-panel {
  display: grid;
  gap: 12px;
  align-content: start;
}

.settings-form {
  display: grid;
  gap: 14px;
}

.settings-block {
  display: grid;
  grid-template-columns: minmax(220px, 0.32fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.settings-block-head {
  position: sticky;
  top: 12px;
  display: grid;
  gap: 5px;
}

.settings-block-kicker {
  color: var(--gold-dark);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.settings-block-head h2 {
  margin: 0;
  font-size: 22px;
}

.settings-block-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.settings-small-row {
  display: grid;
  grid-template-columns: minmax(180px, 320px);
  margin-top: 12px;
}

.settings-due-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.settings-signature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.settings-save-bar {
  position: sticky;
  bottom: 12px;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid #ead6b4;
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 0 16px 36px rgba(16, 22, 31, 0.14);
  backdrop-filter: blur(10px);
}

.settings-save-bar strong,
.settings-save-bar span {
  display: block;
}

.settings-save-bar span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.terms-default-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.terms-default-card,
.settings-field-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.terms-default-card strong,
.terms-default-card span,
.settings-field-card strong,
.settings-field-card span {
  display: block;
}

.terms-default-card span,
.settings-field-card span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.sequence-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
}

.form-panel .panel-head,
.table-panel .panel-head,
.document-detail > .panel-head {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.document-form {
  position: relative;
  display: grid;
  gap: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}

.compact-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.date-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.customer-picker-field {
  grid-column: span 2;
}

.invoice-search-field {
  grid-column: span 2;
}

.customer-switch-panels {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}

.supplier-switch-block {
  display: grid;
  gap: 0;
  justify-items: start;
}

.customer-mode-panel {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.customer-mode-panel .customer-picker-field {
  grid-column: auto;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
}

.expense-items-editor {
  grid-column: span 2;
  display: grid;
  gap: 8px;
}

.expense-form-stack {
  display: grid;
  gap: 10px;
  align-content: start;
}

.expense-form-stack .accounting-form {
  max-width: none;
}

.expense-form-stack > .accounting-form {
  max-width: none;
}

.expense-form-tabs {
  display: inline-flex;
  width: fit-content;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fb;
}

.expense-form-tabs a {
  border: 0;
  border-radius: 6px;
  padding: 7px 10px;
  background: transparent;
  color: var(--muted);
  text-decoration: none;
}

.expense-form-tabs a.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.expense-layout .table-panel {
  width: 100%;
}

.expense-record-panel {
  position: sticky;
  top: 14px;
  overflow: hidden;
}

.expense-record-panel table {
  min-width: 760px;
  table-layout: fixed;
}

.expense-record-panel th,
.expense-record-panel td {
  padding: 8px 6px;
  vertical-align: top;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.expense-record-panel th:nth-child(1),
.expense-record-panel td:nth-child(1),
.expense-record-panel th:nth-child(2),
.expense-record-panel td:nth-child(2) {
  width: 76px;
}

.expense-record-panel th:nth-child(3),
.expense-record-panel td:nth-child(3),
.expense-record-panel th:nth-child(5),
.expense-record-panel td:nth-child(5) {
  width: 16%;
}

.expense-record-panel th:nth-child(4),
.expense-record-panel td:nth-child(4) {
  width: 21%;
}

.expense-record-panel th:nth-child(6),
.expense-record-panel td:nth-child(6) {
  width: 92px;
}

.expense-record-panel th:nth-child(7),
.expense-record-panel td:nth-child(7) {
  width: 86px;
}

.expense-record-panel th:nth-child(8),
.expense-record-panel td:nth-child(8) {
  width: 136px;
}

.expense-record-panel .entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.expense-record-panel .entry-actions form,
.expense-record-panel .entry-actions button:not(.icon-btn),
.expense-record-panel .entry-actions .button {
  flex: 1 1 auto;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.icon-btn:hover {
  background: var(--wash);
  color: var(--ink);
  border-color: #9da8b3;
}

.icon-btn--danger {
  color: #9d332d;
  border-color: #f0c8c8;
}

.icon-btn--danger:hover {
  background: #fff0f0;
  border-color: #9d332d;
}

.expense-record-panel .expense-items-row > td {
  padding: 0;
  background: #f6f8fa;
  border-top: none;
}

.expense-items-detail {
  padding: 0 6px 8px;
  overflow-x: auto;
}

.expense-items-mini {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
  font-size: 11px;
}

.expense-items-mini th,
.expense-items-mini td {
  padding: 5px 7px;
  border: 1px solid #e1e4e8;
  text-align: left;
  vertical-align: top;
}

.expense-items-mini thead th {
  background: #f0f2f5;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #57606a;
}

.expense-items-head,
.expense-section-totals {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.expense-items-head > div {
  display: grid;
  gap: 3px;
}

.expense-cogs-header {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.expense-cogs-header .invoice-search-field {
  grid-column: span 3;
}

.expense-section-block {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.expense-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.expense-section-head > div {
  display: grid;
  gap: 2px;
}

.expense-items-table,
.petty-cash-table {
  min-width: 600px;
}

.expense-items-table th,
.expense-items-table td,
.petty-cash-table th,
.petty-cash-table td {
  padding: 6px;
  font-size: 13px;
}

.expense-items-table input,
.expense-items-table select,
.petty-cash-table input,
.petty-cash-table select {
  min-width: 72px;
  padding: 6px;
}

.expense-items-table td:nth-child(1) input {
  min-width: 120px;
}

.expense-items-table td:nth-child(2) input {
  min-width: 150px;
}

.petty-cash-table td:nth-child(1) input {
  min-width: 160px;
}

.petty-cash-table td:nth-child(2) input {
  min-width: 130px;
}

.petty-cash-table td:nth-child(3) input {
  min-width: 90px;
}

.petty-cash-table tfoot td {
  padding: 8px 6px;
  font-size: 13px;
}

.expense-section-totals {
  justify-content: flex-start;
  color: var(--muted);
  font-size: 13px;
}

.expense-section-totals span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.expense-section-totals strong {
  color: var(--ink);
}

.expense-accounting-details {
  grid-column: span 2;
  border-top: 1px solid var(--line);
  padding-top: 4px;
}

.expense-accounting-details summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 700;
}

.expense-accounting-details .form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.expense-accounting-details .supplier-switch-block {
  grid-column: span 2;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px 2px;
  font-size: 13px;
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

tbody tr:hover {
  background: #fbfcfd;
}

.low-stock-row {
  background: #fff8ed;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-left: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
}

.status-pill.warning {
  border-color: #f4b75d;
  color: #8a5200;
  background: #fff3dd;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #eef1f5;
}

.badge.vat {
  color: var(--blue);
  background: #e8f2fb;
}

.badge.non {
  color: var(--green);
  background: #e7f5ee;
}

.list,
.project-grid,
.ledger-summary {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.work-item,
.project-card,
.summary-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.project-card:not(:has(.card-summary)) {
  padding: 12px;
}

.project-card:has(.card-summary) {
  padding: 0;
  overflow: hidden;
  cursor: default;
}

.work-item,
.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.project-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.project-board-panel {
  overflow: hidden;
}

.project-page {
  display: grid;
  gap: 14px;
}

.project-intake-panel .form-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.project-customer-switch {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.project-customer-switch .form-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.project-board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(260px, 1fr);
  gap: 12px;
  margin-top: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.project-column {
  display: flex;
  flex-direction: column;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fb;
}

.project-column header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.project-column h3 {
  margin: 0;
  font-size: 14px;
}

.project-column header span {
  min-width: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.project-column-body {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 250px;
  padding: 10px;
}

.project-column.drop-target {
  border-color: var(--accent);
  background: #eef6ff;
}

.invoice-month-group {
  display: grid;
  align-content: start;
  gap: 10px;
}

.invoice-month-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.invoice-month-header .hdr-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.invoice-month-header .count {
  min-width: 20px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}

.invoice-month-header .group-chevron {
  color: var(--muted);
  font-size: 0.7rem;
  transition: transform 0.15s ease;
}

.invoice-month-cards {
  display: grid;
  gap: 10px;
}

.invoice-month-group.is-collapsed .invoice-month-cards {
  display: none;
}

.invoice-month-group.is-collapsed .group-chevron {
  transform: rotate(-90deg);
}

.invoice-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.invoice-card-id {
  flex: 1;
  min-width: 0;
}

.invoice-card-id .project-card-link strong,
.invoice-card-id .meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.invoice-card-amounts {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.amount-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  min-width: 72px;
  text-align: right;
}

.amount-box small {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

.amount-box strong {
  font-size: 0.9rem;
  color: var(--ink);
}

.status-new-lead {
  --status-color: #7c3aed;
  --status-bg: #f5f3ff;
  --status-border: #ddd6fe;
}

.status-contacted,
.status-quoted {
  --status-color: #64748b;
  --status-bg: #f1f5f9;
  --status-border: #cbd5e1;
}

.status-approved,
.status-converted,
.status-paid,
.status-confirmed {
  --status-color: #047857;
  --status-bg: #ecfdf5;
  --status-border: #a7f3d0;
}

.status-in-production,
.status-sent,
.status-part-paid {
  --status-color: #0369a1;
  --status-bg: #e0f2fe;
  --status-border: #7dd3fc;
}

.status-delivered,
.status-reconciled {
  --status-color: #4338ca;
  --status-bg: #eef2ff;
  --status-border: #c7d2fe;
}

.status-closed {
  --status-color: #334155;
  --status-bg: #e2e8f0;
  --status-border: #94a3b8;
}

.status-lost,
.status-rejected,
.status-void,
.status-overdue {
  --status-color: #b91c1c;
  --status-bg: #fef2f2;
  --status-border: #fecaca;
}

.status-draft,
.status-quote,
.status-payment,
.status-invoice,
.status-open {
  --status-color: #b45309;
  --status-bg: #fffbeb;
  --status-border: #fde68a;
}

.project-column[class*="status-"] {
  border-color: var(--status-border);
  background: color-mix(in srgb, var(--status-bg) 72%, #fff);
}

.project-column[class*="status-"] header {
  border-color: var(--status-border);
}

.project-column[class*="status-"] h3,
.project-column[class*="status-"] header span {
  color: var(--status-color);
}

.project-column-empty {
  margin: 0;
  padding: 18px 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.project-card strong {
  display: block;
  margin-bottom: 6px;
}

.project-card[draggable="true"] {
  cursor: grab;
  position: relative;
  transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.project-card[draggable="true"]::before {
  content: "⠿";
  position: absolute;
  top: 3px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
  opacity: 0.35;
  pointer-events: none;
}

.project-card[draggable="true"]:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.project-card[draggable="true"]:hover::before {
  opacity: 0.75;
}

.project-card.dragging {
  opacity: 0.55;
  cursor: grabbing;
}

.project-card.board-just-moved {
  outline: 3px solid #2f7d46;
  outline-offset: 2px;
  border-color: #2f7d46;
  background: rgba(47, 125, 70, 0.06);
  animation: board-just-moved-pulse 0.9s ease-in-out 3;
  position: relative;
  z-index: 3;
}

@keyframes board-just-moved-pulse {
  0%, 100% { box-shadow: 0 0 0 5px rgba(47, 125, 70, 0.18), 0 10px 26px rgba(47, 125, 70, 0.22); }
  50% { box-shadow: 0 0 0 11px rgba(47, 125, 70, 0.30), 0 12px 30px rgba(47, 125, 70, 0.32); }
}

.foc-form {
  margin-top: 8px;
}

.detail-bottom-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin: 26px 0 10px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.draft-restore-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 14px;
  border: 1px solid #fde68a;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-weight: 600;
}

.draft-restore-banner span {
  flex: 1 1 auto;
  min-width: 180px;
}

.foc-badge {
  padding: 1px 8px !important;
  border-radius: 999px;
  background: #e7f4ec;
  border: 1px solid #b7dcc4;
  color: #1f7a45 !important;
  font-weight: 800 !important;
  font-size: 11px;
  letter-spacing: 0.02em;
}

.board-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  padding: 10px 18px;
  border-radius: 999px;
  background: #245b34;
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 2000;
}

.board-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.project-card[class*="status-"] {
  border-left: 5px solid var(--status-color);
}

.project-card-link {
  color: inherit;
  text-decoration: none;
}

.project-card-link:hover strong {
  color: var(--accent);
}

.project-card-lead {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.project-card-lead span {
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
}

.project-progress {
  width: 100%;
  height: 8px;
  margin: 10px 0 4px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef1f5;
}

.project-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--status-color, var(--accent)), color-mix(in srgb, var(--status-color, #19a974) 68%, #fff));
}

.project-progress.large {
  height: 12px;
  margin: 0 0 10px;
}

.project-card-money {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0;
}

.project-card-money span {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
}

.project-card-money strong {
  margin: 3px 0 0;
  color: var(--text);
  font-size: 14px;
}

.project-workspace {
  align-items: start;
  grid-template-columns: minmax(300px, 0.95fr) minmax(0, 1.05fr);
}

.project-workspace .form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.project-detail-page {
  min-width: 0;
}

.project-detail-page .workspace-hero,
.project-detail-page .metric,
.project-detail-page .panel,
.project-detail-page .table-wrap {
  min-width: 0;
}

.project-detail-page .workspace-hero h2 {
  overflow-wrap: anywhere;
}

.project-detail-page .report-statement div {
  min-width: 0;
}

.project-detail-page .report-statement strong {
  overflow-wrap: anywhere;
}

.status-badge,
.status-metric {
  border-color: var(--status-border);
  background: var(--status-bg);
  color: var(--status-color);
}

.document-workspace {
  display: grid;
  gap: 14px;
}

.vat-document-letterhead {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 0.95fr);
  gap: 18px;
  align-items: center;
  margin-bottom: 14px;
  border-top: 4px solid var(--gold);
  background: linear-gradient(135deg, #fffaf0, #ffffff 58%, #f8fafb);
}

.vat-document-brand img {
  display: block;
  width: min(430px, 100%);
  max-height: 104px;
  object-fit: contain;
}

.vat-document-quote .vat-document-brand img,
.vat-document-receipt .vat-document-brand img {
  width: min(310px, 100%);
}

.vat-document-company {
  display: grid;
  gap: 4px;
  justify-items: end;
  text-align: right;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}

.vat-document-title {
  grid-column: 1 / -1;
  padding-top: 12px;
  border-top: 1px solid #e6d4a9;
  text-align: center;
}

.vat-document-title span {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  padding: 0 18px;
  border: 1px solid #d8c08c;
  border-radius: 999px;
  background: #fff8e8;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.vat-invoice-sheet {
  margin-bottom: 14px;
  background: #fff;
  font-family: "Ingella Khmer", Arial, sans-serif;
}

.vat-sheet-header {
  display: grid;
  gap: 4px;
  justify-items: center;
  text-align: center;
  color: #111;
  font-size: 13px;
  line-height: 1.35;
}

.vat-sheet-header img {
  width: min(430px, 100%);
}

.vat-tax-title {
  margin: 12px 0 10px;
  text-align: center;
  font-size: 22px;
  line-height: 1.25;
}

.vat-tax-title span {
  font-size: 18px;
}

.vat-excel-customer,
.vat-excel-totals,
.vat-excel-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid #111;
  border-bottom: 0;
}

.vat-excel-customer div,
.vat-excel-totals div,
.vat-excel-totals strong,
.vat-excel-signatures div {
  min-height: 34px;
  padding: 8px;
  border-right: 1px solid #111;
  border-bottom: 1px solid #111;
}

.vat-excel-customer div:nth-child(2n),
.vat-excel-totals strong,
.vat-excel-signatures div:nth-child(2n) {
  border-right: 0;
}

.vat-excel-signatures div {
  min-height: 136px;
}

.vat-excel-signatures .client-signature-space {
  padding-top: 10px;
}

.vat-excel-items {
  margin-top: 0;
  min-width: 0;
  border-collapse: collapse;
  font-family: "Ingella Khmer", Arial, sans-serif;
}

.vat-excel-items th,
.vat-excel-items td {
  border: 1px solid #111;
  color: #111;
}

.vat-excel-items th {
  background: #fff;
  text-align: center;
}

.vat-excel-items td:nth-child(1),
.vat-excel-items td:nth-child(3) {
  text-align: center;
}

.vat-excel-items td:nth-child(4),
.vat-excel-items td:nth-child(5),
.vat-excel-totals strong {
  text-align: right;
}

.vat-excel-note {
  padding: 10px;
  border: 1px solid #111;
  border-top: 0;
  line-height: 1.55;
}

.workspace-hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
  padding: 18px;
  border: 1px solid #d9e2ec;
  border-radius: 18px;
  background:
    radial-gradient(circle at 8% 10%, rgba(33, 95, 154, 0.10), transparent 28%),
    linear-gradient(135deg, #f8fbfd, #ffffff 58%, #f8fafb);
  box-shadow: var(--shadow);
}

.workspace-hero h2 {
  margin-bottom: 4px;
  font-size: 24px;
}

.workspace-hero p,
.workspace-hero span {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.hero-stat,
.hero-actions {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.hero-stat {
  display: grid;
  justify-items: center;
  min-width: 110px;
  padding: 12px;
  border: 1px solid rgba(33, 95, 154, 0.16);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.hero-stat strong {
  font-size: 28px;
}

.dashboard-hero {
  border-color: #d8e5dd;
  background:
    radial-gradient(circle at 8% 10%, rgba(31, 122, 77, 0.12), transparent 28%),
    linear-gradient(135deg, #f4fbf7, #ffffff 58%, #f8fafb);
}

.dashboard-command {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 22px;
  border: 1px solid #d8e5dd;
  border-radius: 22px;
  background:
    radial-gradient(circle at 85% 20%, rgba(31, 122, 77, 0.16), transparent 24%),
    radial-gradient(circle at 8% 10%, rgba(199, 146, 53, 0.16), transparent 28%),
    linear-gradient(135deg, #f5fbf7, #ffffff 52%, #f8fafb);
  box-shadow: var(--shadow);
}

.dashboard-command h2 {
  max-width: 720px;
  margin-bottom: 6px;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1;
  letter-spacing: -1.5px;
}

.dashboard-command span {
  color: var(--muted);
}

.dashboard-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.date-filter {
  display: flex;
  flex: 1 1 460px;
  gap: 8px;
  align-items: end;
  flex-wrap: wrap;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.smart-search {
  display: flex;
  flex: 999 1 640px;
  gap: 8px;
  align-items: end;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.smart-search label {
  flex: 1 1 320px;
  min-width: 0;
}

.smart-search label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.smart-search button {
  min-width: 84px;
}

.smart-search a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
}

.date-filter label {
  min-width: 140px;
  flex: 1 1 140px;
}

.date-filter button {
  min-width: 84px;
}

.book-switcher {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 360px;
  margin: 0;
  padding: 10px;
  border: 1px solid #d8c49d;
  border-radius: 14px;
  background:
    radial-gradient(circle at 20% 0%, rgba(199, 146, 53, 0.18), transparent 32%),
    linear-gradient(135deg, #fffaf0, #ffffff);
}

.book-switcher span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.book-switcher strong {
  display: block;
  margin-top: 2px;
}

.book-switcher-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  gap: 6px;
  padding: 5px;
  border-radius: 14px;
  background: rgba(31, 35, 40, 0.06);
}

.book-switcher-options a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  color: var(--ink);
  text-decoration: none;
  border-radius: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.book-switcher-options a.active {
  color: #fff;
  background: var(--ink);
  box-shadow: 0 8px 18px rgba(31, 35, 40, 0.18);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1.6fr) repeat(3, minmax(150px, 0.7fr));
  gap: 14px;
  margin-top: 14px;
}

.dashboard-focus-card,
.dashboard-mini-card,
.pipeline-step {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
}

.dashboard-focus-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  background:
    linear-gradient(135deg, #1f2328, #35404b);
  color: #fff;
}

.dashboard-focus-card > span,
.dashboard-focus-card p,
.focus-foot {
  color: rgba(255, 255, 255, 0.72);
}

.dashboard-focus-card > strong,
.dashboard-focus-card > .num-sensitive-wrap > strong {
  font-size: clamp(34px, 5vw, 54px);
  line-height: 0.95;
  letter-spacing: -1.5px;
}

.dashboard-focus-card p {
  margin-bottom: 0;
}

.dashboard-focus-card .num-sensitive,
.dashboard-focus-card .num-sensitive-wrap {
  color: #fff;
}
.dashboard-focus-card .num-eye-btn {
  color: rgba(255, 255, 255, 0.72);
}

.focus-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.focus-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), #f2d091);
}

.focus-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.dashboard-mini-card {
  display: grid;
  align-content: space-between;
  gap: 16px;
  padding: 16px;
}

.dashboard-mini-card.warning {
  border-color: #ff4d4d;
  background: #fff5f5;
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.22), 0 0 22px rgba(239, 68, 68, 0.3);
}

.dashboard-due-glow {
  position: relative;
  padding-left: 26px;
  animation: dashboard-red-alert 1.7s ease-in-out infinite;
}

.dashboard-due-glow::before {
  content: "";
  position: absolute;
  top: 14px;
  left: 10px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #ef4444;
  box-shadow: 0 0 10px #ef4444, 0 0 22px rgba(239, 68, 68, 0.8);
}

@keyframes dashboard-red-alert {
  0%,
  100% {
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.2), 0 0 14px rgba(239, 68, 68, 0.18);
  }
  50% {
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.5), 0 0 28px rgba(239, 68, 68, 0.45);
  }
}

.dashboard-mini-card span,
.pipeline-step span,
.pipeline-step small {
  color: var(--muted);
}

.dashboard-mini-card strong,
.pipeline-step strong {
  font-size: 34px;
}

.dashboard-mini-card a,
.pipeline-step {
  color: var(--ink);
  text-decoration: none;
}

.document-pipeline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.pipeline-step {
  display: grid;
  gap: 4px;
  padding: 16px;
  transition: transform 160ms ease, border-color 160ms ease;
}

.pipeline-step:hover {
  transform: translateY(-1px);
  border-color: #c8d0da;
}

.dashboard-columns {
  display: grid;
  grid-template-columns: minmax(280px, 1.15fr) minmax(280px, 1fr) minmax(240px, 0.85fr);
  gap: 14px;
  margin-top: 14px;
  align-items: start;
}

.dashboard-panel {
  min-height: 100%;
}

.dashboard-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.dashboard-list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

a.dashboard-list-item {
  color: inherit;
  text-decoration: none;
}

.due-panel {
  margin-top: 14px;
  min-height: 0;
  padding: 12px;
}

.due-list {
  grid-template-columns: 1fr;
}

.due-category-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  max-height: 360px;
  overflow: auto;
  padding: 4px;
}

.due-category {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
}

.due-category header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.due-category h3 {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.due-category header span {
  min-width: 26px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #fee2e2;
  color: #991b1b;
  text-align: center;
  font-size: 12px;
  font-weight: 900;
}

.due-item[class*="status-"] {
  border-left: 5px solid var(--status-color);
}

.due-item.is-overdue,
.due-item.is-due-now {
  border-color: #ef4444;
  background: #fff7f7;
}

.due-item.is-due-soon {
  border-color: #f97316;
  background: #fff8ed;
  box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.12), 0 0 16px rgba(249, 115, 22, 0.16);
}

.due-panel .panel-head {
  padding-bottom: 8px;
}

.due-panel .panel-head span {
  font-size: 12px;
}

.due-panel .dashboard-list {
  gap: 8px;
  margin-top: 10px;
}

.due-panel .dashboard-list-item {
  padding: 9px;
  border-radius: 10px;
}

.due-panel .dashboard-list-item.dashboard-due-glow {
  padding-left: 28px;
}

.due-panel .dashboard-list-item strong {
  margin-bottom: 2px;
  font-size: 13px;
}

.due-panel .badge {
  min-height: 20px;
  padding: 0 7px;
  font-size: 10px;
}

.dashboard-list-item strong {
  display: block;
  margin-bottom: 4px;
}

.dashboard-list-item span,
.dashboard-list-item small {
  color: var(--muted);
  font-size: 13px;
}

.list-side {
  display: grid;
  justify-items: end;
  gap: 4px;
  text-align: right;
}

.money-item .list-side a {
  color: var(--gold-dark);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.vat-stack {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.vat-stack div {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 14px;
  background: #f8fafb;
  border: 1px solid var(--line);
}

.vat-stack span {
  color: var(--muted);
  font-size: 13px;
}

.vat-stack strong {
  font-size: 20px;
}

.client-hero,
.supplier-hero {
  border-color: #ead6b4;
  background:
    radial-gradient(circle at 8% 10%, rgba(199, 146, 53, 0.16), transparent 28%),
    linear-gradient(135deg, #fffaf1, #ffffff 58%, #f8fafb);
}

.accounting-head.workspace-hero {
  display: grid;
  margin-bottom: 14px;
}

.document-hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 16px;
  align-items: center;
  padding: 18px;
  border: 1px solid #ead6b4;
  border-radius: 18px;
  background:
    radial-gradient(circle at 8% 10%, rgba(199, 146, 53, 0.18), transparent 28%),
    linear-gradient(135deg, #fffaf1, #ffffff 58%, #f8fafb);
  box-shadow: var(--shadow);
}

.invoice-workspace .document-hero {
  border-color: #cfe0f0;
  background:
    radial-gradient(circle at 8% 10%, rgba(33, 95, 154, 0.14), transparent 28%),
    linear-gradient(135deg, #f4f9fd, #ffffff 58%, #f8fafb);
}

.receipt-workspace .document-hero {
  border-color: #cce8d9;
  background:
    radial-gradient(circle at 8% 10%, rgba(31, 122, 77, 0.14), transparent 28%),
    linear-gradient(135deg, #f2fbf6, #ffffff 58%, #f8fafb);
}

.document-hero h2 {
  margin-bottom: 4px;
  font-size: 24px;
}

.document-hero span {
  color: var(--muted);
  font-size: 13px;
}

.document-hero-stat {
  display: grid;
  justify-items: center;
  min-width: 96px;
  padding: 12px;
  border: 1px solid rgba(199, 146, 53, 0.24);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.document-hero-stat strong {
  font-size: 28px;
}

.document-list {
  display: grid;
  gap: 12px;
}

.quote-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0 12px;
  padding: 14px;
  border: 1px solid #ead6b4;
  border-radius: 12px;
  background: #fff8ec;
}

.quote-alert div {
  display: grid;
  gap: 3px;
}

.quote-alert span {
  color: var(--muted);
  font-size: 13px;
}

.quote-filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.quote-filter-tabs a {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}

.quote-filter-tabs a.active {
  border-color: #c79235;
  background: #fff8ec;
  color: var(--gold-dark);
}

.document-card {
  display: grid;
  grid-template-columns: minmax(260px, 1.15fr) minmax(260px, 0.9fr) minmax(220px, 0.35fr);
  gap: 16px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(33, 39, 45, 0.05);
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
  scroll-margin: 120px;
}

.document-card:hover {
  transform: translateY(-1px);
  border-color: #c8d0da;
  box-shadow: 0 16px 36px rgba(33, 39, 45, 0.08);
}

.created-card,
.highlighted-card {
  border-color: var(--gold);
  background: #fffaf1;
  animation: document-glow 2.8s ease-out 2;
  box-shadow: 0 0 0 2px rgba(199, 146, 53, 0.3), 0 18px 46px rgba(199, 146, 53, 0.28);
}

@keyframes document-glow {
  0% {
    border-color: #d49a32;
    box-shadow: 0 0 0 0 rgba(199, 146, 53, 0.55), 0 18px 46px rgba(199, 146, 53, 0.24);
    transform: translateY(-1px);
  }
  45% {
    border-color: #f2c46d;
    box-shadow: 0 0 0 8px rgba(199, 146, 53, 0.16), 0 22px 52px rgba(199, 146, 53, 0.22);
  }
  100% {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(199, 146, 53, 0.24), 0 18px 46px rgba(199, 146, 53, 0.16);
    transform: translateY(0);
  }
}

.document-main {
  display: grid;
  gap: 10px;
}

.document-title-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.document-title-row strong {
  margin-bottom: 0;
  font-size: 17px;
}

.document-type-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #7c541a;
  background: #fff3d9;
  font-weight: 800;
}

.invoice-workspace .document-type-mark {
  color: var(--blue);
  background: #e8f2fb;
}

.receipt-workspace .document-type-mark {
  color: var(--green);
  background: #e7f5ee;
}

.status-badge {
  background: #fff8ec;
  color: var(--gold-dark);
}

.document-status-form label {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafbfc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.document-status-form[class*="status-"] label {
  border-color: var(--status-border);
  background: var(--status-bg);
  color: var(--status-color);
}

.document-status-form select {
  width: 100%;
  min-width: 0;
  min-height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 15px;
  font-weight: 800;
}

.document-client {
  display: grid;
  gap: 2px;
}

.document-client strong {
  margin-bottom: 0;
}

.document-client span,
.document-meta-row {
  color: var(--muted);
  font-size: 13px;
}

.document-meta-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.document-meta-row span {
  padding: 4px 8px;
  border-radius: 999px;
  background: #f4f6f8;
}

.document-money {
  display: grid;
  grid-template-columns: repeat(3, minmax(78px, 1fr));
  gap: 8px;
}

.document-money div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafbfc;
}

.document-money span {
  color: var(--muted);
  font-size: 12px;
}

.document-money strong {
  margin-bottom: 0;
  font-size: 15px;
}

.document-money .balance-due {
  border-color: #ead6b4;
  background: #fffaf1;
}

.document-money .reconciled-ok {
  border-color: #cce8d9;
  background: #f2fbf6;
}

.document-money .reconciled-ok strong {
  color: var(--green);
}

.document-money .reconcile-open {
  border-color: #ead6b4;
  background: #fffaf1;
}

.document-money .reconcile-open strong {
  color: var(--gold-dark);
}

.document-actions {
  display: grid;
  gap: 8px;
  justify-items: stretch;
  align-content: center;
}

.document-actions > a,
.document-actions > form,
.document-actions > form > button {
  width: 100%;
}

.document-view-action {
  width: 100%;
  min-height: 38px;
  border-radius: 999px;
  box-shadow: 0 10px 20px rgba(31, 35, 40, 0.12);
}

.document-next-step button,
.document-next-link {
  width: 100%;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #ead6b4;
  border-radius: 8px;
  background: #fffdf8;
  color: var(--gold-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  font-weight: 800;
}

.convert-invoice-action {
  border-color: #b7cffc;
  background: #f4f8ff;
  color: #1d4ed8;
  box-shadow: none;
}

.convert-invoice-action:hover {
  background: #eaf2ff;
  border-color: #93b7f7;
}

.record-payment-action {
  border-color: #bfe8cc;
  background: #f2fbf6;
  color: #15803d;
  box-shadow: none;
}

.record-payment-action:hover {
  background: #e8f8ee;
  border-color: #9bd8b0;
}

.document-quiet-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.document-quiet-actions form {
  display: flex;
  margin: 0;
}

.document-quiet-actions a,
.document-quiet-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  text-decoration: none;
}

.document-quiet-actions .document-icon-action {
  display: inline-grid;
  place-items: center;
  width: 28px;
  min-width: 28px;
  padding: 0;
  border: 1px solid transparent;
  line-height: 0;
}

.document-icon-action svg {
  display: block;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.document-language-action {
  min-width: 48px;
  padding: 0 8px;
  border: 1px solid #ead6b4;
  background: #fffaf1;
  color: var(--gold-dark);
  font-weight: 700;
}

.preview-action {
  border-color: #c8ddff !important;
  background: #f4f8ff !important;
  color: #2563eb !important;
}

.duplicate-action {
  border-color: #ddd6fe !important;
  background: #faf7ff !important;
  color: #6d28d9 !important;
}

.edit-action {
  border-color: #f3d59b !important;
  background: #fff8ec !important;
  color: #b45309 !important;
}

.document-quiet-actions .danger-action {
  border-color: #f4b8b0 !important;
  background: #fff5f4 !important;
  color: #b42318 !important;
}

.document-quiet-actions a:hover,
.document-quiet-actions button:hover {
  color: var(--ink);
  filter: saturate(1.1) brightness(0.98);
  text-decoration: none;
}

.document-empty {
  display: grid;
  gap: 4px;
  padding: 28px;
  border: 1px dashed #cbd3dc;
  border-radius: 16px;
  background: #fff;
  text-align: center;
}

.payment-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.payment-form input,
.payment-form select {
  width: 118px;
  min-height: 32px;
  padding: 6px 8px;
}

.invoice-payment-panel {
  border-color: #ead6b4;
  background:
    radial-gradient(circle at 100% 0%, rgba(199, 146, 53, 0.12), transparent 30%),
    #fffaf1;
}

.payment-context {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 8px;
}

.payment-context div {
  padding: 10px;
  border: 1px solid rgba(199, 146, 53, 0.24);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
}

.payment-context span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.payment-context strong {
  font-size: 17px;
}

.payment-context .balance-due strong {
  color: var(--gold-dark);
}

.invoice-payment-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.invoice-payment-form button {
  min-height: 40px;
  white-space: nowrap;
}

.make-invoice-form {
  max-width: 980px;
}

.invoice-item-picker {
  display: grid;
  gap: 8px;
}

.invoice-pick-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.invoice-pick-row:has(input:checked) {
  border-color: #ead6b4;
  background: #fffaf1;
}

.invoice-pick-row input {
  min-height: auto;
}

.invoice-pick-row strong,
.invoice-pick-row small {
  display: block;
}

.invoice-pick-row small {
  margin-top: 3px;
  color: var(--muted);
}

.invoice-pick-row em {
  color: var(--ink);
  font-style: normal;
  font-weight: 800;
}

.quote-confirm-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.quote-confirm-row:has(input[type="checkbox"]:checked) {
  border-color: var(--status-border, #ead6b4);
  background: color-mix(in srgb, var(--status-bg, #fffaf1) 72%, #ffffff);
}

.quote-confirm-item {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: flex-start;
  gap: 10px;
}

.quote-confirm-item input[type="checkbox"] {
  flex: 0 0 auto;
  margin-top: 3px;
}

.quote-confirm-item span {
  min-width: 0;
}

.quote-confirm-item strong,
.quote-confirm-item small {
  display: block;
}

.quote-confirm-item strong {
  overflow-wrap: anywhere;
  word-break: normal;
}

.quote-confirm-item small {
  margin-top: 3px;
  color: var(--muted);
}

.quote-confirm-fields {
  display: grid;
  grid-template-columns: minmax(96px, 0.8fr) minmax(140px, 1fr) minmax(112px, auto);
  gap: 8px;
  align-items: end;
}

.quote-confirm-fields label,
.quote-confirm-note {
  min-width: 0;
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.quote-confirm-fields input,
.quote-confirm-note input {
  width: 100%;
}

.quote-confirm-total {
  min-height: 42px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.quote-confirm-total span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.quote-confirm-total strong {
  white-space: nowrap;
  font-size: 13px;
}

.quote-confirm-note {
  grid-column: 1 / -1;
}

.document-detail {
  display: grid;
  gap: 16px;
}

.non-vat-document-hero {
  position: relative;
  overflow: hidden;
  border: 1px solid #d8c49d;
  background:
    radial-gradient(circle at 18% 18%, rgba(199, 146, 53, 0.22), transparent 26%),
    linear-gradient(135deg, #fff8e7, #ffffff);
}

.non-vat-document-hero::after {
  content: "";
  position: absolute;
  inset: auto -50px -90px auto;
  width: 220px;
  height: 220px;
  border-radius: 999px;
  background: rgba(199, 146, 53, 0.13);
  pointer-events: none;
}

.non-vat-document-invoice {
  border-color: #b8d4c7;
  background:
    radial-gradient(circle at 18% 18%, rgba(31, 122, 77, 0.18), transparent 26%),
    linear-gradient(135deg, #eef6f2, #ffffff);
}

.non-vat-document-receipt {
  border-color: #b9c7e8;
  background:
    radial-gradient(circle at 18% 18%, rgba(33, 95, 154, 0.16), transparent 26%),
    linear-gradient(135deg, #f1f5ff, #ffffff);
}

.non-vat-document-hero h2 {
  font-size: clamp(34px, 5vw, 58px);
  line-height: 0.95;
  letter-spacing: -2px;
}

.non-vat-purpose-strip {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr 0.85fr;
  gap: 12px;
  margin-bottom: 14px;
}

.non-vat-purpose-strip article {
  padding: 18px;
  border: 1px solid #d8c49d;
  border-radius: 20px;
  background: #fffdf7;
  box-shadow: var(--shadow);
}

.non-vat-purpose-invoice article {
  border-color: #b8d4c7;
  background: #f8fffb;
}

.non-vat-purpose-receipt article {
  border-color: #b9c7e8;
  background: #fbfcff;
}

.non-vat-purpose-strip span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.non-vat-purpose-strip strong {
  display: block;
  font-size: 22px;
}

.non-vat-purpose-strip p {
  margin: 6px 0 0;
  color: var(--muted);
}

.non-vat-document-detail {
  border-color: #d8c49d;
  background: linear-gradient(180deg, #fffdf7, #ffffff 34%);
}

.non-vat-detail-invoice {
  border-color: #b8d4c7;
  background: linear-gradient(180deg, #f8fffb, #ffffff 34%);
}

.non-vat-detail-receipt {
  border-color: #b9c7e8;
  background: linear-gradient(180deg, #fbfcff, #ffffff 34%);
}

.non-vat-document-detail .detail-summary article,
.non-vat-document-detail .detail-box,
.non-vat-document-detail .detail-totals div {
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
}

.detail-summary,
.detail-grid,
.detail-totals {
  display: grid;
  gap: 12px;
}

.detail-summary {
  grid-template-columns: repeat(4, minmax(140px, 1fr));
}

.detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-summary article,
.detail-box,
.detail-totals div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
}

.detail-summary span,
.detail-totals span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.detail-summary strong,
.detail-totals strong {
  font-size: 18px;
}

.detail-box p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

.detail-box p strong {
  color: var(--ink);
}

.detail-totals {
  grid-template-columns: repeat(6, minmax(120px, 1fr));
}

.detail-reference {
  width: 160px;
  max-height: 140px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.document-actions button,
.mini {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.document-actions > form > .document-next-link,
.document-actions > .document-view-action {
  min-height: 38px;
  padding: 0 12px;
}

.danger-action {
  color: #9d332d;
  border-color: #f0c6c0;
}

.danger-action:hover {
  background: #fff4f2;
}

/* ── Timeline card collapse/expand ── */
.project-card-timeline { padding: 0; overflow: hidden; cursor: default; }

.timeline-card-summary,
.card-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
}

.card-summary > div { flex: 1; min-width: 0; }

.timeline-card-summary:hover,
.card-summary:hover { background: var(--wash); }

.card-detail { padding: 0 14px 12px; }

.timeline-card-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.timeline-card-name {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline-card-invoice {
  font-size: 11px;
  font-weight: 600;
  color: var(--gold-dark);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 4px;
  padding: 1px 6px;
  width: fit-content;
}

.timeline-card-progress-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.timeline-card-pct {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  min-width: 30px;
  text-align: right;
}

.timeline-card-chevron {
  font-size: 22px;
  color: var(--muted);
  flex-shrink: 0;
  transition: transform 0.15s;
  line-height: 1;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--wash);
}

.timeline-card-detail {
  padding: 10px 14px 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.timeline-card-detail[hidden] { display: none !important; }

.contacted-action {
  color: #1a56a0;
  border-color: #bfdbfe;
  background: #eff6ff;
}

.contacted-action:hover {
  background: #dbeafe;
}

.lost-action {
  color: #9d332d;
  border-color: #f0c6c0;
  background: #fff4f2;
}

.lost-action:hover {
  background: #fee2e2;
}

/* ── Lost & Quoted Page ── */
.lq-page {
  padding: 24px 28px 60px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.lq-header {
  margin-bottom: 28px;
}

.lq-header-stats {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  width: fit-content;
}

.lq-stat {
  display: flex;
  flex-direction: column;
  padding: 14px 24px;
  gap: 2px;
}

.lq-stat-number {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}

.lq-stat-label {
  font-size: 12px;
  color: var(--muted);
}

.lq-stat-divider {
  width: 1px;
  align-self: stretch;
  background: var(--line);
}

.lq-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 20px;
}

.lq-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.lq-section-title h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  color: var(--ink);
}

.lq-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1px 8px;
}

.lq-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.lq-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 10px 16px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  background: var(--surface-muted);
}

.lq-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--wash);
  vertical-align: middle;
  color: var(--ink);
}

.lq-table tbody tr:last-child td { border-bottom: none; }
.lq-table tbody tr:hover td { background: var(--wash); }

.lq-table .num { text-align: right; }

.lq-client-link {
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}
.lq-client-link:hover { text-decoration: underline; color: var(--gold-dark); }

.lq-job { color: var(--muted); max-width: 200px; }
.lq-muted { color: var(--muted); font-size: 13px; }
.lq-date { font-size: 13px; }
.lq-value { font-size: 13.5px; color: var(--ink); }

.lq-row-alert td { background: #fff9f9; }
.lq-date-alert { color: #9d332d; font-size: 13px; }

.lq-status {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

.lq-status-draft { background: var(--wash); color: var(--muted); border: 1px solid var(--line); }
.lq-status-sent { background: #eff6ff; color: #1a56a0; border: 1px solid #bfdbfe; }
.lq-status-quoted { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.lq-status-lost { background: #fff4f2; color: #9d332d; border: 1px solid #f0c6c0; }

.lq-actions {
  white-space: nowrap;
  text-align: right;
}
.lq-actions .button + .button,
.lq-actions .button + form,
.lq-actions form + .button,
.lq-actions form + form { margin-left: 4px; }

.lq-empty {
  padding: 32px 20px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.card-highlighted {
  animation: card-highlight-fade 3s ease forwards;
}
tr.card-highlighted td {
  animation: row-highlight-fade 3s ease forwards;
}
@keyframes card-highlight-fade {
  0%   { outline: 3px solid #f5c842; box-shadow: 0 0 0 6px rgba(245,200,66,0.3); background: rgba(245,200,66,0.08); }
  60%  { outline: 3px solid #f5c842; box-shadow: 0 0 0 6px rgba(245,200,66,0.3); background: rgba(245,200,66,0.08); }
  100% { outline: 3px solid transparent; box-shadow: none; background: transparent; }
}
@keyframes row-highlight-fade {
  0%   { background: rgba(245,200,66,0.22); }
  60%  { background: rgba(245,200,66,0.22); }
  100% { background: transparent; }
}
td.row-highlighted {
  animation: row-highlight-fade 3s ease forwards;
}

.duplicate-warning { background: #fff8e1; border: 1px solid #f5c842; border-radius: 8px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.duplicate-warning strong { color: #7a5c00; font-size: 14px; }
.duplicate-warning span { font-size: 13px; color: #7a5c00; }
.duplicate-actions { display: flex; gap: 8px; margin-top: 4px; }
.dup-match-list { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.dup-match-list li a { display: flex; align-items: baseline; gap: 8px; padding: 6px 10px; border: 1px solid #f0d27a; border-radius: 6px; background: #fffdf5; color: #7a5c00; text-decoration: none; }
.dup-match-list li a:hover { background: #fff4cc; }
.dup-match-list .meta { font-size: 12px; color: #9a7b1f; }

/* Petty Cash page */
.pc-page { display: flex; flex-direction: column; gap: 16px; }
.pc-balance-card { padding: 24px 28px; display: flex; flex-direction: column; gap: 6px; }
.pc-balance-positive { border-left: 4px solid var(--green, #2ecc71); }
.pc-balance-negative { border-left: 4px solid var(--red, #e74c3c); }
.pc-balance-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.pc-balance-amount { font-size: 36px; font-weight: 700; line-height: 1.1; }
.pc-balance-meta { display: flex; gap: 20px; font-size: 13px; color: var(--muted); margin-top: 4px; }
.pc-forms { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pc-form { max-width: none; }
.pc-log-panel {}
.pc-type-chip { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.pc-type-in { background: #d4edda; color: #155724; }
.pc-type-out { background: #f8d7da; color: #721c24; }
.pc-amount-in { color: var(--green, #27ae60); }
.pc-amount-out { color: var(--red, #e74c3c); }

.hero-stat-group {
  display: flex;
  gap: 20px;
}

.accounting-head {
  margin-bottom: 14px;
}

.accounting-metrics {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.accounting-ledger {
  margin-bottom: 14px;
}

.accounting-report-cover {
  display: grid;
  grid-template-columns: minmax(280px, 1.3fr) repeat(2, minmax(180px, 0.7fr));
  gap: 14px;
  margin-bottom: 14px;
}

.report-hero-card,
.report-balance-card {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border: 1px solid #ead6b4;
  border-radius: 20px;
  background:
    radial-gradient(circle at 12% 0%, rgba(199, 146, 53, 0.18), transparent 32%),
    linear-gradient(135deg, #fffaf0, #ffffff 62%);
  box-shadow: var(--shadow);
}

.pl-cover .report-hero-card {
  border-color: #cfe0d7;
  background:
    radial-gradient(circle at 12% 0%, rgba(31, 122, 77, 0.16), transparent 32%),
    linear-gradient(135deg, #f4fbf6, #ffffff 62%);
}

.report-hero-card span,
.report-balance-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.report-hero-card strong,
.report-balance-card strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(28px, 4vw, 44px);
  letter-spacing: -0.04em;
}

.report-balance-card strong {
  font-size: 28px;
}

.report-hero-card p,
.report-balance-card small {
  display: block;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.report-balance-card a {
  display: inline-flex;
  margin-top: 14px;
  color: var(--gold-dark);
  font-weight: 800;
  text-decoration: none;
}

.report-balance-card.warning {
  border-color: #e4c7a0;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

/* A lone report card (e.g. the P&L statement in non-VAT mode) spans full width. */
.report-grid > .report-card:only-child {
  grid-column: 1 / -1;
}

.report-card {
  min-height: 100%;
}

/* Data-table number formatting: right-align numeric columns and use tabular
   figures so money columns align and don't shift (number-tabular). */
td.num,
th.num {
  text-align: right;
}

/* Segmented-control tabs (P&L detail) */
.pl-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 5px;
  margin: 6px 0 16px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.pl-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}
.pl-tab:hover {
  color: var(--ink);
}
.pl-tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(31, 35, 40, 0.08), 0 6px 16px rgba(31, 35, 40, 0.08);
}
.pl-tab svg {
  opacity: 0.7;
}
.pl-tab.active svg {
  color: var(--gold-dark);
  opacity: 1;
}
.pl-tab strong {
  font-size: 12px;
  line-height: 1;
  padding: 3px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 16%, transparent);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.pl-tab.active strong {
  background: var(--accent-soft);
  color: var(--gold-dark);
}
@media (max-width: 560px) {
  .pl-tabs { display: flex; width: 100%; }
  .pl-tab { flex: 1; justify-content: center; }
}

/* Sortable table headers */
table.sortable-table th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
table.sortable-table th.sortable::after {
  content: "↕";
  margin-left: 6px;
  font-size: 11px;
  opacity: 0.3;
}
table.sortable-table th.sortable[aria-sort="ascending"]::after {
  content: "↑";
  opacity: 0.85;
}
table.sortable-table th.sortable[aria-sort="descending"]::after {
  content: "↓";
  opacity: 0.85;
}

table td,
table th,
.report-statement strong,
.report-hero-card strong,
.report-balance-card strong,
.metric strong,
.pc-balance-amount,
.due-chip,
.project-card-money strong {
  font-variant-numeric: tabular-nums;
}

.report-statement {
  display: grid;
  gap: 2px;
  margin-top: 14px;
}

.report-statement div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.report-statement span {
  color: var(--muted);
}

.report-statement strong {
  text-align: right;
}

.report-statement .subtotal {
  border-top: 1px solid #bdc7d1;
}

.report-statement .total {
  margin-top: 4px;
  padding: 14px;
  border: 1px solid #ead6b4;
  border-radius: 14px;
  background: #fffaf1;
}

.statement-large .total strong {
  font-size: 22px;
}

.report-action-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.report-action-list a {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcfd;
  color: inherit;
  text-decoration: none;
}

.report-action-list strong {
  font-size: 20px;
}

.report-action-list span {
  color: var(--muted);
}

.report-action-list em {
  color: var(--gold-dark);
  font-style: normal;
  font-weight: 800;
}

.accounting-flow-report {
  margin-bottom: 14px;
}

.report-flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.report-flow a {
  display: grid;
  gap: 8px;
  min-height: 132px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #fbfcfd);
  color: inherit;
  text-decoration: none;
}

.report-flow span {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #fffaf1;
  color: var(--gold-dark);
  font-weight: 900;
}

.report-flow small {
  color: var(--muted);
  line-height: 1.4;
}

.report-table-card {
  overflow: hidden;
}

.entry-actions {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  align-items: center;
  white-space: nowrap;
}

.table-panel table td { vertical-align: middle; }

.registry-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.registry-actions form {
  margin: 0;
}

.audit-field-list {
  display: grid;
  gap: 4px;
  min-width: 220px;
}

.audit-field-list span {
  color: var(--muted);
  font-size: 13px;
}

.audit-field-list strong {
  color: var(--ink);
}

.role-permissions-panel {
  margin-top: 14px;
}

.role-permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.role-card {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.role-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.role-card-head div {
  display: grid;
  gap: 4px;
}

.role-card-head strong {
  font-size: 16px;
}

.role-card-head span {
  color: var(--muted);
  font-size: 13px;
}

.role-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #f3f6f8;
  color: var(--ink);
  font-weight: 800;
}

.permission-chip-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.permission-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.permission-chip strong {
  font-size: 13px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.permission-chip em {
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
}

.permission-full {
  border-color: #b9e4c9;
  background: #f0fbf4;
  color: #176336;
}

.permission-manage {
  border-color: #bcd0ff;
  background: #f1f5ff;
  color: #244fa5;
}

.permission-view {
  border-color: #ead6b4;
  background: #fffaf1;
  color: var(--gold-dark);
}

.permission-none {
  color: #8b949e;
  background: #f6f8fa;
}

.permission-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.permission-legend span {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.help-flow-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.help-flow-strip span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid #ead6b4;
  border-radius: 8px;
  background: #fffaf1;
  color: var(--gold-dark);
  font-weight: 800;
  text-align: center;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.help-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.help-card p,
.help-card span {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.help-card strong {
  color: var(--ink);
}

.help-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 30px;
  border-radius: 999px;
  background: #f1f5ff;
  color: #244fa5;
  font-weight: 900;
  font-size: 12px;
}

.help-panel {
  margin-bottom: 0;
}

.help-rule-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.help-rule-grid div {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.help-rule-grid span {
  color: var(--muted);
  line-height: 1.5;
}

.accounting-head p {
  max-width: 680px;
  margin-bottom: 0;
}

.flash {
  margin-bottom: 14px;
  display: grid;
  gap: 8px;
}

.flash span {
  padding: 10px 12px;
  border: 1px solid #d7ebdc;
  border-radius: 8px;
  background: #edf8f0;
  color: #245b34;
}

.line-editor {
  display: grid;
  gap: 12px;
}

.line-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.reference-upload {
  display: grid;
  gap: 12px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.reference-upload h2 {
  margin-bottom: 4px;
}

.line-table {
  display: grid;
  gap: 8px;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.line-head,
.line-row {
  display: grid;
  /* Base columns (JS overrides this dynamically for optional columns) */
  grid-template-columns: minmax(180px, 1.2fr) minmax(120px, 0.9fr) minmax(180px, 1.3fr) 70px 70px 70px 82px 78px 60px 108px 72px 44px;
  gap: 8px;
  align-items: start;
  min-width: 1228px;
}

/* JS controls visibility of optional columns via el.hidden — no CSS display:none here */

.line-row textarea {
  resize: vertical;
  min-height: 36px;
  line-height: 1.4;
  padding: 7px 10px;
  font-size: inherit;
  font-family: inherit;
}

.line-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.line-row {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafbfc;
}

.remove-line {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 999px;
  color: #9d332d;
  font-size: 20px;
  line-height: 1;
}

.line-more-toggle {
  min-height: 36px;
  padding: 0 10px;
}

.payment-schedule-editor {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.agreement-details-editor {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.agreement-detail-group {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.agreement-detail-group:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.agreement-detail-group h3 {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.payment-schedule-table {
  display: grid;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.payment-schedule-head,
.payment-schedule-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.1fr) 150px 130px minmax(260px, 1.3fr) 40px 44px;
  gap: 8px;
  align-items: center;
  min-width: 820px;
}

.payment-schedule-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.payment-schedule-row {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafbfc;
}

.payment-schedule-note {
  display: grid;
  grid-template-columns: minmax(120px, 0.75fr) minmax(140px, 1fr);
  gap: 8px;
}

.remove-payment-schedule-row {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 999px;
  color: #9d332d;
  font-size: 20px;
  line-height: 1;
}

.line-more-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(180px, 0.35fr) minmax(260px, 1fr);
  gap: 10px;
  padding: 10px;
  border: 1px dashed #d8c49f;
  border-radius: 10px;
  background: #fffaf1;
}

.line-more-panel[hidden] {
  display: none;
}

.form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.document-save-actions {
  justify-content: flex-end;
}

.document-save-actions button[type="submit"] {
  order: 2;
}

.document-save-actions .button {
  order: 1;
}

.quick-create {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px dashed #cbd3dc;
  border-radius: 8px;
  background: #fbfcfd;
}

.customer-choice {
  width: fit-content;
  display: inline-grid;
  grid-template-columns: repeat(2, max-content);
  gap: 1px;
  padding: 1px;
  border: 1px solid #cfd5dd;
  border-radius: 6px;
  background: #f8fafc;
}

.customer-choice label {
  min-height: 18px;
  padding: 0 6px;
  border-radius: 4px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 10px;
  font-weight: 650;
  line-height: 1;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.customer-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.customer-choice label:has(input:checked) {
  background: var(--ink);
  color: #fff;
  box-shadow: none;
}

.compact-create {
  gap: 10px;
  padding: 12px;
}

.compact-create .panel-head {
  display: block;
}

.compact-create h2 {
  font-size: 15px;
}

.advanced-fields {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.advanced-fields summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 700;
}

.advanced-fields .form-grid {
  margin-top: 12px;
}

.totals-preview {
  display: grid;
  grid-template-columns: minmax(180px, 1.25fr) repeat(5, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.invoice-discount-field {
  padding: 8px;
  border: 1px solid #ead6b4;
  border-radius: 7px;
  background: #fffaf1;
}

.invoice-discount-field input {
  min-height: 34px;
}

.deposit-field {
  padding: 8px;
  border: 1px solid #cfe3d6;
  border-radius: 7px;
  background: #f4fbf6;
}

.deposit-field input {
  min-height: 34px;
  width: 100%;
}

.discount-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px;
  gap: 6px;
}

.discount-input input,
.discount-input select {
  min-width: 0;
}

.totals-preview div {
  display: grid;
  gap: 4px;
  padding: 8px;
  border-radius: 7px;
  background: #f8fafb;
}

.totals-preview span {
  color: var(--muted);
  font-size: 12px;
}

.totals-preview strong {
  font-size: 16px;
}

.reference-panel {
  margin-top: 14px;
}

.reference-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.reference-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.reference-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.item-reference-field {
  display: grid;
  gap: 6px;
}

.reference-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: start;
}

.detail-reference-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.reference-thumb {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  flex: 0 0 auto;
}

.reference-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.reference-thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.72);
  color: #fff;
  font-size: 13px;
  line-height: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reference-thumb-remove:hover {
  background: #b91c1c;
}

.reference-add {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  border: 1px dashed color-mix(in srgb, var(--accent) 55%, var(--line));
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  color: var(--accent);
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.reference-add:hover {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border-color: var(--accent);
}

.reference-add.is-uploading {
  opacity: 0.6;
  pointer-events: none;
}

.signature-upload {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed #d8c08c;
  border-radius: 12px;
  background: linear-gradient(135deg, #fffaf0, #ffffff);
}

.sig-scale-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.sig-scale-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.sig-scale-range {
  flex: 1;
  accent-color: var(--gold);
  cursor: pointer;
}

.signature-preview {
  display: grid;
  gap: 6px;
  justify-items: center;
  margin: 0;
  padding: 10px;
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.signature-preview img,
.signature-image {
  max-width: 180px;
  max-height: 82px;
  object-fit: contain;
}

.signature-preview figcaption {
  color: var(--muted);
  font-size: 12px;
}

.signature-image {
  display: block;
  margin-bottom: 10px;
}

.inline-check {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.inline-check input {
  width: auto;
}

@media (max-width: 980px) {
  body {
    grid-template-columns: 1fr;
  }

  body > main {
    grid-column: 1 / -1;
  }

  .mobile-menu-toggle {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 60;
    width: 42px;
    min-width: 42px;
    min-height: 42px;
    padding: 0;
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow);
  }

  .mobile-menu-toggle svg,
  .mobile-menu-close svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mobile-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: block;
    opacity: 0;
    pointer-events: none;
    background: rgba(15, 23, 42, 0.42);
    transition: opacity 160ms ease;
  }

  body.mobile-menu-open {
    overflow: hidden;
  }

  body.mobile-menu-open .mobile-menu-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 70;
    width: min(320px, 86vw);
    height: 100dvh;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    gap: 14px;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: 18px 0 48px rgba(15, 23, 42, 0.18);
  }

  body.mobile-menu-open .sidebar {
    transform: translateX(0);
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: space-between;
  }

  .brand img {
    width: 120px;
  }

  .mobile-menu-close {
    width: 38px;
    min-width: 38px;
    min-height: 38px;
    padding: 0;
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-soft);
    color: var(--ink);
  }

  .brand span {
    margin-top: 0;
  }

  nav {
    grid-auto-flow: row;
    grid-template-columns: 1fr;
    overflow-x: visible;
    padding-bottom: 0;
  }

  .nav-item {
    grid-template-columns: 1fr;
  }

  .nav-drag-handle,
  .nav-reset {
    display: none;
  }

  nav a {
    white-space: nowrap;
  }

  main {
    padding: 72px 18px 18px;
    overflow-x: hidden;
  }

  .topbar-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .book-switcher,
  .smart-search,
  .date-filter {
    width: 100%;
    flex: 1 1 auto;
  }

  .metrics,
  .accounting-report-cover,
  .report-grid,
  .report-flow,
  .split,
  .dashboard-command,
  .dashboard-grid,
  .document-pipeline,
  .dashboard-columns,
  .workspace-hero,
  .document-hero,
  .document-card,
  .document-money,
  .accounting-entry-grid,
  .workspace,
  .ledger-grid,
  .help-flow-strip,
  .help-grid,
  .help-rule-grid,
  .form-grid,
  .detail-summary,
  .detail-grid,
  .detail-totals,
  .non-vat-purpose-strip,
  .totals-preview,
  .date-pair,
  .flow-steps,
  .line-head,
  .line-row {
    grid-template-columns: 1fr;
  }

  .expense-layout .form-panel {
    grid-template-columns: 1fr;
  }

  .expense-layout .form-panel > .panel-head,
  .expense-layout .form-panel > .expense-items-editor,
  .expense-layout .form-panel > .expense-cogs-header,
  .expense-layout .form-panel > .expense-accounting-details,
  .expense-layout .form-panel > .form-actions,
  .expense-layout .form-panel > label:has(textarea),
  .expense-layout .form-panel > .supplier-switch-block {
    grid-column: auto;
  }

  .line-head {
    display: none;
  }

  .line-table {
    overflow-x: hidden;
  }

  .line-row {
    min-width: 0;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .line-row > :nth-child(1),
  .line-row > :nth-child(2),
  .line-row > :nth-child(3),
  .line-row > .line-more-panel {
    grid-column: 1 / -1;
  }

  .payment-schedule-row {
    min-width: 0;
    grid-template-columns: 1fr;
  }

  .payment-schedule-note {
    grid-template-columns: 1fr;
  }

  .payment-schedule-head {
    display: none;
  }

  .line-head {
    display: none;
  }

  .expense-layout {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  }

  .expense-record-panel {
    position: static;
  }

  .expense-record-panel table {
    min-width: 0;
  }

  .expense-record-panel thead {
    display: none;
  }

  .expense-record-panel tbody,
  .expense-record-panel tr,
  .expense-record-panel td {
    display: block;
    width: 100%;
  }

  .expense-record-panel tr {
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }

  .expense-record-panel td {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 8px;
    padding: 4px 0;
    border-bottom: 0;
  }

  .expense-record-panel td::before {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
  }

  .expense-record-panel td:nth-child(1)::before { content: "Date"; }
  .expense-record-panel td:nth-child(2)::before { content: "Due"; }
  .expense-record-panel td:nth-child(3)::before { content: "Supplier"; }
  .expense-record-panel td:nth-child(4)::before { content: "Expense"; }
  .expense-record-panel td:nth-child(5)::before { content: "Job"; }
  .expense-record-panel td:nth-child(6)::before { content: "Amount"; }
  .expense-record-panel td:nth-child(7)::before { content: "Status"; }
  .expense-record-panel td:nth-child(8)::before { content: ""; }

  .expense-record-panel .expense-items-row,
  .expense-record-panel .expense-items-row > td {
    display: block;
    width: 100%;
    padding: 0;
    border: none;
  }

  .expense-record-panel .expense-items-row > td::before {
    display: none;
  }

  .expense-record-panel .entry-actions {
    flex-wrap: wrap;
  }

  .expense-items-editor {
    grid-column: auto;
  }

  .expense-items-table,
  .expense-items-table tbody,
  .expense-items-table tr,
  .expense-items-table td {
    display: block;
    width: 100%;
  }

  .expense-items-table {
    min-width: 0;
  }

  .expense-items-table tr {
    display: grid;
    gap: 6px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    margin-bottom: 8px;
  }

  .expense-items-table td {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding: 0;
  }

  .expense-items-table td::before {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
  }

  .expense-items-table td:nth-child(1)::before { content: "Supplier"; }
  .expense-items-table td:nth-child(2)::before { content: "Item"; }
  .expense-items-table td:nth-child(3)::before { content: "UoM"; }
  .expense-items-table td:nth-child(4)::before { content: "QTY"; }
  .expense-items-table td:nth-child(5)::before { content: "Unit"; }
  .expense-items-table td:nth-child(6)::before { content: "Total"; }
  .expense-items-table td:nth-child(7)::before { content: "Remark"; }
  .expense-items-table td:nth-child(8)::before { content: ""; }

  .expense-items-table input,
  .expense-items-table select,
  .expense-items-table td:nth-child(2) input {
    min-width: 0;
    width: 100%;
  }

  .expense-items-table td:last-child {
    grid-template-columns: 1fr;
  }

  .expense-accounting-details,
  .expense-accounting-details .supplier-switch-block {
    grid-column: auto;
  }

  .expense-accounting-details .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .quote-confirm-row,
  .quote-confirm-fields {
    grid-template-columns: 1fr;
  }

  .quote-confirm-total strong {
    white-space: normal;
  }

  .topbar,
  .panel-head,
  .accounting-head,
  .document-card,
  .work-item,
  .summary-row {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar,
  .panel-head,
  .accounting-head {
    display: grid;
  }

  .topbar {
    padding-top: 72px;
  }

  .topbar-main {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 55;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    padding: 10px 12px 10px 64px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 10px 28px rgba(31, 35, 40, 0.08);
    backdrop-filter: blur(14px);
  }

  .topbar-main .eyebrow {
    display: none;
  }

  .topbar-main h1 {
    overflow: hidden;
    font-size: 21px;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .expense-layout {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 16px;
  }

  .top-actions,
  .dashboard-actions,
  .expense-form-tabs,
  .filters,
  .subnav,
  .accounting-shortcuts,
  .document-actions,
  .form-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .top-actions form,
  .document-actions form,
  .top-actions button,
  .document-actions button,
  .top-actions .button,
  .document-actions .button,
  .form-actions .button,
  .form-actions button {
    width: 100%;
  }

  .top-actions .icon-button {
    width: 40px;
    justify-self: end;
  }

  .top-actions {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
  }

  .top-actions .user-chip {
    max-width: 112px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .top-actions form {
    width: auto;
  }

  .book-switcher-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metrics,
  .project-grid,
  .reference-grid,
  .document-pipeline {
    grid-template-columns: 1fr;
  }

  .dashboard-command {
    padding: 18px;
  }

  .dashboard-actions {
    justify-content: stretch;
  }

  .customer-choice {
    width: fit-content;
  }

  .document-card {
    grid-template-columns: 1fr;
  }

  .document-hero-stat {
    justify-items: start;
  }

  .document-actions {
    max-width: none;
    justify-items: stretch;
  }

  .document-quiet-actions {
    justify-content: center;
  }

  .document-next-link,
  .document-next-step,
  .document-next-step button {
    width: 100%;
  }

  .document-next-link,
  .document-next-step button {
    justify-content: center;
  }

  .project-detail-page .workspace-hero {
    gap: 14px;
  }

  .project-detail-page .hero-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .project-detail-page .hero-actions .button {
    width: 100%;
  }

  .project-workspace .form-grid {
    grid-template-columns: 1fr;
  }

  .project-detail-page .report-statement div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
  }

  .project-detail-page .report-statement .total {
    grid-template-columns: 1fr;
  }

  .project-detail-table td {
    display: grid;
    grid-template-columns: minmax(104px, 38%) minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    padding: 8px 0;
  }

  .project-detail-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .project-detail-table td[data-label=""] {
    grid-template-columns: 1fr;
  }

  .project-detail-table td[data-label=""]::before {
    display: none;
  }

  .payment-context,
  .invoice-payment-form,
  .vat-document-letterhead,
  .signature-upload {
    grid-template-columns: 1fr;
  }

  .settings-block {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .settings-block-head {
    position: static;
  }

  .settings-signature-grid,
  .settings-due-grid {
    grid-template-columns: 1fr;
  }

  .settings-save-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-save-bar button {
    width: 100%;
  }

  .terms-default-grid,
  .sequence-settings-grid {
    grid-template-columns: 1fr;
  }

  .vat-document-company {
    justify-items: start;
    text-align: left;
  }

  .template-note {
    display: none;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  tr {
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }

  td {
    padding: 8px 0;
    border-bottom: 0;
  }

  td:last-child form,
  td:last-child button {
    width: 100%;
  }

  .accounting-ledger .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .accounting-ledger table {
    min-width: 480px;
  }

  .accounting-ledger table,
  .accounting-ledger thead,
  .accounting-ledger tbody,
  .accounting-ledger tr,
  .accounting-ledger td {
    display: revert;
    width: auto;
  }

  .totals-preview {
    position: static;
  }

  .expense-items-editor {
    grid-column: auto;
  }

  .expense-items-table,
  .expense-items-table tbody,
  .expense-items-table tr,
  .expense-items-table td {
    display: block;
    width: 100%;
  }

  .expense-items-table {
    min-width: 0;
  }

  .expense-items-table tr {
    display: grid;
    gap: 6px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    margin-bottom: 8px;
  }

  .expense-items-table td {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding: 0;
  }

  .expense-items-table td::before {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
  }

  .expense-items-table td:nth-child(1)::before { content: "Supplier"; }
  .expense-items-table td:nth-child(2)::before { content: "Item"; }
  .expense-items-table td:nth-child(3)::before { content: "UoM"; }
  .expense-items-table td:nth-child(4)::before { content: "QTY"; }
  .expense-items-table td:nth-child(5)::before { content: "Unit"; }
  .expense-items-table td:nth-child(6)::before { content: "Total"; }
  .expense-items-table td:nth-child(7)::before { content: "Remark"; }
  .expense-items-table td:nth-child(8)::before { content: ""; }

  .expense-items-table input,
  .expense-items-table select,
  .expense-items-table td:nth-child(2) input {
    min-width: 0;
    width: 100%;
  }

  .expense-items-table td:last-child {
    grid-template-columns: 1fr;
  }

  .expense-accounting-details,
  .expense-accounting-details .supplier-switch-block {
    grid-column: auto;
  }

  .expense-accounting-details .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .project-board {
    grid-auto-columns: min(280px, calc(100vw - 40px));
    scroll-snap-type: x mandatory;
  }

  .project-column {
    scroll-snap-align: start;
  }

  .sidebar {
    padding: 12px;
  }

  .brand img {
    width: 96px;
  }

  nav {
    grid-auto-columns: minmax(96px, max-content);
  }

  main {
    padding: 72px 12px 12px;
  }

  .panel,
  .metric {
    padding: 12px;
  }

  input,
  select,
  textarea {
    min-height: 44px;
    font-size: 16px;
  }

  button,
  .button {
    min-height: 44px;
  }

  .topbar {
    border-radius: 12px;
  }

  h1 {
    font-size: 20px;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .accounting-report-cover {
    grid-template-columns: 1fr;
  }

  table {
    font-size: 13px;
  }
}

@media (max-width: 720px) {
  .document-frame-panel {
    width: 100%;
    height: 100dvh;
    border-radius: 0;
  }

}

.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(16, 22, 31, 0.55);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: min(760px, 100%);
  max-height: min(86vh, 820px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(16, 22, 31, 0.28);
  padding: 18px;
}

.document-frame-panel {
  width: min(1180px, 100%);
  height: min(92vh, 980px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.document-frame-panel iframe {
  width: 100%;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--wash);
}

.expense-edit-modal-panel {
  width: min(1100px, 100%);
  height: min(90vh, 900px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.expense-edit-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.expense-edit-modal-head h2 {
  margin: 0;
  font-size: 17px;
}

.expense-edit-modal-head span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.expense-edit-modal-frame-wrap {
  flex: 1;
  overflow: hidden;
}

.expense-edit-modal-frame-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: var(--wash);
}

.embedded-body {
  display: block;
  min-height: 100vh;
  background: var(--wash);
}

.embedded-main {
  width: 100%;
  max-width: none;
  padding: 16px;
}

.embedded-main .workspace-hero {
  margin-top: 0;
}

/* Embedded expense edit form */
.embedded-expense-form {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.embedded-expense-body {
  flex: 1;
  display: grid;
  gap: 14px;
  padding: 14px;
}

.embedded-expense-meta {
  display: grid;
  gap: 10px;
}

.embedded-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}

.embedded-job-search {
  display: block;
}

.embedded-expense-sections {
  display: grid;
  gap: 10px;
}

.embedded-expense-section {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}

.embedded-expense-section--credit {
  border-left: 3px solid #22863a;
}

.embedded-expense-section--stock {
  border-left: 3px solid #6f42c1;
}

.embedded-expense-section--advance {
  border-left: 3px solid #e36209;
}

.embedded-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: #f6f8fa;
  border-bottom: 1px solid var(--line);
}

.embedded-section-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.embedded-section-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.embedded-section-badge--credit {
  background: #dcffe4;
  color: #155724;
}

.embedded-section-badge--stock {
  background: #f0e6ff;
  color: #4a1a8c;
}

.embedded-section-badge--advance {
  background: #fff3cd;
  color: #7d4700;
}

.embedded-section-hint {
  font-size: 12px;
  color: var(--muted);
}

.embedded-section-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.embedded-section-meta strong {
  font-size: 13px;
  min-width: 56px;
  text-align: right;
}

.embedded-expense-section .table-wrap {
  padding: 0;
}

.embedded-expense-section .expense-items-table {
  border-radius: 0;
}

.embedded-expense-footer-fields {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.embedded-expense-footer-fields > label {
  flex: 1;
}

.embedded-expense-grand-total {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  flex-shrink: 0;
  min-width: 130px;
}

.embedded-expense-grand-total span {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
}

.embedded-expense-grand-total strong {
  font-size: 18px;
}

.embedded-expense-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  z-index: 10;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.modal-head h2 {
  margin: 0;
}

.modal-head span {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.lead-modal-form {
  display: grid;
  gap: 14px;
}

.expense-preview-panel {
  width: min(960px, 100%);
  max-height: min(88vh, 860px);
  display: flex;
  flex-direction: column;
}

.expense-preview-panel .modal-head {
  flex-shrink: 0;
}

#expenseModalBody {
  overflow-y: auto;
  display: grid;
  gap: 14px;
}

.expense-preview-meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.expense-preview-meta div {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
}

.expense-preview-meta span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.expense-preview-items {
  overflow-x: auto;
}

.expense-preview-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.expense-preview-totals div {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
}

.expense-preview-totals span {
  color: var(--muted);
}

.expense-preview-notes {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
}

.expense-preview-notes strong {
  display: block;
  margin-bottom: 4px;
}

.expense-preview-notes p {
  margin: 0;
  color: var(--muted);
}

.board-create-action {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  text-align: left;
  background: var(--status-color, var(--blue));
  color: #ffffff;
  border: 1px solid var(--status-color, var(--blue));
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 10px 22px color-mix(in srgb, var(--status-color, var(--blue)) 24%, transparent);
  text-decoration: none;
}

.board-create-action:hover {
  background: color-mix(in srgb, var(--status-color, var(--blue)) 86%, #ffffff);
  border-color: color-mix(in srgb, var(--status-color, var(--blue)) 86%, #ffffff);
  text-decoration: none;
}

.board-create-action:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.board-create-icon {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.board-create-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.board-create-copy strong {
  margin: 0;
  font-size: 13px;
}

.board-create-copy small {
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  font-weight: 700;
}

.create-quote-action {
  background: var(--status-color, var(--blue));
  border-color: var(--status-color, var(--blue));
}

.create-quote-action .board-create-icon {
  background: rgba(255, 255, 255, 0.18);
}

.create-quote-action:hover {
  background: color-mix(in srgb, var(--status-color, var(--blue)) 86%, #ffffff);
  border-color: color-mix(in srgb, var(--status-color, var(--blue)) 86%, #ffffff);
}

.process-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 14px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 82%, var(--wash));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.56), 0 10px 24px rgba(31, 35, 40, 0.04);
}

.process-tab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 10px 14px 10px 44px;
  background: transparent;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 7px;
  overflow: hidden;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.process-tab::before {
  content: "";
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--surface);
}

.process-tab::after {
  content: "";
  position: absolute;
  left: 20px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: transparent;
}

.process-tab:hover {
  background: var(--surface);
  border-color: var(--line);
  transform: translateY(-1px);
}

.process-tab:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.process-tab span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.process-tab strong {
  min-width: 34px;
  text-align: center;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 13px;
}

.process-tab.active {
  border-color: var(--accent-line);
  background: var(--surface);
  box-shadow: 0 12px 28px rgba(31, 35, 40, 0.08);
}

.process-tab.active::before {
  border-color: var(--gold);
  background: var(--accent-soft);
}

.process-tab.active::after {
  background: var(--gold);
}

.process-tab.active strong {
  background: var(--gold);
  color: #1f2328;
  border-color: var(--gold);
}

@media (max-width: 720px) {
  .process-tabs {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(190px, 1fr);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

  .process-tab {
    scroll-snap-align: start;
  }
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.card-actions form {
  margin: 0;
}

.project-card.has-due-alert {
  border-color: color-mix(in srgb, #ff3b30 34%, var(--line));
  box-shadow: 0 0 0 1px rgba(255, 59, 48, 0.08), 0 12px 26px rgba(255, 59, 48, 0.08);
}

.project-card.board-focus-card {
  animation: card-highlight-fade 2.2s ease forwards;
}

.due-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--muted);
}

.due-chip span {
  color: var(--ink);
  font-weight: 800;
}

.due-chip small {
  font-size: 12px;
  white-space: nowrap;
}

.due-chip.is-overdue {
  border-color: #ff3b30;
  background: color-mix(in srgb, #ff3b30 10%, var(--surface));
  box-shadow: 0 0 0 1px rgba(255, 59, 48, 0.18), 0 0 18px rgba(255, 59, 48, 0.22);
}

.due-chip.is-overdue span {
  color: #b42318;
}

.due-chip.is-due-now {
  border-color: var(--gold);
  background: color-mix(in srgb, var(--gold) 12%, var(--surface));
  box-shadow: 0 0 14px rgba(199, 146, 53, 0.22);
}

.due-chip.is-due-now span {
  color: var(--gold-dark);
}

.due-chip.is-due-soon {
  border-color: var(--gold);
  background: color-mix(in srgb, var(--gold) 12%, var(--surface));
  box-shadow: 0 0 14px rgba(199, 146, 53, 0.22);
}

.due-chip.is-due-soon span {
  color: var(--gold-dark);
}

.due-chip.is-ontrack {
  border-color: #34d399;
  background: color-mix(in srgb, #34d399 12%, var(--surface));
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.16);
}

.due-chip.is-ontrack span {
  color: #047857;
}

.board-action-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
  margin: 12px 0 16px;
}

.board-action-summary strong {
  display: block;
  margin-bottom: 4px;
}

.board-action-summary p {
  margin: 0;
  color: var(--muted);
}

.board-document-fields {
  display: grid;
  gap: 12px;
  margin: 12px 0 16px;
}

.board-document-fields label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.board-document-fields input,
.board-document-fields select,
.board-document-fields textarea {
  width: 100%;
  color: var(--ink);
  font-weight: 600;
}


/* Inline project/customer assign in the P&L Expense Breakdown */
.inline-assign { margin: 0; }
.inline-project-input {
  max-width: 240px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.inline-project-input:hover { border-color: var(--muted); }
