@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wdth,wght@12..96,75..100,200..800&display=swap');

/* Stella components. Class names match the Stella app's markup (Bootstrap-compatible), so these rules
   can replace framework.css values one for one. Every colour, size and radius comes from a token. */

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: var(--font-sans); font-size: 14px; line-height: 20px; font-optical-sizing: auto;
  color: var(--color-text-primary); background: var(--color-bg-base); -webkit-font-smoothing: antialiased; }
a { color: var(--color-text-link); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--color-border-focus); outline-offset: 2px; }
.tabular, .table td, .metric { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.ic { width: var(--size-icon-md); height: var(--size-icon-md); flex: none; fill: none; stroke: currentColor;
  stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ic-sm { width: var(--size-icon-sm); height: var(--size-icon-sm); }
.kbd { display: inline-flex; align-items: center; height: 18px; padding: 0 5px; border: 1px solid var(--color-border);
  border-bottom-width: 2px; border-radius: var(--radius-xs); font: 500 11px/1 var(--font-sans); color: var(--color-text-secondary);
  background: var(--color-bg-surface); }

/* preview-only layout helpers */
.pv { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; padding: var(--space-5); }
.pv-col { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-5); }
.pv-grid { display: grid; gap: var(--space-4); padding: var(--space-5); }
.pv-label { font-size: 11px; line-height: 14px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--color-text-secondary); }

/* Form controls take the app font (browsers give buttons and fields their
   own, which showed as Arial in the reply bar and elsewhere). Element
   selectors, so any component that sets its own font still wins. */
button, input, select, textarea, optgroup { font-family: inherit; }

/* ------------------------------------------------------------------ the star (logo and assistant) */
.st-star { display: block; flex: none; --st-face: var(--color-on-brand); }
.st-star .st-body { fill: var(--color-brand); }
.st-star.on-midnight { --st-face: var(--color-midnight); }
.st-star.on-midnight .st-body { fill: var(--color-starlight); }
@keyframes st-blink { 0%, 93%, 100% { transform: scaleY(1) } 96% { transform: scaleY(0.12) } }
.st-blink { animation: st-blink 5s var(--easing-standard) infinite; transform-box: fill-box; transform-origin: center; }
@keyframes st-cyc { 0% { opacity: 1 } 18.06% { opacity: 1 } 20% { opacity: 0 } 97.22% { opacity: 0 } 100% { opacity: 1 } }
.st-cyc { animation: st-cyc 9s linear infinite; }
.st-c0 { animation-delay: 0s; } .st-c1 { animation-delay: -7.2s; } .st-c2 { animation-delay: -5.4s; }
.st-c3 { animation-delay: -3.6s; } .st-c4 { animation-delay: -1.8s; }
/* the living logo on the web: one round in under 5 seconds, then Hello stays (WCAG 2.2.2) */
@keyframes st-once-0 {0% {opacity:1}
16.00% {opacity:1}
20.00% {opacity:0}
96.00% {opacity:0}
100% {opacity:1}
}
.st-once .st-c0 {animation:st-once-0 5.0s linear 1 both}
@keyframes st-once-1 {0% {opacity:0}
16.00% {opacity:0}
20.00% {opacity:1}
36.00% {opacity:1}
40.00% {opacity:0}
100% {opacity:0}
}
.st-once .st-c1 {animation:st-once-1 5.0s linear 1 both}
@keyframes st-once-2 {0% {opacity:0}
36.00% {opacity:0}
40.00% {opacity:1}
56.00% {opacity:1}
60.00% {opacity:0}
100% {opacity:0}
}
.st-once .st-c2 {animation:st-once-2 5.0s linear 1 both}
@keyframes st-once-3 {0% {opacity:0}
56.00% {opacity:0}
60.00% {opacity:1}
76.00% {opacity:1}
80.00% {opacity:0}
100% {opacity:0}
}
.st-once .st-c3 {animation:st-once-3 5.0s linear 1 both}
@keyframes st-once-4 {0% {opacity:0}
76.00% {opacity:0}
80.00% {opacity:1}
96.00% {opacity:1}
100% {opacity:0}
}
.st-once .st-c4 {animation:st-once-4 5.0s linear 1 both}
@media (prefers-reduced-motion: reduce) {.st-once [class*="st-c"] {animation:none;opacity:0}
.st-once .st-c0 {opacity:1}
}
@keyframes st-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .55 } 30% { transform: translateY(-2.2px); opacity: 1 } }
.st-dot { animation: st-dot 1.2s var(--easing-standard) infinite; transform-box: fill-box; transform-origin: center; }
.st-d2 { animation-delay: .15s; } .st-d3 { animation-delay: .3s; }
@media (prefers-reduced-motion: reduce) {
  .st-cyc { animation: none; opacity: 0; } .st-cyc.st-c0 { opacity: 1; }
  .st-dot, .st-blink, .skeleton { animation: none !important; }
}

/* ------------------------------------------------------------------ buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); height: var(--size-control-md);
  padding: 0 var(--space-4); border: 1px solid transparent; border-radius: var(--radius-md); font: inherit; font-size: 14px;
  font-weight: 600; line-height: 1; white-space: nowrap; text-decoration: none; cursor: pointer; background: transparent;
  color: var(--color-text-primary); transition: background-color var(--duration-fast) var(--easing-standard),
  border-color var(--duration-fast) var(--easing-standard), color var(--duration-fast) var(--easing-standard); }
.btn-primary, .btn-ai { background: var(--color-primary); color: var(--color-on-primary); }
.btn-primary:hover, .btn-ai:hover { background: var(--color-primary-hover); }
.btn-primary:active, .btn-ai:active { background: var(--color-primary-active); }
.btn-secondary, .btn-outline-secondary, .btn-outline-primary { background: var(--color-bg-surface); color: var(--color-text-primary);
  border-color: var(--color-border-strong); }
.btn-secondary:hover, .btn-outline-secondary:hover, .btn-outline-primary:hover { background: var(--color-bg-surface-hover); }
.btn-ghost { color: var(--color-text-primary); }
.btn-ghost:hover { background: var(--color-bg-surface-hover); }
.btn-danger { background: var(--color-danger); color: var(--color-on-danger); }
.btn-danger:hover { filter: brightness(0.92); }
.btn-outline-danger { background: var(--color-bg-surface); color: var(--color-danger-text); border-color: var(--color-danger-border); }
.btn-link { height: auto; padding: 0; color: var(--color-text-link); font-weight: 500; text-decoration: underline; }
.btn-sm { height: var(--size-control-sm); padding: 0 var(--space-3); font-size: 13px; border-radius: var(--radius-sm); }
.btn-lg { height: var(--size-control-lg); padding: 0 var(--space-5); font-size: 15px; }
.btn-icon { width: var(--size-control-md); padding: 0; }
.btn-icon.btn-sm { width: var(--size-control-sm); }
.btn:disabled, .btn.disabled { opacity: var(--opacity-disabled); cursor: not-allowed; }
.btn-close { width: var(--size-control-sm); height: var(--size-control-sm); padding: 0; border-radius: var(--radius-sm);
  color: var(--color-text-secondary); }
.btn-close:hover { background: var(--color-bg-surface-hover); color: var(--color-text-primary); }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.btn-group .btn:last-child { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.btn-group .btn + .btn { margin-left: -1px; }

/* ------------------------------------------------------------------ forms */
.form-field { display: flex; flex-direction: column; gap: var(--space-1); }
.form-label { font-size: 13px; line-height: 16px; font-weight: 500; color: var(--color-text-primary); }
.form-control, .form-select { width: 100%; height: var(--size-control-md); padding: 0 var(--space-3); font: inherit;
  font-size: 14px; color: var(--color-text-primary); background-color: var(--color-bg-input);
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); }
textarea.form-control { height: auto; min-height: 88px; padding: var(--space-2) var(--space-3); line-height: 22px; resize: vertical; }
.form-control::placeholder { color: var(--color-text-tertiary); }
.form-control:focus, .form-select:focus { outline: 2px solid var(--color-border-focus); outline-offset: 1px; border-color: var(--color-border-focus); }
.form-control:disabled { color: var(--color-text-muted); background: var(--color-bg-sunken); }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--color-danger); }
.invalid-feedback { font-size: 13px; line-height: 18px; color: var(--color-danger-text); }
.form-text { font-size: 13px; line-height: 18px; color: var(--color-text-secondary); }
.form-select { appearance: none; padding-right: 36px; background-repeat: no-repeat; background-position: right 12px center;
  background-size: 16px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235E6168' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
[data-theme="dark"] .form-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23A9A6CC' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.input-group .btn { border-radius: 0 var(--radius-md) var(--radius-md) 0; margin-left: -1px; }
.form-check { display: flex; align-items: center; gap: var(--space-2); min-height: var(--size-target-min); font-size: 14px; }
.form-check-input { appearance: none; flex: none; width: 16px; height: 16px; margin: 0; border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-xs); background: var(--color-bg-input) center / 12px no-repeat; cursor: pointer; }
.form-check-input[type="radio"] { border-radius: 50%; }
.form-check-input:checked { background-color: var(--color-primary); border-color: var(--color-primary); }
.form-check-input[type="checkbox"]:checked { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FFFFFF' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5 9-10'/%3E%3C/svg%3E"); }
[data-theme="dark"] .form-check-input[type="checkbox"]:checked { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231E1B66' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5 9-10'/%3E%3C/svg%3E"); }
.form-check-input[type="radio"]:checked { box-shadow: inset 0 0 0 4px var(--color-bg-input); }
.form-switch .form-check-input { width: 32px; height: 18px; border-radius: var(--radius-full); border-color: var(--color-border-strong);
  background: var(--color-border-strong) radial-gradient(circle, var(--color-bg-surface) 6px, transparent 6.5px) left 1px center / 16px 16px no-repeat;
  transition: background-position var(--duration-fast) var(--easing-standard); }
.form-switch .form-check-input:checked, .form-check.form-switch .form-check-input[type="checkbox"]:checked, [data-theme="dark"] .form-check.form-switch .form-check-input[type="checkbox"]:checked { background-color: var(--color-primary); border-color: var(--color-primary);
  background-image: radial-gradient(circle, var(--color-on-primary) 6px, transparent 6.5px); background-position: right 1px center; }

/* ------------------------------------------------------------------ badges */
.badge { display: inline-flex; align-items: center; gap: var(--space-1); height: 20px; padding: 0 var(--space-2);
  border-radius: var(--radius-xs); font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap;
  background: var(--label-grey-bg); color: var(--label-grey-text); }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-status-new { background: var(--color-primary-subtle); color: var(--color-ai-text); }
.badge-status-open { background: var(--color-info-bg); color: var(--color-info-text); }
.badge-status-pending { background: var(--color-warning-bg); color: var(--color-warning-text); }
.badge-status-resolved { background: var(--color-success-bg); color: var(--color-success-text); }
.badge-status-closed { background: var(--label-grey-bg); color: var(--label-grey-text); }
.badge-status-spam { background: var(--color-danger-bg); color: var(--color-danger-text); }
.badge-priority-low { background: var(--label-grey-bg); color: var(--label-grey-text); }
.badge-priority-medium { background: var(--label-blue-bg); color: var(--label-blue-text); }
.badge-priority-high { background: var(--label-orange-bg); color: var(--label-orange-text); }
.badge-priority-urgent { background: var(--color-danger); color: var(--color-on-danger); }
.badge-label-grey { background: var(--label-grey-bg); color: var(--label-grey-text); }
.badge-label-blue { background: var(--label-blue-bg); color: var(--label-blue-text); }
.badge-label-teal { background: var(--label-teal-bg); color: var(--label-teal-text); }
.badge-label-green { background: var(--label-green-bg); color: var(--label-green-text); }
.badge-label-amber { background: var(--label-amber-bg); color: var(--label-amber-text); }
.badge-label-orange { background: var(--label-orange-bg); color: var(--label-orange-text); }
.badge-label-red { background: var(--label-red-bg); color: var(--label-red-text); }
.badge-label-pink { background: var(--label-pink-bg); color: var(--label-pink-text); }
.badge-label-indigo { background: var(--label-indigo-bg); color: var(--label-indigo-text); }
.badge-ai, .ai-badge { background: var(--color-ai-surface); color: var(--color-ai-text); box-shadow: inset 0 0 0 1px var(--color-ai-border); }
.badge-count { height: 18px; min-width: 18px; padding: 0 6px; justify-content: center; border-radius: var(--radius-full);
  font-variant-numeric: tabular-nums; background: var(--color-bg-surface-hover); color: var(--color-text-secondary); }
.sla { display: inline-flex; align-items: center; gap: var(--space-1); font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; }
.sla-ok { color: var(--color-text-secondary); }
.sla-soon { color: var(--color-warning-text); }
.sla-overdue { color: var(--color-danger-text); }

/* ------------------------------------------------------------------ cards and stats */
.card { background: var(--color-bg-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border); font-size: 15px; font-weight: 600; }
.card-body { padding: var(--space-5); }
.stat-card, .stat-card-modern { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-4) var(--space-5);
  background: var(--color-bg-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); }
.stat-label { font-size: 13px; font-weight: 500; color: var(--color-text-secondary); }
.metric { font-size: 32px; line-height: 36px; font-weight: 600; letter-spacing: -0.01em; }
.stat-delta { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 500; }
.stat-delta.up { color: var(--color-success-text); } .stat-delta.down { color: var(--color-danger-text); }

/* ------------------------------------------------------------------ alerts, toasts, tooltips */
.alert { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); border: 1px solid;
  border-radius: var(--radius-md); font-size: 14px; line-height: 20px; }
.alert .ic { margin-top: 0; }
.alert strong { font-weight: 600; }
.alert-success { background: var(--color-success-bg); border-color: var(--color-success-border); color: var(--color-success-text); }
.alert-warning { background: var(--color-warning-bg); border-color: var(--color-warning-border); color: var(--color-warning-text); }
.alert-danger { background: var(--color-danger-bg); border-color: var(--color-danger-border); color: var(--color-danger-text); }
.alert-info { background: var(--color-info-bg); border-color: var(--color-info-border); color: var(--color-info-text); }
.toast { display: flex; align-items: center; gap: var(--space-3); min-width: 280px; max-width: 420px; padding: var(--space-3) var(--space-4);
  background: var(--color-bg-inverse); color: var(--color-text-inverse); border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  font-size: 14px; line-height: 20px; }
.toast-text { flex: 1; min-width: 0; }
.toast-action { color: var(--color-link-inverse); font-weight: 600; text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; padding: 0; }
.tooltip { display: inline-block; max-width: 240px; padding: var(--space-1) var(--space-2); background: var(--color-bg-inverse);
  color: var(--color-text-inverse); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); font-size: 12px; line-height: 16px; }
.tooltip .kbd { background: transparent; color: inherit; border-color: color-mix(in srgb, currentColor 35%, transparent); margin-left: 6px; }
/* A hover tooltip on an icon button: <button data-tip="Split ticket">, the
   .tooltip chip above the button, shown on hover and keyboard focus.
   data-tip-align="end" lines it up with the button's right edge (for buttons
   at the right of a card). Keep an aria-label for screen readers. */
:is(button, a, .has-tip)[data-tip] { position: relative; }
:is(button, a, .has-tip)[data-tip]::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translate(-50%, 2px);
  z-index: 30; padding: var(--space-1) var(--space-2); white-space: nowrap; pointer-events: none;
  background: var(--color-bg-inverse); color: var(--color-text-inverse); border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: 0; text-transform: none;
  opacity: 0; visibility: hidden; transition: opacity 120ms ease, transform 120ms ease, visibility 0s linear 120ms; }
:is(button, a, .has-tip)[data-tip][data-tip-align="end"]::after { left: auto; right: 0; transform: translate(0, 2px); }
:is(button, a, .has-tip)[data-tip]:hover::after, :is(button, a, .has-tip)[data-tip]:focus-visible::after {
  opacity: 1; visibility: visible; transform: translate(-50%, 0); transition-delay: 250ms, 250ms, 0s; }
:is(button, a, .has-tip)[data-tip][data-tip-align="end"]:hover::after, :is(button, a, .has-tip)[data-tip][data-tip-align="end"]:focus-visible::after { transform: translate(0, 0); }
@media (hover: none) { :is(button, a, .has-tip)[data-tip]::after { display: none; } }
/* With static/js/tooltip.js the chip lives on the page itself (.st-tip), placed
   inside the window, so a card or panel around the button cannot clip it. */
.has-js-tips :is(button, a, .has-tip)[data-tip]::after { display: none; }
.st-tip { position: fixed; z-index: 2000; max-width: min(320px, calc(100vw - 16px)); padding: var(--space-1) var(--space-2);
  background: var(--color-bg-inverse); color: var(--color-text-inverse); border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  font-size: 12px; line-height: 16px; font-weight: 500; white-space: normal; overflow-wrap: break-word; pointer-events: none;
  opacity: 0; transform: translateY(2px); transition: opacity 120ms ease, transform 120ms ease; }
.st-tip.is-shown { opacity: 1; transform: none; }
.st-tip[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .st-tip { transition: none; } }

/* ------------------------------------------------------------------ overlays: modal, dropdown */
.modal-backdrop { background: var(--color-bg-overlay); }
.modal-content { background: var(--color-bg-elevated); border: 1px solid var(--color-border); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-5) var(--space-6) var(--space-2); }
.modal-title { font-family: var(--font-display); margin: 0; font-size: 20px; line-height: 26px; font-weight: 600; letter-spacing: -0.01em; }
.modal-body { padding: var(--space-2) var(--space-6) var(--space-5); color: var(--color-text-secondary); }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border); background: var(--color-bg-surface); }
/* Stella's confirm box (static/js/confirm-dialog.js), in place of confirm(). */
.st-confirm { width: min(420px, calc(100vw - 32px)); max-width: none; padding: 0; margin: auto; border: 0; background: transparent; color: var(--color-text-primary); overflow: visible; }
.st-confirm::backdrop { background: var(--color-bg-overlay); }
.st-confirm .modal-content { animation: st-confirm-in var(--duration-base, 200ms) ease-out both; }
.st-confirm .modal-header { padding-bottom: var(--space-5); border-bottom: 0; }
.st-confirm .modal-header:has(+ .modal-body) { padding-bottom: var(--space-2); }
.st-confirm .modal-title { font-size: 18px; line-height: 24px; }
.st-confirm .modal-body p { margin: 0; font-size: 14px; line-height: 21px; color: var(--color-text-secondary); }
@keyframes st-confirm-in { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .st-confirm .modal-content { animation: none; } }
.dropdown-menu { min-width: 220px; padding: var(--space-1); background: var(--color-bg-elevated); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.dropdown-header { padding: var(--space-2) var(--space-2) var(--space-1); font-size: 11px; line-height: 14px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-text-secondary); }
.dropdown-item { display: flex; align-items: center; gap: var(--space-2); min-height: 32px; padding: 0 var(--space-2);
  border-radius: var(--radius-sm); color: var(--color-text-primary); font-size: 14px; text-decoration: none; }
.dropdown-item:hover, .dropdown-item.active { background: var(--color-bg-surface-hover); }
.dropdown-item .kbd { margin-left: auto; }
.dropdown-item.danger { color: var(--color-danger-text); }
.dropdown-divider { height: 1px; margin: var(--space-1) 0; background: var(--color-border-subtle); }

/* ------------------------------------------------------------------ navigation */
.nav-tabs { display: flex; gap: var(--space-5); border-bottom: 1px solid var(--color-border); }
.nav-tabs .nav-link { display: inline-flex; align-items: center; gap: var(--space-2); padding: var(--space-2) 0 10px;
  margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--color-text-secondary); font-weight: 500; text-decoration: none; }
.nav-tabs .nav-link:hover { color: var(--color-text-primary); }
.nav-tabs .nav-link.active { color: var(--color-text-primary); border-bottom-color: var(--color-brand); font-weight: 600; }
.segmented { display: inline-flex; padding: 2px; gap: 2px; background: var(--color-bg-sunken); border-radius: var(--radius-md); }
.segmented button { height: 28px; padding: 0 var(--space-3); border: 0; border-radius: var(--radius-sm); background: transparent;
  font: inherit; font-size: 13px; font-weight: 500; color: var(--color-text-secondary); cursor: pointer; }
.segmented button.active { background: var(--color-bg-surface); color: var(--color-text-primary); box-shadow: var(--shadow-xs); }
.pagination { display: flex; align-items: center; gap: var(--space-1); list-style: none; margin: 0; padding: 0; }
.page-link { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 var(--space-2);
  border-radius: var(--radius-sm); color: var(--color-text-primary); text-decoration: none; font-variant-numeric: tabular-nums; }
.page-link:hover { background: var(--color-bg-surface-hover); }
.page-item.active .page-link { background: var(--color-primary); color: var(--color-on-primary); font-weight: 600; }
.page-item.disabled .page-link { color: var(--color-text-muted); pointer-events: none; }
.breadcrumb { display: flex; align-items: center; gap: var(--space-2); list-style: none; margin: 0; padding: 0; font-size: 13px; color: var(--color-text-secondary); }
.breadcrumb a { color: var(--color-text-secondary); text-decoration: none; }
.breadcrumb a:hover { color: var(--color-text-primary); text-decoration: underline; }
.breadcrumb-item + .breadcrumb-item::before { content: "/"; margin-right: var(--space-2); color: var(--color-text-muted); }

/* ------------------------------------------------------------------ app shell: nav rail and top bar */
.app-shell { display: flex; min-height: 100%; background: var(--color-bg-base); }
.app-sidebar { width: var(--sidebar-width); flex: none; display: flex; flex-direction: column; gap: 2px; padding: var(--space-3);
  background: var(--color-nav-bg); color: var(--color-nav-text); }
.sidebar-brand { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-2) var(--space-4); }
.sidebar-brand svg { display: block; }
.sidebar-section { padding: var(--space-4) var(--space-2) var(--space-1); font-size: 11px; line-height: 14px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-nav-text-muted); }
.sidebar-link { display: flex; align-items: center; gap: var(--space-3); min-height: 34px; padding: 0 var(--space-2);
  border-radius: var(--radius-md); color: var(--color-nav-text); font-size: 14px; text-decoration: none; }
.sidebar-link:hover { background: var(--color-nav-item-hover); }
.sidebar-link.active { background: var(--color-nav-item-active); font-weight: 600; }
.sidebar-link .count { margin-left: auto; font-size: 12px; color: var(--color-nav-text-muted); font-variant-numeric: tabular-nums; }
.sidebar-link.active .count { color: var(--color-nav-text); }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar { height: var(--topbar-height); display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-5);
  background: var(--color-bg-surface); border-bottom: 1px solid var(--color-border); }
.topbar-search { flex: 1; max-width: 420px; display: flex; align-items: center; gap: var(--space-2); height: 34px; padding: 0 var(--space-3);
  border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-bg-base); color: var(--color-text-tertiary); font-size: 14px; white-space: nowrap; overflow: hidden; }
.topbar-search .kbd { margin-left: auto; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-6) var(--space-8) var(--space-4); }
.page-header h1 { font-family: var(--font-display); margin: 0; font-size: 28px; line-height: 34px; font-weight: 600; letter-spacing: -0.01em; }

/* ------------------------------------------------------------------ tables and the inbox */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { padding: var(--space-2) var(--space-3); text-align: left; font-size: 13px; font-weight: 500; color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.table td { padding: var(--space-3); border-bottom: 1px solid var(--color-border-subtle); vertical-align: middle; }
.table-hover tbody tr:hover { background: var(--color-bg-surface-hover); }
.table .num { text-align: right; }
.inbox-list { background: var(--color-bg-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; }
.ticket-row { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: var(--space-3); align-items: start;
  padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border-subtle); color: inherit; text-decoration: none; }
.ticket-row:last-child { border-bottom: 0; }
.ticket-row:hover { background: var(--color-bg-surface-hover); }
.ticket-row.is-selected { background: var(--color-bg-selected); box-shadow: inset 2px 0 0 var(--color-brand); }
.inbox-list.is-compact .ticket-row { grid-template-columns: 16px minmax(0, 1fr) auto; align-items: center; padding: var(--space-2) var(--space-4); }
.inbox-list.is-compact .ticket-main { flex-direction: row; align-items: center; gap: var(--space-3); }
.inbox-list.is-compact .ticket-meta { flex: none; max-width: 40%; }
.inbox-list.is-compact .ticket-side { flex-direction: row; align-items: center; gap: var(--space-2); }
.ticket-row .form-check-input { margin-top: 2px; }
.ticket-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ticket-top { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.ticket-subject { font-size: 14px; line-height: 20px; color: var(--color-text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket-row.is-unread .ticket-subject { font-weight: 600; }
.ticket-unread { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--color-brand); }
.ticket-meta { font-size: 13px; line-height: 18px; color: var(--color-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket-side { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-1); }
.ticket-time { font-size: 12px; line-height: 16px; color: var(--color-text-secondary); font-variant-numeric: tabular-nums; }
.ticket-tags { display: flex; gap: var(--space-1); }
.bulk-action-bar { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3);
  background: var(--color-bg-inverse); color: var(--color-text-inverse); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); font-size: 14px; }
.bulk-action-bar .btn { color: var(--color-text-inverse); }
.bulk-action-bar .btn:hover { background: color-mix(in srgb, var(--color-text-inverse) 14%, transparent); }

/* ------------------------------------------------------------------ avatars */
.avatar { display: inline-flex; align-items: center; justify-content: center; flex: none; width: var(--size-avatar-md); height: var(--size-avatar-md);
  border-radius: var(--radius-full); font-size: 12px; font-weight: 600; letter-spacing: 0.02em; overflow: hidden;
  background: var(--label-indigo-bg); color: var(--label-indigo-text); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: var(--size-avatar-sm); height: var(--size-avatar-sm); font-size: 10px; }
.avatar-lg { width: var(--size-avatar-lg); height: var(--size-avatar-lg); font-size: 14px; }
.avatar-teal { background: var(--label-teal-bg); color: var(--label-teal-text); }
.avatar-amber { background: var(--label-amber-bg); color: var(--label-amber-text); }
.avatar-pink { background: var(--label-pink-bg); color: var(--label-pink-text); }
.avatar-blue { background: var(--label-blue-bg); color: var(--label-blue-text); }
.avatar-stella { background: transparent; border-radius: 0; overflow: visible; }

/* ------------------------------------------------------------------ the conversation: messages, AI drafts, private notes, composer */
.thread { display: flex; flex-direction: column; gap: var(--space-4); }
.message { display: grid; grid-template-columns: var(--size-avatar-md) minmax(0, 1fr); gap: var(--space-3); align-items: start; }
.message-card { padding: var(--space-3) var(--space-4); background: var(--color-bg-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); }
.message-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--space-2); font-size: 13px; line-height: 18px; }
.message-author { font-weight: 600; color: var(--color-text-primary); }
.message-time, .message-via { color: var(--color-text-secondary); }
.message-body { margin-top: var(--space-1); font-size: 14px; line-height: 22px; color: var(--color-text-primary); }
.message-body p { margin: 0 0 var(--space-2); }
.message-body p:last-child { margin-bottom: 0; }
.note-card { padding: var(--space-3) var(--space-4); background: var(--color-note-surface); border: 1px solid var(--color-note-border); border-radius: var(--radius-lg); }
.note-label { display: inline-flex; align-items: center; gap: var(--space-1); font-size: 12px; line-height: 16px; font-weight: 600; color: var(--color-note-text); }
.ai-card { padding: var(--space-3) var(--space-4); background: var(--color-ai-surface); border: 1px solid var(--color-ai-border); border-radius: var(--radius-lg); }
.ai-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; line-height: 18px; font-weight: 600; color: var(--color-ai-text); }
.ai-label .ai-sub { font-weight: 500; color: var(--color-text-secondary); }
.ai-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-3); }
.ai-sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--space-3); }
.source-chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 var(--space-2); border: 1px solid var(--color-ai-border);
  border-radius: var(--radius-full); background: var(--color-bg-surface); color: var(--color-ai-text); font-size: 12px; font-weight: 500; text-decoration: none; }
.composer { background: var(--color-bg-input); border: 1px solid var(--color-border-strong); border-radius: var(--radius-lg); overflow: hidden; }
.composer.is-note { background: var(--color-note-surface); border-color: var(--color-note-border); }
.composer-tabs { display: flex; gap: var(--space-1); padding: var(--space-2) var(--space-2) 0; }
.composer-tab { height: 28px; padding: 0 var(--space-3); border: 0; border-radius: var(--radius-sm); background: transparent; font: inherit;
  font-size: 13px; font-weight: 500; color: var(--color-text-secondary); cursor: pointer; }
.composer-tab.active { background: var(--color-bg-surface-hover); color: var(--color-text-primary); font-weight: 600; }
.composer.is-note .composer-tab.active { background: color-mix(in srgb, var(--color-note-border) 45%, transparent); color: var(--color-note-text); }
.composer-input { display: block; width: 100%; min-height: 88px; padding: var(--space-3); border: 0; background: transparent; font: inherit;
  font-size: 14px; line-height: 22px; color: var(--color-text-primary); resize: vertical; }
.composer-input:focus { outline: none; }
.composer:focus-within { outline: 2px solid var(--color-border-focus); outline-offset: 1px; }
.composer-foot { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2); border-top: 1px solid var(--color-border-subtle); }
.composer-foot .grow { flex: 1; }

/* ------------------------------------------------------------------ feedback: empty state, loading */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-3); padding: var(--space-12) var(--space-6); }
.empty-title { font-family: var(--font-display); margin: var(--space-2) 0 0; font-size: 18px; line-height: 24px; font-weight: 600; }
.empty-text { margin: 0; max-width: 360px; color: var(--color-text-secondary); }
@keyframes st-shimmer { from { background-position: 200% 0 } to { background-position: -200% 0 } }
.skeleton { display: block; height: 12px; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--color-bg-surface-hover) 0%, var(--color-border) 50%, var(--color-bg-surface-hover) 100%) 0 0 / 200% 100%;
  animation: st-shimmer 1.6s linear infinite; }
.st-working { display: inline-flex; align-items: center; gap: var(--space-2); font-size: 13px; color: var(--color-text-secondary); }

/* ------------------------------------------------------------------ the chat widget (namespaced stw- so it never collides with a client site) */
.stw { --stw-accent: var(--color-primary); --stw-on-accent: var(--color-on-primary); font-family: var(--font-sans); }
.stw-launcher { width: var(--widget-launcher); height: var(--widget-launcher); padding: 0; border: 0; background: none; cursor: pointer;
  filter: drop-shadow(0 6px 14px rgba(13, 11, 38, 0.28)); }
.stw-launcher:focus-visible { outline-offset: 4px; border-radius: var(--radius-full); }
.stw-panel { width: var(--widget-width); max-width: 100%; max-height: 680px; display: flex; flex-direction: column; background: var(--color-bg-elevated);
  border: 1px solid var(--color-border); border-radius: var(--radius-xl); box-shadow: var(--shadow-xl); overflow: hidden; }
.stw-head { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); }
.stw-title { display: flex; align-items: center; gap: var(--space-2); font-size: 15px; line-height: 20px; font-weight: 600; }
.stw-sub { font-size: 12px; line-height: 16px; color: var(--color-text-secondary); }
.stw-head .grow { flex: 1; min-width: 0; }
.stw-body { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4); font-size: 15px; line-height: 22px; overflow: auto; }
.stw-row { display: flex; align-items: flex-end; gap: var(--space-2); }
.stw-row.visitor { justify-content: flex-end; }
.stw-stack { display: flex; flex-direction: column; gap: 4px; max-width: 80%; }
.stw-row.visitor .stw-stack { align-items: flex-end; }
.stw-bubble { padding: var(--space-2) var(--space-3); border-radius: var(--radius-xl); }
.stw-bubble.ai { background: var(--color-ai-surface); color: var(--color-text-primary); border-bottom-left-radius: var(--radius-xs); }
.stw-bubble.human { background: var(--color-bg-surface); color: var(--color-text-primary); border: 1px solid var(--color-border); border-bottom-left-radius: var(--radius-xs); }
.stw-bubble.visitor { background: var(--stw-accent); color: var(--stw-on-accent); border-bottom-right-radius: var(--radius-xs); }
.stw-meta { font-size: 12px; line-height: 16px; color: var(--color-text-secondary); }
.stw-quick { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); }
.stw-chip { height: 32px; padding: 0 var(--space-3); border: 1px solid var(--color-border-strong); border-radius: var(--radius-full);
  background: var(--color-bg-surface); color: var(--color-text-primary); font: inherit; font-size: 14px; cursor: pointer; }
.stw-chip:hover { background: var(--color-bg-surface-hover); }
.stw-system { align-self: center; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--color-text-secondary); }
.stw-input { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3); border-top: 1px solid var(--color-border); }
.stw-input .form-control { height: var(--size-control-lg); border-radius: var(--radius-full); padding: 0 var(--space-4); font-size: 15px; }
.stw-send { width: var(--size-control-lg); height: var(--size-control-lg); flex: none; display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: var(--radius-full); background: var(--stw-accent); color: var(--stw-on-accent); cursor: pointer; }
.stw-foot { padding: 0 0 var(--space-2); text-align: center; font-size: 11px; line-height: 14px; color: var(--color-text-secondary); }
.stw-status { padding: var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-bg-surface); font-size: 14px; }
.stw-status-title { font-weight: 600; }
.stw-steps { display: flex; gap: 4px; margin: var(--space-3) 0 var(--space-2); }
.stw-steps span { flex: 1; height: 6px; border-radius: var(--radius-full); background: var(--color-border); }
.stw-steps span.done { background: var(--color-brand); }
.stw-steps-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--color-text-secondary); }

/* ------------------------------------------------------------------ help centre defaults (each client can re-brand) */
.hc-hero { display: flex; flex-direction: column; align-items: center; gap: var(--space-4); padding: var(--space-12) var(--space-6);
  background: var(--color-midnight); color: var(--neutral-0); text-align: center; border-radius: var(--radius-xl); }
.hc-hero h1 { font-family: var(--font-display); margin: 0; font-size: 40px; line-height: 44px; font-weight: 600; letter-spacing: -0.02em; }
.hc-search { display: flex; align-items: center; gap: var(--space-2); width: 100%; max-width: 520px; height: 52px; padding: 0 var(--space-4);
  background: var(--neutral-0); color: var(--neutral-600); border-radius: var(--radius-full); font-size: 16px; }
.hc-popular { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2) var(--space-4); font-size: 14px; }
.hc-popular a { color: var(--color-starlight); }
.hc-article { max-width: 68ch; font-size: 17px; line-height: 28px; }
.hc-article h2 { font-family: var(--font-display); font-size: 22px; line-height: 28px; margin: var(--space-6) 0 var(--space-2); }
.hc-feedback { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); background: var(--color-bg-surface); font-size: 14px; }
.hc-feedback button { width: 40px; height: 40px; padding: 0; border: 1px solid var(--color-border); border-radius: var(--radius-full);
  background: var(--color-bg-surface); cursor: pointer; }
.hc-feedback button:hover { background: var(--color-bg-surface-hover); }

/* The right-hand side panel spot, shared by the reply box's Stella panel,
   Help articles and the Ask Stella chat: 420px (the chat can be dragged
   wider; ai-chat.js sets --side-panel-w), one at a time. On a wide
   screen the page makes room for it (the ticket page also hides its
   properties column); on a narrow one it sits over the page. */
@media (min-width: 1100px) {
  body.has-side-panel .app-main { padding-right: var(--side-panel-w, 420px); transition: padding-right 160ms ease; }
  body.has-side-panel .copilot-backdrop { display: none !important; }
}
@media (prefers-reduced-motion: reduce) { body.has-side-panel .app-main { transition: none; } }
/* Stella, busy (partials/brand/star_busy.html): the three dots inside her star */
@keyframes st-busy-dot { 0%, 80%, 100% { opacity: 0.35; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1.15); } }
.st-busy circle { transform-box: fill-box; transform-origin: center; animation: st-busy-dot 1.2s ease-in-out infinite; }
.st-busy .st-dot2 { animation-delay: 0.15s; }
.st-busy .st-dot3 { animation-delay: 0.3s; }
@media (prefers-reduced-motion: reduce) { .st-busy circle { animation: none; opacity: 1; } }


/* Connections (partials/stella_connections.html): what Stella may use for a
   customer company. Ticket Stella tab and the company page. */
.conn-list { display: flex; flex-direction: column; gap: 12px; }
.conn { display: flex; flex-direction: column; gap: 6px; }
.conn-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13px; }
.conn-head .ic { width: 14px; height: 14px; color: var(--color-text-secondary); }
.conn-addr { font-size: 12.5px; }
.conn-switch { display: flex; align-items: flex-start; gap: 8px; margin: 0; padding: 6px 0 0 2px; opacity: .85; }
.conn-switch span { display: flex; flex-direction: column; gap: 1px; font-size: 12.5px; flex: 1; min-width: 0; }
.conn-switch small { color: var(--color-text-tertiary); font-size: 12px; }
.pill.soon { flex: none; font-size: 10.5px; background: var(--color-bg-surface-hover); color: var(--color-text-tertiary); }
.pill.ok { font-size: 11px; background: var(--color-success-bg); color: var(--color-success-text); }


/* Freshdesk's tag field (static/js/tagbox.js): ticket Details tab, New ticket form; (chips in a box, a short
   dropdown of matching tags while typing) */
.tagbox { position: relative; }
.tagbox-field { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-height: 34px; padding: 4px 6px;
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); background: var(--color-bg-input, var(--color-bg-surface)); cursor: text; }
.tagbox-field:focus-within { border-color: var(--color-border-focus); box-shadow: 0 0 0 3px var(--color-focus-ring, rgba(79, 70, 229, .15)); }
.tagbox-chip { display: inline-flex; align-items: center; gap: 2px; height: 22px; padding: 0 2px 0 8px; border-radius: var(--radius-sm);
  background: var(--label-indigo-bg); color: var(--label-indigo-text); font-size: 12px; font-weight: 500; max-width: 100%; }
.tagbox-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tagbox-chip button { width: 18px; height: 18px; border: 0; border-radius: var(--radius-sm); background: none; color: inherit; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 14px; line-height: 1; opacity: .7; }
.tagbox-chip button:hover { opacity: 1; background: rgba(0, 0, 0, .06); }
.tagbox-input { flex: 1 0 70px; min-width: 70px; height: 24px; border: 0; outline: 0; background: none; font: inherit; font-size: 13px; color: var(--color-text-primary); }
.tagbox-menu { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); max-height: 232px; overflow-y: auto; margin: 0; padding: 4px;
  list-style: none; background: var(--color-bg-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,.12)); }
.tagbox-menu li { padding: 6px 10px; border-radius: var(--radius-sm); font-size: 13px; cursor: pointer; color: var(--color-text-primary); }
.tagbox-menu li.active, .tagbox-menu li:hover { background: var(--color-bg-surface-hover); }
.tagbox-menu li.empty { color: var(--color-text-tertiary); cursor: default; background: none; }
.tagbox-menu.up { top: auto; bottom: calc(100% + 4px); }
.tagbox-menu li { display: flex; align-items: center; gap: 8px; }
.tagbox-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--label-indigo-text, var(--color-text-tertiary)); }
