/* ==========================================================================
   ZELQIVO - STS — design system
   Warm, approachable, 2026. One token system, real light + dark themes,
   white-label extension points preserved: --brand, --brand-hover, --brand-2,
   --accent, --brand-logo-url, --brand-logo-filter are overridden at runtime
   by /api/settings/branding.css when a SuperAdmin sets custom branding.
   ========================================================================== */

/* ---- Fonts (self-hosted; CSP has no font CDN allowance, and doesn't need one) ---- */

@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('fonts/bricolage-grotesque-variable.woff2') format('woff2-variations'),
       url('fonts/bricolage-grotesque-variable.woff2') format('woff2');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Plus Jakarta Sans';
  src: url('fonts/plus-jakarta-sans-variable.woff2') format('woff2-variations'),
       url('fonts/plus-jakarta-sans-variable.woff2') format('woff2');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Mono';
  src: url('fonts/ibm-plex-mono-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Mono';
  src: url('fonts/ibm-plex-mono-500.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Mono';
  src: url('fonts/ibm-plex-mono-600.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* ---- Reset ---- */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

img,
svg {
  max-width: 100%;
}

a {
  color: var(--brand);
  text-underline-offset: 3px;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

ul,
ol {
  list-style: none;
}

/* ==========================================================================
   Tokens
   ========================================================================== */

:root {
  color-scheme: light;

  /* Type */
  --font-display: 'Bricolage Grotesque', ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: 'Plus Jakarta Sans', ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Space */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Radius */
  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  /* Motion */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --fast: 140ms;
  --med: 220ms;

  /* Light palette — warm paper, plum-warm ink, coral-pink brand, amber accent */
  --canvas: #fcf8f4;
  --surface: #ffffff;
  --surface-2: #f7f0ea;
  --surface-raised: #ffffff;
  --ink: #2a2024;
  --ink-soft: #5c4e52;
  --muted: #776a6e;
  --line: #eee2da;
  --line-strong: #dfccc0;
  --on-brand: #ffffff;

  --brand: #c03e5e;
  --brand-hover: #9d324d;
  --brand-2: #e8a33d;
  --accent: #e8a33d;
  --brand-soft: #fde6ec;
  --logo-filter-default: invert(1) grayscale(1) contrast(1.12);

  /* Semantic — independent of brand so pills stay meaningful under any white-label color.
     All foreground/soft-background pairs below are tuned to WCAG AA (>=4.5:1). */
  --sem-info: #2f6fb0;
  --sem-info-soft: #e7f1fa;
  --sem-warning: #9b6118;
  --sem-warning-soft: #fbf0de;
  --sem-violet: #7757b0;
  --sem-violet-soft: #f0ebfb;
  --sem-neutral: #6b5d61;
  --sem-neutral-soft: #f1e9e4;

  --danger: #c03e3e;
  --danger-hover: #9d3232;
  --danger-soft: #fbeae7;
  --success: #367a52;
  --success-soft: #e8f5ec;

  --shadow-xs: 0 1px 2px rgba(58, 28, 24, 0.06);
  --shadow-soft: 0 8px 24px rgba(58, 28, 24, 0.08);
  --shadow-pop: 0 24px 64px rgba(58, 28, 24, 0.16);
  --shadow-inset: inset 0 0 0 1px rgba(58, 28, 24, 0.05);

  --header-bg: rgba(255, 255, 255, 0.78);
}

/* ==========================================================================
   Base
   ========================================================================== */

html {
  min-height: 100%;
  background: var(--canvas);
}

body {
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  overflow-x: hidden;
  transition: background var(--med) var(--ease), color var(--med) var(--ease);
}

html.require-admin-auth:not(.admin-authed) body,
html.require-user-auth:not(.user-authed) body {
  display: none;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  text-wrap: balance;
  color: var(--ink);
}

h2 { font-size: 1.55rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

code, pre {
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}

.is-hidden {
  display: none !important;
}

.skip-link {
  position: absolute;
  left: 18px;
  top: -60px;
  z-index: 10000;
  background: var(--ink);
  color: var(--canvas);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.skip-link:focus {
  top: 14px;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--brand-soft);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ==========================================================================
   Header / nav
   ========================================================================== */

header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(18px, 4vw, 48px);
  background: var(--header-bg);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}

header .logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: transparent;
  font-size: 0;
  line-height: 1;
}

header .logo::before {
  content: "";
  display: block;
  width: clamp(170px, 20vw, 240px);
  max-width: min(56vw, 240px);
  aspect-ratio: 1100 / 230;
  background: var(--brand-logo-url, url("Main_header_logo_white.png")) center / contain no-repeat;
  filter: var(--brand-logo-filter, var(--logo-filter-default));
}

header .logo[data-role-label]::after {
  content: attr(data-role-label);
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

header nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

header nav a,
header nav button,
header nav .logout-btn {
  display: inline-flex;
  align-items: center;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  border: 1px solid transparent;
  background: transparent;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}

header nav a:hover,
header nav button:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--ink);
}

header nav a.active,
.view-chip.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
}

header nav a.active:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
}

header nav .logout-btn,
#logoutBtn {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
}

header nav .logout-btn:hover,
#logoutBtn:hover {
  background: var(--surface-2);
  border-color: var(--muted);
  color: var(--ink);
}

/* ==========================================================================
   Sidebar & topbar

   Applies only to pages with a persistent authenticated nav (body.has-sidebar).
   Light-only, matching the rest of the app (no dark chrome, no theme toggle —
   dark mode was deliberately removed app-wide, see project history). Built
   entirely from existing, already WCAG-AA-verified tokens so it stays correct
   under any white-label branding override (--brand/--brand-2/--accent) with
   no changes here, and the brand logo renders in its true configured colors
   (same var(--brand-logo-filter, var(--logo-filter-default)) mechanism the
   top header already uses) rather than a forced monochrome treatment.
   ========================================================================== */

:root {
  --sidebar-w: 264px;
}

body.has-sidebar {
  margin-left: var(--sidebar-w);
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  z-index: 50;
  transition: transform var(--med) var(--ease);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  min-height: 56px;
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--space-2);
  overflow: hidden;
}

.sidebar__brand-mark {
  display: block;
  flex: 1 1 auto;
  height: 56px;
  background: var(--brand-logo-url, url("Main_header_logo_white.png")) left center / auto 100% no-repeat;
  filter: var(--brand-logo-filter, var(--logo-filter-default));
}

.sidebar__close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  margin-left: var(--space-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
}

.sidebar__close:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.sidebar__close-bar {
  position: relative;
  display: block;
  width: 14px;
  height: 14px;
}

.sidebar__close-bar::before,
.sidebar__close-bar::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 0;
  width: 14px;
  height: 2px;
  background: currentColor;
}

.sidebar__close-bar::before { transform: rotate(45deg); }
.sidebar__close-bar::after { transform: rotate(-45deg); }

.sidebar__groups {
  flex: 1 1 auto;
  padding: var(--space-2) var(--space-3) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.sidebar__group-label {
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}

.sidebar__link:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.sidebar__link.is-active {
  background: var(--brand);
  color: var(--on-brand);
}

.sidebar__link-dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
}

.sidebar__link.is-active .sidebar__link-dot {
  opacity: 1;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 12, 14, 0.4);
  z-index: 45;
}

.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
}

.sidebar-toggle:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.sidebar-toggle__bar {
  display: block;
  width: 16px;
  height: 2px;
  background: currentColor;
  position: relative;
  transition: background var(--fast) var(--ease);
}

.sidebar-toggle__bar::before,
.sidebar-toggle__bar::after {
  content: "";
  position: absolute;
  left: 0;
  width: 16px;
  height: 2px;
  background: currentColor;
  transition: transform var(--fast) var(--ease), top var(--fast) var(--ease);
}

.sidebar-toggle__bar::before { top: -5px; }
.sidebar-toggle__bar::after { top: 5px; }

body.sidebar-open .sidebar-toggle__bar {
  background: transparent;
}

body.sidebar-open .sidebar-toggle__bar::before {
  top: 0;
  transform: rotate(45deg);
}

body.sidebar-open .sidebar-toggle__bar::after {
  top: 0;
  transform: rotate(-45deg);
}

.topbar__title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: none;
  width: max-content;
}

/* Same JS-untouched mechanism as the old header .logo[data-role-label]::after
   badge: the element's own text is hidden, and admin.js/admin-home.js/etc.
   already set data-role-label to "Admin"/"SUPERAdmin" dynamically. */
.topbar .role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 10px;
  color: transparent;
  font-size: 0;
}

.topbar .role-badge[data-role-label]::after {
  content: attr(data-role-label);
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ==========================================================================
   Layout shells
   ========================================================================== */

main {
  display: block;
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(24px, 4vw, 48px) clamp(18px, 4vw, 48px) 80px;
}

.dashboard,
.dashboard--wide,
.form-section {
  max-width: 1180px;
  margin: 0 auto;
}

.form-section {
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: clamp(28px, 5vw, 40px);
}

body.auth-page main {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 74px);
  padding-top: clamp(32px, 8vh, 64px);
  padding-bottom: clamp(32px, 8vh, 64px);
}

.dash-header {
  margin-bottom: var(--space-8);
}

.dash-header h2 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  margin-bottom: 6px;
}

.dash-subtitle {
  color: var(--muted);
  font-size: 0.98rem;
  max-width: 62ch;
  margin-bottom: var(--space-3);
}

.dash-grid,
.grid-container,
.admin-two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-6);
  align-items: start;
}

.dash-grid--home {
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
}

.dash-grid--no-stretch {
  align-items: start;
}

.dash-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  min-width: 0;
}

.dash-sep {
  border: none;
  border-top: 1px solid var(--line);
  margin: var(--space-6) 0;
}

/* ==========================================================================
   Cards
   ========================================================================== */

.dash-card,
.admin-section,
.ticket-card,
.user-card,
.admin-modal__panel,
.confirm-dialog__panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: var(--space-6);
  min-width: 0;
  transition: box-shadow var(--med) var(--ease), border-color var(--med) var(--ease), transform var(--med) var(--ease);
}

.dash-card h3,
.admin-section h3 {
  margin-bottom: 4px;
}

.dash-card > .dash-subtitle {
  margin-bottom: var(--space-5);
}

.dash-card--wide {
  grid-column: 1 / -1;
}

.user-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.admin-subcard,
.ticket-panel {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--space-4) var(--space-5);
  min-width: 0;
}

details.admin-subcard summary {
  cursor: pointer;
  font-weight: 650;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

details.admin-subcard summary:hover {
  color: var(--ink);
}

details.admin-subcard[open] summary {
  margin-bottom: var(--space-3);
}

.ticket-panel--wide {
  grid-column: 1 / -1;
}

.ticket-panel--danger {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 30%, var(--line));
}

.ticket-panel__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: 8px;
}

.empty-state {
  padding: var(--space-8) var(--space-5);
  text-align: center;
  color: var(--muted);
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

button,
.btn,
.attach-upload {
  background: var(--brand);
  color: var(--on-brand);
  border: 1px solid var(--brand);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-weight: 650;
  font-size: 0.92rem;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease), transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
  box-shadow: var(--shadow-xs);
}

button:hover:not(:disabled),
.btn:hover:not(:disabled) {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:disabled,
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.ghost-btn,
a.ghost-btn {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

.ghost-btn:hover:not(:disabled),
a.ghost-btn:hover {
  background: var(--surface-2);
  border-color: var(--muted);
  color: var(--ink);
}

.ghost-btn--active,
.ghost-btn.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--canvas);
}

.delete-btn,
.delete-user-btn,
.row-delete-btn,
.danger-btn,
.ticket-panel--danger button {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.delete-btn:hover:not(:disabled),
.delete-user-btn:hover:not(:disabled),
.row-delete-btn:hover:not(:disabled),
.danger-btn:hover:not(:disabled) {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}

.row-delete-btn:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--danger) 35%, transparent);
  outline-offset: 2px;
}

.escalate-btn {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.escalate-btn:hover:not(:disabled) {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}

.make-admin-btn {
  background: var(--sem-violet);
  border-color: var(--sem-violet);
  color: #fff;
}

.link-btn {
  background: none;
  border: none;
  box-shadow: none;
  color: var(--brand);
  padding: 4px 6px;
  font-weight: 600;
}

.link-btn:hover:not(:disabled) {
  background: var(--brand-soft);
  transform: none;
}

/* ==========================================================================
   Forms
   ========================================================================== */

.ticket-form,
.admin-modal__field,
.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.ticket-form {
  gap: var(--space-4);
}

.form-row label,
.check-row,
label {
  font-weight: 650;
  font-size: 0.86rem;
  color: var(--ink-soft);
}

input,
select,
textarea,
.filter-input,
.response-input,
.thread-input,
.attach-file {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 0.94rem;
  color: var(--ink);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}

input:hover:not(:disabled),
select:hover:not(:disabled),
textarea:hover:not(:disabled) {
  border-color: var(--muted);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

/* input[type=color]'s swatch is a shadow-DOM element that collapses to a
   sliver if it inherits the generic text-input padding, so it needs its own
   box model. */
input[type="color"] {
  padding: 4px;
  height: 44px;
  cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 6px;
}

input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 6px;
}

textarea {
  min-height: 96px;
  resize: vertical;
  font-family: var(--font-body);
}

.thread-input {
  min-height: 64px;
}

.attach-file::file-selector-button {
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  padding: 7px 12px;
  margin-right: 10px;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--ink-soft);
  transition: background var(--fast) var(--ease);
}

.attach-file::file-selector-button:hover {
  background: var(--line);
}

.check-row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.check-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.field-hint {
  color: var(--muted);
  font-size: 0.82rem;
}

.field-hint code {
  background: var(--surface-2);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 0.8em;
}

.form-msg {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--ink-soft);
}

.form-msg.is-ok {
  background: var(--success-soft);
  color: var(--success);
}

.form-msg.is-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ==========================================================================
   Help points (contextual "?" tooltips)
   ========================================================================== */

.label-line {
  display: flex;
  align-items: center;
  gap: 6px;
}

.help-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.help-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

button.help-point {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0;
  box-shadow: none;
  position: relative;
}

button.help-point:hover {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand);
  transform: none;
}

button.help-point.is-open::after {
  content: attr(data-help);
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 60;
  width: max-content;
  max-width: 260px;
  background: var(--ink);
  color: var(--canvas);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.45;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-pop);
}

/* ==========================================================================
   Pills / badges
   ========================================================================== */

.meta-pill,
.audit-pill,
.status-pill,
.confirm-dialog__kicker,
.sem-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  font-size: 0.76rem;
  font-weight: 650;
  background: var(--sem-neutral-soft);
  color: var(--sem-neutral);
  white-space: nowrap;
}

.user-pill {
  background: var(--surface-2);
  color: var(--ink-soft);
}

.status-pill.is-open { background: var(--sem-info-soft); color: var(--sem-info); }
.status-pill.is-resolved { background: var(--success-soft); color: var(--success); }
.status-pill.is-escalated { background: var(--danger-soft); color: var(--danger); }
.status-pill.is-waiting-customer { background: var(--sem-warning-soft); color: var(--sem-warning); }
.status-pill.is-waiting-support { background: var(--sem-violet-soft); color: var(--sem-violet); }

.urgent-icon {
  color: var(--danger);
}

.priority-low { background: var(--sem-info-soft); color: var(--sem-info); }
.priority-normal { background: var(--sem-neutral-soft); color: var(--sem-neutral); }
.priority-high { background: var(--sem-warning-soft); color: var(--sem-warning); }
.priority-urgent { background: var(--danger-soft); color: var(--danger); }

.sla-pill {
  background: var(--sem-neutral-soft);
  color: var(--sem-neutral);
}

.sla-pill.is-overdue {
  background: var(--danger-soft);
  color: var(--danger);
}

.meta-pill.is-auto-escalated {
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 600;
}

.meta-pill.is-license-active { background: var(--success-soft); color: var(--success); }
.meta-pill.is-license-expired,
.meta-pill.is-license-invalid { background: var(--danger-soft); color: var(--danger); }

.licensing-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.licensing-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.licensing-row__info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.licensing-row__info strong {
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.licensing-row__status {
  justify-self: start;
}

.licensing-row__form {
  display: flex;
  gap: var(--space-2);
  min-width: 0;
}

.licensing-key-input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.audit-pill--risk {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ==========================================================================
   Tickets: filters, viewbar, grid, pager
   ========================================================================== */

.tickets-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.ticket-viewbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: var(--space-4);
}

.view-chip {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 15px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.85rem;
  box-shadow: none;
}

.view-chip:hover:not(:disabled) {
  background: var(--surface-2);
  transform: none;
}

.view-chip--utility {
  border-style: dashed;
}

.tickets-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
}

.tickets-pager {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: var(--space-5) 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.bulk-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  background: var(--sem-info-soft);
  border: 1px solid var(--sem-info);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-5);
}

.bulk-toolbar #bulkSelectedCount {
  font-weight: 600;
  color: var(--ink);
}

.ticket-select-checkbox {
  width: 18px;
  height: 18px;
  margin-right: var(--space-3);
}

.ticket-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

#ticketsSection.is-compact .ticket-grid {
  gap: var(--space-3);
}

#ticketsSection.is-compact .ticket-card {
  padding: var(--space-4);
}

/* Compact mode used to only tighten the card's own padding and the gap
   between cards, which barely mattered once a card's action grid was open —
   that's most of a populated card's height. Tighten the panels themselves. */
#ticketsSection.is-compact .ticket-card__head {
  margin-bottom: var(--space-2);
}

#ticketsSection.is-compact .meta-row {
  gap: 6px;
  margin-bottom: var(--space-2);
}

#ticketsSection.is-compact .meta-pill,
#ticketsSection.is-compact .status-pill,
#ticketsSection.is-compact .audit-pill {
  height: 22px;
  font-size: 0.7rem;
}

#ticketsSection.is-compact .ticket-summary,
#ticketsSection.is-compact .customer-history {
  margin-bottom: var(--space-2);
}

#ticketsSection.is-compact .ticket-action-grid {
  gap: var(--space-2);
  margin-top: var(--space-3);
}

#ticketsSection.is-compact .ticket-panel {
  padding: var(--space-3);
}

#ticketsSection.is-compact .thread-messages {
  max-height: 200px;
}

/* ==========================================================================
   Ticket card
   ========================================================================== */

.ticket-card {
  position: relative;
  overflow: hidden;
}

.ticket-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--line-strong);
}

.ticket-card:has(.priority-urgent)::before,
.ticket-card:has(.status-pill.is-escalated)::before {
  background: var(--danger);
}

.ticket-card:has(.priority-high)::before {
  background: var(--sem-warning);
}

.ticket-card:has(.status-pill.is-resolved)::before {
  background: var(--success);
}

.ticket-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.ticket-card__head h3,
.ticket-card__head h4 {
  font-size: 1.05rem;
}

.ticket-id {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: var(--space-3);
}

.ticket-summary {
  color: var(--ink-soft);
  font-size: 0.94rem;
  line-height: 1.55;
  margin-bottom: var(--space-3);
}

.customer-history {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: var(--space-3);
}

.customer-history__label {
  font-weight: 650;
  color: var(--ink-soft);
}

.customer-timeline-details {
  margin-bottom: var(--space-3);
  font-size: 0.85rem;
}

.customer-timeline-details summary {
  cursor: pointer;
  color: var(--brand);
  font-weight: 600;
}

.customer-timeline__list {
  list-style: none;
  margin: var(--space-2) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.customer-timeline__list li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.duplicate-candidate {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-top: var(--space-2);
}

.team-input {
  max-width: 160px;
}

.ticket-detail-btn,
.ticket-message-btn {
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
  box-shadow: none;
  position: relative;
}

.ticket-detail-btn:hover:not(:disabled),
.ticket-message-btn:hover:not(:disabled) {
  background: var(--line);
  transform: none;
}

.ticket-message-btn.is-unread {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
  animation: ticket-message-pulse 1.8s ease-in-out infinite;
}

@keyframes ticket-message-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand) 45%, transparent); }
  50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--brand) 0%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  .ticket-message-btn.is-unread {
    animation: none;
  }
}

.ticket-action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.ticket-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.ticket-metadata {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ticket-status-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.ticket-status-bar__item {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  text-decoration: none;
  box-shadow: var(--shadow-soft);
  transition: transform var(--med) var(--ease), box-shadow var(--med) var(--ease);
}

.ticket-status-bar__item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-pop);
}

.ticket-status-bar__item:nth-child(2) { border-left-color: var(--sem-info); }
.ticket-status-bar__item:nth-child(3) { border-left-color: var(--danger); }

.ticket-status-bar__label {
  display: block;
  font-size: 0.92rem;
  color: var(--muted);
  font-weight: 650;
}

.ticket-status-bar__value {
  display: block;
  font-family: var(--font-display);
  font-size: 3rem;
  line-height: 1.1;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin: 6px 0;
}

.ticket-status-bar__hint {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
}

#ticketStatusBar.is-loading {
  opacity: 0.5;
}

/* ==========================================================================
   Conversation thread
   ========================================================================== */

.thread {
  display: none;
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px dashed var(--line-strong);
}

.thread.is-open {
  display: block;
}

.thread-layout {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: var(--space-4);
}

.thread-panel {
  min-width: 0;
}

.thread-panel--side {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
}

.thread-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: var(--space-3);
  padding-right: 4px;
}

.thread-msg {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  max-width: 88%;
  align-self: flex-start;
}

.thread-msg--admin {
  align-self: flex-end;
  background: var(--brand-soft);
}

.thread-msg__meta {
  display: flex;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 3px;
  font-weight: 650;
}

.thread-msg__body {
  font-size: 0.9rem;
  white-space: pre-wrap;
  line-height: 1.5;
}

.thread-compose {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.canned-replies {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.response-read {
  background: var(--sem-info-soft);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  margin-bottom: var(--space-3);
}

.response-read__head {
  font-size: 0.76rem;
  font-weight: 650;
  color: var(--sem-info);
  margin-bottom: 3px;
}

.response-read__body {
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.satisfaction-widget {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}

.satisfaction-stars {
  display: flex;
  gap: 6px;
  margin: var(--space-2) 0;
}

.satisfaction-star {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
  font-weight: 700;
  box-shadow: none;
}

.satisfaction-star.is-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--surface);
}

.satisfaction-comment {
  width: 100%;
  min-height: 60px;
  margin-bottom: var(--space-2);
}

.satisfaction-submitted {
  margin-bottom: var(--space-3);
}

/* ==========================================================================
   Internal notes
   ========================================================================== */

.internal-notes__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: var(--space-3);
  max-height: 220px;
  overflow-y: auto;
}

.internal-note {
  background: var(--sem-warning-soft);
  border-radius: var(--radius-xs);
  padding: 8px 11px;
}

.internal-note__meta {
  font-size: 0.7rem;
  color: var(--sem-warning);
  font-weight: 650;
  margin-bottom: 2px;
}

.internal-note__body {
  font-size: 0.85rem;
  white-space: pre-wrap;
}

/* ==========================================================================
   Attachments
   ========================================================================== */

.attachments {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px dashed var(--line-strong);
}

.attachments__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.attachments__list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--space-3);
}

.attach-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-2);
  border-radius: var(--radius-xs);
  padding: 7px 11px;
  font-size: 0.85rem;
}

.attach-link {
  color: var(--brand);
  font-weight: 600;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attach-meta {
  color: var(--muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.attachments__controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ==========================================================================
   AI assist / KB suggestions / visit request
   ========================================================================== */

.ai-assist {
  background: linear-gradient(155deg, var(--brand-soft), var(--sem-violet-soft));
  border: 1px solid var(--line);
}

.ai-summary-input {
  min-height: 76px;
}

.ai-suggestion-output {
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: var(--surface);
  border-radius: var(--radius-xs);
  padding: 8px 11px;
  margin-top: 8px;
}

.kb-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: var(--space-2);
}

.kb-suggestion {
  display: block;
  background: var(--sem-info-soft);
  color: var(--sem-info);
  border-radius: var(--radius-xs);
  padding: 8px 11px;
  font-size: 0.85rem;
  text-decoration: none;
}

.visit-request {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px dashed var(--line-strong);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ==========================================================================
   Audit log
   ========================================================================== */

.audit-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
}

.audit-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.audit-row {
  padding: var(--space-4);
}

.audit-row__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}

.audit-muted {
  color: var(--muted);
  font-size: 0.82rem;
}

.audit-details {
  margin-top: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.audit-block__title {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 6px;
}

.audit-kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  font-size: 0.85rem;
}

.audit-k {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.audit-v {
  color: var(--ink);
  word-break: break-word;
}

.audit-diff-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
  flex-wrap: wrap;
}

.audit-before {
  color: var(--danger);
  text-decoration: line-through;
  opacity: 0.75;
}

.audit-after {
  color: var(--success);
  font-weight: 650;
}

.audit-arrow {
  color: var(--muted);
}

/* ==========================================================================
   Modals / dialogs
   ========================================================================== */

.admin-modal,
.confirm-dialog {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-modal__backdrop,
.confirm-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 12, 14, 0.5);
  backdrop-filter: blur(3px);
}

.admin-modal__panel,
.confirm-dialog__panel {
  position: relative;
  width: min(420px, 92vw);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: var(--space-6);
}

.confirm-dialog__content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.confirm-dialog__kicker {
  align-self: flex-start;
  background: var(--danger-soft);
  color: var(--danger);
}

.admin-modal__title,
.confirm-dialog__title {
  font-size: 1.15rem;
}

.admin-modal__message,
.confirm-dialog__message {
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.55;
}

.admin-modal__field {
  margin-top: var(--space-3);
}

.admin-modal__check {
  flex-direction: row;
  align-items: center;
}

.admin-modal__actions,
.confirm-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: var(--space-5);
}

.confirm-dialog__cancel,
.secondary {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

.confirm-dialog__cancel:hover,
.secondary:hover {
  background: var(--surface-2);
}

/* ==========================================================================
   Toasts / notification center
   ========================================================================== */

.toast-container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 340px;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop);
  padding: 12px 15px;
  font-size: 0.86rem;
  opacity: 1;
  transform: translateY(0);
  transition: opacity var(--med) var(--ease), transform var(--med) var(--ease);
}

.toast--hide {
  opacity: 0;
  transform: translateY(8px);
}

/* Fixed to the viewport, not the document: it's appended once to <body> by
   admin.js, so without this it just sits in normal document flow whenever
   that happens to fall — usually clipped at the bottom of short pages.
   Anchored bottom-right (not bottom-left) so it never sits over the sidebar's
   own bottom-left collapse control on pages with the sidebar. */
.notification-center {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 260;
}

.notification-center__button {
  position: relative;
}

.notification-center__count {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--danger);
  color: #fff;
  border-radius: var(--radius-pill);
  font-size: 0.65rem;
  min-width: 17px;
  height: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.notification-center__panel {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  width: 320px;
  max-width: 88vw;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  padding: var(--space-4);
  z-index: 250;
}

.notification-center__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.notification-center__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}

.notification-center__item {
  background: var(--surface-2);
  border-radius: var(--radius-xs);
  padding: 8px 10px;
  font-size: 0.83rem;
}

/* ==========================================================================
   MFA / account
   ========================================================================== */

body.account-page main {
  max-width: 900px;
}

/* The sidebar already narrows the effective content column, so account pages
   (profile.html, admin-account.html) drop the borrowed 1.4fr/1fr home-page
   split for a plain single-column stack instead of stretching it thinner. */
body.account-page .dash-grid,
body.account-page .dash-grid--home {
  grid-template-columns: 1fr;
}

.account-password-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Stacked, not side-by-side: this panel lives inside admin-account's narrow
   760px-capped, uneven-split (1.4fr/1fr) layout, so the card it sits in can be
   as little as ~270px wide — nowhere near enough to fit a 168px QR code next
   to readable key text in a row. A vertical stack is correct at any width the
   card can realistically be, not just below a viewport media query. */
.mfa-setup-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.mfa-qr-box {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: var(--space-4);
  border: 1px solid var(--line);
  display: inline-flex;
  align-self: flex-start;
}

.mfa-qr-code {
  width: 168px;
  height: 168px;
  display: block;
}

#mfaSecretText {
  display: inline-block;
  max-width: 100%;
  word-break: break-all;
}

.mfa-uri-details {
  min-width: 0;
}

.mfa-uri-details summary {
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.mfa-uri-details code {
  display: block;
  margin-top: 8px;
  padding: 10px 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  font-size: 0.78rem;
  line-height: 1.5;
  word-break: break-all;
}

.admin-subcard code {
  font-family: var(--font-mono);
  background: var(--surface);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.85em;
}

/* ==========================================================================
   Branding admin controls
   ========================================================================== */

.brand-preview-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.brand-logo-preview {
  max-height: 60px;
  max-width: 220px;
  object-fit: contain;
  border-radius: var(--radius-xs);
}

.brand-favicon-preview {
  max-height: 32px;
  max-width: 32px;
  object-fit: contain;
}

/* ==========================================================================
   Ops dashboard
   ========================================================================== */

.ops-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.ops-panel {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.ops-panel__title {
  font-family: var(--font-display);
  font-weight: 700;
  margin-bottom: var(--space-3);
}

.ops-checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.ops-check {
  background: var(--surface);
  border-radius: var(--radius-xs);
  border-left: 3px solid var(--line-strong);
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.85rem;
}

.ops-check.is-ok { border-left-color: var(--success); }
.ops-check.is-bad { border-left-color: var(--danger); }

.ops-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.ops-tile {
  background: var(--surface);
  border-radius: var(--radius-xs);
  padding: 10px 13px;
}

.ops-tile__label {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 650;
}

.ops-tile__value {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  margin: 3px 0;
}

.ops-tile__hint {
  font-size: 0.74rem;
  color: var(--muted);
}

.ops-trend {
  margin-top: var(--space-3);
}

.ops-trend__title {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 650;
  margin-bottom: 6px;
}

.ops-trend__chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 60px;
  background: var(--surface);
  border-radius: var(--radius-xs);
  padding: 6px 6px 0;
}

.ops-trend__day {
  flex: 1 1 auto;
  display: flex;
  align-items: flex-end;
  gap: 1px;
  height: 100%;
  min-width: 3px;
}

.ops-trend__bar {
  flex: 1 1 auto;
  min-height: 2px;
  border-radius: 1px 1px 0 0;
}

.ops-trend__bar--created { background: var(--brand); }
.ops-trend__bar--resolved { background: var(--success); }

/* Fixed height steps (not inline style="height:...") so bar heights work under the
   app's style-src-attr 'none' CSP. */
.ops-trend__bar--h0 { height: 2px; }
.ops-trend__bar--h10 { height: 10%; }
.ops-trend__bar--h20 { height: 20%; }
.ops-trend__bar--h30 { height: 30%; }
.ops-trend__bar--h40 { height: 40%; }
.ops-trend__bar--h50 { height: 50%; }
.ops-trend__bar--h60 { height: 60%; }
.ops-trend__bar--h70 { height: 70%; }
.ops-trend__bar--h80 { height: 80%; }
.ops-trend__bar--h90 { height: 90%; }
.ops-trend__bar--h100 { height: 100%; }

.ops-trend__legend {
  display: flex;
  gap: var(--space-3);
  margin-top: 6px;
  font-size: 0.74rem;
  color: var(--muted);
}

.ops-trend__legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.ops-trend__swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
}

.ops-trend__swatch--created { background: var(--brand); }
.ops-trend__swatch--resolved { background: var(--success); }

/* ==========================================================================
   Marketing / auth hero
   ========================================================================== */

.hero {
  text-align: center;
  padding: clamp(48px, 10vh, 96px) 20px;
}

.hero-logo {
  width: clamp(300px, 42vw, 520px);
  aspect-ratio: 1100 / 230;
  margin: 0 auto var(--space-8);
  color: transparent;
  font-size: 0;
  line-height: 1;
  background: var(--brand-logo-url, url("Main_header_logo_white.png")) center / contain no-repeat;
  filter: var(--brand-logo-filter, var(--logo-filter-default));
}

.hero h1 {
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  line-height: 1.05;
  margin-bottom: var(--space-4);
}

.hero p {
  color: var(--muted);
  font-size: 1.05rem;
  margin-bottom: var(--space-6);
}

.hero .btn,
.hero button,
.hero a.btn {
  display: inline-flex;
  padding: 13px 28px;
  font-size: 1rem;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: var(--space-8) 20px var(--space-10);
}

/* ==========================================================================
   Utilities
   ========================================================================== */

.mt-0 { margin-top: 0 !important; }
.mt-10 { margin-top: 10px !important; }
.mt-12 { margin-top: 12px !important; }
.mt-14 { margin-top: 14px !important; }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1180px) {
  /* Every page using these grid classes now sits beside a fixed-width
     sidebar (see "Sidebar & topbar" above), so this collapses at a wider
     viewport than a full-bleed page would need, to keep columns readable. */
  .dash-grid,
  .dash-grid--home,
  .grid-container,
  .admin-two-col,
  .ticket-status-bar,
  .thread-layout {
    grid-template-columns: 1fr;
  }

  .licensing-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .ticket-card__head {
    flex-direction: column;
  }
}

@media (max-width: 860px) {
  body.has-sidebar {
    margin-left: 0;
  }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-pop);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-overlay {
    display: block;
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .sidebar__close {
    display: inline-flex;
  }
}

@media (max-width: 620px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
  }

  header .logo::before {
    width: min(210px, 78vw);
  }

  header nav {
    width: 100%;
  }

  header nav a,
  header nav button {
    flex: 1 1 auto;
    justify-content: center;
  }

  /* .topbar is a `header`, but unlike the plain nav-link header above it
     never grows a wide link list, so it stays a single row even at this
     width instead of inheriting the stacked layout meant for `header nav`. */
  .topbar {
    flex-direction: row;
    align-items: center;
    gap: var(--space-2);
    padding: 10px 14px;
  }

  .topbar__title {
    font-size: 1.05rem;
  }

  /* Overrides the `header nav a, header nav button { flex: 1 1 auto }` rule
     above: that rule assumes a full-width stacked link list (the plain
     header), but .topbar__actions is only ever 1-2 small action items and
     was stretching to fill the row width, overflowing the viewport. */
  .topbar__actions a,
  .topbar__actions button {
    flex: none;
  }

  .tickets-filters,
  .audit-filters {
    grid-template-columns: 1fr;
  }

  .toast-container {
    left: 12px;
    right: 12px;
    max-width: none;
  }

  .admin-modal__panel,
  .confirm-dialog__panel {
    padding: var(--space-5);
  }
}

@media (max-width: 560px) {
  .notification-center__panel {
    position: fixed;
    top: 68px;
    right: 12px;
    left: 12px;
    width: auto;
  }

  .canned-replies {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ==========================================================================
   Licensed-feature visibility (INTEGRATION.md §5.4)

   body.no-license-<product> is set by admin.js/app.js from the public
   licensing-status endpoint. This is display-only — the actual enforcement
   is the requireLicense() middleware on each route; hiding here just keeps
   unlicensed UI out of the way rather than showing a disabled teaser.
   ========================================================================== */

body.no-license-assist section.ticket-panel:has(.ai-assist) {
  display: none;
}

body.no-license-flow .ticket-actions:has(.team-input) {
  display: none;
}

body.no-license-field .visit-request {
  display: none;
}

body.no-license-knowledge .kb-suggestions {
  display: none;
}

/* Distinct branded identity per licensed product, next to the panel/section
   it lives in — the real ZELQIVO module logo lockups (public/modules/), not
   an invented badge, sized to sit inline with a panel title. */
.product-badge {
  display: inline-block;
  height: 15px;
  width: auto;
  margin-left: var(--space-2);
  vertical-align: middle;
}

.product-badge--lg {
  height: 22px;
  margin-left: 0;
}
