/* =====================================================
   A4A Dashboard — Shared CSS
   Brand tokens ported from mobile theme.ts
   Layout ported from old dashboard shared.css
   ===================================================== */

:root {
  /* Brand colours */
  --a4a-navy: #2E303E;
  --a4a-dark-orange: #D75404;
  --a4a-orange: #F08B33;
  --a4a-orange-soft: #F08B33;
  --a4a-cream: #EECC8D;
  --a4a-mid-blue: #54678F;
  --a4a-light-blue: #9199BE;
  --a4a-grey: #6C6B74;
  --a4a-deep-red: #8A2C02;
  --a4a-brown: #BE9063;
  --a4a-green: #525B56;

  /* Brand colour opacities */
  --a4a-orange-06: rgba(240, 139, 51, .06);
  --a4a-orange-08: rgba(240, 139, 51, .08);
  --a4a-orange-12: rgba(240, 139, 51, .12);
  --a4a-orange-15: rgba(240, 139, 51, .15);
  --a4a-orange-25: rgba(240, 139, 51, .25);
  --a4a-orange-35: rgba(240, 139, 51, .35);
  --a4a-orange-45: rgba(240, 139, 51, .45);

  /* Semantic tokens */
  --bg: #ffffff;
  --ink: #2E303E;
  --muted: rgba(46, 48, 62, .85);
  --line: rgba(46, 48, 62, .12);
  --nav-bg: #2E303E;
  --nav-ink: #ffffff;
  --nav-muted: rgba(255, 255, 255, .80);
  --nav-line: rgba(255, 255, 255, .12);
  --accent: var(--a4a-orange);
  --accent-soft: var(--a4a-orange-12);
  --can-reply: #54678F;
  --cannot-reply: #8A2C02;
  --report: #9199BE;
  --danger: #c0392b;
  --disabled-bg: #f2f2f2;
  --bg-subtle: #fafafa;
  --r: 5px;

  /* Badge status colours */
  --badge-success-bg: #d4edda;
  --badge-success-ink: #155724;
  --badge-danger-bg: #f8d7da;
  --badge-danger-ink: #721c24;
  --badge-warning-bg: #fff3cd;
  --badge-warning-ink: #856404;
  --badge-neutral-bg: #e2e3e5;
  --badge-neutral-ink: #383d41;
  --badge-info-bg: #cce5ff;
  --badge-info-ink: #004085;
  --badge-noreply-bg: #fce4ec;
  --badge-noreply-ink: #c62828;

  /* Z-index scale */
  --z-sticky: 100;
  --z-dropdown: 500;
  --z-modal: 1000;

  /* Custom select carets — used because appearance: auto pins the
     native arrow to the right edge regardless of padding-right.
     With appearance: none we draw our own and position it with a gap. */
  --caret-dark: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%232E303E' d='M0 0l5 6 5-6z'/></svg>");
  --caret-light: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%23ffffff' d='M0 0l5 6 5-6z'/></svg>");
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: Roboto, system-ui, sans-serif;
  font-weight: 200;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ===== TITLES ===== */
.panel-title, .list-title, .detail-title, .auth-title, .modal-title {
  font-family: "Josefin Sans", sans-serif;
  font-weight: 300;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.panel-title, .list-title, .detail-title { color: var(--a4a-orange-soft); }
.auth-title, .modal-title { color: var(--a4a-orange); }

/* ===== TOP BAR ===== */
.topbar {
  flex: 0 0 auto;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-line);
  padding: 20px 16px 20px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-width: 0;
}
.topbar > * { min-width: 0; }
.topbar-user {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}
.brand { display: flex; align-items: center; gap: 16px; }

/* Hamburger nav-toggle in topbar */
.nav-toggle {
  background: transparent;
  border: 1px solid var(--nav-line);
  color: var(--nav-ink);
  padding: 6px 11px;
  margin-right: 16px;
  border-radius: var(--r);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  font-family: inherit;
}
.nav-toggle:hover { background: var(--nav-line); }
.brand-logo { height: 40px; display: block; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-user { color: var(--nav-muted); font-size: 13px; }
.topbar-signout {
  background: none; border: 1px solid var(--nav-line); color: var(--nav-muted);
  padding: 6px 14px; border-radius: var(--r); cursor: pointer; font-size: 12px;
  font-family: inherit;
}
.topbar-signout:hover { background: var(--nav-line); }

/* Business name in topbar */
.topbar-biz {
  color: var(--a4a-orange);
  font-family: "Josefin Sans", sans-serif;
  font-weight: 300;
  font-size: 16px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* ===== LAYOUT ===== */
.shell {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 240px minmax(320px, 360px) minmax(400px, 1fr);
  width: 100%;
  min-width: 0;
  max-width: 100vw;
  overflow: hidden;
}

/* ===== PANELS ===== */
.nav {
  background: var(--nav-bg);
  color: var(--nav-ink);
  border-right: 1px solid var(--nav-line);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  min-height: 0;
  padding-bottom: 12px;
}
.list, .detail {
  background: var(--bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.detail { border-right: none; }

/* ===== NAV ===== */
.panel-title { font-size: 12px; padding: 14px 14px 8px; }
.nav-links { display: flex; flex-direction: column; gap: 6px; padding: 0 10px 10px; }
.nav-version {
  margin-top: 40px;
  padding: 0 4px;
  font-family: "Josefin Sans", sans-serif;
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.55);
}
.nav-item {
  background: transparent; border: 1px solid transparent; color: var(--nav-ink);
  padding: 10px; border-radius: var(--r); display: flex; align-items: center;
  gap: 10px; cursor: pointer; font-weight: 300; font-size: 14px;
  font-family: Roboto, system-ui, sans-serif;
}
.nav-item:hover { background: var(--nav-line); }
.nav-item.is-active { background: var(--a4a-orange-15); border-color: var(--a4a-orange-35); }
.nav-item:disabled { opacity: .45; cursor: not-allowed; }
.nav-item.drag-over {
  background: var(--a4a-orange-35);
  border-color: var(--a4a-orange);
  box-shadow: 0 0 0 2px var(--a4a-orange-25);
}
.nav-ico { width: 18px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--a4a-orange);
  color: var(--nav-ink);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}
.nav-badge:empty { display: none; }
.divider { height: 1px; background: var(--nav-line); margin: 10px 0; }

/* ===== LIST ===== */
.list-header, .detail-header {
  padding: 14px; border-bottom: 1px solid var(--line);
  min-height: 68px; box-sizing: border-box; background: var(--a4a-navy);
}
.list-title { font-size: 14px; }
.list-subtitle { font-size: 12px; color: var(--nav-muted); margin-top: 6px; }

.items { flex: 1 1 auto; overflow: auto; padding: 10px; min-height: 0; }
.item {
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px; margin-bottom: 10px; cursor: pointer;
}
.item:hover { background: rgba(0,0,0,.02); }
.item.is-active { border-color: var(--a4a-orange-45); box-shadow: 0 0 0 2px var(--a4a-orange-12); }
.item-top { display: flex; justify-content: space-between; gap: 10px; }
.item-subject { font-size: 14px; font-weight: 700; color: var(--a4a-navy); }
.item-subject.is-read { font-weight: 300; color: var(--a4a-grey); }
.item-taxonomy { font-size: 11px; color: var(--a4a-orange); margin-top: 4px; padding: 0; }
.item-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.item-badge-row { margin-top: 3px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.item-type-badge {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; padding: 2px 6px; border-radius: 3px;
}
.item-type-badge.enquiry { background: var(--accent-soft); color: var(--a4a-dark-orange); }
.item-type-badge.followup { background: rgba(84,103,143,.12); color: var(--a4a-mid-blue); }
.item-type-badge.admin { background: var(--a4a-navy); color: #fff; }
.locality-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 500; padding: 2px 6px; border-radius: 3px;
  background: rgba(84,103,143,.12); color: var(--a4a-mid-blue);
  white-space: nowrap;
}
.locality-badge i { font-size: 9px; }
.detail-locality { margin-top: 6px; }

/* Helper text shown under the department dropdown in compose flows */
.nm-dept-description {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
  font-style: italic;
}
.item-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex-shrink: 0; }
.item-time { font-size: 12px; color: var(--muted); min-width: 100px; text-align: right; white-space: nowrap; }
.item-actions { display: flex; gap: 10px; align-items: center; }

/* Status icons */
.status-fa { font-size: 14px; }
.status-fa.can-reply { color: var(--can-reply); }
.status-fa.cannot-reply { color: var(--cannot-reply); }
.item-trash { background: none; border: none; cursor: pointer; color: rgba(46,48,62,.6); }
.item-trash:hover { color: rgba(46,48,62,.9); }

/* ===== THREAD ===== */
.detail-title { font-size: 14px; }
.detail-meta {
  font-size: 12px; color: var(--nav-muted); margin-top: 6px;
  min-height: 18px; font-family: Roboto, system-ui, sans-serif;
  font-weight: 200; text-transform: none; letter-spacing: 0;
}
.thread { flex: 1 1 auto; overflow: auto; padding: 14px; }
.msg {
  width: 90%; border: 1px solid var(--line);
  border-radius: var(--r); padding: 12px; margin-bottom: 10px;
}
.msg.is-business { margin-left: 20px; background: var(--a4a-orange-06); }
.msg-meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.msg-body { white-space: pre-wrap; line-height: 1.5; }

/* Attachments on a message bubble */
.msg-attachments { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.msg-attachment-link {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
  color: var(--a4a-dark-orange); text-decoration: none; padding: 4px 8px;
  background: rgba(255,255,255,0.6); border: 1px solid var(--line);
  border-radius: 5px; align-self: flex-start; max-width: 100%;
}
.msg-attachment-link:hover { background: #fff; text-decoration: underline; }
.msg-attachment-link i { font-size: 12px; opacity: .8; }

/* System message */
.msg.is-system { border-color: var(--cannot-reply); color: var(--cannot-reply); }
.msg.is-system .msg-meta { color: var(--cannot-reply); }
.msg.is-system .system-reason { margin-top: 8px; font-style: italic; opacity: .9; white-space: pre-line; }

/* Limit banner */
.limit-banner {
  background: var(--a4a-orange-08); border: 1px solid var(--a4a-orange);
  border-radius: var(--r); padding: 12px; margin: 10px 14px;
  font-size: 13px; color: var(--a4a-dark-orange); text-align: center;
}

/* ===== COMPOSER ===== */
.composer { border-top: 1px solid var(--line); padding: 14px; }
.composer textarea { width: 100%; min-height: 96px; }
.composer textarea:disabled { background: var(--disabled-bg); }
.composer-waiting { color: var(--muted); font-size: 13px; }
.composer-actions {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 10px; gap: 12px;
}
.hint {
  font-size: 14px; color: var(--accent); margin-top: 8px;
  min-height: 16px; font-family: Roboto, system-ui, sans-serif;
  font-weight: 200; text-align: right;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--a4a-orange); color: var(--nav-ink);
  border: 2px solid var(--a4a-orange); border-radius: var(--r);
  padding: 10px 14px; font-weight: 200; cursor: pointer;
  font-family: Roboto, system-ui, sans-serif; font-size: 14px;
}
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-secondary { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-secondary:hover { background: rgba(0,0,0,.04); }
.btn-small { padding: 6px 12px; font-size: 12px; }
.btn-blue { background: var(--a4a-mid-blue); border-color: var(--a4a-mid-blue); color: var(--nav-ink); }
.btn.btn-save { background: #2e7d32; border-color: #2e7d32; color: var(--nav-ink); }
.btn.btn-message { background: var(--a4a-mid-blue); border-color: var(--a4a-mid-blue); color: var(--nav-ink); }
.btn.btn-suspend { background: var(--a4a-orange); border-color: var(--a4a-orange); color: var(--nav-ink); }
.btn.btn-danger { background: var(--a4a-deep-red); border-color: var(--a4a-deep-red); color: var(--nav-ink); }
.btn-blue:hover, .btn.btn-save:hover, .btn.btn-message:hover,
.btn.btn-suspend:hover, .btn.btn-danger:hover { filter: brightness(1.1); }

/* Logo upload area */
.logo-upload-area {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: var(--r);
  min-width: 360px;
}
.logo-upload-area img {
  max-height: 48px;
  max-width: 200px;
  border-radius: var(--r);
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 0;
}
.pagination-info {
  font-size: 12px;
  color: var(--muted);
}
.btn-success { background: var(--a4a-green); border-color: var(--a4a-green); color: var(--nav-ink); }
.btn-report {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--a4a-mid-blue); border: 2px solid var(--a4a-mid-blue); color: var(--nav-ink);
  border-radius: var(--r); padding: 10px 14px; cursor: pointer;
  font-family: Roboto, system-ui, sans-serif; font-weight: 200; font-size: 14px;
}
.btn-report:hover { filter: brightness(1.05); }
.btn-report:disabled { opacity: .55; cursor: not-allowed; }
.btn-report.btn-small { padding: 6px 12px; font-size: 12px; }
.btn-favourite {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--a4a-cream); border: 2px solid var(--a4a-cream); color: var(--a4a-navy);
  border-radius: var(--r); padding: 10px 14px; cursor: pointer;
  font-family: Roboto, system-ui, sans-serif; font-weight: 200; font-size: 14px;
}
.btn-favourite:hover { filter: brightness(1.05); }
.btn-favourite:disabled { opacity: .45; cursor: not-allowed; }

.empty {
  border: 1px dashed var(--line); padding: 14px;
  border-radius: var(--r); color: var(--muted);
}

/* ===== FORMS ===== */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; font-size: 12px; }
input, textarea, select {
  border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px;
  font-family: Roboto, system-ui, sans-serif; color: var(--ink);
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--a4a-orange);
  box-shadow: 0 0 0 2px var(--a4a-orange-15);
}
select {
  background: var(--bg);
  background-image: var(--caret-dark);
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
  padding-right: 32px;
  appearance: none;
  -webkit-appearance: none;
}

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed; inset: 0; display: none;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,.45); z-index: var(--z-modal);
}
.modal-backdrop.is-open { display: flex; }
.modal {
  width: min(560px, calc(100vw - 32px));
  background: var(--bg); border-radius: 12px;
  border: 1px solid rgba(0,0,0,.12); padding: 16px;
}
.modal.modal-wide {
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  display: flex; flex-direction: column;
}
.modal-header { margin-bottom: 10px; }
.modal-warning { margin: 0 0 12px; }
.modal-label { display: block; font-size: 13px; margin: 10px 0 6px; color: var(--muted); }

/* Section header for grouping fields inside a modal — Josefin Sans,
   uppercase, brand orange. Slightly bigger than a label so it reads
   as a divider. */
.modal-section-title {
  font-family: "Josefin Sans", sans-serif;
  font-weight: 300;
  font-size: 16px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--a4a-orange);
  margin: 18px 0 8px;
}
.modal-textarea {
  width: 100%; resize: vertical; padding: 10px; border-radius: var(--r);
  border: 1px solid rgba(0,0,0,.18); font: inherit;
}
.modal-hint { margin-top: 6px; font-size: 12px; color: var(--cannot-reply); }
.modal-warning { color: var(--cannot-reply); font-size: 13px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.modal-body-scroll { overflow-y: auto; max-height: 60vh; padding-right: 8px; }
.modal-info { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.modal-input {
  width: 100%; padding: 10px 12px; border-radius: var(--r);
  border: 1px solid rgba(0,0,0,.18); font: inherit; font-size: 14px;
}
.modal-input:disabled { background: var(--disabled-bg); color: var(--muted); }
.modal-input:focus { outline: none; border-color: var(--a4a-orange); box-shadow: 0 0 0 2px var(--a4a-orange-15); }

/* Form layout */
.form-row { margin-bottom: 12px; }
.form-row-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-group { display: flex; flex-direction: column; }
.form-group .modal-label { margin: 10px; }
.form-divider { height: 1px; background: var(--line); margin: 20px 0; }

/* ===== SIGNATURE PREVIEW ===== */
.signature-preview {
  background: var(--bg-subtle); border: 1px solid var(--line);
  border-radius: var(--r); padding: 16px; font-size: 14px;
  line-height: 1.5; min-height: 120px;
}
.signature-preview .sig-line { margin-bottom: 4px; }
.signature-preview .sig-name { font-weight: 600; color: var(--ink); }
.signature-preview .sig-role { color: var(--muted); }
.signature-preview .sig-contact { font-size: 13px; }
.signature-preview .sig-divider { height: 1px; background: var(--line); margin: 12px 0; }
.signature-preview .sig-business { display: block; margin-bottom: 8px; }
.signature-preview .sig-business img.sig-logo,
.signature-preview .sig-logo img { display: block; max-height: 80px; max-width: 280px; height: auto; width: auto; margin-bottom: 6px; image-rendering: -webkit-optimize-contrast; }
.signature-preview .sig-logo { display: block; margin-bottom: 6px; }
.signature-preview .sig-business-name { display: block; font-weight: 600; color: var(--ink); }
.link-profile { color: var(--a4a-orange); text-decoration: none; font-weight: 600; }
.link-profile:hover { text-decoration: underline; }
.signature-preview .sig-tagline { font-style: italic; color: var(--muted); font-size: 13px; }
.signature-preview .sig-address { font-size: 13px; color: var(--muted); }
.signature-preview .sig-credentials { font-size: 12px; color: var(--muted); margin-top: 8px; }
.signature-preview .sig-disclaimer {
  font-size: 11px; color: var(--muted); margin-top: 12px;
  padding-top: 8px; border-top: 1px solid var(--line);
}

.signature-preview .sig-social {
  display: flex; gap: 12px; margin-top: 8px;
}
.signature-preview .sig-social a {
  color: var(--muted); font-size: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px;
  text-decoration: none;
}
.signature-preview .sig-social a:hover { color: var(--a4a-orange); }

/* In-thread signature */
.signature-preview.msg-signature {
  background: transparent; border: none; padding: 12px 0 0;
  margin-top: 12px; border-radius: 0; font-size: 13px;
}
.signature-preview.msg-signature .sig-divider {
  max-width: 160px;
}
.signature-preview.msg-signature .sig-disclaimer {
  border-top: none; padding-top: 4px;
}

/* ===== NEW MESSAGE TAXONOMY ===== */
.nm-taxonomy {
  background: var(--a4a-navy); color: var(--nav-ink);
  padding: 16px; flex: 1 1 auto; overflow: auto;
}
.nm-taxonomy-row { margin-bottom: 16px; }
.nm-taxonomy-row label {
  display: block; font-family: "Josefin Sans", sans-serif;
  font-weight: 300; font-size: 11px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--nav-muted); margin-bottom: 6px;
}
.nm-taxonomy-row select {
  width: 100%; background: var(--a4a-orange-soft); color: var(--nav-ink);
  background-image: var(--caret-light);
  background-repeat: no-repeat;
  background-position: right 14px center;
  border: none; border-radius: var(--r); padding: 12px 32px 12px 14px;
  font-family: Roboto, system-ui, sans-serif; font-size: 14px;
  font-weight: 300; cursor: pointer;
}
.nm-taxonomy-row select:disabled { opacity: .45; cursor: not-allowed; }
.nm-taxonomy-row select option { background: var(--a4a-navy); color: var(--nav-ink); }
.nm-taxonomy-row select.nm-sector { background-color: var(--a4a-dark-orange); background-image: var(--caret-light); }
.nm-taxonomy-row select.nm-dept   { background-color: var(--a4a-orange-soft); background-image: var(--caret-light); }
.nm-taxonomy-row select.nm-spec   { background-color: var(--a4a-cream); background-image: var(--caret-dark); color: var(--ink); }
.nm-taxonomy-row select.nm-spec option { background: var(--a4a-navy); color: var(--nav-ink); }

/* ===== NEW MESSAGE FORM ===== */
.new-message-form { padding: 24px; }
.new-message-form .form-row { margin-bottom: 16px; }
.new-message-form label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.new-message-form select,
.new-message-form input,
.new-message-form textarea { width: 100%; }
.new-message-form textarea { min-height: 140px; }

/* ===== STATUS BADGES (billing, etc.) ===== */
.status-badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
  padding: 2px 8px; border-radius: 3px;
}
.badge-success { background: var(--badge-success-bg); color: var(--badge-success-ink); }
.badge-danger  { background: var(--badge-danger-bg);  color: var(--badge-danger-ink); }
.badge-warning { background: var(--badge-warning-bg); color: var(--badge-warning-ink); }
.badge-neutral { background: var(--badge-neutral-bg); color: var(--badge-neutral-ink); }
.badge-info    { background: var(--badge-info-bg);    color: var(--badge-info-ink); }

/* ===== UTILITY ===== */
.hidden { display: none !important; }
a { color: var(--a4a-orange); }
a:hover { text-decoration: underline; }

/* Loading spinner */
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 40px; color: var(--muted); font-size: 14px;
}

/* ===== TRANSITIONS ===== */
.btn, .btn-secondary, .btn-report, .btn-danger, .btn-favourite,
.topbar-signout, .nav-item, .item, .tab-btn {
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, filter .15s ease;
}
input, textarea, select { transition: border-color .15s ease, box-shadow .15s ease; }

/* ===== KEYBOARD-FOCUS RING =====
   Visible orange outline only when navigating by keyboard (not on
   click) — :focus-visible respects pointer focus and mouse-and-touch
   activation. */
.nav-item:focus-visible,
.tab-btn:focus-visible,
.sub-tab-btn:focus-visible,
.col-resizer:focus-visible,
.btn:focus-visible,
.btn-secondary:focus-visible,
.btn-blue:focus-visible,
.btn-report:focus-visible,
.btn-favourite:focus-visible,
.btn-success:focus-visible,
.topbar-signout:focus-visible,
.pw-toggle:focus-visible,
.item-trash:focus-visible,
.admin-btn:focus-visible,
.period-btn:focus-visible,
.login-btn:focus-visible,
.login-social-btn:focus-visible,
.forgot-pw-link:focus-visible,
.tax-actions button:focus-visible {
  outline: 2px solid var(--a4a-orange);
  outline-offset: 2px;
}

/* ===== LOGIN ===== */
.login-body { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; background: var(--a4a-navy); }
.login-card { background: var(--bg); border-radius: 8px; padding: 40px 36px 32px; width: 360px; box-shadow: 0 4px 24px rgba(0,0,0,.15); }
.login-version {
  margin-top: 18px;
  font-family: "Josefin Sans", sans-serif;
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.55);
}
.login-logo { display: block; max-width: 200px; margin: 0 auto 24px; }
.login-title { font-family: "Josefin Sans", sans-serif; font-weight: 300; font-size: 14px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); text-align: center; margin-bottom: 20px; }
.login-field { display: flex; flex-direction: column; margin-bottom: 14px; }
.login-field label { font-size: 12px; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .5px; }
.login-field input { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); font-size: 14px; font-family: inherit; }
.login-field input:focus { outline: none; border-color: var(--a4a-orange); }
.login-btn { width: 100%; padding: 12px; background: var(--a4a-orange); color: var(--nav-ink); border: none; border-radius: var(--r); font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; margin-top: 8px; transition: filter .15s ease; }
.login-btn:hover { filter: brightness(1.1); }
.login-btn:disabled { opacity: .5; cursor: not-allowed; }
.password-wrapper { position: relative; display: flex; align-items: center; }
.password-wrapper input { flex: 1; padding-right: 36px; box-sizing: border-box; }
.pw-toggle { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--muted); padding: 0; display: flex; align-items: center; line-height: 1; }
.pw-toggle:hover { color: var(--ink); }
.forgot-pw-link { display: block; text-align: center; font-size: 12px; color: var(--a4a-orange); margin-top: 16px; text-decoration: none; }
.forgot-pw-link:hover { text-decoration: underline; }
.login-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0 16px; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.login-divider span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.login-social-btn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); font-size: 14px; font-family: inherit; font-weight: 500; cursor: pointer; transition: background .15s ease, border-color .15s ease; margin-bottom: 8px; }
.login-social-btn:hover { background: var(--hover); border-color: var(--muted); }
.login-social-btn svg { flex-shrink: 0; }
.apple-btn { background: #000; color: #fff; border-color: #000; }
.apple-btn:hover { background: #222; border-color: #222; }
.login-status { font-size: 12px; color: var(--muted); text-align: center; margin-top: 12px; min-height: 18px; }
.login-status.is-error { color: var(--danger); }
.login-status.is-notice {
  color: var(--danger);
  font-weight: 700;
  font-size: 16px;
  line-height: 1.4;
  margin-top: 16px;
  padding: 12px 14px;
  background: rgba(192, 57, 43, 0.08);
  border: 1px solid var(--danger);
  border-radius: var(--r);
}

/* ===== INLINE STYLE REPLACEMENTS ===== */
.item-draft { color: var(--a4a-mid-blue); }
.composer-row { display: flex; justify-content: space-between; align-items: center; }
.hint-left { text-align: left; }
.hint-success { color: var(--a4a-green); }
.hint-error { color: var(--cannot-reply); }
.hint-navy { color: var(--a4a-navy); margin-bottom: 12px; }
.hint-inline { margin: 0; }
.sent-waiting { margin-top: 10px; }

/* Form actions row — Send/Save button inline with status hint */
.form-actions-inline {
  display: flex;
  gap: 10px;
  align-items: center;
}
.form-actions-inline.has-top-margin { margin-top: 12px; }

/* Composer action button group — left or right cluster inside .composer-actions */
.composer-actions-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Logo upload — vertical button column */
.logo-upload-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Signature editor scrollable form pane */
.signature-form-wrap {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

/* Small descriptor text below an input/label */
.field-hint {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
}
.field-hint.is-danger { color: var(--danger); }

/* Responsive checkbox grid (modals — Add Seat, etc.) */
.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
  margin-top: 6px;
  margin-bottom: 16px;
}

/* Plan + seat-status hero card. Used at the top of the Add Seat modal
   so the business sees "Plan 200" prominently with "1/20 seats used"
   as supporting text. Two visual states:
     .plan-card           — neutral / under limit (orange brand)
     .plan-card.is-danger — at-or-over limit      (red callout) */
.plan-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  margin-bottom: 16px;
  border-radius: var(--r);
  background: var(--a4a-orange-08);
  border: 1px solid var(--a4a-orange-35);
  text-align: right;
}
.plan-card.is-danger {
  background: rgba(192, 57, 43, 0.06);
  border-color: var(--danger);
}
.plan-card-name {
  font-family: "Josefin Sans", sans-serif;
  font-weight: 300;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-size: 22px;
  color: var(--a4a-orange);
}
.plan-card.is-danger .plan-card-name { color: var(--danger); }
.plan-card-seats {
  font-size: 14px;
  color: var(--ink);
}
@media (max-width: 480px) {
  .checkbox-grid { grid-template-columns: 1fr; }
}

/* Preferences-style checkbox row — flex-aligned label with checkbox.
   Used by admin Preferences tab and the business Add Seat modal. */
.pref-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 16px;
}
.pref-section-title {
  grid-column: 1 / -1;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  margin-bottom: 6px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
}
.pref-section .empty { grid-column: 1 / -1; }
.pref-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0 4px 12px;
  font-size: 13px;
  cursor: pointer;
}
.pref-check input[type="checkbox"] {
  accent-color: var(--a4a-orange);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
}

/* Invoice From section — meta and email rows */
.company-info-meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
.company-info-email { margin-top: 8px; }

/* ===== FULL-CONTENT LAYOUT (hide list panel, span detail) ===== */
.shell.full-content {
  grid-template-columns: 240px 1fr !important;
}
.shell.full-content > .list { display: none; }
.shell.full-content > .detail { grid-column: 2; overflow-y: auto; }

/* ===== STATS / SECTION TABLES (shared by admin and business) ===== */
.fin-section { margin-bottom: 24px; }
.fin-section-title {
  font-family: "Josefin Sans", sans-serif;
  font-weight: 300;
  font-size: 13px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--a4a-orange);
  margin-bottom: 8px;
}
.fin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 12px;
}
.fin-table th,
.fin-table td {
  text-align: left;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
}
.fin-table th {
  font-weight: 700;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}
.fin-table tr.fin-total {
  font-weight: 700;
  background: var(--a4a-orange-06);
}
.fin-table td.num { text-align: right; }
.fin-table th.num { text-align: right; }

.stats-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}
@media (max-width: 900px) {
  .stats-grid-2col { grid-template-columns: 1fr; }
}
.stats-grid-2col .fin-section { margin-bottom: 0; }

/* Departments page — navy background, orange brand buttons */
.dept-page-body {
  background: var(--a4a-navy);
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px 40px 36px;
}
.dept-page-inner {
  max-width: 720px;
  margin: 0;
}
.dept-intro-banner {
  margin-bottom: 24px;
}
.dept-intro-title {
  font-family: "Josefin Sans", sans-serif;
  font-weight: 300;
  font-size: 22px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--a4a-orange);
  margin-bottom: 8px;
}
.dept-intro-text {
  font-size: 13px;
  color: var(--nav-muted);
  line-height: 1.5;
  margin-bottom: 10px;
}
.dept-intro-counter {
  font-size: 12px;
  color: var(--nav-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}

/* Department opt-in checkbox list — orange branded boxes */
.dept-checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dept-check {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border: 2px solid var(--a4a-orange);
  border-radius: var(--r);
  background: var(--a4a-orange);
  color: var(--nav-ink);
  cursor: pointer;
  font-family: "Josefin Sans", sans-serif;
  font-weight: 300;
  font-size: 14px;
  letter-spacing: .08em;
  text-transform: uppercase;
  transition: filter .15s ease;
}
.dept-check:hover { filter: brightness(1.08); }
.dept-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--nav-ink);
  cursor: pointer;
}
.dept-check input[type="checkbox"]:disabled { cursor: wait; opacity: .5; }
/* Unchecked state — outline only, transparent fill */
.dept-check:has(input[type="checkbox"]:not(:checked)) {
  background: transparent;
  color: var(--a4a-orange);
}
.dept-check:has(input[type="checkbox"]:not(:checked)):hover {
  background: var(--a4a-orange-06);
  filter: none;
}

.dept-support-note {
  margin-top: 24px;
  padding: 14px 16px;
  background: var(--a4a-orange-12);
  border-left: 3px solid var(--a4a-orange);
  border-radius: var(--r);
  font-size: 13px;
  color: var(--nav-muted);
  display: flex;
  align-items: center;
  gap: 10px;
}
.dept-support-note i { color: var(--a4a-orange); font-size: 16px; }

/* Fixed-layout tables — make columns line up across stacked tables */
.fin-table-fixed { table-layout: fixed; }

/* Stats row label with icon (matches nav-ico style) */
.stats-row-label { display: inline-flex; align-items: center; gap: 10px; }
.stats-row-icon {
  width: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ===== INVOICE PREVIEW (shared by admin and business) ===== */
.invoice-page-body { padding: 16px; overflow-y: auto; flex: 1; }
.invoice-preview {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  max-width: 720px;
}
.invoice-preview-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  gap: 24px;
}
.invoice-from-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin-bottom: 4px;
}
.invoice-from {
  font-size: 14px;
  line-height: 1.5;
}
.invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}
.invoice-table th, .invoice-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.invoice-table th.num, .invoice-table td.num { text-align: right; }
.invoice-table tr.invoice-total td {
  border-bottom: none;
  font-size: 16px;
  padding-top: 16px;
}
.invoice-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  font-size: 13px;
  color: var(--ink);
  max-width: 720px;
}
.invoice-meta-grid strong { color: var(--muted); font-weight: 500; }
.invoice-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  max-width: 720px;
}

/* ===== TABLET / SMALL-LAPTOP RESPONSIVE OVERRIDES =====
   Default desktop layout: nav 240, list 320–360, detail flexible.
   Admin: nav 240, list 580 (resizable), 6px resizer, detail 360+.

   The admin list track uses min(var(--list-width), calc(viewport-fit))
   so the user can still drag the resizer to whatever width they
   want, while the layout cannot overflow the viewport even if a
   stale wide width was saved on a desktop session. */
@media (max-width: 1100px) {
  .shell {
    grid-template-columns: 200px minmax(280px, 320px) minmax(280px, 1fr);
  }
  .admin-shell {
    grid-template-columns:
      200px
      min(var(--list-width, 360px), calc(100vw - 200px - 6px - 280px))
      6px
      minmax(280px, 1fr);
  }
  .topbar { padding: 16px 14px 16px 24px; }
  .nav-links { gap: 4px; padding: 0 8px 8px; }
  .nav-item { padding: 8px 10px; font-size: 13px; }
}

/* iPad portrait — tighten further; everything must fit 768px wide. */
@media (max-width: 820px) {
  .shell {
    grid-template-columns: 180px minmax(240px, 280px) minmax(240px, 1fr);
  }
  .admin-shell {
    grid-template-columns:
      180px
      min(var(--list-width, 280px), calc(100vw - 180px - 6px - 220px))
      6px
      minmax(220px, 1fr);
  }
  .nav-item { padding: 7px 8px; font-size: 12px; gap: 8px; }
  .panel-title { padding: 10px 10px 6px; font-size: 11px; }
}

/* ===== NAV-COLLAPSED STATE (hamburger toggle) =====
   When body.nav-collapsed is set, the left nav is hidden and the
   shell becomes a 2-column grid. Saved in localStorage via the
   .nav-toggle handler in shared/helpers.js. */
body.nav-collapsed .nav { display: none; }
body.nav-collapsed .shell {
  grid-template-columns: minmax(280px, 360px) minmax(400px, 1fr);
}
body.nav-collapsed .admin-shell {
  grid-template-columns:
    min(var(--list-width, 580px), calc(100vw - 6px - 360px))
    6px
    minmax(360px, 1fr);
}
@media (max-width: 1100px) {
  body.nav-collapsed .shell {
    grid-template-columns: minmax(280px, 360px) minmax(280px, 1fr);
  }
  body.nav-collapsed .admin-shell {
    grid-template-columns:
      min(var(--list-width, 360px), calc(100vw - 6px - 280px))
      6px
      minmax(280px, 1fr);
  }
}
@media (max-width: 820px) {
  body.nav-collapsed .shell {
    grid-template-columns: minmax(240px, 320px) minmax(240px, 1fr);
  }
  body.nav-collapsed .admin-shell {
    grid-template-columns:
      min(var(--list-width, 280px), calc(100vw - 6px - 240px))
      6px
      minmax(240px, 1fr);
  }
}

/* ===== PRINT (invoice → PDF) ===== */
@media print {
  body.printing-invoice {
    background: white !important;
    overflow: visible !important;
    height: auto !important;
  }
  body.printing-invoice .topbar,
  body.printing-invoice .nav,
  body.printing-invoice .list,
  body.printing-invoice .detail-header,
  body.printing-invoice #filterBar,
  body.printing-invoice .no-print {
    display: none !important;
  }
  body.printing-invoice .shell,
  body.printing-invoice .admin-shell {
    display: block !important;
    grid-template-columns: 1fr !important;
    height: auto !important;
  }
  body.printing-invoice .detail,
  body.printing-invoice #detailPane,
  body.printing-invoice .admin-detail-body {
    display: block !important;
    overflow: visible !important;
    padding: 0 !important;
    border: none !important;
    background: white !important;
    height: auto !important;
  }
  body.printing-invoice .invoice-print-area {
    padding: 32px;
    max-width: 800px;
    margin: 0 auto;
  }
  body.printing-invoice .invoice-preview {
    border: none !important;
    box-shadow: none !important;
    page-break-inside: avoid;
  }
  body.printing-invoice .badge {
    border: 1px solid var(--line);
  }
  @page {
    margin: 12mm;
    size: A4;
  }
}
