/* Left-hand navigation rail (v3.18.0)
   Goals: persistent on desktop with a hide toggle that slides it off-screen;
   slides in from the left on mobile via a hamburger; settings (theme + logout)
   live behind a cog popover at the bottom-left. */

:root {
  --left-nav-width: 220px;
}

.left-nav {
  position: fixed;
  /* Small inset that matches the trimmed content-sheet top/left margins */
  top: 3px;
  left: 4px;
  bottom: 0;
  width: var(--left-nav-width);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 12px;
  background: #fafafa;
  border: 1px solid var(--hairline);
  border-bottom: 0;
  border-top-right-radius: 10px;
  z-index: 1030;
  overflow-y: auto;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: transform 0.2s ease;
}

.left-nav.is-collapsed {
  transform: translateX(-100%);
  box-shadow: none;
}

.left-nav__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.left-nav__brand {
  display: inline-block;
  padding: 0;
  line-height: 0;
  width: 48px;
  height: 48px;
  /* Crop the whitespace around the C-mark by scaling the image up inside
     a fixed-size frame and clipping the overflow. */
  overflow: hidden;
  border-radius: 6px;
  position: relative;   /* sit above the voice aura (issue #44) */
  z-index: 1;
  cursor: pointer;
}

.left-nav__brand img.left-nav__brand-mark {
  /* Matched-size to the hide button so tops align. The scale crops the
     ~20% white margin baked into the favicon PNG. */
  width: 48px;
  height: 48px;
  border-radius: 0;
  object-fit: contain;
  display: block;
  transform: scale(1.5);
  transform-origin: center;
}

/* === Issue #44: voice assistant lives on the Custodia logo =============== */
/* #voice-trigger (the logo) toggles the assistant. voice-widget.tpl.php
   reflects conversation state + mic level onto .left-nav__brand-wrap as
   [data-voice-state] and the --level custom property. */
.left-nav__brand-wrap {
  position: relative;
  display: inline-block;
  isolation: isolate;        /* keep the aura stacked behind this logo only */
  --level: 0;
}
.left-nav__brand-aura {
  position: absolute;
  inset: -6px;
  z-index: 0;                /* behind the logo (.left-nav__brand is z-index:1) */
  border-radius: 14px;
  opacity: 0;
  transform: scale(0.6);
  pointer-events: none;
  background: conic-gradient(from 0deg,
    #ff3b30, #ff9f0a, #ffd60a, #34c759, #00c7be, #0a84ff, #5e5ce6, #bf5af2, #ff2d55, #ff3b30);
  filter: blur(7px) saturate(1.25);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
/* Listening / speaking: the aura fades in, slowly spins and breathes; its
   intensity and scale track the live mic level (--level, 0..1). */
.left-nav__brand-wrap[data-voice-state="listening"] .left-nav__brand-aura,
.left-nav__brand-wrap[data-voice-state="speaking"]  .left-nav__brand-aura {
  opacity: calc(0.68 + var(--level, 0) * 0.32);
  transform: scale(calc(1 + var(--level, 0) * 0.16));
  animation: brand-aura-spin 6s linear infinite,
             brand-aura-breathe 2.6s ease-in-out infinite;
}
/* Thinking: a small rainbow segment ping-pongs left<->right beneath the logo. */
.left-nav__brand-think {
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: -7px;
  height: 3px;
  z-index: 2;
  border-radius: 3px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.left-nav__brand-think::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 42%;
  border-radius: 3px;
  background: linear-gradient(90deg,
    #ff3b30, #ff9f0a, #ffd60a, #34c759, #0a84ff, #5e5ce6, #bf5af2);
}
.left-nav__brand-wrap[data-voice-state="thinking"] .left-nav__brand-think { opacity: 1; }
.left-nav__brand-wrap[data-voice-state="thinking"] .left-nav__brand-think::before {
  animation: brand-think-slide 1s ease-in-out infinite alternate;
}
@keyframes brand-aura-spin { to { rotate: 360deg; } }
@keyframes brand-aura-breathe {
  0%, 100% { filter: blur(6px) saturate(1.2); }
  50%      { filter: blur(10px) saturate(1.5); }
}
@keyframes brand-think-slide {
  from { transform: translateX(0); }
  to   { transform: translateX(138%); }
}
@media (prefers-reduced-motion: reduce) {
  .left-nav__brand-aura,
  .left-nav__brand-think::before { animation: none !important; }
}
/* Customers table: cap row height so notes/road-map can't blow rows up.
   line-clamp would need display:-webkit-box which breaks table-cell layout,
   so use plain max-height. truncateWords:12 (server-side) handles the
   text length; this rule enforces the visual cap. */
table#customerTable td.row_data {
  max-height: 4.6em;
  line-height: 1.4;
  overflow: hidden;
}
table#customerTable td .expandable-short {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}

.left-nav__search {
  display: flex;
  gap: 4px;
}

.left-nav__search .form-control {
  flex: 1 1 auto;
  min-width: 0;
}

.left-nav__primary,
.left-nav__group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Groups stack with a hairline divider between them. The first group
   (Glass) has no top divider; the last group (Admin, when present) hugs
   the bottom of the rail via the existing .left-nav__spacer above it. */
.left-nav__group + .left-nav__group {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--hairline);
}

.left-nav__link {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  color: inherit;
  text-decoration: none;
  font-size: 0.95rem;
  line-height: 1.4;
  transition: background 0.15s ease;
}

.left-nav__link:hover,
.left-nav__link:focus-visible {
  background: rgba(0, 0, 0, 0.06);
}

.left-nav__link.active {
  background: rgba(0, 0, 0, 0.08);
  font-weight: 600;
}

.left-nav__link--disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.left-nav__spacer {
  flex: 1 1 auto;
}

/* In-rail "hide" chevron: same size as the C-mark, top-aligned via flex */
.left-nav__hide {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  line-height: 1;
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 6px;
  color: inherit;
  cursor: pointer;
}

.left-nav__hide:hover,
.left-nav__hide:focus-visible {
  background: rgba(0, 0, 0, 0.06);
}

/* The show toggle: mirror of the hide button (same 48x48 styled rectangle,
   right-pointing chevron). Visible only when the rail is hidden. */
.left-nav__toggle {
  position: fixed;
  top: 3px;
  left: 4px;
  z-index: 1031;
  width: 48px;
  height: 48px;
  padding: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  line-height: 1;
  background: #fafafa;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  color: inherit;
  cursor: pointer;
}

.left-nav__toggle:hover,
.left-nav__toggle:focus-visible {
  background: rgba(0, 0, 0, 0.06);
}

body.left-nav-collapsed .left-nav__toggle {
  display: inline-flex;
}

/* Push page content right of the rail when it's visible; reclaim space when collapsed.
   Applied to outermost wrappers only; <main> is nested inside .main-wrapper.
   margin-left = rail-width + 4px left inset so content doesn't sit under the rail. */
body.has-left-nav .main-wrapper,
body.has-left-nav > footer {
  margin-left: calc(var(--left-nav-width) + 4px);
  transition: margin-left 0.2s ease;
}

body.left-nav-collapsed .main-wrapper,
body.left-nav-collapsed > footer {
  margin-left: 0;
}

/* Footer block: user name on the left, cog popover on the right */
.left-nav__footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.left-nav__user-name {
  flex: 1 1 auto;
  font-size: 0.85rem;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Bottom-left settings link: navigates to /settings (cog page). */
.left-nav__settings-link {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  background: transparent;
  font-size: 1.1rem;
  line-height: 1;
  color: inherit;
  text-decoration: none;
  transition: background 0.15s ease;
}
.left-nav__settings-link svg { width: 18px; height: 18px; display: block; }

.left-nav__settings-link:hover,
.left-nav__settings-link:focus-visible {
  background: rgba(0, 0, 0, 0.06);
  color: inherit;
}

/* Settings page cards (rendered by views\Settings) */
.settings-card {
  padding: 16px 20px;
  margin-bottom: 16px;
  background: #fff;
  border: 1px solid #d8dadd;
  border-radius: 8px;
}

.settings-card__title {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.settings-card__row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
}

.settings-card .theme-actions {
  display: flex;
  gap: 8px;
}

.settings-card__hint { font-size: 0.85rem; opacity: 0.65; margin: -8px 0 12px; }

.voice-constitution-form { display: flex; flex-direction: column; gap: 10px; }
.voice-constitution__text {
  font-size: 0.9rem;
  line-height: 1.5;
  min-height: 120px;
  resize: vertical;
}
.voice-constitution__actions { display: flex; gap: 10px; align-items: center; }
.voice-constitution__reset { color: #c62828; padding: 0; }
.settings-card__empty { font-size: 0.9rem; opacity: 0.6; padding: 8px 0; }

.settings-flash {
  margin-bottom: 16px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
}
.settings-flash--success { background: #e8f5e9; color: #1b5e20; border: 1px solid #c8e6c9; }
.settings-flash--error   { background: #ffebee; color: #b71c1c; border: 1px solid #ffcdd2; }
.settings-flash--info    { background: #e3f2fd; color: #0d47a1; border: 1px solid #bbdefb; }

.ics-feeds-list { list-style: none; margin: 0 0 12px; padding: 0; }
.ics-feed {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--hairline);
}
.ics-feed:last-child { border-bottom: 0; }
.ics-feed__swatch {
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  display: inline-block;
}
.ics-feed__meta { flex: 1 1 auto; min-width: 0; }
.ics-feed__label { font-weight: 600; font-size: 0.9rem; }
.ics-feed__url {
  font-size: 0.75rem; opacity: 0.6;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ics-feed__remove { margin: 0; flex: 0 0 auto; }
.ics-feed__remove-btn { color: #c62828; }

.ics-feed-add__fields {
  display: grid;
  grid-template-columns: minmax(120px, 200px) 1fr 40px auto;
  gap: 8px;
  align-items: center;
}
.ics-feed-add__color {
  width: 40px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--hairline);
  border-radius: 4px;
}
@media (max-width: 600px) {
  .ics-feed-add__fields { grid-template-columns: 1fr; }
  .ics-feed-add__color { width: 100%; }
}

/* v3.18.1 UI polish: darken hairlines for clearer section boundaries and
   drop the white "sheet" colour to grey so the page background and the main
   surface match. Cards/panels keep their white fill. */
:root {
  --hairline: #c8ccd1;
  --surface-1: #fafafa;
}

/* Page background is plain white; the rail picks up the faded grey
   so it reads as a distinct surface. */
body.has-left-nav {
  background-color: #ffffff !important;
}

body.has-left-nav .main-wrapper {
  /* Top and left margins shrunk to 25% of previous (12->3, 16->4);
     right and bottom unchanged. margin-left is set by the earlier
     general rule and overridden by .left-nav-collapsed when the rail
     hides — do not redeclare it here or the collapse rule loses. */
  padding: 3px 16px 16px 4px;
}

body.has-left-nav .main-wrapper > main {
  /* Match the rail surface (#fafafa) so the sheet reads as the
     primary working surface against the white page edge. */
  background-color: #fafafa;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  margin: 0;
  /* Tight top padding to match the rail's 3px top inset; ample bottom
     padding for a comfortable scroll bottom. */
  padding: 3px 20px 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  /* Anchor for the absolute-positioned .header-btns below. */
  position: relative;
}

/* Float the page-action buttons (New Customer / New Contact) to the top
   right of the sheet so they don't consume a 76px row above the content.
   Empty page-title (list views) is hidden so the .header collapses. */
body.has-left-nav .main-wrapper > main .layout-default > .header {
  position: relative;
  min-height: 0;
}
body.has-left-nav .main-wrapper > main .layout-default > .header > .header-btns {
  position: absolute;
  top: 12px;
  right: 20px;
  z-index: 2;
  padding-top: 0;
}
body.has-left-nav .main-wrapper > main .layout-default > .header > .page-title:empty {
  display: none;
}
/* When .page-title has content (detail views), keep header in flow so the
   title and content stack normally. */
body.has-left-nav .main-wrapper > main .layout-default > .header:has(.page-title:not(:empty)) {
  display: block;
  min-height: auto;
}

/* Sections / panels / cards: darker borders for separation */
.panel,
.section,
.card,
.details-card,
.customer-details {
  border-color: var(--hairline) !important;
}

/* Glass page (curated dashboard surface).
   Two INDEPENDENT columns. Each column is its own vertical flex stack, so the
   columns clear separately: a tall card in one column never reserves height in
   the other (the row-major grid we used before coupled the two, dragging the
   opposite column's cards down). Each widget belongs to exactly one column;
   drag moves it within or between columns and the layout saves per-column. */
.glass-cols {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.glass-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
/* Disabled widgets live here (removed from both columns) until re-added. */
.glass-hidden { display: none; }

@media (max-width: 900px) {
  .glass-cols { flex-direction: column; }
}

/* In edit mode the two columns read as distinct drop zones, and an emptied
   column keeps enough height to still be a drop target. */
.glass-grid.is-editing .glass-col {
  min-height: 80px;
  outline: 1px dashed var(--hairline);
  outline-offset: 8px;
  border-radius: 8px;
}

/* Widget shell is the grid item. min-width:0 lets it shrink below its
   content's intrinsic width — without it a wide child (e.g. an SVG chart with
   a large viewBox) forces its column past 1fr and the two-column grid blows
   out into a single overflowing column. */
.glass-widget {
  margin-bottom: 0;
  position: relative;
  min-width: 0;
}

.glass-card {
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 16px 20px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ----- Glass edit mode ----- */
.glass-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 12px;
}
.glass-toolbar__edit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--hairline);
  background: #fff;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.85rem;
  cursor: pointer;
}
.glass-toolbar__cog { width: 15px; height: 15px; }
.glass-toolbar__edit[aria-pressed="true"] { background: #fff8e1; border-color: #f6c43c; }
.glass-toolbar__edit-actions { display: flex; gap: 8px; }
/* The HTML `hidden` attribute must win over the display:flex above. */
.glass-toolbar__edit-actions[hidden] { display: none; }

/* Per-widget edit chrome: grab bar + close. Hidden until edit mode. */
.glass-widget__bar { display: none; }
.glass-grid.is-editing .glass-widget {
  outline: 1px dashed var(--hairline);
  outline-offset: 3px;
  border-radius: 8px;
  cursor: grab;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.glass-grid.is-editing .glass-widget:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.08); }
.glass-grid.is-editing .glass-widget__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  margin-bottom: 6px;
  background: #fff8e1;
  border: 1px solid #f6c43c;
  border-radius: 6px;
  font-size: 0.78rem;
}
.glass-widget__grip { font-weight: 600; opacity: 0.8; user-select: none; }
.glass-widget__close {
  border: 0;
  background: transparent;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  color: #c62828;
  padding: 0 4px;
}
.glass-widget.is-dragging { opacity: 0.5; }

/* Add-widget control (last grid item; shown only in edit mode) */
.glass-add { break-inside: avoid; margin-bottom: 16px; position: relative; }
.glass-add[hidden] { display: none; }
.glass-add__btn {
  width: 100%;
  border: 1px dashed var(--hairline);
  background: #fff;
  border-radius: 8px;
  padding: 14px;
  font-size: 0.9rem;
  cursor: pointer;
  color: #555;
}
.glass-add__btn:hover { border-color: #f6c43c; background: #fffdf5; }
.glass-add__btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.glass-add__menu {
  margin-top: 6px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  overflow: hidden;
}
.glass-add__item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 9px 12px;
  font-size: 0.88rem;
  cursor: pointer;
}
.glass-add__item:hover { background: rgba(0,0,0,0.05); }
.glass-add__item[hidden] { display: none; }

.glass-card__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 8px;
}

.glass-card__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.glass-card__more {
  font-size: 0.85rem;
  text-decoration: none;
  opacity: 0.7;
}
.glass-card__more:hover { opacity: 1; }

.glass-card__body { flex: 1 1 auto; min-width: 0; }

.recent-empty { padding: 8px 0; font-size: 0.9rem; opacity: 0.6; }

/* The floating voice orb overlay was removed (issue #89): the only voice control
   is the Custodia logo (#voice-trigger) in the rail, and the transcript lives in
   the Glass assistant card (.glass-card--voice). */

/* === Voice assistant card =============================================== */
.glass-card--voice .voice-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-top: 4px;
}
.voice-state {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #6b6256;
  background: rgba(251, 208, 104, 0.14);
  opacity: 0.75;
  transition: color 0.2s ease, background 0.2s ease, opacity 0.2s ease;
}
.voice-state[data-state="listening"] { color: #a9781a; background: rgba(251, 208, 104, 0.30); opacity: 1; }
.voice-state[data-state="speaking"]  { color: #0f7d6e; background: rgba(15, 125, 110, 0.12); opacity: 1; }

/* Thinking: the same little rainbow bar the Custodia voice assistant shows beneath
   the logo — a thin spectrum segment that slides back and forth under the label.
   Reuses the brand-think-slide animation so it matches the assistant exactly. */
.voice-state[data-state="thinking"] {
  opacity: 1;
  color: #6b6256;
  background: rgba(251, 208, 104, 0.14);
  overflow: hidden;
  padding-bottom: 6px;
}
.voice-state[data-state="thinking"]::after {
  content: "";
  position: absolute;
  left: 4px;
  bottom: 2px;
  width: 42%;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg,
    #ff3b30, #ff9f0a, #ffd60a, #34c759, #0a84ff, #5e5ce6, #bf5af2);
  animation: brand-think-slide 1s ease-in-out infinite alternate;
}
@media (prefers-reduced-motion: reduce) {
  .voice-state[data-state="thinking"]::after { animation: none; }
}

/* Brand-yellow pulsing circle with the C-mark in the middle. Two outer
   rings (ring--1, ring--2) emanate outward when active; --level (0..1)
   is set from the AudioContext analyser so the rings intensity tracks
   live audio. */
.voice-orb {
  --brand: #f6c43c;
  --brand-dim: rgba(246, 196, 60, 0.55);
  --level: 0;
  position: relative;
  width: 140px;
  height: 140px;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
}
.voice-orb:focus-visible { outline: 2px solid rgba(0,0,0,0.2); outline-offset: 6px; }
.voice-orb[disabled] { opacity: 0.4; cursor: not-allowed; }

.voice-orb__core {
  position: absolute;
  inset: 22px;
  border-radius: 50%;
  background: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.voice-orb:hover .voice-orb__core { transform: scale(1.04); }

.voice-orb__logo {
  width: 64%;
  height: 64%;
  object-fit: contain;
  /* The favicon image has built-in whitespace — scale up + clip inside
     the core so the C mark fills the circle properly. */
  transform: scale(1.4);
}

/* Two concentric pulse rings. Idle: subtle slow breath. Active states
   speed them up and react to --level. */
.voice-orb__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--brand-dim);
  pointer-events: none;
  opacity: 0;
  animation: voice-pulse-ring 2.4s ease-out infinite;
}
.voice-orb__ring--2 { animation-delay: 1.2s; }

@keyframes voice-pulse-ring {
  0%   { transform: scale(0.85); opacity: 0.75; }
  80%  { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* Active states: faster rings + thicker glow proportional to --level. */
.voice-orb[data-state="listening"] .voice-orb__ring,
.voice-orb[data-state="speaking"]  .voice-orb__ring {
  animation-duration: 1.4s;
}
.voice-orb[data-state="listening"] .voice-orb__core,
.voice-orb[data-state="speaking"]  .voice-orb__core {
  box-shadow:
    0 6px 18px rgba(246, 196, 60, calc(0.35 + var(--level) * 0.4)),
    0 0 0 calc(2px + var(--level) * 10px) rgba(246, 196, 60, calc(0.25 + var(--level) * 0.4));
}

/* Thinking state: keep the rings going at a slower pace so the user knows
   we're still processing. */
.voice-orb[data-state="thinking"] .voice-orb__ring {
  animation-duration: 2s;
  border-color: rgba(246, 196, 60, 0.7);
}
.voice-orb[data-state="thinking"] .voice-orb__core {
  animation: voice-thinking-bob 1.6s ease-in-out infinite;
}
@keyframes voice-thinking-bob {
  0%, 100% { transform: scale(0.97); }
  50%      { transform: scale(1.03); }
}

/* Idle state: rings still breathe slowly so the orb doesn't feel dead. */
.voice-orb[data-state="idle"] .voice-orb__ring {
  animation-duration: 3.5s;
  opacity: 1;
}

.voice-help { font-size: 0.8rem; opacity: 0.7; text-align: center; max-width: 360px; }
.voice-log {
  list-style: none;
  margin: 4px 0 0;
  padding: 2px;
  width: 100%;
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.95rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(251, 208, 104, 0.6) transparent;
}
.voice-log::-webkit-scrollbar { width: 8px; }
.voice-log::-webkit-scrollbar-thumb { background: rgba(251, 208, 104, 0.55); border-radius: 99px; }
.voice-log__item {
  position: relative;
  max-width: 86%;
  padding: 7px 11px;
  border-radius: 14px;
  line-height: 1.4;
  background: rgba(20, 18, 14, 0.05);
  animation: voice-log-pop 0.18s ease-out;
}
@keyframes voice-log-pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
/* User on the right in brand yellow; assistant on the left in soft ink. */
.voice-log__item--user {
  align-self: flex-end;
  background: linear-gradient(180deg, rgba(251, 208, 104, 0.30), rgba(251, 208, 104, 0.20));
  border: 1px solid rgba(251, 208, 104, 0.45);
  border-bottom-right-radius: 5px;
  color: #4a3c12;
}
.voice-log__item--assistant {
  align-self: flex-start;
  background: rgba(20, 18, 14, 0.045);
  border: 1px solid rgba(20, 18, 14, 0.06);
  border-bottom-left-radius: 5px;
  color: #2a2723;
}
.voice-log__item--error {
  align-self: flex-start;
  background: rgba(198, 40, 40, 0.08);
  border: 1px solid rgba(198, 40, 40, 0.18);
  color: #b71c1c;
}

/* Rich assistant replies (#99): Markdown block typography inside the bubble. */
.voice-log__item--assistant p { margin: 0 0 0.5em; }
.voice-log__item--assistant p:last-child { margin-bottom: 0; }
.voice-log__item--assistant ul,
.voice-log__item--assistant ol { margin: 0.25em 0 0.5em; padding-left: 1.25em; }
.voice-log__item--assistant li { margin: 0.15em 0; }
.voice-log__item--assistant .md-h { font-weight: 700; font-size: 0.98em; margin: 0.45em 0 0.25em; }
.voice-log__item--assistant .md-h:first-child { margin-top: 0; }
.voice-log__item--assistant code {
  background: rgba(20, 18, 14, 0.07);
  padding: 0.05em 0.32em;
  border-radius: 4px;
  font-size: 0.9em;
}
.voice-log__item--assistant a { color: #8a6d1f; text-decoration: underline; }

/* Card layout when the assistant returns a ```ui blocks payload. */
.voice-log__item--rich {
  max-width: 96%;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  background: transparent;
  border: 0;
  padding: 0;
}
.voice-log__item--rich .assistant-text p { margin: 0 0 0.4em; }
.voice-log__item--rich .assistant-text p:last-child { margin-bottom: 0; }
.assistant-card {
  background: #fff;
  border: 1px solid rgba(20, 18, 14, 0.10);
  border-left: 3px solid #fbd068;
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
}
.assistant-card__title {
  font-weight: 700;
  font-size: 0.85em;
  color: #3a3526;
  margin-bottom: 0.2rem;
}
.assistant-card__body p { margin: 0 0 0.4em; }
.assistant-card__body p:last-child { margin-bottom: 0; }
.assistant-card__body ul,
.assistant-card__body ol { margin: 0.2em 0 0.35em; padding-left: 1.2em; }

/* Glass assistant card: transcript + chat box (orb lives in the floating
   widget now). Taller transcript since this is the inspection surface. */
.voice-chatpanel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.voice-chatpanel .voice-log {
  /* Doubled from 320px so the inspection transcript can show far more at once. */
  max-height: 640px;
  flex: 1 1 auto;
}
.voice-chatpanel .voice-log:empty::before {
  content: "No conversation yet — tap the orb to talk, or type below.";
  align-self: center;
  margin: auto;
  padding: 18px 8px;
  opacity: 0.5;
  font-size: 0.85rem;
  text-align: center;
}
.voice-chatform {
  display: flex;
  gap: 6px;
  align-items: center;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 4px 4px 4px 14px;
  background: #fff;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.voice-chatform:focus-within {
  border-color: rgba(20, 18, 14, 0.28);
}
.voice-chatform__input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 0.98rem;
  color: #2a2723;
}
.voice-chatform__input::placeholder { color: #9a948a; }
.voice-chatform__send {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(180deg, #fbd068, #f6c43c);
  color: #4a3c12;
  font-size: 1rem;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(246, 196, 60, 0.5);
  transition: transform 0.12s ease, box-shadow 0.18s ease, filter 0.18s ease;
}
.voice-chatform__send:hover { filter: brightness(1.04); box-shadow: 0 2px 8px rgba(246, 196, 60, 0.6); }
.voice-chatform__send:active { transform: translateY(1px) scale(0.97); }
.voice-chatform__send:focus-visible { outline: 2px solid rgba(251, 208, 104, 0.9); outline-offset: 2px; }

/* === Card 0: Today (calendar) ============================================ */
.today-view-toggle {
  display: inline-flex;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  overflow: hidden;
  margin-right: 8px;
}
.today-view-toggle__btn {
  font-size: 0.75rem;
  padding: 4px 10px;
  color: inherit;
  text-decoration: none;
  background: #fff;
  line-height: 1;
}
.today-view-toggle__btn + .today-view-toggle__btn { border-left: 1px solid var(--hairline); }
.today-view-toggle__btn.is-active { background: rgba(0, 0, 0, 0.08); font-weight: 600; }
.today-view-toggle__btn:hover { background: rgba(0, 0, 0, 0.04); color: inherit; }

/* Now marker between rows */
.today-now {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  margin: 6px 0;
  animation: today-now-slide 0.6s ease-out both;
}
.today-now__time {
  flex: 0 0 70px;
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  font-weight: 700;
  color: #c62828;
}
.today-now__line {
  flex: 1 1 auto;
  height: 0;
  border-top: 2px solid #c62828;
  position: relative;
}
.today-now__line::before {
  content: '';
  position: absolute;
  left: -6px;
  top: -5px;
  width: 8px;
  height: 8px;
  background: #c62828;
  border-radius: 50%;
}
@keyframes today-now-slide {
  from { transform: translateY(-8px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* Week view: 5 narrow day columns (Mon–Fri) */
.today-week {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.today-weekcol {
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 6px 6px 8px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.today-weekcol--current { background: #fffdf5; border-color: #e0a800; }
.today-weekcol__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 4px;
}
.today-weekcol__dow {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.6;
}
.today-weekcol__date { font-weight: 700; font-size: 0.95rem; }
.today-weekcol__ev {
  font-size: 0.75rem;
  padding: 2px 4px 2px 6px;
  border-left: 3px solid #4a7bf5;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.02);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.today-weekcol__evtime { font-weight: 600; margin-right: 4px; }
.today-weekcol__empty { font-size: 0.7rem; opacity: 0.35; text-align: center; padding: 8px 0; }

/* Month view: Mon–Fri grid only (no weekend columns), one row per week. */
.today-month { display: flex; flex-direction: column; gap: 4px; }
.today-month__head,
.today-month__row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
}
.today-month__head {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.55;
  padding-bottom: 2px;
}
.today-month__head span { text-align: center; }
.today-monthcell {
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 4px 5px;
  background: #fff;
  min-width: 0;
  min-height: 46px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.today-monthcell--out { background: rgba(0, 0, 0, 0.02); opacity: 0.45; }
.today-monthcell--today { background: #fffdf5; border-color: #e0a800; }
.today-monthcell__date { font-weight: 700; font-size: 0.78rem; }
.today-monthcell__ev {
  font-size: 0.68rem;
  padding: 1px 3px 1px 5px;
  border-left: 3px solid #4a7bf5;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.02);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.today-monthcell__more { font-size: 0.65rem; opacity: 0.6; padding-left: 2px; }

.today-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.today-nav__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  background: #fff;
  font-size: 0.75rem;
  color: inherit;
  text-decoration: none;
  line-height: 1;
}
.today-nav__btn:hover,
.today-nav__btn:focus-visible {
  background: rgba(0, 0, 0, 0.04);
  color: inherit;
}
.today-nav__btn--today { font-size: 0.7rem; letter-spacing: 0.04em; }

.today-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.today-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--hairline);
}
.today-row:last-child { border-bottom: 0; }
.today-row__swatch {
  flex: 0 0 10px;
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 50%;
  display: inline-block;
}
.today-row__time {
  flex: 0 0 70px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.85rem;
}
.today-row__summary { font-weight: 600; font-size: 0.9rem; }
.today-row__location { font-size: 0.8rem; opacity: 0.7; }
.today-row--all-day {
  background: rgba(0, 0, 0, 0.02);
}
.today-row--all-day .today-row__time {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.7;
}

/* Recent Documents card hugs its content instead of stretching to the
   tallest card in the row — "just enough to show the documents". */
.glass-card--recent { align-self: start; }

/* === Card 1: Recent Documents (thumbnail grid) ============================ */
.recent-section + .recent-section { margin-top: 12px; }
.recent-section__title {
  margin: 0 0 8px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.55;
}
/* Three thumbnails hard-constrained per row (matches Ink's welcome screen
   preview sizing: 156x156 with a scaled .recent-card-inner inside).
   Using minmax(0, 1fr) so very-long doc names can't blow the column out. */
.recent-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.recent-card-scope {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.7;
}
.recent-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  text-align: center;
  transition: opacity 0.15s ease;
}
.recent-card:hover { opacity: 0.8; color: inherit; }
.recent-card-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  background: #fff;
}
.recent-card-inner {
  position: absolute;
  top: 0;
  left: 0;
  /* Render the doc as a fixed 800×1067 "page" (3:4 portrait, ~A4) and scale it
     down so it fills whatever tile width the grid resolves to. The scale is set
     by JS (see recentDocsScript) to preview-width / 800; the 0.195 here is the
     no-JS fallback for a ~156px tile. transform-origin stays top-left so the
     page's top-left corner maps to the tile's. */
  width: 800px;
  height: 1067px;
  transform: scale(0.195);
  transform-origin: top left;
  pointer-events: none;
  font-family: 'Times New Roman', Times, serif;
  font-size: 12pt;
  color: #222;
}
.recent-card-inner * { max-width: 100% !important; }
.recent-card-inner img { display: none; }
.recent-card-name {
  font-size: 11px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recent-card-time { font-size: 10px; opacity: 0.55; }

/* === Card 2: KPI tile ===================================================== */
.glass-card--kpi .kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.kpi {
  padding: 14px 16px;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: #fafafa;
}
.kpi--muted { background: #fff; }
.kpi__value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}
.kpi__label { font-size: 0.8rem; opacity: 0.65; }

/* === Card 3: Latest notes feed =========================================== */
.feed-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.feed-item {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--hairline);
}
.feed-item:last-child { border-bottom: 0; padding-bottom: 0; }
.feed-item__head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}
.feed-item__company { color: inherit; text-decoration: none; font-weight: 600; }
.feed-item__company:hover { text-decoration: underline; }
.feed-item__when { font-size: 0.75rem; opacity: 0.55; flex: 0 0 auto; }
.feed-item__body { font-size: 0.88rem; opacity: 0.85; }

/* === Card 4: Upcoming agenda ============================================ */
.agenda-list { list-style: none; margin: 0; padding: 0; }
.agenda-row {
  display: flex;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--hairline);
  align-items: center;
}
.agenda-row:last-child { border-bottom: 0; }
.agenda-row__date {
  flex: 0 0 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-right: 1px solid var(--hairline);
  padding-right: 8px;
  line-height: 1;
}
.agenda-row__day { font-size: 1.2rem; font-weight: 700; }
.agenda-row__mon { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.6; }
.agenda-row__company { color: inherit; text-decoration: none; font-weight: 600; font-size: 0.9rem; }
.agenda-row__company:hover { text-decoration: underline; }
.agenda-row__kind { font-size: 0.75rem; opacity: 0.55; }

/* === Card 5: Onboarded bar chart ======================================== */
.glass-chart { width: 100%; height: auto; }
.chart-bar { fill: #4a7bf5; }
.chart-bar-value { fill: #333; font-size: 9px; font-weight: 600; }
.chart-axis { fill: #888; font-size: 9px; }

/* === Card 6: Donut chart ================================================ */
.donut-body { display: flex; align-items: flex-start; gap: 16px; }
.donut { width: 120px; height: 120px; flex: 0 0 120px; }
.donut-num { font-size: 22px; font-weight: 700; fill: #1a1a1a; }
.donut-lbl { font-size: 9px; fill: #888; text-transform: uppercase; letter-spacing: 0.08em; }
.donut-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.85rem;
  min-width: 0;
  flex: 1 1 auto;
}
.donut-legend li { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.donut-legend__row { display: flex; align-items: center; gap: 8px; }
.donut-legend__label { white-space: nowrap; }
.donut-legend .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: 0 0 10px; }
.donut-legend .dot--valid { background: #2e7d32; }
.donut-legend .dot--due-soon { background: #e0a800; }
.donut-legend .dot--expired { background: #c62828; }
.donut-legend .dot--missing { background: #999; }
.donut-legend .dot--due30 { background: #e8730c; }
.donut-legend .dot--due90 { background: #e0a800; }
.donut-legend .dot--ok { background: #2e7d32; }
.donut-legend .num { margin-left: auto; font-weight: 600; opacity: 0.8; }
.donut-legend__names {
  padding-left: 18px;
  font-size: 0.72rem;
  line-height: 1.3;
  color: #6b7280;
  word-break: break-word;
}

/* === Card 10: Bookings (per-customer, sortable) ========================= */
/* Wide table — span the full grid width instead of one masonry column. */
.glass-grid .glass-widget[data-widget="bookings"] {
  column-span: all;
  -webkit-column-span: all;
}
.bookings-summary { font-size: 0.82rem; color: #666; margin: 0 0 8px; }
.bookings-summary strong { color: #1a1a1a; }
.bookings-scroll { overflow-x: auto; }
.bookings-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.bookings-table th,
.bookings-table td { text-align: left; padding: 5px 8px; border-bottom: 1px solid #eef0f2; white-space: nowrap; }
.bookings-table th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #888;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.bookings-table th:hover { color: #1a1a1a; }
.bookings-table th[aria-sort] { color: #1a1a1a; }
.bookings-table th[aria-sort="ascending"]::after { content: " \25B2"; font-size: 0.7em; }
.bookings-table th[aria-sort="descending"]::after { content: " \25BC"; font-size: 0.7em; }
.bookings-table tbody tr:last-child td { border-bottom: 0; }
.bookings-name { color: #1a1a1a; text-decoration: none; }
.bookings-name:hover { text-decoration: underline; }
.bk--yes { color: #1e7a36; font-weight: 600; }
.bk--no { color: #b3261e; font-weight: 600; }
.bk--muted { color: #888; }

/* Filtered-list banner (voice-driven attribute filters on /customers) */
.filter-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  padding: 8px 14px;
  background: #fff8e1;
  border: 1px solid #f6c43c;
  border-radius: 6px;
  font-size: 0.9rem;
}
.filter-banner__clear {
  margin-left: auto;
  font-weight: 600;
  text-decoration: none;
  color: #8a6d00;
}
.filter-banner__clear:hover { text-decoration: underline; }

/* Page metadata panel (below content, e.g. audit details on detail views) */
.page-meta {
  margin: 24px 16px 16px;
  padding: 12px 16px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.02);
  font-size: 0.9rem;
}

.page-meta .additional-info-header {
  font-weight: 600;
  display: block;
  margin-bottom: 6px;
}

.page-meta ul.list-group {
  --bs-list-group-border-color: transparent;
  --bs-list-group-bg: transparent;
}

/* Mobile: rail starts hidden, slides in from the left on toggle */
@media (max-width: 767.98px) {
  .left-nav {
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
  }
  .left-nav.is-open {
    transform: translateX(0);
  }
  body.has-left-nav .main-wrapper,
  body.has-left-nav > footer {
    margin-left: 0;
  }
  .left-nav__toggle {
    display: inline-flex;
  }
  /* Hide the in-rail hide button on mobile — tapping outside (or the toggle) closes */
  .left-nav__hide {
    display: none;
  }
  body.has-left-nav main {
    padding-top: 56px;
  }
  /* Backdrop appears behind the rail when it's open */
  body.has-left-nav::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    pointer-events: none;
    transition: background 0.2s ease;
    z-index: 1029;
  }
  body.has-left-nav:has(.left-nav.is-open)::before {
    background: rgba(0, 0, 0, 0.35);
    pointer-events: auto;
  }
}

/* ── Calendar feed: always-editable inline rows ─────────────────────────── */
.ics-feed { display: block; padding: 8px 0; }
.ics-feed-row { display: flex; align-items: center; gap: 8px; margin: 0; flex-wrap: wrap; }

/* Custom colour dropdown (shows a colour dot beside each name) */
.cdrop { position: relative; flex: 0 0 auto; }
.cdrop__sum {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  min-width: 104px;
  border: 1px solid #cfd2d6;
  border-radius: 6px;
  background: #fff;
  font-size: 0.85rem;
}
.cdrop__sum::-webkit-details-marker { display: none; }
.cdrop__sum::after { content: '▾'; margin-left: auto; opacity: 0.55; font-size: 0.8em; }
.cdrop__menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  min-width: 150px;
  max-height: 244px;
  overflow: auto;
  padding: 4px;
  background: #fff;
  border: 1px solid #cfd2d6;
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
}
.cdrop__opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
}
.cdrop__opt:hover { background: #f1f4f8; }
.cdrop__opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.cdrop__opt input:checked ~ .cdot { box-shadow: 0 0 0 1px rgba(0,0,0,0.15), 0 0 0 3px rgba(74,123,245,0.35); }
.cdot {
  display: inline-block;
  width: 14px; height: 14px;
  flex: 0 0 14px;
  border-radius: 50%;
  background: var(--swatch, #4a7bf5);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.ics-feed__label-in { flex: 0 1 170px; min-width: 110px; }
.ics-feed__url-in { flex: 1 1 220px; min-width: 150px; }
.ics-feed__delform { display: none; }
.ics-feed-add { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--hairline); }

/* ── Personal memory cards (Settings → Assistant, and the admin editor) ───── */
.memory-list { list-style: none; margin: 0 0 6px; padding: 0; }
.memory-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--hairline); }
.memory-item:last-child { border-bottom: 0; }
.memory-item__edit { display: flex; align-items: center; gap: 6px; flex: 1 1 auto; min-width: 0; margin: 0; }
.memory-item__edit input[type="text"] { flex: 1 1 auto; min-width: 0; }
.memory-item__del { margin: 0; flex: 0 0 auto; }
.memory-item__text { flex: 1 1 auto; min-width: 0; }
.memory-item__src { flex: 0 0 auto; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; color: #9aa0a6; }
.memory-empty { color: #888; font-style: italic; padding: 6px 0; }
.memory-subhead { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: #666; margin: 14px 0 6px; }
.memory-item--pending {
  flex-wrap: wrap;
  background: rgba(251, 208, 104, 0.10);
  border: 1px solid rgba(251, 208, 104, 0.4);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
}
.memory-add { display: flex; gap: 8px; margin-top: 12px; }
.memory-add input { flex: 1 1 auto; }
.memory-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.memory-tools form { margin: 0; }
.memory-suggestions { margin: 8px 0; padding: 12px; background: #f6f8fb; border: 1px solid var(--hairline); border-radius: 10px; }
.memory-suggestions .memory-subhead { margin-top: 0; }
.memory-list--suggestions { margin: 0; }
.memory-item--suggestion { flex-wrap: wrap; border-bottom: 1px dashed var(--hairline); }

/* ── Customer list: Cyber Essentials-only view filter (views\Customers::getList) ── */
.customer-list-filter { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.9rem; }
.customer-list-filter label { font-weight: 600; color: #3a4046; font-size: 0.9rem; }
.customer-list-filter select { padding: 0.4rem 0.6rem; border: 1px solid #ccd2d8; border-radius: 6px; font-size: 0.9rem; background: #fff; }

/* ── Customer add/edit form: Cyber Essentials-only field hiding (views\Customers::ceOnlyScript) ──
   Uses :has() keyed on the fields' ids; the checkbox toggles the .ce-only class on the form. */
form.ce-only .input-group:has(#onoboarding-date),
form.ce-only .input-group:has(#primary-audit-date),
form.ce-only .input-group:has(#secondary-audit-date),
form.ce-only .input-group:has(#restore-test-1-date),
form.ce-only .input-group:has(#restore-test-2-date),
form.ce-only .input-group:has(#contract-end-date),
form.ce-only .input-group:has(input[type=file]),
form.ce-only .requirements.section,
form.ce-only details.edit-acc:has(.requirements.section) { display: none !important; }
.ce-only-check { display: flex; align-items: center; gap: 0.6rem; }
.ce-only-hint { font-size: 0.8rem; color: #6b7580; }
.ce-only-field input[type=checkbox] { width: 1.15rem; height: 1.15rem; flex: 0 0 auto; }

/* ── Customer edit page: accordion cards (views\Customers::edit) ──
   The whole edit page is one .form (a CSS grid with row-gap between its direct children).
   Wrapping fields in accordions made the <details> the grid children, so the .input-group
   rows inside a card lost .form's row-gap and packed tightly. Give each card body the same
   grid rhythm as .form so rows breathe consistently. */
.customer-edit .form { row-gap: var(--spacing-lg); }
.customer-edit .edit-acc { border: 1px solid var(--color-gray-300, #d8dadd); border-radius: 10px; background: #fff; overflow: hidden; }
.customer-edit .edit-acc__summary { cursor: pointer; padding: .85rem 1.2rem; font-weight: 600; font-size: 1.05rem; list-style: none; background: var(--color-gray-100, #f3f5f7); }
.customer-edit .edit-acc[open] .edit-acc__summary { border-bottom: 1px solid var(--color-gray-300, #e2e6ea); }
.customer-edit .edit-acc__summary::-webkit-details-marker { display: none; }
.customer-edit .edit-acc__summary::before { content: "\25B8"; display: inline-block; margin-right: .5rem; transition: transform .15s; color: #888; }
.customer-edit .edit-acc[open] .edit-acc__summary::before { transform: rotate(90deg); }
.customer-edit .edit-acc__body { padding: 1.4rem 1.2rem; display: grid; gap: var(--spacing-sm); row-gap: var(--spacing); }
/* Quill/textarea groups: keep the label tight above its editor, not stretched by the row grid. */
.customer-edit .edit-acc__body .input-group:has(textarea) { align-content: start; }
.customer-edit .edit-contacts-list { list-style: none; padding: 0; margin: 0; }
.customer-edit .edit-contact { padding: .55rem 0; border-bottom: 1px solid var(--color-gray-200, #eee); }
.customer-edit .edit-contact:last-child { border-bottom: 0; }
.customer-edit .edit-contact__name { font-weight: 600; }
.customer-edit .edit-contact__type { font-size: .8rem; color: #666; text-transform: capitalize; margin-left: .4rem; }
.customer-edit .edit-contact__meta { font-size: .85rem; color: #555; margin-top: .15rem; }
.customer-edit .section-actions { margin-top: .4rem; }
/* The accordion summary already titles each card — drop the requirements block's duplicate
   <legend> (its own subgrid row spacing is left untouched). */
.customer-edit .edit-acc .requirements.section > legend { display: none; }

/* ── Customer Details tab: Finance (Xero) card (views\Finance) ── */
.fin-card { border: 1px solid #d8dadd; border-radius: 10px; background: #fff; padding: 1rem 1.2rem; margin-top: 1rem; }
.fin-card__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; flex-wrap: wrap; }
.fin-card__title { font-size: 1.1rem; margin: 0; }
.fin-stats { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.fin-stat { flex: 1 1 150px; background: #f7f9fb; border: 1px solid #e2e6ea; border-radius: 8px; padding: .6rem .8rem; }
.fin-stat__label { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: #666; }
.fin-stat__value { font-size: 1.25rem; font-weight: 600; }
.fin-stat--bad .fin-stat__value { color: #a12; }
.fin-table-wrap { overflow-x: auto; }
.fin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.fin-table th, .fin-table td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid #eee; }
.fin-table th.fin-num, .fin-table td.fin-num { text-align: right; white-space: nowrap; }
.fin-empty { color: #888; text-align: center; padding: 1rem; }
.fin-badge { display: inline-block; padding: .1rem .5rem; border-radius: 12px; font-size: .78rem; font-weight: 600; }
.fin-badge--paid { background: #e3f4e8; color: #1a7f3c; }
.fin-badge--unpaid { background: #fff3cd; color: #8a6d00; }
.fin-badge--overdue { background: #fde2e4; color: #a12; }
.fin-badge--muted { background: #eef0f2; color: #666; }

/* ── Customer Details tab: audit footer and Finance / Cloud Security panels (customer-tabs.tpl.php, v3.107.2-3.107.4) ── */
.customer-tab-details-footer{margin-top:1.5rem;width:100%;}
.customer-tab-details-footer .section{margin:0;padding:0;background:none;border:0;box-shadow:none;}
.audit-footer{display:flex;flex-wrap:wrap;align-items:baseline;gap:0.4rem 1.75rem;width:100%;box-sizing:border-box;padding:0.7rem 1rem;border:1px solid #d8dadd;border-radius:8px;background:#f6f7f8;font-size:0.85rem;color:#444;}
.audit-footer__title{font-weight:600;text-transform:uppercase;letter-spacing:0.06em;font-size:0.76rem;color:#666;}
.audit-footer__label{color:#8a8f94;margin-right:0.25rem;}
.customer-tab-col > .section{min-width:0;}
/* Finance (Xero) panel: the panel supplies frame and title, so the fragment's fin-card is flattened. */
.customer-tab-finance-row .fin-card{border:0;border-radius:0;background:none;padding:0;margin:0;}
.customer-tab-finance-row .fin-card__title{display:none;}
.customer-tab-finance-row .fin-card__head{justify-content:flex-end;}
/* Cloud Security panel: the fragment's blocks are sub-sections of the panel, not cards in a card. */
.customer-tab-cloud-row .sec-card{background:none;border:0;border-radius:0;padding:0;margin:0;}
.customer-tab-cloud-row .sec-card__head{display:flex;align-items:center;justify-content:space-between;gap:0.75rem;margin:0 0 0.75rem;}
.customer-tab-cloud-row .sec-card__title{font-size:1rem;font-weight:600;margin:0;}

/* ── Customer Security tab: expanded check detail and loading states (views\Cloudsecurity::checkDetailHtml, v3.108.0) ── */
/* Expanded-check tables (Checkdetail): flagged first, then everything else checked. */
.sec-fd__items{margin:0 0 0.75rem;}
.sec-dt-block{margin:0 0 0.9rem;}
.sec-dt-block h5{margin:0 0 0.35rem;font-size:0.72rem;text-transform:uppercase;letter-spacing:0.05em;color:#8a8f94;font-weight:700;display:flex;align-items:center;gap:0.4rem;}
.sec-dt-block--flagged h5{color:#b3261e;}
.sec-dt-count{background:#eceff1;color:#4a5157;border-radius:999px;padding:0 7px;font-size:0.7rem;letter-spacing:0;}
.sec-dt-block--flagged .sec-dt-count{background:#fde8e6;color:#9b1c13;}
.sec-dt-scroll{max-height:360px;overflow:auto;border:1px solid #e3e6ea;border-radius:8px;}
.sec-dt-block--flagged .sec-dt-scroll{border-color:#f3c7c2;}
.sec-dt{width:100%;border-collapse:collapse;font-size:0.84rem;background:#fff;}
.sec-dt th{position:sticky;top:0;background:#f6f7f8;text-align:left;font-size:0.72rem;text-transform:uppercase;letter-spacing:0.04em;color:#666;padding:0.4rem 0.6rem;border-bottom:1px solid #e3e6ea;z-index:1;}
.sec-dt td{padding:0.4rem 0.6rem;border-bottom:1px solid #eef0f2;vertical-align:top;overflow-wrap:anywhere;}
/* Names and short text columns keep a readable width; the permission chips take the rest. */
.sec-dt td:first-child{min-width:11rem;overflow-wrap:break-word;}
.sec-dt td:not(:first-child):not(:has(.sec-pchip)){min-width:7.5rem;}
.sec-dt-sub--warn{color:#b3261e !important;font-weight:600;}
.sec-dt tr:last-child td{border-bottom:0;}
.sec-dt-sub{color:#8a8f94;font-size:0.76rem;margin-top:1px;}
.sec-dt td.sec-dt-warn{color:#b3261e;font-weight:600;}
.sec-dt td.sec-dt-warn .sec-dt-sub{color:#b3261e;font-weight:400;}
.sec-pchip{display:inline-block;margin:0 4px 4px 0;padding:1px 7px;border-radius:6px;background:#eef0f2;color:#3a4046;font-size:0.76rem;line-height:1.5;}
.sec-pchip--hi{background:#fde8e6;color:#9b1c13;font-weight:600;}
.sec-dt-note{color:#8a8f94;font-size:0.82rem;margin:0.3rem 0 0.6rem;}
/* Loading state for anything that takes a moment (detail load, scan, acknowledge, files). */
.sec-loading{display:flex;align-items:center;gap:0.5rem;color:#5f6368;font-size:0.86rem;padding:0.5rem 0;}
.sec-loading .spinner-border{width:1rem;height:1rem;border-width:0.15em;}
.sec-busy .spinner-border{width:0.85rem;height:0.85rem;border-width:0.15em;margin-right:0.35rem;vertical-align:-0.1em;}
.sec-refreshing{display:flex;align-items:center;gap:0.5rem;position:sticky;top:0;z-index:5;background:#fff8e1;border:1px solid #f0d68a;color:#6b5200;border-radius:8px;padding:0.45rem 0.8rem;margin:0 0 0.8rem;font-size:0.86rem;}
.sec-refreshing .spinner-border{width:0.9rem;height:0.9rem;border-width:0.15em;}

/* ── Cloud alert rule editor (views\Alertrules, app/assets/js/alert-rules.js, v3.107.0) ── */
.alert-rules{font-size:0.9rem;}
.alert-rules .ar-head{display:flex;align-items:center;justify-content:space-between;gap:0.6rem;margin:0 0 0.5rem;}
.alert-rules .ar-title{font-size:0.92rem;font-weight:600;margin:0;color:#1a1a1a;}
.alert-rules .ar-title--sub{margin:1rem 0 0.4rem;color:#555;}
.alert-rules .ar-table{width:100%;border-collapse:collapse;background:#fff;border:1px solid #d8dadd;border-radius:8px;overflow:hidden;}
.alert-rules .ar-table th,.alert-rules .ar-table td{padding:0.45rem 0.65rem;border-bottom:1px solid #e6e8ea;text-align:left;vertical-align:top;}
.alert-rules .ar-table th{background:#f3f5f7;font-size:0.74rem;text-transform:uppercase;letter-spacing:0.05em;color:#666;}
.alert-rules .ar-table tr:last-child td{border-bottom:0;}
.alert-rules .ar-num{width:2rem;color:#8a8f94;}
.alert-rules .ar-off td{opacity:0.55;}
.alert-rules .ar-note{color:#8a8f94;font-size:0.82rem;margin-top:2px;}
.alert-rules .ar-actions{white-space:nowrap;text-align:right;}
.alert-rules .ar-pill{display:inline-block;padding:1px 8px;border-radius:10px;font-size:0.76rem;font-weight:600;margin-right:4px;}
.alert-rules .ar-pill--alert{background:#fde8e6;color:#9b1c13;}
.alert-rules .ar-pill--suppress{background:#eceff1;color:#4a5157;}
.alert-rules .ar-pill--off{background:#fff4d6;color:#7a5a00;}
.alert-rules .ar-btn{border:1px solid #cfd2d6;background:#fff;border-radius:6px;padding:0.2rem 0.55rem;font-size:0.8rem;margin-left:3px;cursor:pointer;}
.alert-rules .ar-btn:hover{background:#f3f5f7;}
.alert-rules .ar-btn--primary{background:#1a1a1a;color:#fff;border-color:#1a1a1a;}
.alert-rules .ar-btn--primary:hover{background:#333;}
.alert-rules .ar-btn--danger{color:#b3261e;}
.alert-rules .ar-form{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:0.5rem 0.9rem;background:#fff;border:1px solid #d8dadd;border-radius:8px;padding:0.8rem;margin:0 0 0.7rem;}
.alert-rules .ar-form label{display:flex;flex-direction:column;gap:0.2rem;color:#555;font-size:0.82rem;min-width:0;}
.alert-rules .ar-form .ar-input{width:100%;min-width:0;box-sizing:border-box;}
.alert-rules .ar-form .ar-span2{grid-column:span 2;}
.alert-rules .ar-form .ar-wide{grid-column:1/-1;}
.alert-rules .ar-form__title{grid-column:1/-1;font-weight:600;color:#1a1a1a;}
.alert-rules .ar-form__actions{grid-column:1/-1;display:flex;align-items:center;gap:0.4rem;}
.alert-rules .ar-input{padding:0.35rem 0.5rem;border:1px solid #cfd2d6;border-radius:6px;font-size:0.88rem;background:#fff;}
.alert-rules .ar-msg{color:#b3261e;font-size:0.84rem;}
.alert-rules .ar-hint,.alert-rules .ar-empty{color:#8a8f94;font-size:0.84rem;margin:0.5rem 0 0;}

/* ── Customer Security tab: Change alerts card (views\Cloudalerts, v3.107.0) ── */
.cloud-alerts .ca-intro:first-child{margin-top:0;}
.cloud-alerts .ca-intro{color:#666;font-size:0.88rem;margin:0 0 0.8rem;}
.cloud-alerts .ca-h{font-size:0.95rem;font-weight:600;margin:1rem 0 0.5rem;color:#1a1a1a;}
.cloud-alerts .ca-empty{color:#8a8f94;font-size:0.88rem;}
.cloud-alerts .ca-scroll{max-height:420px;overflow:auto;border:1px solid #d8dadd;border-radius:8px;}
.cloud-alerts .ca-table{width:100%;border-collapse:collapse;background:#fff;font-size:0.88rem;}
.cloud-alerts .ca-table th,.cloud-alerts .ca-table td{padding:0.45rem 0.65rem;border-bottom:1px solid #e6e8ea;text-align:left;vertical-align:top;}
.cloud-alerts .ca-table th{background:#f3f5f7;font-size:0.74rem;text-transform:uppercase;letter-spacing:0.05em;color:#666;position:sticky;top:0;}
.cloud-alerts .ca-when{white-space:nowrap;color:#555;}
.cloud-alerts .ca-sub{color:#8a8f94;font-size:0.78rem;margin-top:2px;}
.cloud-alerts .ca-act{text-align:right;white-space:nowrap;}
.cloud-alerts .ca-btn{border:1px solid #cfd2d6;background:#fff;border-radius:6px;padding:0.2rem 0.55rem;font-size:0.78rem;cursor:pointer;}
.cloud-alerts .ca-pill{display:inline-block;padding:1px 8px;border-radius:10px;font-size:0.76rem;font-weight:600;}
.cloud-alerts .ca-pill--alert{background:#fde8e6;color:#9b1c13;}
.cloud-alerts .ca-pill--suppress{background:#eceff1;color:#4a5157;}
.cloud-alerts .ca-sev{display:inline-block;padding:1px 8px;border-radius:10px;color:#fff;font-size:0.74rem;}
.cloud-alerts .ca-sev--critical{background:#7a1010;}.cloud-alerts .ca-sev--high{background:#b3261e;}
.cloud-alerts .ca-sev--medium{background:#b26a00;}.cloud-alerts .ca-sev--low{background:#3b6ea8;}
.cloud-alerts .ca-sev--info{background:#5f6368;}

/* ── Admin Alerts tab: alert email channel, outbox and banner (views\Alertsadmin, v3.107.0) ── */
.alerts-tab .am-status{background:#fff;border:1px solid #d8dadd;border-radius:8px;padding:0.6rem 0.8rem;margin:0 0 0.9rem;font-size:0.9rem;display:flex;flex-direction:column;align-items:flex-start;gap:0.25rem;}
.alerts-tab .am-form{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:0.6rem 1rem;max-width:760px;}
.alerts-tab .am-field{display:flex;flex-direction:column;gap:0.25rem;font-size:0.88rem;color:#555;}
.alerts-tab .am-field input{padding:0.4rem 0.6rem;border:1px solid #cfd2d6;border-radius:6px;font-size:0.92rem;background:#fff;}
.alerts-tab .am-actions{display:flex;align-items:center;gap:0.5rem;margin-top:0.9rem;flex-wrap:wrap;}
.alerts-tab .am-msg{font-size:0.88rem;}
.alerts-tab .am-msg.ok{color:#1e7a36;}.alerts-tab .am-msg.err{color:#b3261e;}
.alerts-tab .am-device{margin-top:0.9rem;background:#fff;border:1px dashed #b26a00;border-radius:8px;padding:0.8rem;font-size:0.92rem;}
.alerts-tab .am-step{margin:0.2rem 0 0.4rem;color:#444;}
.alerts-tab .am-row{display:flex;align-items:center;gap:0.75rem;flex-wrap:wrap;margin:0 0 0.9rem;}
.alerts-tab .am-device code{font-family:monospace;font-size:1.4rem;font-weight:700;letter-spacing:0.15em;padding:0.3rem 0.8rem;background:#fff;border:1px solid #ddd;border-radius:6px;user-select:all;color:#1a1a1a;}
.alerts-tab .am-url{color:#0b57d0;text-decoration:underline;word-break:break-all;}
.alerts-tab .am-pill{display:inline-block;padding:1px 8px;border-radius:10px;font-size:0.78rem;font-weight:600;margin-right:4px;}
.alerts-tab .am-pill--ok{background:#e3f4e8;color:#1e7a36;}.alerts-tab .am-pill--warn{background:#fff4d6;color:#7a5a00;}
.alerts-tab .am-pill--bad{background:#fde8e6;color:#9b1c13;}
.alerts-tab .am-err{color:#b3261e;font-size:0.84rem;}
.alerts-tab .am-scroll{max-height:360px;overflow:auto;border:1px solid #d8dadd;border-radius:8px;}
.alerts-tab .am-table{width:100%;border-collapse:collapse;background:#fff;font-size:0.86rem;}
.alerts-tab .am-table th,.alerts-tab .am-table td{padding:0.4rem 0.65rem;border-bottom:1px solid #e6e8ea;text-align:left;vertical-align:top;}
.alerts-tab .am-table th{background:#f3f5f7;font-size:0.74rem;text-transform:uppercase;letter-spacing:0.05em;color:#666;position:sticky;top:0;}
.alerts-tab .am-nowrap{white-space:nowrap;}
.alert.alerts-banner{margin:0 0 1rem;}
