:root {
  color: #17221d;
  background: #f4f3ed;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  font-synthesis: none;
  --forest: #173f35;
  --deep: #0f2d26;
  --mint: #9ae6c8;
  --lime: #c4f36b;
  --cream: #f4f3ed;
  --paper: #fbfaf6;
  --ink: #17221d;
  --muted: #69746f;
  --line: #dce0d8;
  --danger: #9d3e31;
  --warn: #9a5d19;
  --shadow: 0 16px 50px rgba(26, 49, 40, 0.08);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #65c9a5;
  outline-offset: 2px;
}
a {
  color: inherit;
  text-decoration: none;
}
.boot {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--muted);
}
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--lime);
  color: var(--deep);
  font-weight: 900;
}
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(340px, 1.05fr) minmax(420px, 0.95fr);
}
.auth-story {
  padding: clamp(38px, 7vw, 96px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: radial-gradient(circle at 80% 15%, #2a5a4c, var(--deep) 55%, #071a15);
  color: white;
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
}
.wordmark small {
  display: block;
  margin-top: 2px;
  color: #8aa69b;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.auth-copy {
  max-width: 650px;
}
.eyebrow {
  color: var(--mint);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}
.auth-copy h1 {
  max-width: 680px;
  margin: 18px 0;
  font-size: clamp(42px, 6vw, 78px);
  line-height: 0.98;
  letter-spacing: -0.055em;
}
.auth-copy p {
  max-width: 600px;
  color: #c7d9d2;
  line-height: 1.75;
}
.auth-foot {
  color: #819b91;
  font-size: 11px;
}
.auth-panel {
  padding: clamp(30px, 7vw, 90px);
  display: grid;
  place-content: center;
  background: var(--paper);
}
.auth-card {
  width: min(440px, 100%);
}
.auth-card h2 {
  margin: 8px 0 10px;
  font-size: 32px;
  letter-spacing: -0.035em;
}
.auth-card > p {
  margin: 0 0 28px;
  color: var(--muted);
  line-height: 1.55;
}
.form {
  display: grid;
  gap: 17px;
}
label {
  display: grid;
  gap: 7px;
  color: #44514b;
  font-size: 12px;
  font-weight: 750;
}
input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid #cbd2cc;
  border-radius: 9px;
  background: white;
  color: var(--ink);
}
textarea {
  min-height: 88px;
  resize: vertical;
}
input:focus,
select:focus,
textarea:focus {
  border-color: #4caa88;
  box-shadow: 0 0 0 4px rgba(76, 170, 136, 0.1);
  outline: 0;
}
.button {
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--forest);
  color: white;
  font-weight: 800;
  cursor: pointer;
}
.button:hover {
  background: var(--deep);
}
.button:disabled {
  opacity: 0.55;
  cursor: wait;
}
.button.secondary {
  border: 1px solid #bdc8c0;
  background: transparent;
  color: var(--forest);
}
.button.secondary:hover {
  background: #edf2ee;
}
.button.ghost {
  background: transparent;
  color: var(--forest);
}
.button.danger {
  background: #f9e8e5;
  color: var(--danger);
}
.button.small {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 11px;
}
.form-message,
.notice {
  padding: 12px 14px;
  border-radius: 8px;
  background: #fce8e4;
  color: #8e3528;
  font-size: 12px;
  line-height: 1.5;
}
.form-message {
  margin-bottom: 18px;
}
.form-message.success {
  background: #e4f5ec;
  color: #256347;
}
.auth-links {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  font-weight: 750;
}
.auth-links a {
  color: var(--forest);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.field-help {
  margin-top: -10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}
.notice.success {
  background: #e4f5ec;
  color: #256347;
}
.profile-notice {
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff0dc;
  color: var(--warn);
}
.profile-notice span {
  flex: 1;
}
.security-note {
  margin-top: 20px;
  color: #87918c;
  font-size: 11px;
}
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  background: var(--deep);
  color: #d5e1dc;
}
.sidebar .wordmark {
  padding: 0 10px 22px;
}
.sidebar-nav {
  display: grid;
  gap: 4px;
}
.nav-label {
  margin: 16px 10px 8px;
  color: #719188;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}
.nav-item {
  min-height: 43px;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  color: #c8d7d1;
  font-size: 12px;
  font-weight: 650;
}
.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.09);
  color: white;
}
.nav-glyph {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 7px;
  color: #a6c0b6;
  font-size: 9px;
  font-weight: 900;
}
.sidebar-foot {
  margin-top: auto;
  padding: 16px 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #829d93;
  font-size: 10px;
}
.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 50%;
  background: #65d49f;
  box-shadow: 0 0 0 4px rgba(101, 212, 159, 0.1);
}
.workspace {
  min-width: 0;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 70px;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 246, 0.94);
  backdrop-filter: blur(12px);
}
.menu-button {
  display: none;
}
.global-search {
  position: relative;
  flex: 1;
  max-width: 560px;
}
.global-search input {
  min-height: 40px;
  padding-left: 36px;
  background: #f0f1eb;
  border-color: transparent;
}
.global-search::before {
  content: '⌕';
  position: absolute;
  left: 13px;
  top: 9px;
  color: #819089;
}
.user-context {
  margin-left: auto;
  text-align: right;
}
.user-context span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.user-context strong {
  font-size: 12px;
}
.page {
  padding: clamp(24px, 4vw, 52px);
}
.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}
.page-head h1 {
  margin: 5px 0 0;
  font-size: clamp(31px, 4vw, 50px);
  letter-spacing: -0.05em;
}
.page-head p {
  max-width: 650px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}
.kicker {
  color: #38836c;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}
.metric {
  min-height: 128px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.metric span {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.metric strong {
  display: block;
  margin-top: 14px;
  font-size: 30px;
  letter-spacing: -0.04em;
}
.metric small {
  color: #8b9590;
}
.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
  gap: 18px;
}
.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  min-height: 62px;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 {
  margin: 0;
  font-size: 17px;
}
.panel-body {
  padding: 20px;
}
.section-gap {
  margin-top: 18px;
}
.muted {
  color: var(--muted);
  line-height: 1.6;
}
.filter-bar {
  padding: 14px 18px;
  display: flex;
  align-items: end;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  background: #f7f7f2;
}
.filter-bar label {
  min-width: min(320px, 100%);
}
.filter-bar input,
.filter-bar select {
  min-height: 40px;
}
.report-filter {
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.report-filter label {
  min-width: 180px;
}
.summary-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.summary-chip {
  padding: 9px 11px;
  border-radius: 8px;
  background: #e5f5ec;
  color: #2a6d50;
  font-size: 11px;
}
.summary-chip strong {
  font-size: 15px;
}
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  padding: 13px 18px;
  border-bottom: 1px solid #e9ebe7;
  text-align: left;
  font-size: 11px;
  white-space: nowrap;
}
th {
  color: #8a948f;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
td.primary-cell {
  font-weight: 750;
  color: #21362e;
}
.row-actions {
  display: flex;
  gap: 5px;
}
.status {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e5f5ec;
  color: #2a6d50;
  font-size: 8px;
  font-weight: 850;
  text-transform: uppercase;
}
.status.Draft {
  background: #edf0ed;
  color: #69746f;
}
.status.Declined,
.status.Cancelled {
  background: #f9e8e5;
  color: var(--danger);
}
.status.Sent,
.status.Awaiting-Payment {
  background: #fff0dc;
  color: var(--warn);
}
.status.Part-paid {
  background: #e9ecff;
  color: #454d9a;
}
.status.Overdue {
  background: #f9e8e5;
  color: var(--danger);
}
.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
}
.empty strong {
  display: block;
  margin-bottom: 5px;
  color: var(--ink);
}
.stack {
  display: grid;
  gap: 13px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
}
.form-grid .wide {
  grid-column: 1 / -1;
}
.line-items {
  display: grid;
  gap: 8px;
}
.line-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 85px 110px 70px 34px;
  gap: 8px;
  align-items: end;
}
.line-row label {
  font-size: 9px;
}
.line-row input,
.line-row select {
  min-height: 40px;
}
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  justify-items: end;
  background: rgba(7, 18, 15, 0.48);
}
.confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(7, 18, 15, 0.56);
}
.confirm-dialog {
  width: min(420px, 100%);
  padding: 22px 22px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
}
.confirm-dialog h3 {
  margin: 0 0 10px;
  font-size: 20px;
  color: var(--ink);
}
.confirm-dialog p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}
.confirm-actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}
.button.danger:hover {
  background: #f3d5cf;
}
.muted-note {
  margin: 8px 0 0;
  flex: 1 1 100%;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.invoice-danger-zone {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.invoice-danger-zone .muted {
  margin: 0;
  max-width: 42rem;
}
.drawer {
  width: min(620px, 100%);
  height: 100%;
  padding: 26px;
  overflow-y: auto;
  background: var(--paper);
  box-shadow: -20px 0 70px rgba(0, 0, 0, 0.16);
}
.drawer-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.drawer-head h2 {
  margin: 4px 0 0;
  font-size: 26px;
}
.drawer-actions {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.detail-grid > div {
  min-height: 76px;
  padding: 13px;
  display: grid;
  align-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
}
.detail-grid > div.wide {
  grid-column: 1 / -1;
}
.detail-grid span {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.detail-grid strong {
  overflow-wrap: anywhere;
  font-size: 12px;
}
.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  cursor: pointer;
}
.search-results {
  position: absolute;
  z-index: 40;
  top: 46px;
  left: 0;
  right: 0;
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  box-shadow: var(--shadow);
}
.search-result {
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid #eef0eb;
  font-size: 11px;
}
.search-result small {
  color: var(--muted);
}
.timeline-list {
  display: grid;
  gap: 1px;
  background: var(--line);
}
.timeline-event {
  padding: 14px 18px;
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 16px;
  background: var(--paper);
}
.timeline-event time {
  color: var(--muted);
  font-size: 10px;
}
.timeline-event strong {
  font-size: 12px;
}
.timeline-event pre {
  margin: 5px 0 0;
  color: var(--muted);
  font:
    10px/1.45 ui-monospace,
    monospace;
  white-space: pre-wrap;
}
.timeline-event p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}
.activity-list {
  display: grid;
}
.activity-event {
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 165px minmax(0, 1fr);
  gap: 18px;
  border-bottom: 1px solid var(--line);
}
.activity-event time {
  color: var(--muted);
  font-size: 10px;
}
.activity-event h3 {
  margin: 4px 0 5px;
  font-size: 15px;
}
.activity-event p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 120;
  max-width: 390px;
  padding: 13px 16px;
  border-radius: 9px;
  background: var(--deep);
  color: white;
  box-shadow: 0 14px 45px rgba(0, 0, 0, 0.2);
  font-size: 12px;
}
.toast.error {
  background: #7f3026;
}
.mobile-overlay {
  display: none;
}
@media (max-width: 1050px) {
  .metric-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 780px) {
  .auth-page {
    grid-template-columns: 1fr;
  }
  .auth-story {
    min-height: 300px;
    padding: 34px 26px;
  }
  .auth-copy h1 {
    font-size: 44px;
  }
  .auth-foot {
    display: none;
  }
  .auth-panel {
    padding: 42px 24px;
  }
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    z-index: 70;
    left: 0;
    transform: translateX(-105%);
    width: 245px;
    transition: transform 0.2s ease;
  }
  .app-shell.menu-open .sidebar {
    transform: translateX(0);
  }
  .mobile-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(0, 0, 0, 0.35);
  }
  .app-shell.menu-open .mobile-overlay {
    display: block;
  }
  .menu-button {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
  }
  .topbar {
    padding: 10px 16px;
  }
  .user-context {
    display: none;
  }
  .page {
    padding: 26px 16px 50px;
  }
  .page-head {
    align-items: start;
    flex-direction: column;
  }
  .profile-notice,
  .filter-bar {
    align-items: stretch;
    flex-direction: column;
  }
  .filter-bar label,
  .report-filter label {
    min-width: 0;
  }
  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }
  .metric {
    min-height: 112px;
    padding: 16px;
  }
  .metric strong {
    font-size: 24px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .detail-grid {
    grid-template-columns: 1fr;
  }
  .detail-grid > div.wide {
    grid-column: auto;
  }
  .activity-event {
    grid-template-columns: 1fr;
    gap: 7px;
  }
  .line-row {
    grid-template-columns: 1fr 72px 92px 60px 34px;
  }
}
@media (max-width: 520px) {
  .metric-grid {
    grid-template-columns: 1fr;
  }
  .line-row {
    grid-template-columns: 1fr 1fr;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 9px;
  }
  .line-row label:first-child {
    grid-column: 1 / -1;
  }
  .line-row .remove-line {
    align-self: end;
  }
  .drawer {
    padding: 20px 16px;
  }
}
/* Full-page invoice editor (curtain)
   Open: top → bottom. Close: bottom → top (retract upward).
   Motion is driven by Web Animations API in invoice-editor.js.
   CSS holds resting transforms only — no CSS transition (avoids skipped mounts). */
.invoice-curtain,
[data-invoice-editor] {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: linear-gradient(180deg, #eef2ec 0%, var(--cream) 42%, #e7ebe3 100%);
  transform: translate3d(0, -100%, 0);
  overflow: auto;
  will-change: transform;
  backface-visibility: hidden;
  contain: layout style;
}
.invoice-curtain.is-open,
[data-invoice-editor].is-open {
  transform: translate3d(0, 0, 0);
}
.invoice-curtain.is-closing,
[data-invoice-editor].is-closing {
  transform: translate3d(0, -100%, 0);
}
.invoice-workspace {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
}
.invoice-toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  background: rgba(251, 250, 246, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.invoice-toolbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.invoice-toolbar-brand small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.invoice-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.invoice-sheet {
  width: min(1080px, calc(100% - 32px));
  margin: 22px auto 40px;
  padding: clamp(22px, 4vw, 40px);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.invoice-doc-header {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.invoice-company {
  display: flex;
  gap: 14px;
  align-items: start;
}
.invoice-company h1 {
  margin: 0 0 6px;
  font-size: clamp(24px, 3vw, 32px);
  color: var(--deep);
}
.invoice-company p,
.invoice-bank p {
  margin: 0 0 4px;
  color: var(--muted);
  line-height: 1.45;
}
.invoice-logo {
  width: 52px;
  height: 52px;
  font-size: 22px;
}
.invoice-meta {
  text-align: right;
}
.invoice-doc-title {
  margin: 0 0 14px;
  font-size: 28px;
  letter-spacing: 0.08em;
  font-weight: 800;
  color: var(--forest);
}
.invoice-meta dl {
  margin: 0;
  display: grid;
  gap: 8px;
}
.invoice-meta dl > div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}
.invoice-meta dt {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.invoice-meta dd {
  margin: 0;
  font-weight: 700;
}
.invoice-meta input[type='date'] {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  background: white;
}
.invoice-section {
  margin-top: 28px;
}
.invoice-section h2,
.invoice-bank h3 {
  margin: 0 0 12px;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.invoice-section-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
}
.invoice-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.invoice-field {
  display: grid;
  gap: 6px;
}
.invoice-field-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted, #5b6470);
}
.invoice-field-error {
  color: #b42318;
  font-size: 0.85rem;
  line-height: 1.35;
}
.invoice-field input[aria-invalid='true'],
.invoice-field select[aria-invalid='true'],
.invoice-field textarea[aria-invalid='true'] {
  border-color: #f04438;
  box-shadow: 0 0 0 3px rgba(240, 68, 56, 0.15);
}
.invoice-field input,
.invoice-field select,
.invoice-field textarea,
.invoice-lines-table input,
.invoice-lines-table select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: white;
  position: relative;
  z-index: 1;
  -webkit-user-select: text;
  user-select: text;
  pointer-events: auto;
  touch-action: manipulation;
}
.invoice-field input[name='title'],
.invoice-lines-table input[name='description'] {
  cursor: text;
}
.invoice-clipboard-hint {
  margin: 8px 2px 0;
  font-size: 13px;
  color: var(--danger);
}
.invoice-editable-cell {
  vertical-align: middle;
}
.invoice-cell-text {
  display: block;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 10px;
  background: transparent;
  color: inherit;
  cursor: text;
  -webkit-user-select: text;
  user-select: text;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.35;
}
.invoice-cell-text:focus {
  outline: 2px solid rgba(23, 63, 53, 0.25);
  outline-offset: 1px;
}
.invoice-editable-cell.is-editing .invoice-cell-text {
  display: none;
}
.invoice-editable-cell:not(.is-editing) .invoice-cell-input {
  display: none !important;
}
.invoice-editable-cell.is-editing .invoice-cell-input {
  display: block;
  width: 100%;
}
.invoice-line-number-cell,
.invoice-line-number,
.invoice-line-actions,
.invoice-line-actions * {
  -webkit-user-select: none;
  user-select: none;
}
.invoice-line-number-cell,
.invoice-line-number {
  cursor: grab;
  touch-action: none;
}
.invoice-lines-table {
  -webkit-user-select: text;
  user-select: text;
}
.invoice-line-number {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 2.75ch;
  min-height: 34px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--muted);
}
.invoice-line.is-dragging .invoice-line-number {
  cursor: grabbing;
}
.invoice-section-head-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.invoice-line-count {
  font-size: 13px;
  white-space: nowrap;
}
.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;
}
.invoice-field textarea {
  min-height: 96px;
  resize: vertical;
}
.invoice-billto-static,
.invoice-billto-preview {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7f8f4;
}
.invoice-billto-static strong,
.invoice-billto-preview strong {
  color: var(--deep);
}
.invoice-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.invoice-lines-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}
.invoice-lines-table th,
.invoice-lines-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.invoice-lines-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: #f3f5f0;
}
.invoice-lines-table th.narrow,
.invoice-lines-table td.invoice-line-actions {
  width: 1%;
  white-space: nowrap;
}
.invoice-lines-table th.invoice-line-number-col,
.invoice-lines-table td.invoice-line-number-cell {
  width: 4.5ch;
  min-width: 4.5ch;
  max-width: 5.5ch;
  text-align: right;
  white-space: nowrap;
  vertical-align: middle;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.invoice-line-total {
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}
.invoice-line.is-dragging {
  opacity: 0.45;
}
.invoice-line.drag-over {
  outline: 2px solid var(--mint);
}
.invoice-line-actions {
  display: flex;
  gap: 2px;
}
.invoice-footer-grid {
  margin-top: 28px;
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
  align-items: start;
}
.invoice-notes-block {
  display: grid;
  gap: 14px;
}
.invoice-bank {
  padding: 14px;
  border-radius: 12px;
  border: 1px dashed var(--line);
  background: #f7f8f4;
}
.invoice-totals {
  position: sticky;
  top: 86px;
  display: grid;
  gap: 12px;
  padding: 18px;
  border-radius: 14px;
  background: var(--deep);
  color: white;
}
.invoice-totals > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
}
.invoice-totals span {
  color: #b7cfc4;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.invoice-totals strong {
  font-size: 18px;
}
.invoice-grand {
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}
.invoice-grand strong {
  font-size: 26px;
  color: var(--lime);
}
@media (max-width: 900px) {
  .invoice-doc-header,
  .invoice-section-grid,
  .invoice-footer-grid {
    grid-template-columns: 1fr;
  }
  .invoice-meta {
    text-align: left;
  }
  .invoice-totals {
    position: static;
  }
}
@media (max-width: 640px) {
  .invoice-toolbar {
    padding: 12px 14px;
  }
  .invoice-sheet {
    width: calc(100% - 16px);
    margin-top: 12px;
    padding: 16px;
    border-radius: 12px;
  }
  .invoice-toolbar-actions .button {
    flex: 1 1 calc(50% - 8px);
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  .invoice-curtain,
  .invoice-curtain.is-open,
  .invoice-curtain.is-closing {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

/* Brand logos */
.brand-logo,
.invoice-logo.brand-logo,
.settings-logo-preview {
  display: block;
  object-fit: contain;
  background: #fbfaf6;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.wordmark .brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}
.invoice-logo.brand-logo {
  width: 52px;
  height: 52px;
}

.logo-platform-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0 0 1.25rem;
}

/* Logo Creator */
.logo-studio-grid {
  margin-bottom: 18px;
}
.logo-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.logo-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  overflow: hidden;
  display: grid;
  gap: 0;
}
.logo-card.is-selected {
  border-color: var(--deep);
  box-shadow: 0 0 0 1px var(--deep);
}
.logo-card-preview {
  min-height: 140px;
  background: linear-gradient(180deg, #f7f6f1, #fff);
  display: grid;
  place-items: center;
  padding: 10px;
}
.logo-card-preview svg {
  width: 100%;
  height: auto;
  max-height: 160px;
}
.logo-card-meta,
.logo-card-actions {
  padding: 10px 12px;
}
.logo-card-meta {
  display: grid;
  gap: 2px;
  border-top: 1px solid var(--line);
}
.logo-card-meta span {
  color: var(--muted);
  font-size: 12px;
  text-transform: capitalize;
}
.logo-card-meta strong {
  text-transform: capitalize;
}
.logo-card-actions {
  border-top: 1px solid var(--line);
}
.logo-active-preview {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.empty-state {
  grid-column: 1 / -1;
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}

/* Invoice template recreate */
.template-compare {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(260px, 1fr) minmax(320px, 1.2fr);
  margin-top: 16px;
}
.template-review-grid {
  display: grid;
  gap: 14px;
}
.template-original-frame,
.template-original-image {
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.template-original-image {
  object-fit: contain;
  min-height: 280px;
  max-height: 520px;
}
.template-limitations {
  margin: 0 0 12px;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}
.template-columns {
  display: grid;
  gap: 8px;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.checkbox-row em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}
.file-drop input[type='file'] {
  display: block;
  margin-top: 8px;
  width: 100%;
}
.invoice-template-hint {
  margin: 4px 0 10px;
}
@media (max-width: 960px) {
  .template-compare {
    grid-template-columns: 1fr;
  }
}

/* Inventory workspace */
.inventory-page .inventory-alert-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.inventory-alert {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(248, 246, 242, 0.95)),
    radial-gradient(circle at top right, rgba(196, 149, 74, 0.12), transparent 55%);
}
.inventory-alert strong {
  display: block;
  text-transform: capitalize;
  margin-bottom: 6px;
}
.inventory-alert p {
  margin: 0 0 8px;
  color: var(--ink);
}
.inventory-alert span {
  color: var(--muted);
  font-size: 13px;
}
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.muted {
  color: var(--muted);
  font-size: 12px;
}
@media (max-width: 720px) {
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* =============================================================================
   Quantum Hire / Cart N Tip dedicated invoice document shell
   Geometry is derived from measured PDF points in quantum-hire-layout.ts.
   This is intentionally NOT the Aleya .invoice-sheet layout.
   ============================================================================= */
.qh-workspace {
  /* 1 PDF point → CSS px. Keep this a <length> so min()/calc stay valid. */
  --qh-pt: calc(min(794px, 100vw - 48px) / 595.276);
  background:
    radial-gradient(circle at 12% 0%, rgba(20, 20, 20, 0.06), transparent 42%),
    linear-gradient(180deg, #ececec 0%, #f5f5f5 48%, #e8e8e8 100%);
}
.qh-controls {
  width: calc(595.276 * var(--qh-pt));
  max-width: calc(100% - 32px);
  margin: 14px auto 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.08);
}
.qh-controls .invoice-field {
  margin: 0;
}
.qh-controls .invoice-field input,
.qh-controls .invoice-field select {
  min-height: 38px;
}
.qh-page {
  width: calc(595.276 * var(--qh-pt));
  min-height: calc(841.89 * var(--qh-pt));
  max-width: calc(100% - 32px);
  margin: 16px auto 48px;
  background: #ffffff;
  color: #111111;
  border: 1px solid #c8c8c8;
  border-radius: 0;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.12);
  font-family: Helvetica, Arial, 'Liberation Sans', sans-serif;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}
.qh-header {
  position: relative;
  height: calc(193.89 * var(--qh-pt));
}
.qh-logo-wrap {
  position: absolute;
  left: calc(34 * var(--qh-pt));
  top: calc(29.56 * var(--qh-pt));
  width: calc(178 * var(--qh-pt));
  height: calc(118.66 * var(--qh-pt));
}
.qh-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: left top;
}
.qh-header-divider {
  position: absolute;
  left: calc(276 * var(--qh-pt));
  top: calc(31.89 * var(--qh-pt));
  width: 1px;
  height: calc(137 * var(--qh-pt));
  background: #cfcfcf;
}
.qh-meta {
  position: absolute;
  left: calc(320 * var(--qh-pt));
  top: calc(30.9 * var(--qh-pt));
  width: calc(185 * var(--qh-pt));
}
.qh-title {
  margin: 0 0 calc(34 * var(--qh-pt));
  padding: 0;
  font-size: calc(29 * var(--qh-pt));
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0;
  color: #111;
  text-transform: none;
}
.qh-meta-list {
  margin: 0;
  display: grid;
  gap: calc(10 * var(--qh-pt));
}
.qh-meta-list > div {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 8px;
  align-items: baseline;
}
.qh-meta-list dt {
  margin: 0;
  font-size: calc(9.8 * var(--qh-pt));
  font-weight: 700;
  color: #111;
  letter-spacing: 0;
  text-transform: none;
}
.qh-meta-list dd {
  margin: 0;
  text-align: right;
  font-size: calc(10 * var(--qh-pt));
  font-weight: 400;
  color: #111;
  min-width: 0;
  white-space: nowrap;
}
/* Drafts must never look like a missing invoice-number value. */
.qh-meta-list dd[data-invoice-number-display]:empty::before {
  content: 'Not assigned';
  color: #111;
}
.qh-meta-list dd[data-unassigned='true'],
.qh-payment dd[data-unassigned='true'] {
  color: #111;
}
.qh-meta-input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  text-align: right;
  font: inherit;
  color: inherit;
  padding: 0;
  min-height: 0;
}
.qh-meta-input:focus {
  outline: none;
  border-bottom-color: #111;
}
.qh-rule {
  margin: 0 0 0 calc(12 * var(--qh-pt));
  width: calc(530 * var(--qh-pt));
  border: 0;
  border-top: 1px solid #cfcfcf;
}
.qh-parties {
  display: grid;
  grid-template-columns: calc(280 * var(--qh-pt)) 1fr;
  column-gap: 0;
  padding: calc(29 * var(--qh-pt)) calc(12 * var(--qh-pt)) 0;
  min-height: calc(218 * var(--qh-pt));
  box-sizing: border-box;
}
.qh-parties h2 {
  margin: 0 0 calc(22 * var(--qh-pt));
  font-size: calc(11 * var(--qh-pt));
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  color: #111;
}
.qh-billto,
.qh-from {
  display: grid;
  align-content: start;
  gap: calc(8 * var(--qh-pt));
  font-size: calc(8.5 * var(--qh-pt));
  line-height: 1.35;
  color: #111;
}
.qh-party-name,
.qh-from {
  display: grid;
  gap: calc(6 * var(--qh-pt));
}
.qh-party-name strong,
.qh-from strong {
  font-size: calc(8.2 * var(--qh-pt));
  font-weight: 700;
}
.qh-from {
  padding-left: calc(0 * var(--qh-pt));
  margin-left: calc(0 * var(--qh-pt));
}
.qh-lines-section {
  margin-top: calc(20 * var(--qh-pt));
  padding: 0;
}
.qh-lines-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 0 calc(12 * var(--qh-pt)) 8px;
}
.qh-table-wrap {
  margin-left: calc(12 * var(--qh-pt));
  width: calc(582 * var(--qh-pt));
  overflow: hidden;
}
.qh-lines-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: calc(8.7 * var(--qh-pt));
  color: #111;
}
.qh-lines-table thead th {
  background: #000;
  color: #fff;
  font-weight: 700;
  font-size: calc(8.5 * var(--qh-pt));
  height: calc(31 * var(--qh-pt));
  padding: 0 calc(10 * var(--qh-pt));
  text-align: left;
  letter-spacing: 0;
  border: 0;
  vertical-align: middle;
}
.qh-lines-table tbody td {
  height: calc(30 * var(--qh-pt));
  padding: calc(6 * var(--qh-pt)) calc(10 * var(--qh-pt));
  border-bottom: 1px solid #e1e1e1;
  border-left: 1px solid #e1e1e1;
  border-right: 0;
  vertical-align: middle;
  background: #fff;
}
.qh-lines-table tbody td:first-child,
.qh-lines-table thead th:first-child {
  border-left: 1px solid #e1e1e1;
}
.qh-lines-table tbody td:nth-child(5),
.qh-lines-table thead th:nth-child(5) {
  border-right: 1px solid #e1e1e1;
}
.qh-lines-table .qh-col-date {
  width: 15.1%;
}
.qh-lines-table .qh-col-description,
.qh-lines-table th:nth-child(2),
.qh-lines-table td:nth-child(2) {
  width: 37.8%;
}
.qh-lines-table .qh-col-qty,
.qh-lines-table th:nth-child(3),
.qh-lines-table td:nth-child(3) {
  width: 10.7%;
}
.qh-lines-table .qh-col-rate,
.qh-lines-table th:nth-child(4),
.qh-lines-table td:nth-child(4) {
  width: 16.2%;
}
.qh-lines-table .qh-col-amount,
.qh-lines-table th:nth-child(5),
.qh-lines-table td:nth-child(5) {
  width: 20.2%;
}
.qh-lines-table th.narrow,
.qh-lines-table .qh-line-actions {
  width: 72px;
  background: #fff;
  border: 0 !important;
  color: #111;
}
.qh-lines-table thead th.narrow {
  background: #000;
}
/* Native date control: stretch Chromium's calendar-picker-indicator over the
   full input so a click anywhere in the DATE box opens the picker (Windows Chrome).
   Uses the browser's own indicator hit-target — not showPicker() and not a fake overlay. */
.qh-line-date {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 1.6em;
  margin: 0;
  padding: 2px 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 1.25;
  cursor: pointer;
  position: relative;
}
.qh-line-date::-webkit-calendar-picker-indicator {
  background: transparent;
  bottom: 0;
  color: transparent;
  cursor: pointer;
  height: auto;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
  width: auto;
}
.qh-line-date:disabled {
  cursor: default;
  opacity: 1;
  color: inherit;
}
.qh-lines-table .invoice-editable-cell {
  position: relative;
}
.qh-lines-table .invoice-cell-text {
  display: block;
  min-height: 1.2em;
  font-size: inherit;
  line-height: 1.25;
}
.qh-lines-table .invoice-cell-input {
  font-size: inherit;
  min-height: 0;
  border-radius: 0;
  padding: 2px 4px;
}
.qh-line-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-start;
  padding-left: 8px !important;
}
.qh-line-actions select {
  min-height: 28px;
  font-size: 11px;
  padding: 2px 4px;
}
.qh-footer {
  position: relative;
  margin-top: calc(24 * var(--qh-pt));
  min-height: calc(180 * var(--qh-pt));
  padding: calc(17 * var(--qh-pt)) calc(12 * var(--qh-pt)) calc(24 * var(--qh-pt));
  display: grid;
  grid-template-columns: calc(264 * var(--qh-pt)) 1fr;
  column-gap: calc(20 * var(--qh-pt));
  border-top: 1px solid #cfcfcf;
  margin-left: calc(12 * var(--qh-pt));
  margin-right: calc(53 * var(--qh-pt));
}
.qh-footer-divider {
  position: absolute;
  left: calc(264 * var(--qh-pt));
  top: calc(17 * var(--qh-pt));
  width: 1px;
  height: calc(124 * var(--qh-pt));
  background: #cfcfcf;
}
.qh-payment h2,
.qh-note-title {
  margin: 0 0 calc(10 * var(--qh-pt));
  font-size: calc(9.5 * var(--qh-pt));
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  color: #111;
}
.qh-note-title {
  margin-top: calc(14 * var(--qh-pt));
  font-size: calc(7 * var(--qh-pt));
}
.qh-payment dl {
  margin: 0;
  display: grid;
  gap: calc(8 * var(--qh-pt));
}
.qh-payment dl > div {
  display: grid;
  grid-template-columns: calc(85 * var(--qh-pt)) 1fr;
  gap: 6px;
  align-items: baseline;
}
.qh-payment dt {
  margin: 0;
  font-size: calc(6.8 * var(--qh-pt));
  font-weight: 400;
  color: #111;
}
.qh-payment dd {
  margin: 0;
  font-size: calc(7 * var(--qh-pt));
  font-weight: 400;
  color: #111;
}
.qh-notes {
  width: 100%;
  min-height: calc(48 * var(--qh-pt));
  border: 0;
  border-radius: 0;
  resize: vertical;
  padding: 0;
  background: transparent;
  font-size: calc(6.2 * var(--qh-pt));
  line-height: 1.45;
  color: #111;
  font-family: inherit;
}
.qh-notes:focus {
  outline: none;
  box-shadow: inset 0 -1px 0 #111;
}
.qh-totals {
  position: relative;
  padding-left: calc(20 * var(--qh-pt));
  display: grid;
  align-content: start;
  gap: calc(14 * var(--qh-pt));
}
.qh-totals > div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: baseline;
  font-size: calc(8.2 * var(--qh-pt));
}
.qh-totals .qh-grand {
  margin-top: calc(4 * var(--qh-pt));
  padding-top: calc(8 * var(--qh-pt));
  border-top: 1px solid #111;
  font-size: calc(9 * var(--qh-pt));
}
.qh-totals .qh-grand strong {
  font-size: calc(22 * var(--qh-pt));
  font-weight: 700;
  line-height: 1;
}
.qh-thankyou {
  display: block;
  width: calc(110.4 * var(--qh-pt));
  height: calc(46 * var(--qh-pt));
  margin: calc(18 * var(--qh-pt)) 0 0 auto;
  object-fit: contain;
}
.qh-workspace .invoice-danger-zone {
  width: calc(595.276 * var(--qh-pt));
  max-width: calc(100% - 32px);
  margin: 0 auto 32px;
}
@media (max-width: 960px) {
  .qh-controls {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 720px) {
  .qh-workspace {
    --qh-pt: calc(min(720px, 100vw - 24px) / 595.276);
  }
  .qh-controls {
    grid-template-columns: 1fr;
  }
  .qh-footer {
    grid-template-columns: 1fr;
    margin-right: calc(12 * var(--qh-pt));
  }
  .qh-footer-divider {
    display: none;
  }
  .qh-totals {
    padding-left: 0;
  }
  .qh-line-actions {
    flex-wrap: wrap;
  }
}

/* Aleya AI operating layer */
.aleya-ai-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(240px, 0.8fr);
  gap: 18px;
  align-items: start;
}
.aleya-ai-panel,
.aleya-ai-side {
  background: var(--paper, #fff);
  border: 1px solid var(--line, #e5e1d8);
  border-radius: 16px;
  padding: 16px;
}
.aleya-ai-thread {
  min-height: 360px;
  max-height: 55vh;
  overflow: auto;
  display: grid;
  gap: 12px;
  margin: 12px 0;
  padding-right: 4px;
}
.aleya-msg {
  border-radius: 12px;
  padding: 12px 14px;
  background: #f6f4ef;
}
.aleya-msg-user {
  background: rgba(24, 72, 52, 0.08);
}
.aleya-msg-progress {
  background: rgba(40, 90, 140, 0.08);
}
.aleya-msg-error {
  background: rgba(160, 40, 30, 0.1);
  border: 1px solid rgba(160, 40, 30, 0.25);
}
.aleya-msg-role {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted, #6b6458);
  margin-bottom: 6px;
}
.aleya-msg-body {
  line-height: 1.45;
  white-space: normal;
}
.aleya-ai-composer textarea {
  width: 100%;
  min-height: 84px;
  border-radius: 12px;
  border: 1px solid var(--line, #e5e1d8);
  padding: 12px;
  font: inherit;
  resize: vertical;
}
.aleya-ai-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.aleya-ai-confirm {
  margin: 10px 0;
  padding: 12px 14px;
  border: 1px solid rgba(160, 70, 20, 0.35);
  background: rgba(255, 196, 120, 0.18);
  border-radius: 12px;
}
.aleya-ai-tool-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  max-height: 60vh;
  overflow: auto;
}
.aleya-ai-tool-list li {
  display: grid;
  gap: 2px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line, #eee);
}
.aleya-ai-tool-list span {
  color: var(--muted, #6b6458);
  font-size: 12px;
}
@media (max-width: 960px) {
  .aleya-ai-layout {
    grid-template-columns: 1fr;
  }
}

/* Settings tabs */
.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 1.25rem;
  border-bottom: 1px solid var(--line, #e6e1d8);
  padding-bottom: 0.35rem;
}
.settings-tab {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 0.85rem;
  text-decoration: none;
  color: var(--muted, #6b6458);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-weight: 600;
}
.settings-tab:hover {
  color: inherit;
}
.settings-tab.active {
  color: inherit;
  border-bottom-color: currentColor;
}
.settings-bank-feeds {
  display: grid;
  gap: 1rem;
}

/* Banking (Basiq Phase 1) */
.banking-page {
  display: grid;
  gap: 1.25rem;
}
.banking-page .page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}
.banking-summary p {
  margin: 0;
}
.banking-panel {
  display: grid;
  gap: 0.85rem;
  padding: 1rem 0;
  border-top: 1px solid var(--line, #e6e1d8);
}
.banking-panel-head h2 {
  margin: 0 0 0.25rem;
}
.banking-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem 1.25rem;
  margin: 0;
}
.banking-meta dt {
  font-size: 0.75rem;
  color: var(--muted, #6b6458);
}
.banking-meta dd {
  margin: 0.15rem 0 0;
  font-weight: 600;
}
.banking-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.banking-warning {
  color: #8a5a00;
}
.banking-error {
  color: #9b1c1c;
}
.banking-flash {
  color: #17633a;
}
.banking-account-list {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.35rem;
}
.banking-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
}
.banking-filters label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.85rem;
}
.banking-tx-table {
  width: 100%;
  border-collapse: collapse;
}
.banking-tx-table th,
.banking-tx-table td {
  text-align: left;
  padding: 0.55rem 0.35rem;
  border-bottom: 1px solid var(--line, #eee);
  font-size: 0.92rem;
}
.banking-amount-in {
  color: #17633a;
}
.banking-amount-out {
  color: #9b1c1c;
}
.banking-pagination {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}
.btn.danger {
  background: #9b1c1c;
  color: #fff;
  border-color: #9b1c1c;
}
