/* ==========================================================================
   Convo Monitor professional theme
   Loaded last: redefines the design tokens and tightens every shared
   component (shell, cards, tables, forms, buttons, badges, tabs).
   ========================================================================== */

/* ---------------------------------------------------------------- tokens */
:root {
  /* Calm slate neutrals, one indigo-blue brand colour, softened status colours. Status colour is for
     state only (a dot, a tinted chip); text stays slate, so the page is not a mix of pure red, green,
     black and white. */
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --border: #e2e7ef;
  --border-light: #edf1f6;
  --border-dark: #cbd3df;

  --text: #18212f;
  --text-1: #18212f;
  --text-2: #4a5568;
  --text-3: #8792a6;
  --text-muted: #4a5568;

  --primary: #3b5bdb;
  --primary-hover: #3049b8;
  --primary-2: #3b5bdb;
  --primary-soft: #eef1fd;
  --primary-ink: #ffffff;
  --ring: rgba(59, 91, 219, 0.18);

  --success: #138a68;
  --success-hover: #0f7055;
  --success-soft: #e8f5f0;
  --success-text: #0f6b52;
  --warning: #c47a12;
  --warning-hover: #a6650c;
  --warning-soft: #fcf4e6;
  --warning-text: #8f5608;
  --danger: #c93a4a;
  --danger-hover: #ad2f3e;
  --danger-soft: #fbedef;
  --danger-text: #a52c3b;
  --info: #3b5bdb;
  --info-hover: #3049b8;
  --info-soft: #eef1fd;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;

  --shadow-xs: 0 1px 2px rgba(24, 33, 47, 0.04);
  --shadow-sm: 0 1px 3px rgba(24, 33, 47, 0.06), 0 1px 2px rgba(24, 33, 47, 0.03);
  --shadow: 0 4px 12px rgba(24, 33, 47, 0.07), 0 1px 3px rgba(24, 33, 47, 0.04);
  --shadow-lg: 0 12px 32px rgba(24, 33, 47, 0.12), 0 2px 6px rgba(24, 33, 47, 0.05);
  --shadow-3: 0 16px 40px rgba(24, 33, 47, 0.16);

  --sidebar-w: 248px;
  --sidebar-w-mini: 68px;
  --topbar-h: 60px;
  --field-h: 38px;

  --topbar-bg: var(--surface);
  --bottom-nav-bg: rgba(255, 255, 255, 0.96);
  --overlay: rgba(24, 33, 47, 0.45);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html[data-theme="dark"] {
  --bg: #0d1220;
  --surface: #141a29;
  --surface-2: #182032;
  --surface-3: #1f2839;
  --border: #273145;
  --border-light: #1d2536;
  --border-dark: #36425a;

  --text: #e8ecf3;
  --text-1: #e8ecf3;
  --text-2: #a4adbe;
  --text-3: #6f7a8f;
  --text-muted: #a4adbe;

  --primary: #7089f0;
  --primary-hover: #8ea2f4;
  --primary-2: #7089f0;
  --primary-soft: rgba(112, 137, 240, 0.15);
  --primary-ink: #ffffff;
  --ring: rgba(112, 137, 240, 0.3);

  --success: #45c19a;
  --success-soft: rgba(69, 193, 154, 0.13);
  --success-text: #6dd3b1;
  --warning: #e0a64a;
  --warning-soft: rgba(224, 166, 74, 0.13);
  --warning-text: #efc27a;
  --danger: #ef7482;
  --danger-hover: #f3949f;
  --danger-soft: rgba(239, 116, 130, 0.13);
  --danger-text: #f59aa5;
  --info: #7089f0;
  --info-soft: rgba(112, 137, 240, 0.15);

  --topbar-bg: var(--surface);
  --bottom-nav-bg: rgba(19, 25, 38, 0.96);
  --overlay: rgba(0, 0, 0, 0.6);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 14px 36px rgba(0, 0, 0, 0.5);
  --shadow-3: 0 16px 40px rgba(0, 0, 0, 0.55);
}

/* ---------------------------------------------------------------- base fixes */
[hidden] { display: none !important; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { color: var(--text); letter-spacing: -0.01em; font-weight: 600; }
h1 { font-size: 20px; line-height: 1.3; margin: 0 0 2px; }
h2 { font-size: 15px; line-height: 1.4; }
h3 { font-size: 14px; }
a { color: var(--primary); }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.mono, code, kbd { font-family: var(--font-mono); font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
::selection { background: var(--primary-soft); }

/* inline SVG icons from CM.icon() */
.icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; line-height: 0; }
.btn .icon + span, .btn span + .icon { margin-left: 0; }

/* ---------------------------------------------------------------- sidebar */
.sidebar { background: var(--surface); border-right: 1px solid var(--border); box-shadow: none; }
.sidebar-header {
  height: var(--topbar-h);
  padding: 0 12px 0 16px;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}
.brand { gap: 10px; font-size: 15.5px; font-weight: 650; color: var(--text); letter-spacing: -0.015em; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #1b2540, #0b1020); color: #fff; flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
}
.sidebar__collapse {
  margin-left: auto;
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  display: none; align-items: center; justify-content: center;
  color: var(--text-3); background: transparent; border: 0; cursor: pointer;
}
.sidebar__collapse:hover { background: var(--surface-3); color: var(--text); }

.sidebar-nav { padding: 12px 10px; gap: 18px; }
.nav-section-title {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  color: var(--text-3); padding: 0 10px; margin-bottom: 4px;
}
.nav-group { gap: 2px; }
.nav-link {
  height: 36px; padding: 0 10px; gap: 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
  transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease;
}
.nav-link:hover { background: var(--surface-3); color: var(--text); }
.nav-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-link .badge-alert {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; font-size: 11px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--danger); color: #fff;
}

.sidebar-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 12px 12px 14px;
  border-top: 1px solid var(--border);
}
.sidebar-user { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  background: var(--surface-3); color: var(--text-2);
  font-size: 13px; font-weight: 600; border: 1px solid var(--border);
}
.sidebar-user__meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.sidebar-user__name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user__role { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.sidebar-footer__actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.sidebar-logout { margin: 0; display: inline-flex; }

.icon-btn {
  width: 34px; height: 34px; min-height: 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); border: 0; background: transparent;
  color: var(--text-2); cursor: pointer;
  transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn[aria-pressed="false"] { color: var(--text-3); }

/* ---------------------------------------------------------------- topbar */
.topbar {
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: none;
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
.hotel-switcher {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 4px 0 12px; margin: 0;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text-2);
  font-size: 13.5px; font-weight: 500; cursor: pointer;
}
.hotel-switcher:hover { border-color: var(--border-dark); }
.hotel-switcher select {
  border: 0; background-color: transparent; box-shadow: none;
  min-height: 0; height: 34px; padding: 0 26px 0 0;
  color: var(--text); font-size: 13.5px; font-weight: 500; max-width: 220px;
}
.hotel-switcher select:focus { box-shadow: none; }
.global-search { position: relative; flex: 0 1 340px; }
.global-search input {
  height: 36px; min-height: 0; width: 100%;
  padding: 0 32px 0 34px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 13.5px;
}
.global-search input:focus { background: var(--surface); }
.global-search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search-shortcut {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  min-width: 20px; height: 20px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 4px; background: var(--surface);
  color: var(--text-3); font-size: 11px; line-height: 1;
}
.topbar-right { gap: 6px; }
.ws-state {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px; border-radius: 13px;
  font-size: 12px; font-weight: 500; letter-spacing: 0;
  color: var(--text-2); background: var(--surface-3); border: 0;
}
.ws-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.ws-state.on { color: var(--success); background: var(--success-soft); }
.ws-state.on::before { background: var(--success); }
.ws-state.off { color: var(--warning-text); background: var(--warning-soft); }
.ws-state.off::before { background: var(--warning); }

/* ---------------------------------------------------------------- content area */
.content { width: 100%; max-width: 1480px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head .muted { font-size: 13.5px; margin-top: 2px; }
.app-footer {
  text-align: center; font-size: 12px; color: var(--text-3);
  border-top: 0; background: transparent;
}
.alert-stack:empty { display: none; }
.offline-banner {
  border-radius: var(--radius); border: 1px solid var(--warning);
  background: var(--warning-soft); color: var(--warning-text);
  font-weight: 500;
}

/* ---------------------------------------------------------------- cards & stats */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: 20px;
}
.card h2 { font-size: 15px; margin-bottom: 12px; }
.card + .card { margin-top: 16px; }

.stat-grid { gap: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
  padding: 16px 18px;
}
.stat .label {
  font-size: 12.5px; font-weight: 500; color: var(--text-2);
  text-transform: none; letter-spacing: 0;
}
.stat .value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); line-height: 1.25; margin-top: 4px; }
.stat .meta-trend { font-size: 12.5px; color: var(--text-3); margin-top: 6px; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 0; height: 36px; padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-dark);
  background: var(--surface); color: var(--text);
  font-size: 13.5px; font-weight: 500; line-height: 1;
  box-shadow: var(--shadow-xs);
  white-space: nowrap; cursor: pointer;
  transition: background-color var(--dur-fast) ease, border-color var(--dur-fast) ease, color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-dark); text-decoration: none; }
.btn:active { transform: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-lg { height: 42px; padding: 0 18px; font-size: 14.5px; }
.btn-block { width: 100%; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--primary-ink); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: var(--success-hover); border-color: var(--success-hover); color: #fff; }
.btn-warn { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-warn:hover { background: var(--warning-hover); border-color: var(--warning-hover); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--text); }

/* Destructive actions inside tables stay quiet until hovered */
td .btn-danger, .table-wrap .btn-danger {
  background: var(--surface); color: var(--danger); border-color: var(--border-dark);
}
td .btn-danger:hover, .table-wrap .btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
@media (hover: none) {
  .btn-primary:hover { background: var(--primary); }
  .btn-danger:hover { background: var(--danger); }
  td .btn-danger:hover, .table-wrap .btn-danger:hover { background: var(--surface); }
}

.dropdown-menu {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 4px; min-width: 180px;
}
.dropdown-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  height: 34px; padding: 0 10px; border-radius: var(--radius-sm);
  background: transparent; border: 0; color: var(--text);
  font-size: 13.5px; text-align: left; cursor: pointer;
}
.dropdown-item:hover { background: var(--surface-3); }
.dropdown-item--danger, .dropdown-item--danger .icon { color: var(--danger); }
.dropdown-item--danger:hover { background: var(--danger-soft); }
.dropdown-item-icon { color: var(--text-3); display: inline-flex; width: 16px; font-size: 14px; }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }
.dropdown-toggle .icon { color: var(--text-3); }

/* ---------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px;
  border-radius: 11px; border: 1px solid transparent;
  font-size: 12px; font-weight: 500; line-height: 1; letter-spacing: 0;
  text-transform: none; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.sev-LOW, .badge--info { background: var(--info-soft); color: var(--info); }
.sev-MEDIUM, .badge--warning { background: var(--warning-soft); color: var(--warning-text); }
.sev-HIGH, .badge--danger { background: var(--danger-soft); color: var(--danger-text); }
.st-OPEN { background: var(--danger-soft); color: var(--danger-text); }
.st-ACKNOWLEDGED { background: var(--warning-soft); color: var(--warning-text); }
.st-RESOLVED, .badge--success { background: var(--success-soft); color: var(--success-text); }
.badge[class*="sev-"], .badge[class*="st-"], .badge[class*="badge--"] {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 16%, transparent);
}
.badge-listening { background: var(--primary-soft); color: var(--primary); }
.badge-listening::before { background: var(--primary); }

.status-dot { width: 8px; height: 8px; border-radius: 50%; box-shadow: none; }

/* ---------------------------------------------------------------- forms */
label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
input, select, textarea {
  min-height: 0; height: var(--field-h);
  padding: 0 11px;
  font-size: 13.5px; color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
textarea { height: auto; min-height: 84px; padding: 9px 11px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:hover, select:hover, textarea:hover { border-color: var(--text-3); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a94a6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 16px;
}
input[type=checkbox], input[type=radio] {
  height: 16px; width: 16px; min-height: 0; padding: 0; box-shadow: none;
  accent-color: var(--primary);
}
input[type=range] { height: auto; padding: 0; border: 0; box-shadow: none; background: transparent; accent-color: var(--primary); }
input[type=date], input[type=time] { padding-right: 8px; }
html[data-theme="dark"] input[type=date], html[data-theme="dark"] input[type=time] { color-scheme: dark; }
/* Backs up the color-scheme meta: no browser auto-darkening of the light theme. */
html[data-theme="light"] { color-scheme: only light; }
html[data-theme="dark"] { color-scheme: dark; }

/* Toggle switch: the global input height must not stretch it */
input.switch-input {
  appearance: none; -webkit-appearance: none;
  width: 36px; height: 20px; min-height: 0; padding: 0; margin: 0;
  border-radius: 10px; border: 0; box-shadow: none;
  background: var(--border-dark); position: relative; cursor: pointer; flex-shrink: 0;
  transition: background-color var(--dur-base) ease;
}
input.switch-input::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.2);
  transition: transform var(--dur-base) var(--ease-out);
}
input.switch-input:checked { background: var(--primary); }
input.switch-input:checked::after { transform: translateX(16px); }
input.switch-input:hover { border: 0; }
input.switch-input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; box-shadow: none; }
.switch-label { font-size: 13.5px; font-weight: 500; color: var(--text); gap: 12px; }

/* Filter bars: compact, aligned row of fields */
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  align-items: end; gap: 12px;
  padding: 16px;
}
.filters label { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.filters label > input, .filters label > select { width: 100%; margin: 0; }

/* ---------------------------------------------------------------- tables */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: none; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
th {
  height: 40px; padding: 0 16px;
  background: var(--surface-2);
  color: var(--text-2); font-size: 12px; font-weight: 500;
  text-transform: none; letter-spacing: 0; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px 16px; vertical-align: middle;
  border-bottom: 1px solid var(--border-light); color: var(--text);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color var(--dur-fast) ease; }
tbody tr:hover td { background: var(--surface-2); }
tr.clickable { cursor: pointer; }
th.right, td.right { text-align: right; }
td .muted { font-size: 12.5px; }
td.empty { padding: 40px 16px; text-align: center; color: var(--text-3); }
td .row { gap: 6px; flex-wrap: nowrap; }
td.right .row, td.right > .btn + .btn { justify-content: flex-end; }

/* A card that only frames a table becomes a single clean container (desktop) */
@media (min-width: 861px) {
  .card:has(> .table-wrap) { padding: 0; overflow: hidden; }
  .card > .table-wrap { border: 0; border-radius: 0; }
  .card > h2:first-child + .table-wrap, .card > .row + .table-wrap { margin: 0 -1px -1px; }
}

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* ---------------------------------------------------------------- tabs & chips */
.tabs { margin-left: 0; margin-right: 0; padding: 0; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs .tab, .tabs button {
  height: 40px; padding: 0 12px; margin-bottom: -1px;
  border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  background: transparent; color: var(--text-2);
  font-size: 13.5px; font-weight: 500;
}
.tabs .tab:hover, .tabs button:hover { color: var(--text); background: transparent; }
.tabs .tab.is-active, .tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tabs .tab-badge {
  min-width: 20px; height: 18px; padding: 0 6px; margin-left: 6px;
  border-radius: 9px; font-size: 11.5px; font-weight: 500;
  background: var(--surface-3); color: var(--text-2);
}
.tabs .tab.is-active .tab-badge { background: var(--primary-soft); color: var(--primary); }

.chip-bar { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 4px; }
.chip {
  height: 30px; padding: 0 12px; gap: 6px;
  border-radius: 15px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2);
  font-size: 13px; font-weight: 500; box-shadow: none;
}
.chip:hover { border-color: var(--border-dark); color: var(--text); }
.chip.is-active { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.chip-badge { font-size: 11.5px; color: inherit; opacity: .75; background: transparent; }

/* ---------------------------------------------------------------- modal, drawer, toasts */
.modal { border-radius: var(--radius-lg); border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.modal-backdrop, .drawer-backdrop { background: var(--overlay); }
.drawer { border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.toast { border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
/* The kind at a glance: a coloured edge on the left. */
.toast.success { border-left: 3px solid var(--success); }
.toast.error, .toast.incident { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info { border-left: 3px solid var(--info); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity .18s ease, transform .18s ease; }

/* alert banners: solid edge, calm surface */
.alert-banner {
  border-radius: var(--radius); border: 1px solid var(--danger);
  background: var(--danger-soft); box-shadow: none;
}
.alert-banner--medium { border-color: var(--warning); background: var(--warning-soft); }

/* empty / error states */
.list-empty__icon, .list-error__icon { color: var(--text-3); }

/* ---------------------------------------------------------------- desktop shell (≥861px) */
@media (min-width: 861px) {
  .sidebar__collapse { display: inline-flex; }
  html[data-sidebar="expanded"] .sidebar { box-shadow: none; }
  html[data-sidebar="expanded"] .main { margin-left: var(--sidebar-w); }
  html[data-sidebar="mini"] .main { margin-left: var(--sidebar-w-mini); }

  .topbar { height: var(--topbar-h); padding: 0 24px; gap: 12px; }
  .content { padding: 28px 32px 48px; }
  .alert-stack { padding: 16px 32px 0; }
  .offline-banner { margin: 16px 32px 0; }
  .app-footer { padding: 0 32px 24px; }

  /* mini sidebar */
  html[data-sidebar="mini"] .sidebar-header { flex-direction: column; justify-content: center; height: auto; min-height: var(--topbar-h); padding: 12px 0 8px; gap: 8px; }
  html[data-sidebar="mini"] .sidebar__collapse { margin-left: 0; }
  html[data-sidebar="mini"] .sidebar-user__meta { display: none; }
  html[data-sidebar="mini"] .sidebar-user { flex: 0 0 auto; }
  html[data-sidebar="mini"] .sidebar-footer { flex-direction: column; padding: 10px 0; gap: 6px; }
  html[data-sidebar="mini"] .sidebar-footer__actions { flex-direction: column; }
  html[data-sidebar="mini"] .nav-link { width: 40px; height: 40px; padding: 0; justify-content: center; }
  html[data-sidebar="mini"] .nav-link .badge-alert {
    position: absolute; top: 2px; right: 0; margin: 0;
    min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px;
  }
  html[data-sidebar="mini"] .nav-section { display: flex; flex-direction: column; align-items: center; }
  html[data-sidebar="mini"] .nav-section + .nav-section { border-top: 1px solid var(--border-light); padding-top: 14px; }
}

/* ---------------------------------------------------------------- phones (≤860px) */
@media (max-width: 860px) {
  input, select, textarea { font-size: 16px; height: 44px; }
  textarea { height: auto; }
  input.switch-input { height: 20px; width: 36px; }
  .btn { height: 40px; }
  .btn-sm { height: 34px; }
  .content { padding: 16px; }
  .page-head { align-items: flex-start; margin-bottom: 16px; }
  .page-head .muted { display: none; }
  .card { padding: 16px; border-radius: var(--radius-lg); }
  .stat .value { font-size: 22px; }
  .topbar { background: var(--topbar-bg); }
  .sidebar-footer { padding-bottom: calc(12px + var(--safe-bottom)); }
}

/* ---------------------------------------------------------------- page-level touches */
.mobile-filters-btn { display: none; }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 32px 0 12px; }
.section-head h2 { margin: 0; font-size: 15px; }
.section-head .muted { font-size: 13px; margin-top: 2px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.settings-grid > .card + .card { margin-top: 0; }
.option-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 0; border-bottom: 1px solid var(--border-light);
}
.option-row:last-child { border-bottom: 0; }
.option-row strong { display: block; font-size: 13.5px; font-weight: 500; color: var(--text); }
.option-row .muted { font-size: 12.5px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; }
.field .hint { font-size: 12.5px; color: var(--text-3); }

td .status-inline { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

@media (max-width: 860px) {
  .mobile-filters-btn { display: inline-flex; }
  .page-head h1 { display: none; }
  .page-head:not(:has(> :not(div:first-child))) { display: none; }
  .chip-bar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 4px -16px 8px; padding: 0 16px; }
  .chip-bar::-webkit-scrollbar { display: none; }
  .chip { flex-shrink: 0; }
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
}

/* toolbars above tables/forms: search or selector on the left, actions on the right */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.toolbar input[type=search] { width: 300px; max-width: 100%; margin: 0; }
.toolbar__field { display: inline-flex; align-items: center; gap: 10px; margin: 0; }
.toolbar__field > span { font-size: 13px; font-weight: 500; color: var(--text-2); }
.toolbar__field select { min-width: 220px; margin: 0; }
.option-list { margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.steps { list-style: none; margin: 16px 0 4px; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border-light); display: grid; gap: 8px; }
.steps li { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text); }
.steps .badge { min-width: 56px; justify-content: center; }
.card > h2 + .muted.small { margin: -8px 0 8px; }
@media (max-width: 860px) {
  .toolbar input[type=search], .toolbar__field, .toolbar__field select { width: 100%; min-width: 0; }
  .toolbar .btn { width: 100%; }
}
@media (max-width: 860px) {
  /* stacked mobile row-cards should not sit inside another card */
  .card:has(> .table-wrap .table-cards) { padding: 0; background: transparent; border: 0; box-shadow: none; }
  .table-cards tr { border-radius: var(--radius-lg); border: 1px solid var(--border); box-shadow: var(--shadow-xs); }
  .section-head { flex-wrap: wrap; }
}

/* grids of cards align to the top edge */
.grid > .card + .card, .grid-2 > .card + .card, .grid-2 > .stack > .card + .card { margin-top: 0; }
.grid-2 { align-items: start; }

/* sign-in */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: var(--bg); }
.login-card { width: 100%; max-width: 400px; padding: 32px; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.login-brand { margin-bottom: 28px; font-size: 16px; }
.login-title { font-size: 20px; margin: 0 0 4px; }
.login-sub { font-size: 13.5px; margin: 0 0 4px; }
.login-card .field:first-of-type { margin-top: 20px; }
.login-card .notice-small { margin: 16px 0 0; text-align: center; font-size: 12px; color: var(--text-3); }
.alert-error { margin-top: 16px; padding: 10px 12px; border-radius: var(--radius); background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); font-size: 13px; }

/* ==========================================================================
   Live listen card (exact design: orb + timer + waveform + controls)
   ========================================================================== */
.lpx {
  --lpx-bg: #ffffff; --lpx-border: #E5E7EB; --lpx-text: #0F172A; --lpx-muted: #64748B;
  --lpx-chip: #F1F2F7; --lpx-hover: #F3F4F8; --lpx-ib-ink: #334155; --lpx-bar: #CBD5E1;
  position: relative; width: 400px; max-width: 100%;
  background: var(--lpx-bg); color: var(--lpx-text);
  border: 1px solid var(--lpx-border); border-radius: 20px;
  padding: 18px 20px 16px;
  box-shadow: 0 1px 2px rgba(15,23,42,.05), 0 24px 60px -28px rgba(15,23,42,.28);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  touch-action: pan-y;
}
.lpx * { box-sizing: border-box; }
.lpx-hd { display: flex; align-items: center; gap: 10px; }
.lpx-ttl { flex: 1; min-width: 0; }
.lpx-ttl b { display: block; font-size: 16px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lpx-ttl span { display: block; font-size: 12px; color: var(--lpx-muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lpx-pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--lpx-chip); color: var(--lpx-muted); transition: background .2s, color .2s; white-space: nowrap; flex: none; }
.lpx-pill i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.lpx-pill.g { background: #E7F8F2; color: #047857; }
.lpx-pill.g i { animation: lpx-blink 1.6s infinite; }
.lpx-pill.w { background: #FEF3E2; color: #B45309; }
.lpx-pill.n { background: #EEF0FF; color: #4F46E5; }
.lpx-pill.r { background: #FDECEC; color: #B91C1C; }
@keyframes lpx-blink { 50% { opacity: .3; } }
.lpx-x { width: 32px; height: 32px; border-radius: 10px; border: 1px solid var(--lpx-border); background: var(--lpx-bg); color: var(--lpx-muted); display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; flex: none; }
.lpx-x:hover { background: var(--lpx-hover); color: var(--lpx-text); }

.lpx-mid { display: flex; flex-direction: column; align-items: center; padding: 18px 0 6px; }
.lpx-orb { position: relative; width: 96px; height: 96px; display: flex; align-items: center; justify-content: center; }
.lpx-orb::before { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--rc, #4F46E5); opacity: .12; transition: background .25s; }
.lpx-orb.live::before { animation: lpx-ripple 1.8s ease-out infinite; }
@keyframes lpx-ripple { 0% { transform: scale(.82); opacity: .22; } 100% { transform: scale(1.18); opacity: 0; } }
.lpx-orb-btn { position: relative; width: 68px; height: 68px; border-radius: 50%; border: none; background: var(--rc, #4F46E5); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; transition: transform .15s, background .25s; }
.lpx-orb-btn:hover { transform: scale(1.05); }
.lpx-orb-btn:active { transform: scale(.96); }
.lpx-orb-btn:disabled { cursor: default; transform: none; }
.lpx-orb-btn:focus-visible { outline: 2px solid var(--rc, #4F46E5); outline-offset: 4px; }
.lpx-orb-btn.spin .icon { animation: lpx-spin 1s linear infinite; }
@keyframes lpx-spin { to { transform: rotate(360deg); } }
.lpx-orb-btn .icon-play { margin-left: 3px; }
.lpx-orb-btn .icon-play svg, .lpx-orb-btn .icon-pause svg { fill: currentColor; }
.lpx-tm { font-size: 30px; font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin-top: 14px; line-height: 1.2; }
.lpx-wv { display: flex; align-items: center; justify-content: center; gap: 3px; height: 40px; width: 100%; margin: 6px 0 4px; }
.lpx-wv i { width: 4px; height: 4px; border-radius: 99px; background: var(--lpx-bar); transition: height .2s, background .25s; }
.lpx-wv.live i { background: #059669; }
.lpx-wv.wait i, .lpx-wv.warn i { background: #FBBF24; }
.lpx-msg { font-size: 13px; color: var(--lpx-muted); text-align: center; min-height: 20px; }
.lpx-msg.w { color: #B45309; }

.lpx-ctl { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--lpx-border); }
.lpx-ib { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--lpx-border); background: var(--lpx-bg); color: var(--lpx-ib-ink); display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; flex: none; transition: background .15s; }
.lpx-ib:hover:not(:disabled) { background: var(--lpx-hover); }
.lpx input[type=range] { flex: 1; height: 4px; padding: 0; margin: 0; border: 0; box-shadow: none; background: transparent; accent-color: #4F46E5; }
.lpx-stop { height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid #FCA5A5; background: var(--lpx-bg); color: #B91C1C; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; cursor: pointer; font-family: inherit; flex: none; }
.lpx-stop:hover:not(:disabled) { background: #FDECEC; }
.lpx-ib:disabled, .lpx-stop:disabled, .lpx input[type=range]:disabled { opacity: .45; cursor: default; }
.lpx-priv { display: flex; align-items: center; gap: 6px; justify-content: center; font-size: 12px; color: var(--lpx-muted); margin-top: 12px; }
.lpx-act { display: flex; gap: 8px; margin-top: 12px; }
.lpx-act button { flex: 1; height: 40px; border-radius: 12px; border: 1px solid var(--lpx-border); background: var(--lpx-bg); color: var(--lpx-text); font-size: 13px; font-weight: 500; display: flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; font-family: inherit; }
.lpx-act button:hover { background: #F8F9FC; border-color: #CBD5E1; }
@media (prefers-reduced-motion: reduce) {
  .lpx-orb.live::before, .lpx-pill.g i, .lpx-orb-btn.spin .icon { animation: none; }
}

html[data-theme="dark"] .lpx {
  --lpx-bg: #131926; --lpx-border: #252e3f; --lpx-text: #f1f3f6; --lpx-muted: #a3abba;
  --lpx-chip: #1e2636; --lpx-hover: #1e2636; --lpx-ib-ink: #d6dbe4; --lpx-bar: #334055;
  box-shadow: 0 1px 2px rgba(0,0,0,.3), 0 24px 60px -28px rgba(0,0,0,.7);
}
html[data-theme="dark"] .lpx-pill.g { background: rgba(5,150,105,.16); color: #34d399; }
html[data-theme="dark"] .lpx-pill.w { background: rgba(217,119,6,.16); color: #fbbf24; }
html[data-theme="dark"] .lpx-pill.n { background: rgba(99,102,241,.18); color: #a5b4fc; }
html[data-theme="dark"] .lpx-pill.r { background: rgba(239,68,68,.16); color: #fca5a5; }
html[data-theme="dark"] .lpx-msg.w { color: #fbbf24; }
html[data-theme="dark"] .lpx-stop { border-color: rgba(248,113,113,.5); color: #fca5a5; }
html[data-theme="dark"] .lpx-stop:hover:not(:disabled) { background: rgba(239,68,68,.14); }
html[data-theme="dark"] .lpx-act button:hover { background: #1e2636; border-color: #334055; }

/* Placement: inline on the incident page, floating dock on the overview */
#listen-box .lpx { width: 100%; }
.listen-dock { width: auto; }
.listen-dock .lpx { width: 400px; max-width: 100%; margin: 0 auto; }
@media (min-width: 861px) {
  .listen-dock { left: auto; right: 24px; bottom: 24px; transform: none; width: 400px; }
}
@media (max-width: 860px) {
  .listen-dock { left: 0; right: 0; margin: 0 8px; }
  .listen-dock .lpx { width: 100%; }
  .lpx-act { flex-direction: row; }
}

/* AI summaries are two lines: what happened / what staff should do */
.ai-summary-text, .ai-summary-block p { white-space: pre-line; }
.ai-snippet-quote { margin: 8px 0; padding: 8px 12px; background: var(--surface-2); border-radius: var(--radius); font-style: italic; font-size: 13px; }

/* ---------------------------------------------------------------- phones: compact type scale
   Stops Android "font boosting" from enlarging text, and keeps controls at a normal size.
   iOS keeps 16px inputs, otherwise Safari zooms the page when a field is focused. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (max-width: 860px) {
  body { font-size: 14px; }
  input, select, textarea { font-size: 14.5px; height: 42px; }
  textarea { height: auto; }
  input.switch-input { height: 20px; width: 36px; }
  input[type=range] { height: auto; }
  .btn { height: 40px; font-size: 14px; }
  .btn-sm { height: 34px; font-size: 13px; }
  .modal-actions .btn, .ra-modal .modal-actions .btn, .drawer-foot .btn { height: 44px; font-size: 14.5px; }
  .modal-head h2, .modal .modal-head h2, .drawer-title { font-size: 16px; }
  .modal-head__sub { font-size: 12.5px; }
  .card-item__title { font-size: 14px; }
  .stat .value, .u-stat__num { font-size: 20px; }
  .ov-hotel__title h2 { font-size: 15px; }
  .table-cards td.is-primary { font-size: 13px; }
  .act-code__value { font-size: 18px; }
}
@supports (-webkit-touch-callout: none) {
  @media (max-width: 860px) { input, select, textarea { font-size: 16px; } }
}
