/* ===========================================================
   Renewal Tracker — visual system
   Palette:  ink #0F1B2D · paper #F8F5EE · amber #E8A33D
             sage #4A6B5C · alert #C4392A · line #E2DED4
   Type:     IBM Plex Sans (UI) · IBM Plex Mono (fine-clock digits)
   Signature: the fine-clock ticker uses tabular monospaced digits
              so numbers align vertically as they tick up.
   =========================================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&family=IBM+Plex+Sans+Arabic:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --ink: #0F1B2D;
  --ink-soft: #2A3546;
  --paper: #F8F5EE;
  --paper-warm: #EFEBE1;
  --amber: #E8A33D;
  --amber-soft: #F5D9A3;
  --sage: #4A6B5C;
  --alert: #C4392A;
  --alert-deep: #8A2820;
  --line: #E2DED4;
  --muted: #6B7280;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'IBM Plex Sans', -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); }

/* --- Eyebrow labels (all-caps micro-text as structural device) --- */
.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* --- Top bar --- */
.topbar {
  background: var(--ink);
  color: var(--paper);
  padding: 18px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 3px solid var(--amber);
}
.topbar .brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.topbar .brand-name {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.topbar .user-slot {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: #B7BCC9;
}
.topbar .user-slot button {
  background: none;
  border: 1px solid #2E3B4F;
  color: #B7BCC9;
  padding: 6px 12px;
  border-radius: 3px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  letter-spacing: 0.04em;
}
.topbar .user-slot button:hover { border-color: var(--amber); color: var(--amber); }

/* --- Layout --- */
main {
  max-width: 980px;
  margin: 0 auto;
  padding: 36px 28px 80px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 40px 0 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.section-head h2 {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
}

/* --- Summary stat row --- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}
.stat {
  background: var(--paper);
  padding: 22px 20px;
}
.stat .eyebrow { margin-bottom: 8px; display: block; }
.stat .num {
  font-family: 'IBM Plex Mono';
  font-size: 32px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.stat.expired .num { color: var(--alert); }
.stat.urgent .num { color: var(--amber); }
.stat.soon .num { color: var(--sage); }
.stat.risk .num { color: var(--ink); font-size: 26px; }
.stat.risk .num::before { content: 'AED '; font-size: 13px; color: var(--muted); font-weight: 400; margin-right: 4px; letter-spacing: 0.04em; }

@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* --- Add form --- */
.add-panel {
  background: var(--paper-warm);
  padding: 24px 26px;
  border: 1px solid var(--line);
}
.add-panel h3 {
  margin: 0 0 18px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
#itemForm {
  display: grid;
  grid-template-columns: 2fr 1fr 1.5fr;
  gap: 12px;
}
#itemForm .full { grid-column: span 3; }
#itemForm .half { grid-column: span 1; }
#itemForm input, #itemForm select {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  border-radius: 2px;
}
#itemForm input:focus, #itemForm select:focus {
  outline: none;
  border-color: var(--ink);
}
#itemForm button {
  background: var(--ink);
  color: var(--paper);
  border: none;
  padding: 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
}
#itemForm button:hover { background: var(--amber); color: var(--ink); }
@media (max-width: 620px) {
  #itemForm { grid-template-columns: 1fr; }
  #itemForm .full, #itemForm .half { grid-column: span 1; }
}

/* --- Item rows (each row is a document being tracked) --- */
.item-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 20px;
  align-items: center;
  padding: 18px 22px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 4px solid var(--sage);
  margin-bottom: -1px;
}
.item-row.soon { border-left-color: var(--amber); }
.item-row.urgent { border-left-color: var(--alert); }
.item-row.expired { border-left-color: var(--alert-deep); background: #FDF6F3; }

.item-label {
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 4px;
}
.item-meta {
  font-family: 'IBM Plex Mono';
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.item-meta .dot { margin: 0 6px; opacity: 0.5; }

/* --- Fine clock: the signature element --- */
.fine-clock {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 8px;
  background: rgba(196, 57, 42, 0.08);
  border-left: 2px solid var(--alert);
  font-size: 12px;
}
.fine-clock.warning {
  background: rgba(232, 163, 61, 0.10);
  border-left-color: var(--amber);
}
.fine-clock .tick {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--alert);
  animation: pulse 1.6s ease-in-out infinite;
}
.fine-clock.warning .tick { background: var(--amber); animation: none; }
.fine-clock .label {
  font-family: 'IBM Plex Sans';
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10px;
  font-weight: 600;
}
.fine-clock .amount {
  font-family: 'IBM Plex Mono';
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--alert);
}
.fine-clock.warning .amount { color: var(--amber); }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* --- Countdown badge --- */
.countdown {
  text-align: right;
}
.countdown .days {
  font-family: 'IBM Plex Mono';
  font-variant-numeric: tabular-nums;
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1;
}
.item-row.soon .countdown .days { color: var(--amber); }
.item-row.urgent .countdown .days { color: var(--alert); }
.item-row.expired .countdown .days { color: var(--alert-deep); }
.countdown .unit {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 4px;
}

/* --- Item actions --- */
.item-actions button {
  background: none;
  border: 1px solid var(--line);
  padding: 7px 12px;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: 2px;
  margin-left: 4px;
}
.item-actions button:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.item-actions button.danger:hover {
  background: var(--alert);
  border-color: var(--alert);
}

/* --- Empty state --- */
.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  background: var(--paper);
  border: 1px dashed var(--line);
}
.empty .hint {
  font-family: 'IBM Plex Mono';
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 12px;
  color: var(--amber);
}

/* --- Modal (checklist) --- */
.modal {
  position: fixed; inset: 0;
  background: rgba(15, 27, 45, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal.hidden { display: none; }
.modal-body {
  background: var(--paper);
  padding: 32px 34px;
  max-width: 480px;
  width: 100%;
  border-top: 4px solid var(--amber);
  position: relative;
}
.modal-body h3 {
  margin: 8px 0 6px;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.modal-body .subtitle {
  font-family: 'IBM Plex Mono';
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 20px;
}
.modal-body ol {
  padding-left: 0;
  list-style: none;
  counter-reset: step;
}
.modal-body ol li {
  counter-increment: step;
  padding: 12px 0 12px 42px;
  position: relative;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.modal-body ol li:last-child { border-bottom: none; }
.modal-body ol li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 12px;
  font-family: 'IBM Plex Mono';
  font-size: 11px;
  font-weight: 600;
  color: var(--amber);
  letter-spacing: 0.04em;
}
.modal-close {
  position: absolute;
  top: 14px; right: 18px;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--muted);
  cursor: pointer;
}
.modal-close:hover { color: var(--ink); }

/* --- Auth pages (login/signup) --- */
html, body.auth-page { height: 100%; }
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--paper); /* fills any overflow area */
}
.auth-brand {
  background: var(--ink);
  color: var(--paper);
  padding: 60px 50px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 3px solid var(--amber);
}
.auth-brand .brand-mark {
  font-family: 'IBM Plex Mono';
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.12em;
  color: var(--amber);
}
.auth-brand h1 {
  font-size: 40px;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 24px 0 20px;
  max-width: 380px;
}
.auth-brand h1 em {
  font-style: normal;
  color: var(--amber);
  font-weight: 500;
}
.auth-brand p {
  color: #B7BCC9;
  max-width: 360px;
  font-size: 14px;
}
.auth-brand .footer-note {
  font-family: 'IBM Plex Mono';
  font-size: 11px;
  letter-spacing: 0.08em;
  color: #6B7280;
  text-transform: uppercase;
}

.auth-form-wrap {
  padding: 60px 50px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--paper);
  min-height: 100vh;
}
.auth-brand { min-height: 100vh; }
.auth-form-wrap .eyebrow { margin-bottom: 10px; }
.auth-form-wrap h2 {
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0 0 30px;
}
.auth-form-wrap form { max-width: 340px; }
.auth-form-wrap label {
  display: block;
  margin-bottom: 14px;
}
.auth-form-wrap label span {
  display: block;
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.auth-form-wrap input {
  width: 100%;
  padding: 10px 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  border-radius: 2px;
}
.auth-form-wrap input:focus {
  outline: none;
  border-color: var(--ink);
}
.auth-form-wrap button {
  width: 100%;
  padding: 13px;
  margin-top: 8px;
  background: var(--ink);
  color: var(--paper);
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
}
.auth-form-wrap button:hover { background: var(--amber); color: var(--ink); }
.auth-form-wrap .switch {
  margin-top: 22px;
  font-size: 13px;
  color: var(--muted);
}
.auth-form-wrap .switch a {
  color: var(--ink);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--amber);
  text-underline-offset: 3px;
}
.auth-form-wrap .error {
  color: var(--alert);
  font-size: 13px;
  margin-top: 12px;
  min-height: 18px;
}

@media (max-width: 800px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-brand { padding: 40px 30px; border-right: none; border-bottom: 3px solid var(--amber); }
  .auth-brand h1 { font-size: 28px; }
  .auth-form-wrap { padding: 40px 30px; }
}

.iti {
  width: 100%;
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: stretch;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 2px;
  transition: border-color 0.15s;
}
.iti:focus-within { border-color: var(--ink); }

/* Kill the library's absolute positioning on the country button */
.iti__country-container {
  position: static !important;
  flex: 0 0 auto !important;
  display: flex;
  align-items: stretch;
  height: auto;
}

/* The clickable flag + dial-code chip (all three class-name variants
   in case the library version changes) */
.iti__selected-country,
.iti__selected-country-primary,
.iti__selected-flag {
  background: transparent !important;
  border: none !important;
  border-right: 1px solid var(--line) !important;
  border-radius: 0 !important;
  padding: 0 12px !important;
  height: auto !important;
  display: flex !important;
  align-items: center !important;
  gap: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.iti__selected-country:hover,
.iti__selected-country-primary:hover,
.iti__selected-flag:hover {
  background: var(--paper-warm) !important;
}

.iti__flag { margin: 0; }

/* +971 dial code */
.iti__selected-dial-code {
  font-family: 'IBM Plex Mono', monospace !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  color: var(--ink-soft) !important;
  margin-left: 6px !important;
  padding: 0 !important;
}

/* Dropdown arrow */
.iti__arrow,
.iti__dropdown-arrow {
  border-top-color: var(--muted) !important;
  margin-left: 4px;
}

/* Actual phone input — no border, fills remaining space.
   min-width:0 must stay or flex will not shrink it. */
.iti input[type="tel"],
.iti__tel-input {
  flex: 1 1 auto !important;
  width: auto !important;
  min-width: 0 !important;
  padding: 10px 12px !important;
  background: transparent !important;
  border: none !important;
  font-family: inherit !important;
  font-size: 14px !important;
  color: var(--ink) !important;
  border-radius: 0 !important;
}
.iti input[type="tel"]:focus,
.iti__tel-input:focus {
  outline: none !important;
}

/* Country dropdown list */
.iti__country-list,
.iti__dropdown-content {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 13px;
  background: var(--paper) !important;
  border-radius: 2px;
  border: 1px solid var(--line);
  box-shadow: 0 4px 16px rgba(15, 27, 45, 0.08);
  color: var(--ink);
  margin-top: 4px;
}
.iti__country,
.iti__dropdown-content li { color: var(--ink); }
.iti__country:hover,
.iti__country.iti__highlight,
.iti__dropdown-content li:hover {
  background: var(--amber-soft) !important;
  color: var(--ink) !important;
}

/* --- Onboarding wizard --- */
.onboarding {
  max-width: 640px;
  margin: 0 auto;
  padding: 40px 28px 80px;
}
.onboarding-progress {
  display: flex;
  gap: 12px;
  margin-bottom: 40px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.step-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 2px;
  flex: 1;
}
.step-pill.current {
  color: var(--ink);
  border-color: var(--ink);
  background: var(--paper-warm);
}
.step-pill.done {
  color: var(--sage);
  border-color: var(--sage);
}
.step-pill .step-num { font-weight: 600; }
.step-pill .step-label { font-family: 'IBM Plex Sans'; letter-spacing: 0.04em; text-transform: none; font-size: 12px; }
@media (max-width: 600px) {
  .step-pill .step-label { display: none; }
}

.onb-step h2 {
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 10px 0 8px;
}
.onb-hint { color: var(--muted); font-size: 14px; margin-bottom: 30px; }
.onb-step.hidden { display: none; }

.onb-form { display: flex; flex-direction: column; gap: 20px; }
.onb-form label { display: block; }
.onb-form label > span {
  display: block;
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.onb-form input[type="text"],
.onb-form select {
  width: 100%;
  padding: 12px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  border-radius: 2px;
}
.onb-form input:focus, .onb-form select:focus {
  outline: none;
  border-color: var(--ink);
}
.onb-form label.hidden { display: none; }

.radio-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.radio-group.compact {
  grid-template-columns: repeat(4, 1fr);
}
.radio-card {
  position: relative;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--paper);
  cursor: pointer;
  border-radius: 2px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.radio-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}
.radio-card:hover { border-color: var(--ink-soft); }
.radio-card:has(input:checked) {
  border-color: var(--ink);
  background: var(--paper-warm);
  box-shadow: inset 0 0 0 1px var(--ink);
}
.radio-title { font-weight: 600; font-size: 15px; }
.radio-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.radio-group.compact .radio-card {
  justify-content: center;
  font-family: 'IBM Plex Mono';
  font-weight: 600;
  padding: 16px 8px;
}
.radio-group.compact .radio-card > div { text-align: center; font-size: 15px; }

.checkbox-line {
  display: flex !important;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 2px;
  cursor: pointer;
}
.checkbox-line input { margin-top: 2px; }
.checkbox-line > span {
  display: inline !important;
  font-family: 'IBM Plex Sans' !important;
  font-size: 14px !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  color: var(--ink) !important;
  font-weight: 400 !important;
  margin: 0 !important;
}

.onb-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
}
.onb-actions button {
  padding: 12px 24px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
}
.onb-actions .onb-next, .onb-actions #finish {
  background: var(--ink);
  color: var(--paper);
  border: none;
  margin-left: auto;
}
.onb-actions .onb-next:hover, .onb-actions #finish:hover { background: var(--amber); color: var(--ink); }
.onb-actions .onb-back {
  background: none;
  border: 1px solid var(--line);
  color: var(--ink-soft);
}
.onb-actions .onb-back:hover { border-color: var(--ink); color: var(--ink); }

.onb-form .error { color: var(--alert); font-size: 13px; margin-top: 8px; }

/* --- Warqa brand mark (Arabic waw letter) --- */
.topbar .brand-mark {
  font-family: 'IBM Plex Sans Arabic', 'IBM Plex Sans', sans-serif;
  font-size: 22px;
  line-height: 1;
  font-weight: 500;
  letter-spacing: 0;
}
.auth-brand .brand-mark {
  font-family: 'IBM Plex Sans Arabic', 'IBM Plex Mono', monospace;
  font-size: 14px;
  letter-spacing: 0.08em;
}
.auth-brand .brand-mark::first-letter {
  font-size: 22px;
  vertical-align: -2px;
  margin-right: 8px;
}
/* --- Locked "System" tag on item labels --- */
.lock-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  font-family: 'IBM Plex Mono';
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: 2px;
  vertical-align: 2px;
  font-weight: 600;
}

/* --- Edit modal form --- */
.edit-form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.edit-form label { display: block; }
.edit-form label > span {
  display: block;
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.edit-form input, .edit-form select, .edit-form textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  border-radius: 2px;
  resize: vertical;
}
.edit-form input:focus, .edit-form select:focus, .edit-form textarea:focus {
  outline: none;
  border-color: var(--ink);
}
.edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}
.edit-actions button {
  padding: 10px 18px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
}
.edit-actions button[type="submit"] {
  background: var(--ink);
  color: var(--paper);
  border: none;
}
.edit-actions button[type="submit"]:hover { background: var(--amber); color: var(--ink); }
.edit-actions #cancelEdit {
  background: none;
  border: 1px solid var(--line);
  color: var(--ink-soft);
}
.edit-actions #cancelEdit:hover { border-color: var(--ink); color: var(--ink); }
.edit-error {
  color: var(--alert);
  font-size: 13px;
  margin-top: 4px;
  min-height: 18px;
}
/* --- Top nav for switching between modules --- */
.topnav {
  display: flex;
  gap: 4px;
  margin-left: auto;
  margin-right: 20px;
}
.topnav-link {
  padding: 8px 14px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: #B7BCC9;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 2px;
  transition: all 0.15s;
}
.topnav-link:hover {
  color: var(--amber);
  border-color: #2E3B4F;
}
.topnav-link.active {
  color: var(--paper);
  border-color: var(--amber);
  background: rgba(232, 163, 61, 0.08);
}
@media (max-width: 600px) {
  .topnav { display: none; } 
}

/* --- Topnav dropdown menus (Compliance, People) --- */
.topnav-menu {
  position: relative;
  display: inline-flex;
}
.topnav-menu-btn {
  padding: 8px 14px;
  background: none;
  border: 1px solid transparent;
  color: #B7BCC9;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  border-radius: 2px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: all 0.15s;
}
.topnav-menu-btn:hover {
  color: var(--amber);
  border-color: #2E3B4F;
}
.topnav-menu.active .topnav-menu-btn {
  color: var(--paper);
  border-color: var(--amber);
  background: rgba(232, 163, 61, 0.08);
}

.topnav-menu-caret {
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
  transition: transform 0.2s;
  display: inline-block;
}
.topnav-menu.open .topnav-menu-caret {
  transform: rotate(-135deg) translate(-1px, -1px);
}

.topnav-menu-panel {
  position: absolute;
  top: calc(100% + 14px);   /* sits below the topbar's amber underline */
  left: 0;
  min-width: 280px;
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 2px;
  box-shadow: 0 12px 32px rgba(15, 27, 45, 0.15);
  padding: 6px 0;
  z-index: 200;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
}
.topnav-menu.open .topnav-menu-panel {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.topnav-menu-panel a {
  display: block;
  padding: 12px 18px;
  text-decoration: none;
  color: var(--ink);
  border-left: 3px solid transparent;
  transition: background 0.1s, border-color 0.1s;
}
.topnav-menu-panel a:hover {
  background: var(--paper-warm);
  border-left-color: var(--amber);
}
.topnav-menu-panel a.current {
  background: rgba(232, 163, 61, 0.08);
  border-left-color: var(--amber);
}
.topnav-menu-panel .tm-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}
.topnav-menu-panel .tm-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* --- Primary "add" button next to section headers --- */
.primary-btn {
  padding: 9px 16px;
  background: var(--ink);
  color: var(--paper);
  border: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
}
.primary-btn:hover { background: var(--amber); color: var(--ink); }

/* --- "Show inactive" toggle in section headers --- */
.toggle-inactive {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'IBM Plex Mono';
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
}
.toggle-inactive input { accent-color: var(--ink); }

/* --- Month picker (top-right of payroll page) --- */
.month-picker {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--paper);
}
.month-nav {
  background: none;
  border: none;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 6px 12px;
  font-size: 16px;
  border-radius: 2px;
}
.month-nav:hover { background: var(--paper-warm); color: var(--ink); }
.month-label {
  font-family: 'IBM Plex Mono';
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 14px;
  min-width: 130px;
  text-align: center;
}

/* --- Status pill (Draft / Finalized) --- */
.status-pill {
  display: inline-block;
  padding: 6px 12px;
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  border-radius: 2px;
}
.status-pill.draft {
  background: var(--paper-warm);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.status-pill.finalized {
  background: rgba(74, 107, 92, 0.10);
  color: var(--sage);
  border: 1px solid var(--sage);
}

/* --- Roster table --- */
.roster-table {
  background: var(--paper);
  border: 1px solid var(--line);
}
.roster-head, .roster-row {
  display: grid;
  grid-template-columns: 2.4fr 1.1fr 0.9fr 1.1fr 1.2fr 0.9fr;
  gap: 12px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}
.roster-head {
  background: var(--paper-warm);
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.roster-row:last-child { border-bottom: none; }
.num-col { text-align: right; }
.roster-head .num-col { text-align: right; }

.employee-cell { line-height: 1.3; }
.employee-name { font-weight: 500; font-size: 15px; color: var(--ink); }
.employee-sub {
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 2px;
}
.line-warning {
  font-size: 11px;
  color: var(--alert);
  margin-top: 4px;
  font-weight: 500;
}

.line-input {
  width: 100%;
  padding: 7px 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  font-family: 'IBM Plex Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--ink);
  text-align: right;
  border-radius: 2px;
}
.line-input:focus {
  outline: none;
  border-color: var(--ink);
  background: var(--paper-warm);
}
.line-input:disabled {
  background: var(--paper-warm);
  color: var(--muted);
  cursor: not-allowed;
}

.net-cell {
  font-family: 'IBM Plex Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink);
  font-size: 14px;
}

.row-actions { text-align: right; }
button.tiny {
  padding: 5px 9px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: none;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: 2px;
}
button.tiny.danger:hover {
  background: var(--alert);
  color: var(--paper);
  border-color: var(--alert);
}

/* --- Bottom cycle actions bar --- */
.cycle-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 24px;
  margin-top: 20px;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: 2px;
}
.cycle-actions.hidden { display: none; }
.cycle-actions-note {
  font-size: 13px;
  color: var(--muted);
  max-width: 500px;
}
.ghost-btn {
  padding: 10px 16px;
  background: none;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
  margin-right: 8px;
}
.ghost-btn.hidden { display: none; }
.ghost-btn:hover { border-color: var(--ink); color: var(--ink); }
#finalizeBtn.hidden { display: none; }

/* --- Mobile / narrow screens: stack the roster --- */
@media (max-width: 800px) {
  .roster-head { display: none; }
  .roster-row {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 8px;
  }
  .num-col { text-align: left; }
  .num-col::before {
    content: attr(data-label);
    display: block;
    font-family: 'IBM Plex Mono';
    font-size: 10px;
    color: var(--muted);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-bottom: 4px;
  }
  .cycle-actions {
    flex-direction: column;
    gap: 14px;
    align-items: stretch;
  }
}
/* --- SIF section (after finalizing) --- */
.sif-wrap {
  margin-top: 24px;
  border: 1px solid var(--line);
  background: var(--paper);
}
.sif-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
  gap: 20px;
}
.sif-head h3 { margin: 6px 0 4px; font-size: 18px; font-weight: 500; letter-spacing: -0.01em; }
.sif-sub { color: var(--muted); font-size: 13px; margin: 0; }
.sif-sub .mono { font-family: 'IBM Plex Mono'; font-size: 12px; color: var(--ink-soft); }
.sif-download { white-space: nowrap; }

.sif-settings {
  padding: 20px 24px;
  background: rgba(232, 163, 61, 0.06);
  border-bottom: 1px solid var(--line);
}
.sif-settings-title {
  font-family: 'IBM Plex Mono';
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 14px;
}
.sif-settings-form {
  display: grid;
  grid-template-columns: 1.5fr 1fr auto;
  gap: 12px;
  align-items: end;
}
.sif-settings-form label { display: block; }
.sif-settings-form label > span {
  display: block;
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.sif-settings-form input {
  width: 100%;
  padding: 9px 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  border-radius: 2px;
}
.sif-settings-form input:focus { outline: none; border-color: var(--ink); }

.sif-warnings {
  padding: 18px 24px;
  background: rgba(196, 57, 42, 0.06);
  border-bottom: 1px solid var(--line);
}
.sif-warnings:last-child { border-bottom: none; }
.sif-warnings-title {
  font-family: 'IBM Plex Mono';
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--alert);
  margin-bottom: 10px;
}
.sif-warnings-title a {
  color: var(--alert);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.sif-warnings ul {
  margin: 0;
  padding-left: 18px;
  color: var(--ink-soft);
  font-size: 13px;
}
.sif-warnings li { margin-bottom: 4px; }

.sif-ok {
  padding: 18px 24px;
  font-family: 'IBM Plex Mono';
  font-size: 12px;
  color: var(--sage);
  letter-spacing: 0.04em;
}

@media (max-width: 700px) {
  .sif-head { flex-direction: column; align-items: stretch; }
  .sif-settings-form { grid-template-columns: 1fr; }
}

/* --- Critical SIF warnings (block download) --- */
.sif-warnings.critical {
  background: rgba(196, 57, 42, 0.08);
  border-bottom: 1px solid var(--line);
}
.sif-warnings.critical .sif-warnings-title { color: var(--alert); }

/* --- Advisory SIF warnings (verify but don't block) --- */
.sif-warnings.advisory {
  background: rgba(232, 163, 61, 0.10);
  border-bottom: 1px solid var(--line);
}
.sif-warnings.advisory .sif-warnings-title { color: var(--amber); }

.sif-warnings-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
.sif-warnings-hint a {
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: var(--amber);
}

/* --- Disabled download button --- */
.primary-btn.disabled,
.primary-btn:disabled {
  background: var(--paper-warm);
  color: var(--muted);
  border: 1px solid var(--line);
  cursor: not-allowed;
}
.primary-btn.disabled:hover,
.primary-btn:disabled:hover {
  background: var(--paper-warm);
  color: var(--muted);
}

/* --- Dashboard payroll widget --- */
.payroll-widget {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px 24px;
  margin-bottom: 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 2px;
}

.payroll-widget .pw-body { flex: 1; min-width: 0; }
.payroll-widget .pw-eyebrow {
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.payroll-widget .pw-title {
  margin: 6px 0 4px;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.payroll-widget .pw-sub {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
.payroll-widget .pw-amount {
  font-family: 'IBM Plex Mono';
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.payroll-widget .pw-cta {
  padding: 10px 16px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--paper);
  background: var(--ink);
  border-radius: 2px;
  white-space: nowrap;
}
.payroll-widget .pw-cta:hover { background: var(--amber); color: var(--ink); }
.payroll-widget .pw-cta.subtle {
  background: none;
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.payroll-widget .pw-cta.subtle:hover { border-color: var(--ink); color: var(--ink); }

/* Tier variants */
.payroll-widget.grey {
  border-left-color: var(--muted);
  background: var(--paper-warm);
}
.payroll-widget.amber-soft {
  border-left-color: var(--amber);
  background: rgba(232, 163, 61, 0.06);
}
.payroll-widget.sage {
  border-left-color: var(--sage);
  background: rgba(74, 107, 92, 0.06);
}
.payroll-widget.sage .pw-title { color: var(--sage); }
.payroll-widget.amber {
  border-left-color: var(--amber);
  background: rgba(232, 163, 61, 0.10);
}
.payroll-widget.amber .pw-title { color: var(--ink); }
.payroll-widget.red {
  border-left-color: var(--alert);
  background: #FDF6F3;
}
.payroll-widget.red .pw-title { color: var(--alert); }
.payroll-widget.red .pw-cta { background: var(--alert); }
.payroll-widget.red .pw-cta:hover { background: var(--alert-deep); color: var(--paper); }
.payroll-widget.resolved {
  border-left-color: var(--sage);
  background: var(--paper);
}
.payroll-widget.resolved .pw-title { color: var(--sage); }

/* Ticking clock dot */
.payroll-widget .pw-tick {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--amber);
  flex-shrink: 0;
}
.payroll-widget.red .pw-tick { background: var(--alert); }
.payroll-widget .pw-tick.pulsing {
  animation: pw-pulse 1.4s ease-in-out infinite;
}
@keyframes pw-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.75); }
}

.payroll-widget .pw-check {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--sage);
  color: var(--paper);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

/* Status pill: paid variant */
.status-pill.paid {
  background: rgba(74, 107, 92, 0.15);
  color: var(--sage);
  border: 1px solid var(--sage);
}

@media (max-width: 700px) {
  .payroll-widget {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }
  .payroll-widget .pw-cta { text-align: center; }
}
/* --- Business switcher (dropdown in the topbar) --- */
.business-switcher {
  position: relative;
  margin-right: 8px;
}
.business-switcher-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: none;
  border: 1px solid #2E3B4F;
  color: #B7BCC9;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 2px;
  max-width: 240px;
}
.business-switcher-btn:hover {
  border-color: var(--amber);
  color: var(--amber);
}
.business-switcher-btn .bs-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}
.business-switcher-btn .bs-caret {
  font-size: 10px;
  opacity: 0.7;
}

.business-switcher-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 280px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 2px;
  box-shadow: 0 8px 24px rgba(15, 27, 45, 0.15);
  z-index: 120;
  overflow: hidden;
}
.business-switcher-menu.hidden { display: none; }

.bs-option {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  border-bottom: 1px solid var(--line);
}
.bs-option:last-child { border-bottom: none; }
.bs-option:hover { background: var(--paper-warm); }
.bs-option.current { background: rgba(232, 163, 61, 0.06); }
.bs-option-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}
.bs-option-sub {
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 3px;
}
.bs-check {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--amber);
  font-weight: 700;
}
.bs-divider {
  height: 1px;
  background: var(--line);
}
.bs-option.bs-add {
  background: var(--paper-warm);
}
.bs-option.bs-add:hover {
  background: var(--amber-soft);
}
.bs-option.bs-add .bs-option-name {
  color: var(--ink);
  font-weight: 600;
}

@media (max-width: 700px) {
  .business-switcher-btn { max-width: 140px; }
  .business-switcher-btn .bs-label { max-width: 100px; font-size: 12px; }
}
/* --- Auto-calculated rate preview inside laborer modal --- */
.rate-preview {
  padding: 14px 16px;
  background: rgba(232, 163, 61, 0.06);
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  border-radius: 2px;
}
.rate-preview .eyebrow { display: block; margin-bottom: 8px; }
.rate-preview-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.rate-preview-values > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.rp-label {
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.rp-value {
  font-family: 'IBM Plex Mono';
  font-variant-numeric: tabular-nums;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

/* --- Ghost buttons in section headers (used for secondary actions) --- */
a.ghost-btn {
  display: inline-block;
  text-decoration: none;
  padding: 9px 14px;
  background: none;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 2px;
}
a.ghost-btn:hover { border-color: var(--ink); color: var(--ink); }

/* --- Tighter topnav for 4 links on narrow widths --- */
@media (max-width: 900px) {
  .topnav-link { padding: 8px 10px; font-size: 12px; }
}

/* --- Attendance page --- */
.date-picker-input {
  padding: 8px 12px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 2px;
  font-family: 'IBM Plex Mono';
  font-size: 13px;
  color: var(--ink);
  min-width: 160px;
}

.attendance-list {
  border-top: 1px solid var(--line);
}
.attendance-row {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  transition: background 0.15s;
}
.attendance-row.present { border-left: 3px solid var(--sage); }
.attendance-row.absent { border-left: 3px solid var(--line); }
.attendance-row.expanded { background: var(--paper-warm); }

.attendance-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 18px 20px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.attendance-row-head:hover { background: rgba(232, 163, 61, 0.04); }
.lab-info { flex: 1; min-width: 0; }
.lab-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 3px;
}
.lab-meta {
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.lab-status {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.attendance-row.present .status-dot { background: var(--sage); }
.lab-summary {
  font-family: 'IBM Plex Mono';
  font-size: 11px;
  color: var(--ink-soft);
  text-align: right;
}

/* Expanded entry form */
.attendance-form {
  padding: 4px 20px 20px 20px;
  border-top: 1px dashed var(--line);
}
.form-rows { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.entry-row {
  display: grid;
  grid-template-columns: 1fr 90px 90px 32px;
  gap: 10px;
  align-items: end;
  padding: 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 2px;
}
.entry-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.entry-label {
  font-family: 'IBM Plex Mono';
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.entry-input {
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 2px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  width: 100%;
  box-sizing: border-box;
}
.entry-input:focus { outline: none; border-color: var(--amber); }
.entry-remove {
  padding: 8px;
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  border-radius: 2px;
  font-size: 16px;
  line-height: 1;
}
.entry-remove:hover { color: var(--alert); border-color: var(--alert); }

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
  align-items: center;
}
.form-actions .primary-btn { margin-left: auto; }
.form-status {
  margin-top: 10px;
  font-family: 'IBM Plex Mono';
  font-size: 11px;
  letter-spacing: 0.06em;
}
.form-status.ok { color: var(--sage); }
.form-status.warn { color: var(--amber); }
.form-status.error { color: var(--alert); }

/* Mobile tightening */
@media (max-width: 700px) {
  .attendance-row-head { padding: 14px 16px; }
  .lab-name { font-size: 14px; }
  .lab-summary { font-size: 10px; max-width: 140px; }
  .entry-row {
    grid-template-columns: 1fr 1fr 32px;
    grid-template-areas:
      "proj proj remove"
      "reg  ot   .";
  }
  .entry-row .entry-field:nth-child(1) { grid-area: proj; }
  .entry-row .entry-field:nth-child(2) { grid-area: reg; }
  .entry-row .entry-field:nth-child(3) { grid-area: ot; }
  .entry-remove { grid-area: remove; align-self: start; }
  .form-actions .primary-btn { margin-left: 0; width: 100%; order: 10; }
}
/* --- Labour report page --- */
.labour-report-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.labour-report-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 3px solid var(--sage);
  border-radius: 2px;
  padding: 20px 24px;
}
.lr-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.lr-name {
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.lr-meta {
  margin-top: 4px;
  font-family: 'IBM Plex Mono';
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.lr-totals {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 220px;
}
.lr-total-line {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  font-family: 'IBM Plex Mono';
  font-size: 12px;
}
.lr-total-line .lr-total-label { color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.lr-total-line .lr-total-value { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.lr-total-line.lr-grand {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
.lr-total-line.lr-grand .lr-total-label { color: var(--ink); font-weight: 500; }
.lr-total-line.lr-grand .lr-total-value { color: var(--ink); font-weight: 600; }

.lr-projects-head {
  display: grid;
  grid-template-columns: 60px 1fr 70px 80px 80px 130px;
  gap: 12px;
  padding: 8px 4px;
  font-family: 'IBM Plex Mono';
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px dashed var(--line);
  margin-bottom: 4px;
}
.lr-project-row {
  display: grid;
  grid-template-columns: 60px 1fr 70px 80px 80px 130px;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}
.lr-project-row:last-child { border-bottom: none; }
.lr-project-code {
  font-family: 'IBM Plex Mono';
  font-weight: 600;
  color: var(--ink);
  font-size: 13px;
}
.lr-project-name {
  font-size: 13px;
  color: var(--ink-soft);
}
.lr-project-metric {
  font-family: 'IBM Plex Mono';
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--ink);
}
.lr-project-metric em {
  font-style: normal;
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
  margin-left: 4px;
}
.lr-project-cost {
  text-align: right;
  font-family: 'IBM Plex Mono';
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--ink);
}

/* --- Project costs page --- */
.project-cost-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.project-cost-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 3px solid var(--sage);
  border-radius: 2px;
  padding: 20px 24px;
}
.project-cost-card.soon { border-left-color: var(--amber); }
.project-cost-card.expired { border-left-color: var(--alert); }

.pc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.pc-code {
  font-family: 'IBM Plex Mono';
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--amber);
  font-weight: 600;
}
.pc-name {
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin-top: 2px;
}
.pc-meta {
  margin-top: 4px;
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.pc-total { text-align: right; min-width: 200px; }
.pc-total-label {
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.pc-total-value {
  margin-top: 4px;
  font-family: 'IBM Plex Mono';
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.pc-margin-block { margin-bottom: 16px; }
.pc-progress-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.pc-progress-label {
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.pc-progress-value {
  font-family: 'IBM Plex Mono';
  font-size: 12px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.pc-progress-bar {
  height: 8px;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: 1px;
  overflow: hidden;
}
.pc-progress-fill {
  height: 100%;
  background: var(--sage);
  transition: width 0.3s;
}
.pc-progress-fill.over { background: var(--alert); }

.pc-margin-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 10px;
}
.pc-margin-label {
  font-family: 'IBM Plex Mono';
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.pc-margin-value {
  font-family: 'IBM Plex Mono';
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.pc-margin-value.positive { color: var(--sage); }
.pc-margin-value.negative { color: var(--alert); }
.pc-margin-pct {
  font-weight: 400;
  color: var(--muted);
  margin-left: 4px;
}

.pc-no-quote {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 12px 14px;
  background: var(--paper-warm);
  border-radius: 2px;
  margin-bottom: 16px;
}
.pc-no-quote-hint { font-size: 12px; color: var(--muted); }
.pc-no-quote-hint a { color: var(--ink-soft); text-decoration: underline; text-decoration-color: var(--amber); }

.pc-laborers-head {
  display: grid;
  grid-template-columns: 1fr 70px 80px 80px 130px;
  gap: 12px;
  padding: 8px 4px;
  font-family: 'IBM Plex Mono';
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px dashed var(--line);
}
.pc-laborer-row {
  display: grid;
  grid-template-columns: 1fr 70px 80px 80px 130px;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}
.pc-laborer-row:last-child { border-bottom: none; }
.pc-laborer-name { font-size: 13px; color: var(--ink); }
.pc-laborer-metric {
  font-family: 'IBM Plex Mono';
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--ink);
}
.pc-laborer-metric em {
  font-style: normal;
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
  margin-left: 4px;
}
.pc-laborer-cost {
  text-align: right;
  font-family: 'IBM Plex Mono';
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

/* Print styles for both reports */
@media print {
  .no-print { display: none !important; }
  body { background: white; }
  main { max-width: none; padding: 0; }
  .labour-report-card, .project-cost-card {
    page-break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
}

/* Mobile tightening */
@media (max-width: 700px) {
  .lr-projects-head, .lr-project-row {
    grid-template-columns: 50px 1fr 60px 60px;
  }
  .lr-project-row .lr-project-metric:nth-child(5),
  .lr-projects-head span:nth-child(5) { display: none; }
  .lr-project-cost { grid-column: 1 / -1; text-align: left; padding-left: 62px; font-size: 12px; }
  .pc-laborers-head, .pc-laborer-row {
    grid-template-columns: 1fr 60px 60px;
  }
  .pc-laborer-row .pc-laborer-metric:nth-child(4),
  .pc-laborers-head span:nth-child(4) { display: none; }
  .pc-laborer-cost { grid-column: 1 / -1; text-align: left; font-size: 12px; }
  .pc-header { flex-direction: column; align-items: stretch; }
  .pc-total { text-align: left; }
}
/* Inline validation hints under auth inputs */
.inline-hint {
  margin-top: 4px;
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  letter-spacing: 0.05em;
  min-height: 12px;
  color: var(--muted);
}
.inline-hint.ok { color: var(--sage); }
.inline-hint.error { color: var(--alert); }

.password-rules-inline {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: 2px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.password-rules-inline > div {
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  letter-spacing: 0.03em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.password-rules-inline > div.met { color: var(--sage); }
.pri {
  display: inline-block;
  width: 10px;
  text-align: center;
  font-weight: 700;
}

/* Auth error banner */
.auth-error {
  margin-top: 4px;
  font-family: 'IBM Plex Mono';
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--alert);
  min-height: 0;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.2s, opacity 0.2s, padding 0.2s;
}
.auth-error.shown {
  max-height: 100px;
  opacity: 1;
  padding: 10px 14px;
  background: rgba(196, 57, 42, 0.06);
  border-left: 3px solid var(--alert);
  border-radius: 2px;
}
/* --- Onboarding header (skip link + brand mark) --- */
.onboarding-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.onboarding-header .brand-mark {
  font-family: 'IBM Plex Sans Arabic', 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--amber);
  font-weight: 600;
}
.skip-link {
  font-family: 'IBM Plex Mono';
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}
.skip-link:hover { color: var(--ink); }

/* --- Small text label above radio-groups etc. --- */
.onb-field-label {
  display: block;
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

/* --- Module selection cards on step 2 --- */
.module-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.module-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  background: var(--paper);
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.15s;
}
.module-card input[type="checkbox"] {
  margin-top: 2px;
  accent-color: var(--ink);
}
.module-card:hover { border-color: var(--ink-soft); }
.module-card:has(input:checked) {
  border-color: var(--ink);
  background: var(--paper-warm);
  box-shadow: inset 0 0 0 1px var(--ink);
}
.mc-body { flex: 1; }
.mc-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  margin-bottom: 3px;
}
.mc-sub {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}
.mc-tag {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 8px;
  font-family: 'IBM Plex Mono';
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--amber);
  background: rgba(232, 163, 61, 0.10);
  border-radius: 2px;
}

/* --- Reminder chips (step 3) --- */
.reminder-preview {
  padding: 20px 22px;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: 2px;
}
.reminder-preview .eyebrow { display: block; margin-bottom: 12px; }
.reminder-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.reminder-chip {
  position: relative;
  padding: 10px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 2px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink);
}
.reminder-chip input {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}
.reminder-chip:has(input:checked) {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.reminder-note {
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
}

/* --- Summary block on step 4 --- */
.summary-block {
  padding: 20px 24px;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: 2px;
  margin-bottom: 20px;
}
.summary-line {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.summary-line:last-child { border-bottom: none; }
.summary-label {
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.summary-value {
  font-size: 14px;
  color: var(--ink);
  font-weight: 500;
  text-align: right;
}

.summary-modules {
  padding: 20px 24px;
  border: 1px solid var(--line);
  border-radius: 2px;
}
.summary-modules .eyebrow { display: block; margin-bottom: 12px; }
.summary-module {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.summary-module:last-child { border-bottom: none; }
.summary-module-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--sage);
  margin-bottom: 2px;
}
.summary-module-hint {
  font-size: 12px;
  color: var(--muted);
}

/* Larger primary button for the finish step */
.primary-btn-large {
  padding: 14px 28px;
  background: var(--ink);
  color: var(--paper);
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
  margin-left: auto;
}
.primary-btn-large:hover { background: var(--amber); color: var(--ink); }
.primary-btn-large:disabled {
  background: var(--paper-warm);
  color: var(--muted);
  cursor: not-allowed;
}
.onb-error {
  color: var(--alert);
  font-size: 13px;
  margin-top: 12px;
  min-height: 18px;
  text-align: right;
}
/* --- Warm empty-state cards --- */
.empty-state-card {
  padding: 40px 32px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  border-radius: 2px;
  text-align: left;
  max-width: 640px;
}
.empty-state-card .eyebrow {
  display: block;
  margin-bottom: 10px;
}
.empty-state-title {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.empty-state-body {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  max-width: 540px;
}
.empty-state-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.empty-state-actions .primary-btn {
  padding: 12px 20px;
  font-size: 12px;
  text-decoration: none;
  display: inline-block;
}
.empty-state-secondary {
  font-family: 'IBM Plex Mono';
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}
.empty-state-secondary:hover {
  color: var(--ink);
}
.step-pill {
  cursor: pointer;
  transition: all 0.2s ease;
}

.step-pill:hover:not(.current) {
  background-color: rgba(0, 0, 0, 0.05);
  transform: translateY(-1px);
}

.step-pill.current {
  cursor: default;
}

.step-pill.done {
  cursor: pointer;
}

.step-pill.done:hover {
  background-color: rgba(0, 128, 0, 0.1);
}

/* Style for disabled step pills (future steps) */
.step-pill:not(.done):not(.current) {
  opacity: 0.6;
  cursor: not-allowed;
}

.step-pill:not(.done):not(.current):hover {
  transform: none;
}
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
  width: 100%;
  pointer-events: none;
}

.toast {
  background: white;
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  border-left: 4px solid #e74c3c;
  pointer-events: auto;
  animation: slideInRight 0.3s ease;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.toast.success {
  border-left-color: #2ecc71;
}

.toast.warning {
  border-left-color: #f39c12;
}

.toast.info {
  border-left-color: #3498db;
}

.toast-icon {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  font-size: 14px;
  color: #2d3748;
  margin-bottom: 4px;
}

.toast-message {
  font-size: 13px;
  color: #4a5568;
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  color: #a0aec0;
  cursor: pointer;
  font-size: 18px;
  padding: 0 0 0 8px;
  flex-shrink: 0;
  line-height: 1;
}

.toast-close:hover {
  color: #4a5568;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.toast.hiding {
  animation: slideOutRight 0.3s ease forwards;
}

/* ============================================
   In-App Modal Dialog
   ============================================ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden {
  display: none;
}

.modal-box {
  background: white;
  border-radius: 16px;
  padding: 32px;
  max-width: 440px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  animation: scaleIn 0.2s ease;
}

.modal-icon {
  font-size: 40px;
  text-align: center;
  margin-bottom: 12px;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: #2d3748;
  text-align: center;
  margin-bottom: 8px;
}

.modal-message {
  font-size: 14px;
  color: #4a5568;
  text-align: center;
  line-height: 1.5;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.modal-actions button {
  padding: 10px 24px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-btn-primary {
  background: #2d3748;
  color: white;
}

.modal-btn-primary:hover {
  background: #1a202c;
}

.modal-btn-secondary {
  background: #edf2f7;
  color: #2d3748;
}

.modal-btn-secondary:hover {
  background: #e2e8f0;
}

.modal-btn-danger {
  background: #e74c3c;
  color: white;
}

.modal-btn-danger:hover {
  background: #c0392b;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
#setExpiryModal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#setExpiryModal.hidden {
  display: none !important;
}

#setExpiryModal .modal-body {
  background: white;
  border-radius: 16px;
  padding: 32px;
  max-width: 440px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  position: relative;
  animation: scaleIn 0.2s ease;
}

#setExpiryModal .modal-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  font-size: 24px;
  color: #a0aec0;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

#setExpiryModal .modal-close:hover {
  color: #4a5568;
}

#setExpiryModal .modal-body .eyebrow {
  display: block;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a0aec0;
  margin-bottom: 4px;
}

#setExpiryModal .modal-body h3 {
  font-size: 20px;
  font-weight: 600;
  color: #2d3748;
  margin: 0 0 20px 0;
}

#setExpiryModal .edit-form label {
  display: block;
  margin-bottom: 16px;
}

#setExpiryModal .edit-form label span {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #2d3748;
  margin-bottom: 6px;
}

#setExpiryModal .edit-form input[type="date"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  color: #2d3748;
  background: white;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

#setExpiryModal .edit-form input[type="date"]:focus {
  outline: none;
  border-color: #4299e1;
  box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

#setExpiryModal .edit-error {
  color: #e74c3c;
  font-size: 13px;
  margin: 8px 0 12px 0;
  min-height: 20px;
}

#setExpiryModal .edit-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 8px;
}

#setExpiryModal .edit-actions button {
  padding: 10px 24px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

#setExpiryModal .edit-actions button[type="button"] {
  background: #edf2f7;
  color: #2d3748;
}

#setExpiryModal .edit-actions button[type="button"]:hover {
  background: #e2e8f0;
}

#setExpiryModal .edit-actions button[type="submit"] {
  background: #2d3748;
  color: white;
}

#setExpiryModal .edit-actions button[type="submit"]:hover {
  background: #1a202c;
}

@keyframes scaleIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.bs-section-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a0aec0;
  padding: 8px 16px 4px;
  font-weight: 600;
}

.bs-item.draft {
  background: #f7fafc;
  opacity: 0.8;
}

.bs-item.draft:hover {
  background: #edf2f7;
  opacity: 1;
}

.bs-draft-badge {
  font-size: 10px;
  background: #edf2f7;
  color: #4a5568;
  padding: 2px 8px;
  border-radius: 12px;
  margin-left: auto;
  font-weight: 500;
  letter-spacing: 0.03em;
}

.bs-delete-draft {
  background: none;
  border: none;
  color: #a0aec0;
  cursor: pointer;
  padding: 2px 6px;
  font-size: 14px;
  border-radius: 4px;
  transition: all 0.2s ease;
  margin-left: 4px;
}

.bs-delete-draft:hover {
  color: #e74c3c;
  background: #fff5f5;
}

.bs-divider {
  height: 1px;
  background: #e2e8f0;
  margin: 6px 12px;
}

.bs-item.add-business {
  color: #4299e1;
  font-weight: 500;
}

.bs-item.add-business:hover {
  background: #ebf8ff;
  color: #2b6cb0;
}
/* Notes display styles */
.item-notes {
  font-size: 0.85em;
  color: #666;
  margin-top: 4px;
  padding: 4px 8px;
  background: #f8f9fa;
  border-radius: 4px;
  border-left: 3px solid #d1d5db;
  font-style: italic;
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-row .item-notes {
  display: block;
}

/* Ensure edit modal authority dropdown looks consistent */
#editAuthority {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.95rem;
  background: white;
}

/* Modal form labels */
.edit-form label {
  display: block;
  margin-bottom: 12px;
}

.edit-form label span {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 4px;
}

/* Modal improvements */
.modal-body {
  max-width: 500px;
  width: 90%;
  background: white;
  border-radius: 12px;
  padding: 24px;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #9ca3af;
  transition: color 0.2s;
}

.modal-close:hover {
  color: #374151;
}

.edit-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

.edit-actions button {
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: white;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.edit-actions button[type="submit"] {
  background: #2563eb;
  color: white;
  border-color: #2563eb;
}

.edit-actions button[type="submit"]:hover {
  background: #1d4ed8;
}

.edit-actions button[type="button"]:hover {
  background: #f3f4f6;
}

.edit-error {
  color: #dc2626;
  font-size: 0.9rem;
  margin-top: 8px;
}

.invalid {
  border-color: #dc2626 !important;
  background: #fef2f2 !important;
}

.invalid:focus {
  border-color: #dc2626 !important;
  outline: 2px solid rgba(220, 38, 38, 0.2) !important;
}

.field-error {
  color: #dc2626;
  font-size: 0.85rem;
  margin-top: 4px;
  display: none;
}

.field-error.show {
  display: block;
}
/* Company details saved display */
.sif-settings-saved {
  display: flex;
  gap: 24px;
  padding: 12px 0;
  flex-wrap: wrap;
  align-items: center;
}

.sif-settings-saved > div {
  background: var(--paper);
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 2px;
}

.sif-settings-saved > div span:first-child {
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-bottom: 4px;
}

.sif-settings-saved > div span:last-child {
  font-family: 'IBM Plex Mono';
  font-size: 14px;
  font-weight: 500;
}

.sif-settings-saved .ghost-btn {
  margin-left: auto;
}
/* --- Invoice register --- */
.invoice-list { border-top: 1px solid var(--line); }
.invoice-list-head {
  display: grid;
  grid-template-columns: 100px 150px 1fr 120px 120px 100px 150px;
  gap: 16px;
  padding: 12px 16px;
  font-family: 'IBM Plex Mono';
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.invoice-row {
  display: grid;
  grid-template-columns: 100px 150px 1fr 120px 120px 100px 150px;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  align-items: center;
  border-left: 3px solid transparent;
}
.invoice-row.ok { border-left-color: var(--sage); }
.invoice-row.soon { border-left-color: var(--amber); background: rgba(232, 163, 61, 0.04); }
.invoice-row.expired { border-left-color: var(--alert); background: rgba(196, 57, 42, 0.04); }
.invoice-row .num-col { text-align: right; }
.invoice-date { font-size: 12px; color: var(--ink-soft); }
.invoice-number { display: flex; flex-direction: column; gap: 4px; }
.invoice-number .mono { font-size: 13px; color: var(--ink); }
.direction-tag {
  display: inline-block;
  padding: 2px 6px;
  font-family: 'IBM Plex Mono';
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  border-radius: 2px;
  width: fit-content;
}
.direction-tag.input { background: rgba(74, 107, 92, 0.15); color: var(--sage); }
.direction-tag.output { background: rgba(232, 163, 61, 0.15); color: var(--amber); }
.invoice-supplier { min-width: 0; }
.invoice-supplier > div:first-child {
  font-size: 13px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.supplier-trn {
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-top: 2px;
}
.delta-cell { font-weight: 600; }
.invoice-row.ok .delta-cell { color: var(--muted); }
.invoice-row.soon .delta-cell { color: var(--amber); }
.invoice-row.expired .delta-cell { color: var(--alert); }

/* --- OCR processing state --- */
.ocr-processing {
  padding: 20px 24px;
  background: rgba(232, 163, 61, 0.06);
  border: 1px solid var(--amber);
  border-left-width: 4px;
  border-radius: 2px;
  margin-bottom: 24px;
}
.ocr-processing-inner { display: flex; align-items: center; gap: 16px; }
.ocr-processing-title {
  font-family: 'IBM Plex Mono';
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber);
  font-weight: 600;
}
.ocr-processing-hint {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 3px;
}
.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--amber);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Entry modal --- */
.modal-body.wide { max-width: 900px; }
.entry-form-wrap { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 900px) {
  .entry-form-wrap:has(.ocr-preview-panel:not(.hidden)) { grid-template-columns: 1fr 280px; }
}
.entry-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.hint-text {
  font-family: 'IBM Plex Mono';
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-style: normal;
  margin-left: 6px;
  text-transform: uppercase;
}
.supplier-memory-hint {
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--sage);
  margin-left: 8px;
  font-style: normal;
  text-transform: uppercase;
}
.trn-warning {
  margin-top: 4px;
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  letter-spacing: 0.04em;
}
.trn-warning.warn { color: var(--amber); }
.trn-warning.error { color: var(--alert); }

/* Delta preview inside the form */
.delta-preview {
  padding: 14px 16px;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: 2px;
  transition: all 0.15s;
}
.delta-preview.ok { border-left-color: var(--sage); background: rgba(74, 107, 92, 0.06); }
.delta-preview.warn { border-left-color: var(--amber); background: rgba(232, 163, 61, 0.08); }
.delta-preview.error { border-left-color: var(--alert); background: rgba(196, 57, 42, 0.08); }
.delta-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 4px 0;
}
.delta-row .delta-label {
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.delta-row .delta-value {
  font-family: 'IBM Plex Mono';
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  color: var(--ink);
  font-weight: 500;
}
.delta-flag {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-family: 'IBM Plex Mono';
  font-size: 11px;
  letter-spacing: 0.04em;
}
.delta-flag.ok { color: var(--sage); }
.delta-flag.warn { color: var(--amber); }
.delta-flag.error { color: var(--alert); }

/* OCR confidence card */
.ocr-confidence {
  padding: 12px 14px;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: 2px;
}
.ocr-confidence .eyebrow { display: block; margin-bottom: 4px; }
.ocr-confidence span:last-child { font-family: 'IBM Plex Mono'; font-size: 12px; }
.ocr-confidence span.ok { color: var(--sage); }
.ocr-confidence span.warn { color: var(--amber); }
.ocr-confidence span.error { color: var(--alert); }

/* OCR preview panel (image thumbnail) */
.ocr-preview-panel {
  padding: 12px;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: 2px;
}
.ocr-preview-panel img {
  width: 100%;
  height: auto;
  max-height: 400px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 2px;
  margin-top: 8px;
}

.mono { font-family: 'IBM Plex Mono'; font-variant-numeric: tabular-nums; }

/* Mobile invoice list — stack rows */
@media (max-width: 900px) {
  .invoice-list-head { display: none; }
  .invoice-row {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "supplier supplier"
      "date number"
      "taxable vat"
      "delta actions";
    gap: 8px;
  }
  .invoice-supplier { grid-area: supplier; }
  .invoice-date { grid-area: date; }
  .invoice-number { grid-area: number; }
  .invoice-row .num-col:nth-child(4) { grid-area: taxable; text-align: left; }
  .invoice-row .num-col:nth-child(5) { grid-area: vat; text-align: left; }
  .invoice-row .delta-cell { grid-area: delta; text-align: left; }
  .invoice-row .row-actions { grid-area: actions; justify-self: end; }
}
.ocr-processing.hidden { display: none; }

.hidden { display: none !important; }

.section-head-actions select,
.entry-form-row select,
.edit-form select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 9px 32px 9px 14px;
  background-color: var(--paper);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%236B7280' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  border: 1px solid var(--line);
  border-radius: 2px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink);
  cursor: pointer;
  min-width: 160px;
  transition: border-color 0.15s;
}
.section-head-actions select:hover,
.entry-form-row select:hover,
.edit-form select:hover {
  border-color: var(--ink-soft);
}
.section-head-actions select:focus,
.entry-form-row select:focus,
.edit-form select:focus {
  outline: none;
  border-color: var(--ink);
  background-color: var(--paper-warm);
}

/* Style the options inside (browser-supported only in some) */
.section-head-actions select option,
.entry-form-row select option,
.edit-form select option {
  font-family: inherit;
  padding: 8px;
}

/* --- Row action buttons (Edit / Delete on list rows) --- */
.item-actions button,
.row-actions button,
.invoice-row .row-actions button {
  padding: 6px 12px;
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  font-family: 'IBM Plex Mono';
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.15s;
}
.item-actions button:hover,
.row-actions button:hover,
.invoice-row .row-actions button:hover {
  color: var(--ink);
  border-color: var(--ink);
  background: var(--paper-warm);
}

/* Danger variant (Delete) — quieter default, red on hover */
.item-actions button.danger,
.row-actions button.danger,
.invoice-row .row-actions button.danger {
  color: var(--muted);
}
.item-actions button.danger:hover,
.row-actions button.danger:hover,
.invoice-row .row-actions button.danger:hover {
  color: var(--alert);
  border-color: var(--alert);
  background: rgba(196, 57, 42, 0.06);
}

/* Ghost-btn size variant used inline (e.g. Set date, Checklist) */
.item-actions button.ghost-btn {
  padding: 6px 12px;
  font-size: 10px;
}

/* Row-actions container gets a consistent gap */
.row-actions,
.item-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.entry-form-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

/* When preview panel is hidden, completely remove it from layout */
.ocr-preview-panel.hidden {
  display: none !important;
}

/* When preview is hidden, make form take full width */
.entry-form-wrap:has(.ocr-preview-panel.hidden) {
  grid-template-columns: 1fr;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .entry-form-wrap {
    grid-template-columns: 1fr;
  }
  
  .entry-form-wrap .ocr-preview-panel {
    grid-column: 1;
    position: static;
  }
}

/* --- Custom Dropdown Container --- */
.custom-dropdown {
  position: relative;
  display: inline-block;
  width: 100%;
  min-width: 160px;
  font-family: 'IBM Plex Sans', -apple-system, sans-serif;
  z-index: 1;
}

.custom-dropdown {
  position: relative;
  display: inline-block;
  width: 100%;
  min-width: 160px;
  font-family: 'IBM Plex Sans', -apple-system, sans-serif;
}

.custom-dropdown-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--ink);
  font-family: 'IBM Plex Sans', -apple-system, sans-serif;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  gap: 12px;
  min-height: 44px;
}

.custom-dropdown-trigger:hover {
  border-color: var(--ink-soft);
  background: var(--paper-warm);
}

.custom-dropdown-trigger:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(15, 27, 45, 0.08);
}

.custom-dropdown-trigger .dropdown-text {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.custom-dropdown-trigger .dropdown-arrow {
  flex-shrink: 0;
  width: 10px;
  height: 6px;
  margin-left: 8px;
  transition: transform 0.2s ease;
  pointer-events: none;
}

.custom-dropdown-trigger .dropdown-arrow svg {
  display: block;
  width: 100%;
  height: 100%;
}

.custom-dropdown.open .dropdown-arrow {
  transform: rotate(180deg);
}

.custom-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 2px;
  box-shadow: 0 8px 24px rgba(15, 27, 45, 0.12);
  max-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  display: none;
  -webkit-overflow-scrolling: touch;
  min-width: 100%;
}

.custom-dropdown-menu.open-upward {
  top: auto;
  bottom: calc(100% + 4px);
}

.custom-dropdown-menu::-webkit-scrollbar {
  width: 6px;
  background: transparent;
}

.custom-dropdown-menu::-webkit-scrollbar-track {
  background: var(--paper-warm);
  border-radius: 2px;
}

.custom-dropdown-menu::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 2px;
}

.custom-dropdown-menu::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

.custom-dropdown.open .custom-dropdown-menu {
  display: block;
  animation: dropdownSlideIn 0.15s ease;
}

@keyframes dropdownSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.custom-dropdown-option {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-family: 'IBM Plex Sans', -apple-system, sans-serif;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.1s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 44px;
}

.custom-dropdown-option:last-child {
  border-bottom: none;
}

.custom-dropdown-option:hover {
  background: var(--paper-warm);
}

.custom-dropdown-option.selected {
  background: rgba(232, 163, 61, 0.08);
  color: var(--ink);
  font-weight: 500;
  position: relative;
  padding-right: 40px;
}

.custom-dropdown-option.selected::after {
  content: '✓';
  position: absolute;
  right: 14px;
  color: var(--amber);
  font-weight: 600;
}

.custom-dropdown-option.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.custom-dropdown-option.disabled:hover {
  background: none;
}

.custom-dropdown-trigger.placeholder {
  color: var(--muted);
}

.custom-dropdown.disabled .custom-dropdown-trigger {
  background: var(--paper-warm);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.7;
}

.custom-dropdown.disabled .custom-dropdown-trigger:hover {
  border-color: var(--line);
  background: var(--paper-warm);
}

.custom-dropdown.disabled .custom-dropdown-arrow {
  opacity: 0.4;
}

.custom-dropdown.small .custom-dropdown-trigger {
  padding: 6px 10px;
  font-size: 12px;
  min-height: 36px;
}

.custom-dropdown.small .custom-dropdown-option {
  padding: 8px 12px;
  font-size: 12px;
  min-height: 36px;
}

.custom-dropdown.large .custom-dropdown-trigger {
  padding: 12px 16px;
  font-size: 16px;
  min-height: 48px;
}

.custom-dropdown.large .custom-dropdown-option {
  padding: 12px 16px;
  font-size: 16px;
  min-height: 48px;
}

.custom-dropdown.inline {
  display: inline-flex;
  width: auto;
}

.custom-dropdown.inline .custom-dropdown-trigger {
  min-width: 120px;
}

.modal-body .custom-dropdown {
  width: 100%;
}

.custom-dropdown-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 999;
  display: none;
}

.custom-dropdown.open ~ .custom-dropdown-backdrop {
  display: block;
}

[dir="rtl"] .custom-dropdown-trigger .dropdown-text {
  text-align: right;
}

[dir="rtl"] .custom-dropdown-trigger .dropdown-arrow {
  margin-left: 0;
  margin-right: 8px;
}

[dir="rtl"] .custom-dropdown-option.selected::after {
  right: auto;
  left: 14px;
}

.custom-dropdown-trigger:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

@media (max-width: 768px) {
  .custom-dropdown-trigger {
    min-height: 48px;
    padding: 12px 16px;
  }
  
  .custom-dropdown-option {
    min-height: 48px;
    padding: 12px 16px;
  }
  
  .custom-dropdown-menu {
    max-height: 240px;
  }
}

.onboarding .custom-dropdown {
  z-index: 10;
}

.onboarding .custom-dropdown.open {
  z-index: 100;
}

.onboarding .custom-dropdown-menu {
  max-height: 200px;
}

.modal-body .custom-dropdown-menu {
  max-height: 180px;
}

@media (max-width: 480px) {
  .custom-dropdown-menu {
    max-height: 160px;
  }
}

/* Full-screen image viewer */
.image-viewer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.image-viewer-overlay.hidden {
  display: none;
}

.image-viewer-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  font-size: 32px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 10001;
}

.image-viewer-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.image-viewer-controls {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  border-radius: 12px;
  padding: 8px 16px;
  z-index: 10001;
}

.image-viewer-controls button {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.image-viewer-controls button:hover {
  background: rgba(255, 255, 255, 0.35);
}

#zoomLevel {
  color: white;
  font-size: 13px;
  font-weight: 500;
  min-width: 48px;
  text-align: center;
}

.image-viewer-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: grab;
}

.image-viewer-container:active {
  cursor: grabbing;
}

.image-viewer-container.zoomed-in {
  cursor: grab;
}

#imageViewerImage {
  max-width: 90%;
  max-height: 85vh;
  object-fit: contain;
  transition: transform 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  user-select: none;
  pointer-events: none;
}

.image-viewer-footer {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
}

.image-viewer-container {
  padding: 60px 20px;
  box-sizing: border-box;
  overflow: hidden;
}
#imageViewerImage,
.image-viewer-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  transform-origin: center center;
  transition: opacity 0.15s;  
  user-select: none;
  -webkit-user-drag: none;
}

/* Loading indicator */
.image-viewer-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.7);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.image-viewer-loading.hidden { display: none; }
.iv-hint-mobile { display: none; }
@media (hover: none) and (pointer: coarse) {
  .iv-hint-desktop { display: none; }
  .iv-hint-mobile { display: inline; }
}

/* Make the OCR preview clickable */
.ocr-preview-panel {
  cursor: default;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.ocr-preview-panel img {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

/* Remove the "Click to enlarge" text */
.ocr-preview-panel::after {
  display: none;
}


/* --- PDF Viewer Modal (Warqa palette) --- */
.pdf-viewer-modal {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pdf-viewer-modal.hidden { display: none; }

.pdf-viewer-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 27, 45, 0.72);
  backdrop-filter: blur(3px);
}

.pdf-viewer-content {
  position: relative;
  width: 90vw;
  max-width: 1000px;
  height: 90vh;
  max-height: 900px;
  background: var(--paper);
  border-radius: 2px;
  border-top: 4px solid var(--amber);
  box-shadow: 0 20px 60px rgba(15, 27, 45, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pdfSlideUp 0.22s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes pdfSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Header — filename + close */
.pdf-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--paper-warm);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.pdf-viewer-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.pdf-icon { font-size: 16px; }
.pdf-viewer-filename {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pdf-viewer-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.pdf-viewer-close:hover {
  border-color: var(--alert);
  color: var(--alert);
  background: rgba(196, 57, 42, 0.06);
}

/* Body — the actual PDF canvas area */
.pdf-viewer-body {
  flex: 1;
  min-height: 0;
  position: relative;
  background: #2A3546;   /* deeper than ink-soft — reads as a "workspace" */
  overflow: hidden;
}

.pdf-canvas-wrap {
  position: absolute;
  inset: 0;
  overflow: auto;
  display: flex;
  align-items: safe center;
  justify-content: safe center;
  padding: 16px;
  transition: opacity 0.2s;
  -webkit-overflow-scrolling: touch;
}

.pdf-canvas {
  background: white;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  display: block;
  transform-origin: center center;
  will-change: transform;
}

/* Loading + error overlay */
.pdf-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--paper);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  z-index: 2;
}
.pdf-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: pdfSpin 0.8s linear infinite;
}
@keyframes pdfSpin { to { transform: rotate(360deg); } }
.pdf-error-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--alert);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
}
.pdf-error-msg {
  color: var(--paper);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  max-width: 320px;
  text-align: center;
  line-height: 1.5;
}

/* Toolbar — nav on left, zoom on right */
.pdf-viewer-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: var(--paper-warm);
  border-top: 1px solid var(--line);
  gap: 12px;
  flex-shrink: 0;
}
.pdf-nav, .pdf-zoom {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pdf-nav-btn, .pdf-zoom-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.pdf-nav-btn:hover:not(:disabled),
.pdf-zoom-btn:hover {
  border-color: var(--ink);
  color: var(--ink);
  background: var(--paper);
}
.pdf-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.pdf-nav-btn { font-size: 20px; }

.pdf-page-info {
  padding: 0 12px;
  font-family: 'IBM Plex Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--ink);
  letter-spacing: 0.04em;
  min-width: 60px;
  text-align: center;
}
.pdf-page-sep { color: var(--muted); margin: 0 4px; }

.pdf-zoom-level {
  padding: 0 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--ink);
  letter-spacing: 0.04em;
  min-width: 44px;
  text-align: center;
}

/* Footer — download only */
.pdf-viewer-footer {
  display: flex;
  justify-content: flex-end;
  padding: 12px 20px;
  background: var(--paper);
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.pdf-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: 2px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s;
}
.pdf-download-btn:hover { background: var(--amber); color: var(--ink); }
.pdf-download-icon { font-size: 14px; }
.pdf-download-btn {
  padding: 6px 16px;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s;
}

.pdf-download-btn:hover {
  background: #2563eb;
}

/* File type badges for invoice list */
.file-type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.file-type-badge.pdf {
  background: #dbeafe;
  color: #1e40af;
}

.file-type-badge.image {
  background: #fef3c7;
  color: #92400e;
}

/* PDF placeholder in edit modal */
.pdf-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  background: #f9fafb;
  border-radius: 6px;
  border: 2px dashed #d1d5db;
  padding: 16px;
}

.pdf-placeholder-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.pdf-placeholder-icon {
  font-size: 40px;
}

.pdf-placeholder-text {
  font-size: 13px;
  color: #6b7280;
  font-weight: 500;
}

.pdf-view-btn {
  padding: 6px 16px;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s;
}

.pdf-view-btn:hover {
  background: #2563eb;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .pdf-viewer-content {
    width: 95vw;
    height: 95vh;
  }

  .pdf-viewer-header {
    padding: 10px 14px;
  }

  .pdf-viewer-title {
    font-size: 13px;
  }

  .pdf-control-btn {
    width: 26px;
    height: 26px;
    font-size: 12px;
  }

  .pdf-container {
    padding: 10px;
  }

  .pdf-page-info {
    font-size: 12px;
    min-width: 80px;
  }
  
  .row-actions .view-btn {
    font-size: 11px;
    padding: 2px 8px;
  }
}

#imagePlaceholder img {
  max-width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: 4px;
  margin-bottom: 8px;
}
.greeting {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin: 24px 0 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
  }
  .greeting h1 {
    font-size: 28px;
    font-weight: 400;
    letter-spacing: -0.02em;
    margin: 0;
    color: var(--ink);
  }
  .greeting h1 em {
    font-style: normal;
    font-weight: 500;
    color: var(--amber);
  }
  .greeting .today {
    font-family: 'IBM Plex Mono';
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
  }

  /* --- Attention row (top status tiles) --- */
  .attention-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 32px;
  }
  .attention-tile {
    padding: 20px 22px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-left: 4px solid var(--sage);
    border-radius: 2px;
    text-decoration: none;
    color: var(--ink);
    transition: border-color 0.15s, transform 0.1s;
    cursor: pointer;
  }
  .attention-tile:hover { transform: translateY(-1px); }
  .attention-tile.warn { border-left-color: var(--amber); background: rgba(232, 163, 61, 0.04); }
  .attention-tile.alert { border-left-color: var(--alert); background: rgba(196, 57, 42, 0.04); }
  .attention-tile .tile-eyebrow {
    display: block;
    font-family: 'IBM Plex Mono';
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
  }
  .attention-tile .tile-count {
    font-family: 'IBM Plex Mono';
    font-variant-numeric: tabular-nums;
    font-size: 32px;
    font-weight: 500;
    letter-spacing: -0.02em;
    line-height: 1;
    color: var(--ink);
  }
  .attention-tile.warn .tile-count { color: var(--amber); }
  .attention-tile.alert .tile-count { color: var(--alert); }
  .attention-tile .tile-hint {
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
  }
  .all-clear-banner {
    padding: 20px 24px;
    background: rgba(74, 107, 92, 0.06);
    border: 1px solid var(--sage);
    border-left: 4px solid var(--sage);
    border-radius: 2px;
    margin-bottom: 32px;
    display: flex;
    align-items: center;
    gap: 14px;
  }
  .all-clear-banner .check-circle {
    width: 34px;
    height: 34px;
    background: var(--sage);
    color: var(--paper);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
  }
  .all-clear-banner h3 {
    margin: 0 0 2px;
    font-size: 15px;
    font-weight: 500;
    color: var(--sage);
  }
  .all-clear-banner p {
    margin: 0;
    font-size: 13px;
    color: var(--ink-soft);
  }

  /* --- Quick actions --- */
  .quick-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 32px;
  }
  .quick-action {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 120px;
    padding: 20px 22px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 2px;
    text-decoration: none;
    color: var(--ink);
    transition: border-color 0.15s, background 0.15s;
  }
  .quick-action:hover {
    border-color: var(--ink);
    background: var(--paper-warm);
  }
  .qa-icon {
    font-size: 22px;
    line-height: 1;
    color: var(--amber);
    margin-bottom: 12px;
  }
  .qa-title {
    font-weight: 500;
    font-size: 16px;
    color: var(--ink);
    margin-bottom: 4px;
  }
  .qa-hint {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
  }
  .qa-arrow {
    margin-top: 12px;
    font-family: 'IBM Plex Mono';
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .quick-action:hover .qa-arrow { color: var(--ink); }

  /* --- Recent activity --- */
  .activity-list {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 2px;
  }
  .activity-row {
    display: grid;
    grid-template-columns: 100px 1fr auto;
    gap: 20px;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
  }
  .activity-row:last-child { border-bottom: none; }
  .activity-when {
    font-family: 'IBM Plex Mono';
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .activity-desc {
    font-size: 14px;
    color: var(--ink);
  }
  .activity-desc .activity-tag {
    display: inline-block;
    padding: 2px 8px;
    font-family: 'IBM Plex Mono';
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--paper-warm);
    border-radius: 2px;
    margin-right: 8px;
    vertical-align: 1px;
  }
  .activity-link {
    font-family: 'IBM Plex Mono';
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    text-decoration: none;
  }
  .activity-link:hover { color: var(--ink); }
  .activity-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
  }

  @media (max-width: 800px) {
    .attention-row, .quick-actions { grid-template-columns: 1fr; }
    .activity-row { grid-template-columns: 80px 1fr; }
    .activity-row .activity-link { grid-column: 2; text-align: right; }
    .greeting { flex-direction: column; align-items: flex-start; gap: 8px; }
  }

  
 .legal-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 28px 96px;
}
.legal-page h1 {
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  color: var(--ink);
}
.legal-page .last-updated {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 32px;
  display: block;
}
.legal-page h2 {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 40px 0 12px;
  color: var(--ink);
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.legal-page h2:first-of-type {
  border-top: none;
  padding-top: 0;
}
.legal-page h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 20px 0 8px;
  color: var(--ink);
}
.legal-page p {
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink-soft);
  margin: 0 0 14px;
}
.legal-page ul {
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink-soft);
  padding-left: 20px;
  margin: 0 0 14px;
}
.legal-page li { margin-bottom: 8px; }
.legal-page a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--amber);
  text-underline-offset: 3px;
}
.legal-page .back-link {
  display: inline-block;
  margin-bottom: 24px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}
.legal-page .back-link:hover { color: var(--ink); }
.legal-page .pilot-notice {
  padding: 16px 20px;
  background: rgba(232, 163, 61, 0.08);
  border: 1px solid var(--amber);
  border-left-width: 4px;
  border-radius: 2px;
  margin: 24px 0;
  font-size: 14px;
  color: var(--ink);
}
.legal-page table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
}
.legal-page th,
.legal-page td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  vertical-align: top;
}
.legal-page th {
  color: var(--ink);
  font-weight: 500;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Signup Terms of Service checkbox */
.tos-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 8px;
  cursor: pointer;
}
.tos-checkbox-label input[type="checkbox"] {
  margin-top: 4px;
  width: 16px;
  height: 16px;
  accent-color: var(--amber);
  cursor: pointer;
  flex-shrink: 0;
}
.tos-checkbox-label span {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-soft);
}
.tos-checkbox-label a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--amber);
  text-underline-offset: 2px;
}

/* Auth pages legal links footer (login + signup) */
.auth-legal-links {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
.auth-legal-links a {
  color: var(--muted);
  text-decoration: none;
  margin: 0 8px;
}
.auth-legal-links a:hover {
  color: var(--ink);
}