/* West Kirby Windows CRM - shared design system.
   Loaded by every page instead of inline <style> blocks so the
   Content-Security-Policy style-src directive can drop
   'unsafe-inline' (see private/functions.php send_security_headers()
   and .devfiles/WestKirbyWindows_Project.md Phase 6). */

:root {
  --color-primary: #1d4ed8;
  --color-primary-dark: #1e3a8a;
  --color-primary-light: #eef2ff;
  --color-danger: #b91c1c;
  --color-danger-light: #fef2f2;
  --color-success: #15803d;
  --color-success-light: #f0fdf4;
  --color-text: #1f2430;
  --color-text-muted: #667085;
  --color-border: #e2e5ea;
  --color-bg: #f4f6f9;
  --color-surface: #ffffff;
  --radius: .5rem;
  --radius-sm: .375rem;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 2px 8px rgba(16, 24, 40, .06);
  --sidebar-width: 15.5rem;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  font-size: 15px;
  line-height: 1.5;
}

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

h1, h2, h3 { line-height: 1.25; margin: 0 0 .75rem; font-weight: 600; }
h1 { font-size: 1.375rem; }
h2 { font-size: 1.0625rem; }

/* ---------------------------------------------------------------
   Authenticated app shell: fixed sidebar + content column
   --------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-primary-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-bar { display: flex; align-items: center; justify-content: space-between; }

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: .02em;
  padding: 0 .5rem .5rem;
  margin-bottom: .75rem;
}

.brand span { opacity: .75; font-weight: 500; }

/* Contains the account block, both nav groups and the footer;
   .sidebar-nav's flex:1 (below) is what pushes Settings + the
   logout-only footer down to the bottom of the sidebar. */
.sidebar-menu { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; }

.sidebar-account {
  border-bottom: 1px solid rgba(255, 255, 255, .15);
  padding-bottom: .9rem;
  margin-bottom: .5rem;
}

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: .3rem;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.hamburger span { display: block; width: 1.35rem; height: 2px; background: #fff; border-radius: 2px; }
.hamburger:hover { background: rgba(255, 255, 255, .1); }

.sidebar-nav { display: flex; flex-direction: column; gap: .125rem; flex: 1; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .65rem;
  color: rgba(255, 255, 255, .85);
  text-decoration: none;
  padding: .6rem .75rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 500;
  transition: background .15s ease;
}

.sidebar-nav a svg { flex-shrink: 0; }

.sidebar-nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sidebar-nav a.active { background: rgba(255, 255, 255, .16); color: #fff; }

/* Settings, anchored just above the footer rather than taking a
   share of the flexible space above. */
.sidebar-nav-bottom { flex: 0 0 auto; margin-top: .5rem; }

/* Nested links (e.g. "Add New Enquiry" under Enquiries) - same
   pattern used for Settings' children before those were hidden. */
.sidebar-nav a.sidebar-subnav {
  padding-left: 1.5rem;
  font-size: .84rem;
  color: rgba(255, 255, 255, .7);
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, .15);
  padding-top: .5rem;
  margin-top: .75rem;
}

.user-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: 0 .75rem;
  font-size: .875rem;
  font-weight: 600;
}

.sidebar-footer .logout-form { margin: 0; }

.sidebar-footer .logout-link {
  width: 100%;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  display: flex;
  align-items: center;
  gap: .65rem;
  color: rgba(255, 255, 255, .8);
  text-decoration: none;
  padding: .6rem .75rem;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
}

.sidebar-footer .logout-link svg { flex-shrink: 0; }
.sidebar-footer .logout-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.content { flex: 1; min-width: 0; padding: 2rem 2.25rem; }

.content-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  gap: .75rem 1rem;
}

.content-header p { margin: .15rem 0 0; color: var(--color-text-muted); font-size: .9rem; }

/* ---------------------------------------------------------------
   Cards / surfaces
   --------------------------------------------------------------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card > h2:first-child, .card > h1:first-child { margin-top: 0; }
.card-narrow { max-width: 28rem; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.module-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  background: var(--color-primary-light);
}

.module-card h3 { margin: 0; font-size: .95rem; }
.module-card p { margin: .3rem 0 0; font-size: .8rem; color: var(--color-text-muted); }

a.module-card { display: block; text-decoration: none; color: inherit; transition: box-shadow .15s ease, border-color .15s ease; }
a.module-card:hover { border-color: var(--color-primary); box-shadow: var(--shadow); }

/* ---------------------------------------------------------------
   Badges
   --------------------------------------------------------------- */
.badge {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  padding: .2rem .5rem;
  border-radius: 999px;
}

.badge-admin { background: #fef3c7; color: #92400e; }
.badge-management { background: #dbeafe; color: #1e40af; }
.badge-user { background: #e5e7eb; color: #374151; }
.badge-active { background: var(--color-success-light); color: var(--color-success); }
.badge-inactive { background: var(--color-danger-light); color: var(--color-danger); }

.sidebar .badge-admin { background: rgba(255, 255, 255, .18); color: #fff; }
.sidebar .badge-management { background: rgba(255, 255, 255, .18); color: #fff; }
.sidebar .badge-user { background: rgba(255, 255, 255, .18); color: #fff; }

/* ---------------------------------------------------------------
   Alerts
   --------------------------------------------------------------- */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}

.alert-error { background: var(--color-danger-light); color: var(--color-danger); border-color: #fecaca; }
.alert-success { background: var(--color-success-light); color: var(--color-success); border-color: #bbf7d0; }

/* ---------------------------------------------------------------
   Forms
   --------------------------------------------------------------- */
label {
  display: block;
  font-weight: 600;
  font-size: .9rem;
  margin: 0 0 .35rem;
  /* Title Case labels across the CRM ("Start Date", "Contract
     Amount") - capitalises the first letter of each word while
     leaving intentional capitals like IBG/FENSA untouched. */
  text-transform: capitalize;
}

input[type=text], input[type=password], input[type=email], input[type=date],
input[type=tel], input[type=number], input[type=time], input[type=search], select, textarea {
  width: 100%;
  padding: .7rem .9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--color-text);
  min-height: 2.9rem;
}

textarea {
  min-height: 6rem;
  resize: vertical;
  line-height: 1.5;
}

select {
  min-height: 2.9rem;
  /* Custom chevron - the native arrow can't be repositioned with
     padding, so we hide it and draw our own a fixed distance in from
     the right edge. Inline SVG data URI is permitted by the CSP's
     img-src (see send_security_headers()). */
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='10' viewBox='0 0 14 10'%3E%3Cpath d='M1.5 1.5l5.5 5.5 5.5-5.5' fill='none' stroke='%23334155' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .9rem center;
  background-size: .85rem .6rem;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.field { margin-bottom: 1.1rem; }
.field-hint { font-size: .8rem; color: var(--color-text-muted); margin: .3rem 0 0; }

.checkbox-field { display: flex; align-items: center; gap: .6rem; }
.checkbox-field label { margin: 0; font-weight: 500; }
.checkbox-field input { width: auto; min-height: auto; }

.form-inline { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.form-inline .field { margin-bottom: 0; min-width: 10rem; flex: 1; }
.form-inline > .btn { min-height: 2.9rem; }

/* ---------------------------------------------------------------
   Responsive field grids - flow into columns on tablet/laptop
   widths, collapse to a single column on narrow screens.
   --------------------------------------------------------------- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem 1.25rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem 1.25rem;
}

.grid-full { grid-column: 1 / -1; }

.grid-2 .field, .grid-3 .field { margin-bottom: 0; }

/* ---------------------------------------------------------------
   On-demand disclosure sections (e.g. optional addresses) - a
   native <details>/<summary> pair needs no JS and works well with
   touch on tablets.
   --------------------------------------------------------------- */
details.disclosure {
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0 1rem;
  margin-top: 1.25rem;
  background: var(--color-bg);
}

details.disclosure summary {
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  font-size: .9rem;
  color: var(--color-primary);
  padding: .85rem 0;
}

details.disclosure summary::-webkit-details-marker { display: none; }
details.disclosure summary::before { content: '+ Add '; }
details.disclosure[open] summary::before { content: '\2212 Remove '; }
details.disclosure[open] { padding-bottom: 1.1rem; }

/* ---------------------------------------------------------------
   Buttons
   --------------------------------------------------------------- */
.btn {
  display: inline-block;
  padding: .55rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-secondary { background: #fff; color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: var(--color-bg); }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }

/* ---------------------------------------------------------------
   Tables
   --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }

th, td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--color-border); }

th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); font-weight: 600; }

tbody tr:hover { background: var(--color-bg); }

.row-actions { display: flex; gap: .5rem; align-items: center; }
.row-actions form { margin: 0; }

/* ---------------------------------------------------------------
   Standalone / unauthenticated pages (login)
   --------------------------------------------------------------- */
.auth-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.25rem;
  width: 100%;
  max-width: 22rem;
}

.auth-card .brand-mark {
  font-weight: 700;
  color: var(--color-primary-dark);
  font-size: 1.1rem;
  margin-bottom: .25rem;
}

.auth-card h1 { font-size: 1.05rem; color: var(--color-text-muted); font-weight: 500; margin-bottom: 1.5rem; }

.auth-card .btn { width: 100%; text-align: center; }

/* ---------------------------------------------------------------
   Tablet/phone: sidebar becomes a top bar with a hamburger button;
   the nav/settings/account menu collapses behind it rather than
   trying to fit inline. Field grids already collapse on their own
   via auto-fit, so most of this is just the app shell + hamburger.
   --------------------------------------------------------------- */
@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 10;
    padding: .75rem 1rem;
  }
  .brand { margin-bottom: 0; padding: 0; }
  .hamburger { display: flex; }

  .sidebar-menu {
    display: none;
    flex: 0 0 auto;
    margin-top: .75rem;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
  }
  .sidebar-menu.is-open { display: flex; }

  .sidebar-nav { flex: 0 0 auto; }
  .sidebar-nav-bottom { border-top: 1px solid rgba(255, 255, 255, .15); padding-top: .5rem; }
  .sidebar-footer { margin-top: .75rem; }

  .content { padding: 1.5rem; }
}

/* ---------------------------------------------------------------
   Phone: tighten spacing further.
   --------------------------------------------------------------- */
@media (max-width: 560px) {
  html, body { font-size: 14.5px; }
  .content { padding: 1rem; }
  .card { padding: 1.1rem; }
  h1 { font-size: 1.2rem; }
  .content-header { align-items: flex-start; }
  .content-header > .btn, .content-header > a.btn { width: 100%; text-align: center; }
  .form-inline { flex-direction: column; align-items: stretch; }
  .form-inline .field { min-width: 0; }
  .row-actions { flex-wrap: wrap; }
  table { font-size: .85rem; }
  th, td { padding: .55rem .6rem; }
}

/* ---------------------------------------------------------------
   Pipeline stage colours (matches the client's spreadsheet)
   --------------------------------------------------------------- */
.badge-warning { background: #fef3c7; color: #92400e; }

.stage-row.stage-tobespokento    { background: #fef9c3; }
.stage-row.stage-nocontact       { background: #e5e7eb; }
.stage-row.stage-awaitinginfo    { background: #bae6fd; }
.stage-row.stage-homeorshowroomappt { background: #f5d0fe; }
.stage-row.stage-sendforprices   { background: #d1d5db; }
.stage-row.stage-awaitingprices  { background: #fef08a; }
.stage-row.stage-tobequoted      { background: #99f6e4; }
.stage-row.stage-quoted          { background: #bfdbfe; }
.stage-row.stage-sold            { background: #bbf7d0; }
.stage-row.stage-deadlost        { background: #fecaca; }

tbody tr.stage-row:hover { filter: brightness(.96); }

.stage-chip {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  border: 1px solid rgba(0, 0, 0, .12);
}
.stage-chip.stage-tobespokento    { background: #fef9c3; }
.stage-chip.stage-nocontact       { background: #e5e7eb; }
.stage-chip.stage-awaitinginfo    { background: #7dd3fc; }
.stage-chip.stage-homeorshowroomappt { background: #f0abfc; }
.stage-chip.stage-sendforprices   { background: #d1d5db; color: #111827; }
.stage-chip.stage-awaitingprices  { background: #fde047; }
.stage-chip.stage-tobequoted      { background: #5eead4; }
.stage-chip.stage-quoted          { background: #93c5fd; }
.stage-chip.stage-sold            { background: #4ade80; }
.stage-chip.stage-deadlost        { background: #fca5a5; color: #7f1d1d; }

/* ---------------------------------------------------------------
   Filter bars + alert rows on list pages
   --------------------------------------------------------------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.filter-form { display: flex; gap: .75rem; align-items: center; }
.filter-form label { margin: 0; font-size: .85rem; }
.filter-form select { width: auto; min-height: 2.4rem; padding: .35rem .6rem; }

.alert-row {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: center;
  justify-content: space-between;
  padding: .55rem .8rem;
  border: 1px solid var(--color-border);
  border-left-width: 4px;
  border-radius: var(--radius-sm);
  margin-bottom: .5rem;
  background: var(--color-bg);
}
.alert-row.alert-info { border-left-color: #60a5fa; }
.alert-row.alert-warning { border-left-color: #f59e0b; }
.alert-row.alert-overdue { border-left-color: var(--color-danger); }
.alert-msg a { color: inherit; }
.alert-actions { display: flex; gap: .4rem; align-items: center; margin: 0; }
.snooze-days { width: 4rem; min-height: 2rem; padding: .2rem .4rem; }

/* ---------------------------------------------------------------
   Modal dialogs (native <dialog>, opened via [data-modal-open])
   --------------------------------------------------------------- */
dialog.modal {
  border: 1px solid var(--color-border);
  border-left: 5px solid var(--color-primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  width: 100%;
  max-width: 26rem;
  background: var(--color-surface);
  color: var(--color-text);
}
dialog.modal::backdrop { background: rgba(15, 23, 42, .45); }
dialog.modal h3 { margin: 0 0 1rem; color: var(--color-primary-dark); }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.25rem; }

.steps-actions { margin-top: 1.25rem; }
.steps-form-wrap, #steps-form { margin-top: 1rem; }

/* ---------------------------------------------------------------
   Steps editor (payment schedules)
   --------------------------------------------------------------- */
.steps-table input, .steps-table select {
  width: 100%;
  padding: .45rem .7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-family: inherit;
  background: #fff;
  color: var(--color-text);
  min-height: 2.4rem;
}
.steps-table select { padding-right: 2rem; }
.steps-table td { vertical-align: middle; }

.drag-handle {
  cursor: grab;
  color: var(--color-text-muted);
  font-size: 1rem;
  user-select: none;
}
tr.step-row.dragging { opacity: .4; }
tr.step-row td:first-child { width: 2rem; text-align: center; }
.step-seq { font-weight: 600; color: var(--color-text-muted); width: 2.5rem; }

/* ---------------------------------------------------------------
   Small layout/behaviour tweaks
   --------------------------------------------------------------- */
/* Space between stacked field grids inside one card (e.g. enquiry
   form's appointment notes grid above the quote amounts grid). */
.card .grid-2 + .grid-3, .card .grid-3 + .grid-2 { margin-top: 1.1rem; }

/* Selects need enough room for text + chevron - narrow ones were
   overlapping the arrow on top of the label text. */
select { min-width: 8rem; }
.filter-form select { min-width: 11rem; }

/* Amber warning action - sits between neutral secondary and danger. */
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; }

/* ---------------------------------------------------------------
   Invoice print view (invoices/invoice-print.php)
   --------------------------------------------------------------- */
.print-page { background: #fff; }
.invoice-doc {
  max-width: 800px; margin: 2rem auto; padding: 2.5rem;
  background: #fff; color: #1e293b; font-size: .95rem;
}
.invoice-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 3px solid var(--color-primary); padding-bottom: 1.25rem; margin-bottom: 1.5rem;
}
.invoice-head h1 { margin: 0 0 .25rem; font-size: 1.5rem; color: var(--color-primary); }
.invoice-meta h2 { margin: 0 0 .5rem; font-size: 1.2rem; text-transform: uppercase; letter-spacing: .05em; color: var(--color-primary); }
.invoice-meta table { border-collapse: collapse; }
.invoice-meta th { text-align: left; padding: .15rem 1rem .15rem 0; font-weight: 600; color: var(--color-text-muted); }
.invoice-meta td { padding: .15rem 0; }
.invoice-to { margin-bottom: 1.5rem; }
.invoice-to h3, .invoice-payments h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); margin: 0 0 .35rem; }
.invoice-lines { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.invoice-lines th { text-align: left; border-bottom: 2px solid var(--color-border); padding: .5rem .5rem .5rem 0; }
.invoice-lines td { padding: .6rem .5rem .6rem 0; border-bottom: 1px solid var(--color-border); }
.invoice-lines .num, .invoice-totals .num, .invoice-payments .num { text-align: right; }
.muted { color: var(--color-text-muted); }
.invoice-totals { margin-left: auto; border-collapse: collapse; min-width: 16rem; }
.invoice-totals th { text-align: left; padding: .35rem 1.5rem .35rem 0; font-weight: 600; }
.invoice-totals td { padding: .35rem 0; }
.invoice-balance th, .invoice-balance td {
  border-top: 2px solid var(--color-primary); font-size: 1.05rem; font-weight: 700;
  padding-top: .6rem; color: var(--color-primary);
}
.invoice-payments { margin-top: 1.5rem; }
.invoice-payments table { width: 100%; border-collapse: collapse; }
.invoice-payments th { text-align: left; border-bottom: 1px solid var(--color-border); padding: .35rem .5rem .35rem 0; }
.invoice-payments td { padding: .35rem .5rem .35rem 0; }
.invoice-foot { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--color-border); color: var(--color-text-muted); font-size: .85rem; }
.print-toolbar {
  position: fixed; top: 1rem; right: 1rem; display: flex; gap: .5rem;
  padding: .5rem; background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: 0 2px 8px rgba(0,0,0,.1);
}
@media print {
  .no-print { display: none !important; }
  .invoice-doc { margin: 0; padding: 0; max-width: none; }
  body.print-page { background: #fff; }
  /* Printing from the invoice modal: only the invoice is printed. */
  .app-shell, #crm-toasts { display: none !important; }
  dialog.invoice-modal[open] {
    position: static; display: block; width: auto; max-width: none; max-height: none;
    overflow: visible; border: 0; box-shadow: none; margin: 0; padding: 0;
  }
  dialog.invoice-modal::backdrop { display: none; }
}
/* Standalone invoice page: no grey canvas showing below the invoice. */
html:has(body.print-page) { background: #fff; }

/* Invoice modal (invoices list, invoice and contract pages). */
dialog.invoice-modal {
  width: min(52rem, 96vw); max-width: none; max-height: 92vh; padding: 0;
  overflow-y: auto; border-left-width: 1px;
}
.invoice-modal .invoice-doc { margin: 0; padding: 2rem 2.5rem; max-width: none; }
.invoice-modal .modal-actions {
  position: sticky; bottom: 0; margin: 0; padding: .75rem 1.5rem;
  background: var(--color-surface); border-top: 1px solid var(--color-border);
}
.invoice-modal .invoice-loading { padding: 2rem; text-align: center; color: var(--color-text-muted); }
@page { margin: 15mm; }

/* Toast notifications (booking confirmations, errors) - bottom right. */
#crm-toasts {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 100;
  display: flex; flex-direction: column; gap: .5rem; max-width: 22rem;
}
.toast {
  display: flex; align-items: center; gap: .75rem;
  background: #1e293b; color: #fff; padding: .6rem .9rem;
  border-radius: var(--radius); border-left: 4px solid var(--color-primary);
  box-shadow: 0 4px 14px rgba(0,0,0,.25); font-size: .85rem;
  animation: toast-in .2s ease-out;
}
.toast-action {
  background: var(--color-primary); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: .25rem .6rem;
  font-size: .8rem; cursor: pointer; white-space: nowrap;
}
.toast-action:hover { background: var(--color-primary-dark); }
.toast-out { opacity: 0; transition: opacity .4s; }
.toast-success { border-left-color: #22c55e; }
.toast-error { border-left-color: #ef4444; }
.field-counter { font-size: .78rem; color: var(--color-text-muted); margin: .25rem 0 0; text-align: right; }
.field-counter.is-over { color: var(--color-danger); font-weight: 600; }
input.is-over, textarea.is-over { border-color: var(--color-danger); }
dialog.confirm-modal { max-width: 24rem; }
dialog.confirm-modal p { margin: 0; }
.detail-list { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0; }
.detail-list dt { font-weight: 600; color: var(--color-text-muted); font-size: .85rem; }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }
.schedule-table td.num, .schedule-table th.num { text-align: right; }
@keyframes toast-in { from { transform: translateY(.5rem); opacity: 0; } to { transform: none; opacity: 1; } }
.muted-sm { font-size: .75rem; color: var(--color-text-muted); }

/* ---------------------------------------------------------------
   Fixed table layouts + column widths
   --------------------------------------------------------------- */
/* Filterable index tables keep the same column widths regardless of
   which rows the filter returns - widths come from <col> classes in a
   colgroup so no inline styles are needed (CSP-safe). */
.table-fixed { table-layout: fixed; min-width: 66rem; }
.table-fixed td { overflow: hidden; text-overflow: ellipsis; }
.cw-4 { width: 4rem; }  .cw-5 { width: 5rem; }  .cw-6 { width: 6rem; }
.cw-7 { width: 7rem; }  .cw-8 { width: 8rem; }  .cw-9 { width: 9rem; }
.cw-10 { width: 10rem; } .cw-11 { width: 11rem; } .cw-12 { width: 12rem; }

/* Wider filter select for long stage names. */
.select-wide { min-width: 14rem; }

/* ---------------------------------------------------------------
   Alerts panel - header row + severity filter chips
   --------------------------------------------------------------- */
.alerts-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.alerts-head h2 { margin: 0; }
.alert-filters { display: flex; gap: .35rem; }
.chip {
  border: 1px solid var(--color-border); background: #fff; color: var(--color-text);
  border-radius: 999px; padding: .2rem .7rem; font-size: .8rem; cursor: pointer;
}
.chip:hover { border-color: var(--color-primary); }
.chip-on { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.alert-sev {
  flex-shrink: 0; font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; padding: .1rem .45rem; border-radius: var(--radius-sm);
  background: rgba(0,0,0,.08); align-self: center;
}

/* ---------------------------------------------------------------
   Activity timeline (contract-edit.php)
   --------------------------------------------------------------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  padding: .4rem 0 .4rem 1.1rem; border-left: 2px solid var(--color-border);
  margin-left: .35rem; position: relative; font-size: .9rem;
}
.timeline li::before {
  content: ''; position: absolute; left: -0.32rem; top: .75rem;
  width: .45rem; height: .45rem; border-radius: 50%; background: var(--color-primary);
}
.timeline-date { color: var(--color-text-muted); font-size: .8rem; display: inline-block; min-width: 4.5rem; }

/* ---------------------------------------------------------------
   Alerts - slim top bar + on-demand modal (partials/alerts.php)
   --------------------------------------------------------------- */
.alerts-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: .55rem 1rem; margin-bottom: 1rem; border-radius: var(--radius);
  background: #fff; border: 1px solid var(--color-border); border-left: 4px solid var(--color-primary);
  font-size: .9rem;
}
.alerts-bar.alert-warning { border-left-color: #f59e0b; }
.alerts-bar.alert-overdue { border-left-color: var(--color-danger, #dc2626); }
.alerts-modal { width: min(46rem, 92vw); max-width: 46rem; }
.alerts-modal .alert-filters { margin: .4rem 0 .75rem; }
.alerts-modal .alert-list { max-height: 55vh; overflow-y: auto; }
.alerts-modal .alert-row { padding: .45rem .6rem; }

/* ---------------------------------------------------------------
   Contract milestones - vertical phase cards, equal height
   --------------------------------------------------------------- */
.phase-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1rem; align-items: stretch;
}
.phase-card {
  border: 1px solid var(--color-border); border-left: 4px solid var(--color-border);
  border-radius: var(--radius); padding: .9rem; background: #fff;
  display: flex; flex-direction: column; gap: .6rem;
}
.phase-card h3 {
  margin: 0 0 .25rem; font-size: .85rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--color-text-muted);
}
.phase-card.phase-active { border-left-color: #f59e0b; }
.phase-card.phase-active h3 { color: #b45309; }
.phase-card.phase-done { border-left-color: #16a34a; background: #f0fdf4; }
.phase-card.phase-done h3 { color: #15803d; }
.phase-field { margin: 0; }
.phase-field label { font-size: .78rem; }
.phase-field input { width: 100%; }
@media (max-width: 1100px) { .phase-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .phase-grid { grid-template-columns: 1fr; } }

/* Stage filter needs to be comfortably wider than the longest label. */
.select-wide { min-width: 18rem; }

/* Fixed tables: keep cells on one line so column widths hold and
   action buttons never wrap mid-label. */
.table-fixed th, .table-fixed td { white-space: nowrap; }
.table-fixed .row-actions { flex-wrap: nowrap; }
.cw-13 { width: 13rem; } .cw-14 { width: 14rem; }

/* Read-only calculated figures (VAT, totals) shown beside inputs. */
p.calc-value {
  margin: 0; min-height: 2.9rem; display: flex; align-items: center; padding: 0 .9rem;
  font-weight: 600; background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}
.vat-summary { margin-top: 1.1rem; }

/* ---------------------------------------------------------------
   Keyboard focus - visible on every interactive element
   --------------------------------------------------------------- */
a:focus-visible, button:focus-visible, summary:focus-visible, [tabindex]:focus-visible,
.btn:focus-visible, .chip:focus-visible, .book-chip:focus-visible, .legend-chip:focus-visible {
  outline: 2px solid var(--color-primary); outline-offset: 2px;
}
.sidebar a:focus-visible, .sidebar button:focus-visible { outline-color: #fff; }

/* ---------------------------------------------------------------
   Calendar (calendar/index.php) - FullCalendar is vendored in
   assets/vendor/; per-calendar colours live here (one class each,
   matching calendar_definitions() in private/functions.php).
   Colour = pale fill + solid left bar, so calendars stay
   distinguishable without relying on hue alone.
   --------------------------------------------------------------- */
.cal-bengeneral        { --cal-bg: #dbeafe; --cal-bar: #2563eb; }
.cal-bensales          { --cal-bg: #ede9fe; --cal-bar: #7c3aed; }
.cal-showroom          { --cal-bg: #fce7f3; --cal-bar: #db2777; }
.cal-carlinstall       { --cal-bg: #dcfce7; --cal-bar: #16a34a; }
.cal-carlsurveys       { --cal-bg: #ccfbf1; --cal-bar: #0f766e; }
.cal-builder           { --cal-bg: #ffedd5; --cal-bar: #ea580c; }
.cal-deliveries        { --cal-bg: #fef9c3; --cal-bar: #ca8a04; }
.cal-staff             { --cal-bg: #fee2e2; --cal-bar: #dc2626; }

.cal-layout { display: flex; gap: 1.25rem; align-items: flex-start; }
.cal-layout .fc-crm { flex: 1; min-width: 0; position: relative; }
@media (max-width: 1100px) { .cal-layout { flex-direction: column; } .book-panel { width: 100%; } }

.cal-toolbar { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.cal-legend { display: flex; flex-wrap: wrap; gap: .4rem; }
.legend-chip {
  display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .65rem; cursor: pointer;
  border: 1px solid var(--color-border); border-radius: 999px; background: #fff; color: var(--color-text);
  font: inherit; font-size: .8rem;
}
.legend-chip .legend-swatch { width: .8rem; height: .8rem; border-radius: 3px; background: var(--cal-bg); border: 2px solid var(--cal-bar); }
.legend-chip[aria-pressed="false"] { opacity: .55; text-decoration: line-through; background: var(--color-bg); }
.legend-chip[aria-pressed="false"] .legend-swatch { background: transparent; }
.legend-chip:hover { border-color: var(--color-primary); }
.legend-all { border-style: dashed; }
.cal-staff-filter { display: flex; align-items: center; gap: .5rem; }
.cal-staff-filter label { margin: 0; font-size: .85rem; }
.cal-staff-filter select { width: auto; min-width: 11rem; min-height: 2.4rem; padding: .35rem 2rem .35rem .6rem; }

.fc-crm { font-size: .95rem; --fc-event-text-color: #0f172a; --fc-page-bg-color: #fff; --fc-today-bg-color: rgba(29, 78, 216, .07); }
.fc-crm.is-loading { opacity: .6; transition: opacity .15s; }
.fc-crm .fc-toolbar-title { font-size: 1.15rem; color: var(--color-primary-dark); }
.fc-crm .fc-button {
  background: #fff; border: 1px solid var(--color-border); color: var(--color-text);
  font-size: .85rem; padding: .35rem .7rem; text-transform: none;
}
.fc-crm .fc-button:hover { background: var(--color-bg); }
.fc-crm .fc-button-primary:not(:disabled).fc-button-active,
.fc-crm .fc-button-primary:not(:disabled):active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.fc-crm a, .fc-crm .fc-daygrid-day-number, .fc-crm .fc-col-header-cell-cushion,
.fc-crm .fc-list-day-text, .fc-crm .fc-list-day-side { color: #0f172a; }
.fc-crm .fc-event {
  background: var(--cal-bg, #e0e7ff); border: 0; border-left: 4px solid var(--cal-bar, var(--color-primary));
  border-radius: var(--radius-sm); color: #0f172a; cursor: pointer;
}
.fc-crm .fc-event-main, .fc-crm .fc-event-title, .fc-crm .fc-event-time { color: #0f172a; }
.fc-crm .fc-daygrid-event { padding: .15rem .4rem; font-size: .85rem; }
.fc-crm .fc-list-event td { padding: .5rem .6rem; font-size: .95rem; }
.fc-crm .fc-list-event .fc-list-event-dot { border-color: var(--cal-bar, var(--color-primary)); }
.fc-crm .fc-list-event .fc-list-event-title a { color: #0f172a; }
.fc-crm .fc-daygrid-day-events { min-height: 1.4em; }
.fc-crm .fc-event.fc-event-dragging { box-shadow: 0 4px 12px rgba(0, 0, 0, .25); }

/* Drag-to-book side panel */
.book-panel {
  width: 17rem; flex-shrink: 0; padding: 1rem; background: #fff;
  border: 1px solid var(--color-border); border-top: 4px solid var(--color-primary); border-radius: var(--radius);
}
.book-panel h2 { font-size: 1rem; margin: 0 0 .75rem; color: var(--color-primary); }
.book-panel h3 { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); margin: 1rem 0 .4rem; }
.book-panel .field { margin-bottom: .75rem; }
.book-panel select, .book-panel input[type=search] { width: 100%; }
.book-hint { font-size: .8rem; color: var(--color-text-muted); margin: .25rem 0 .5rem; }
.book-list { max-height: 14rem; overflow-y: auto; display: flex; flex-direction: column; gap: .3rem; padding-right: .25rem; }
.book-chip {
  display: flex; align-items: center; gap: .4rem; padding: .35rem .5rem .35rem .6rem; font-size: .82rem;
  background: var(--color-bg); border: 1px solid var(--color-border); border-left: 3px solid var(--color-primary);
  border-radius: var(--radius-sm); cursor: grab;
}
.book-chip .book-chip-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-chip:hover { border-color: var(--color-primary); }
.book-chip:active { cursor: grabbing; }
.chip-book { border: 1px solid var(--color-border); background: #fff; border-radius: var(--radius-sm); cursor: pointer; font-size: .75rem; padding: .1rem .4rem; }
.chip-book:hover { border-color: var(--color-primary); color: var(--color-primary); }

/* Event dialog buttons */
.event-modal-actions { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: flex-end; margin-top: 1.25rem; }
.event-modal-actions form { margin: 0; }

/* Save / delete rows: safe actions on the left, destructive action
   alone on the far right so it is never hit by accident. */
.form-actions { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 1.5rem; }
.form-actions-main { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.form-actions > .btn-danger { margin-left: auto; }
.event-modal-actions { justify-content: space-between; }
.event-modal-actions .event-modal-main { display: flex; gap: .6rem; }

/* Book-from-pipeline panel is twice the original size. */
.book-panel { width: 34rem; padding: 1.5rem; }
.book-panel h2 { font-size: 1.15rem; }
.book-panel h3 { font-size: .85rem; margin: 1.25rem 0 .5rem; }
.book-list { max-height: 24rem; gap: .5rem; }
.book-chip { padding: .6rem .8rem .6rem .9rem; font-size: 1rem; }
.chip-book { font-size: .9rem; padding: .25rem .7rem; }
.book-hint { font-size: .9rem; }
@media (max-width: 1500px) { .book-panel { width: 26rem; } }
@media (max-width: 1100px) { .book-panel { width: 100%; } }

/* Reconciliation tool (admin/reconcile.php) */
.inline-form { display: flex; gap: .5rem; align-items: center; margin: 0; flex-wrap: wrap; }
.inline-form select { width: auto; min-width: 16rem; max-width: 26rem; min-height: 2.4rem; padding-top: .35rem; padding-bottom: .35rem; }
.inline-form input[type=date] { width: auto; min-height: 2.4rem; padding: .35rem .6rem; }
.recon-summary { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: .5rem 1.5rem; }
.recon-summary li { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--color-border); padding: .35rem 0; }

/* ---------------------------------------------------------------
   Settings landing page - compact cards in rows
   --------------------------------------------------------------- */
.settings-group { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--color-text-muted); margin: 1.5rem 0 .6rem; }
.settings-group:first-of-type { margin-top: 0; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .9rem; }
a.settings-card {
  display: block; padding: .9rem 1rem; text-decoration: none; color: inherit;
  background: var(--color-surface); border: 1px solid var(--color-border); border-left: 4px solid var(--color-primary);
  border-radius: var(--radius); box-shadow: var(--shadow); transition: border-color .15s ease, box-shadow .15s ease;
}
a.settings-card:hover { border-color: var(--color-primary); }
a.settings-card h3 { margin: 0 0 .25rem; font-size: .95rem; color: var(--color-primary-dark); }
a.settings-card p { margin: 0; font-size: .82rem; color: var(--color-text-muted); }

/* ---------------------------------------------------------------
   Alerts modal - wide, one line per alert
   --------------------------------------------------------------- */
dialog.modal.alerts-modal { width: min(72rem, 96vw); max-width: 72rem; }
.alerts-modal .alert-row { flex-wrap: nowrap; gap: 1rem; }
.alerts-modal .alert-msg { flex: 1; min-width: 0; }
.alerts-modal .alert-actions { flex-shrink: 0; }
.snooze-unit { font-size: .8rem; color: var(--color-text-muted); }
@media (max-width: 800px) { .alerts-modal .alert-row { flex-wrap: wrap; } }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }

/* ---------------------------------------------------------------
   Filter pills (enquiries, sales ledger, invoices) + status colours
   --------------------------------------------------------------- */
.filter-pills { display: flex; flex-wrap: wrap; gap: .4rem; }
.filter-solo { display: flex; align-items: center; gap: .5rem; }
.filter-solo label { margin: 0; font-size: .85rem; }
.filter-solo select { width: auto; min-height: 2.4rem; padding: .35rem 2rem .35rem .6rem; }
.filter-pill { cursor: pointer; font: inherit; font-size: .8rem; padding: .25rem .7rem; color: var(--color-text); }
.filter-pill.stage-chip[aria-pressed="false"] { background: var(--color-bg); opacity: .5; text-decoration: line-through; }
.filter-pill.filter-all { background: #fff; border: 1px dashed var(--color-border); border-radius: 999px; }
.filter-pill:hover { border-color: var(--color-primary); }
.pill-count { font-weight: 700; opacity: .65; margin-left: .15rem; }
tr[hidden] { display: none; }

.stage-row.stage-active    { background: #e0f2fe; }
.stage-row.stage-completed { background: #bbf7d0; }
.stage-row.stage-onhold    { background: #fef08a; }
.stage-row.stage-cancelled { background: #fecaca; }
.stage-row.stage-unpaid    { background: #fed7aa; }
.stage-row.stage-partpaid  { background: #fef08a; }
.stage-row.stage-paid      { background: #bbf7d0; }
.stage-row.stage-void      { background: #e5e7eb; color: #6b7280; }
.stage-row.stage-overdue   { background: #fecaca; }
.stage-chip.stage-active    { background: #7dd3fc; }
.stage-chip.stage-completed { background: #4ade80; }
.stage-chip.stage-onhold    { background: #fde047; }
.stage-chip.stage-cancelled { background: #fca5a5; color: #7f1d1d; }
.stage-chip.stage-unpaid    { background: #fdba74; }
.stage-chip.stage-partpaid  { background: #fde047; }
.stage-chip.stage-paid      { background: #4ade80; }
.stage-chip.stage-void      { background: #d1d5db; color: #374151; }
.stage-chip.stage-overdue   { background: #f87171; color: #450a0a; }

/* ---------------------------------------------------------------
   Hidden means hidden (component display rules must not override it)
   --------------------------------------------------------------- */
[hidden] { display: none !important; }

/* ---------------------------------------------------------------
   Button colour scheme (used the same way on every page):
     primary  = main forward action (Save, New Invoice, Mark Sold)
     edit     = open / change a record          view = PDF / view
     warning  = reversible change (Snooze, Undo sale, Return)
     success  = complete / resolve             danger = delete / void
     secondary= neutral (Cancel, Back, Close)
   --------------------------------------------------------------- */
.btn-edit { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.btn-edit:hover { background: #bfdbfe; }
.btn-view { background: #ccfbf1; color: #0f766e; border: 1px solid #99f6e4; }
.btn-view:hover { background: #99f6e4; }
.cw-19 { width: 19rem; }

/* ---------------------------------------------------------------
   Dialog header with a window-style close button
   --------------------------------------------------------------- */
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.modal-head h3 { margin: 0; }
.modal-close {
  flex-shrink: 0; border: 0; background: transparent; cursor: pointer; font-size: 1.75rem; line-height: 1;
  color: var(--color-text-muted); padding: 0 .35rem; border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--color-bg); color: var(--color-text); }
dialog.modal > .modal-close { position: absolute; top: .6rem; right: .8rem; }

dialog.event-dialog { width: min(34rem, 94vw); max-width: 34rem; padding: 1.5rem 1.75rem; }
.event-dialog .detail-list { gap: .6rem 1.25rem; }
.event-modal-actions {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--color-border);
}
.event-modal-main { display: flex; gap: .6rem; flex-wrap: wrap; }

dialog.invoice-edit-modal { width: min(58rem, 96vw); max-width: none; max-height: 92vh; overflow-y: auto; padding: 1.5rem 1.75rem; }
.invoice-edit-modal .content-header { margin-right: 2.5rem; margin-bottom: 1rem; }

/* ---------------------------------------------------------------
   Reconciliation page
   --------------------------------------------------------------- */
.recon-summary-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.recon-summary-head h2 { margin: 0; }
.recon-toggle { display: flex; align-items: center; gap: .5rem; margin: 0; font-weight: 500; text-transform: none; cursor: pointer; }
.recon-toggle input { width: auto; min-height: auto; }
.recon-problems { margin: 0; padding-left: 1.1rem; }
.recon-fixes { flex-wrap: wrap; }
dialog.recon-modal { width: min(36rem, 94vw); max-width: 36rem; padding: 1.5rem 1.75rem; }

/* ---------------------------------------------------------------
   Contract cancellation modal, payment entry spacing, alerts
   --------------------------------------------------------------- */
.cw-22 { width: 22rem; }
dialog.contract-cancel-modal { width: min(44rem, 96vw); max-width: none; max-height: 92vh; overflow-y: auto; padding: 1.5rem 1.75rem; }
.contract-cancel-modal .content-header { margin-right: 2.5rem; margin-bottom: 1rem; }
.cancel-heading { margin: 1.25rem 0 .5rem; font-size: 1rem; }
.cancel-changes { margin: 0 0 1rem; padding-left: 1.2rem; display: grid; gap: .4rem; }
.check-label { display: flex; align-items: center; gap: .5rem; margin: .5rem 0; font-weight: 500; text-transform: none; cursor: pointer; }
.check-label input { width: auto; min-height: auto; }
.check-label .refund-amount { width: 8rem; min-height: 2.2rem; padding: .3rem .5rem; }
.card-cancelled { border-left: 4px solid var(--color-danger); }
.payment-entry { margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid var(--color-border); }
.payment-entry-title { margin: 0 0 .75rem; font-size: 1rem; }
.alert-open { flex-shrink: 0; white-space: nowrap; }
/* Sales ledger tick + date tracker */
.track-table input[type="number"], .track-table input[type="date"] { width: 100%; box-sizing: border-box; }
.track-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.track-grid > .card { margin: 0; }
.track-grid > .card:nth-child(3) { grid-row: span 2; }
@media (max-width: 1100px) { .track-grid > .card:nth-child(3) { grid-row: auto; } }
@media (max-width: 1100px) { .track-grid { grid-template-columns: 1fr; } }
.track-grid { margin-bottom: 1rem; }
.track-table { table-layout: fixed; width: 90%; }
.track-table .tc-amount { width: 8rem; }
.track-table .tc-done { width: 4rem; }
.track-table .tc-date { width: 12.5rem; }
.track-table th, .track-table td { text-align: left; vertical-align: middle; }
.track-table .track-tick { width: 1.9rem; height: 1.9rem; cursor: pointer; }
.enquiry-add-actions { margin-top: 1rem; }
.enquiry-save-actions { margin-top: 1.25rem; }
.track-row.is-done td { background: #f0fdf4; }
.track-row.is-done td:first-child { border-left: 4px solid #16a34a; font-weight: 600; color: #15803d; }
.track-row:not(.is-done) td:first-child { border-left: 4px solid #f59e0b; }
.track-na { color: #9ca3af; font-size: .85rem; }
.track-count { font-size: .8rem; font-weight: 600; color: #b45309; margin-left: .5rem; }
.track-count.track-all { color: #15803d; }

/* Red "!" marker beside a record number when it has active alerts */
.alert-dot {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.15rem; height: 1.15rem; margin-left: .6rem;
    border-radius: 50%; background: #dc2626; color: #fff;
    font-size: .75rem; font-weight: 700; line-height: 1; vertical-align: middle;
}

.tick-lg { width: 1.9rem; height: 1.9rem; cursor: pointer; }

.quote-block { position: relative; padding: 1rem 0; border-top: 1px solid #e5e7eb; }
.quote-block .quote-remove { position: absolute; right: 0; bottom: 1rem; margin: 0; }

.quote-amounts { margin-top: 1rem; }

/* Sales Ledger nett sales totals bar */
.sales-bar { display: flex; flex-wrap: wrap; gap: 1rem; align-items: stretch; margin: 0 0 1rem; padding: .85rem 1.1rem; background: #fff; border: 1px solid #e5e7eb; border-left: 4px solid #2563eb; border-radius: 8px; }
.sales-stat { display: flex; flex-direction: column; min-width: 12rem; padding-right: 1.5rem; border-right: 1px solid #e5e7eb; }
.sales-stat:nth-of-type(3) { border-right: 0; }
.sales-stat-label { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: #6b7280; }
.sales-stat-value { font-size: 1.5rem; font-weight: 700; color: #111827; line-height: 1.3; }
.sales-stat-note { font-size: .78rem; color: #6b7280; }
.sales-bar-hint { flex-basis: 100%; margin: 0; font-size: .78rem; color: #9ca3af; }
