/* LeadHell — internal command-center UI (Nodus-aligned: dark navy + blue/cyan, no orange) */

:root {
  /* Surfaces */
  --bg:          #0b1020;
  --bg-2:        #080d18;        /* sidebar */
  --bg-3:        #131c33;        /* inner card surface */
  --panel:       #121a2d;
  --panel-2:     #17213a;        /* hover / active surface */

  /* Borders */
  --line:        #1d2740;
  --line-2:      #22304a;
  --line-soft:   rgba(255, 255, 255, 0.04);

  /* Text */
  --text:        #eef4ff;
  --text-mute:   #8c98ad;
  --text-dim:    #5e6a82;

  /* Accent (Nodus-like calm blue + cyan) */
  --accent:        #2f7cff;
  --accent-2:      #4f93ff;
  --accent-strong: #1f64dc;
  --accent-soft:   rgba(47, 124, 255, 0.14);
  --accent-glow:   rgba(47, 124, 255, 0.32);
  --cyan:          #37c8ff;
  --cyan-soft:     rgba(55, 200, 255, 0.12);

  /* Semantic — calm, no orange */
  --info:   #37c8ff;
  --ok:     #34d399;
  --warn:   #f0c674;
  --danger: #e25c4d;

  /* Radii */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "SF Pro Display", "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0.05px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent-2); }

button { font-family: inherit; }

::selection { background: var(--accent-soft); color: var(--text); }

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
  border-radius: var(--r-sm);
}

/* ───────── layout ───────── */

.lh-app {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

/* ───────── sidebar ───────── */

.lh-side {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.lh-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px;
  border-bottom: 1px solid var(--line);
}
.lh-brand-mark {
  position: relative;
  display: inline-block;
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--cyan) 100%);
  border-radius: 8px;
  box-shadow:
    0 6px 14px var(--accent-glow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  font-size: 0;             /* hide accidental text */
  flex-shrink: 0;
}
.lh-brand-mark::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.10);
  transform: rotate(45deg);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.lh-brand-mark::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 55%);
  pointer-events: none;
}

.lh-brand-name {
  font-weight: 600;
  letter-spacing: 0.2px;
  font-size: 15px;
  color: var(--text);
}
.lh-brand-version {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.2px;
}

.lh-nav {
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}
.lh-nav-link {
  display: block;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  color: var(--text-mute);
  font-size: 14px;
  line-height: 1.4;
  transition: background 120ms ease, color 120ms ease;
}
.lh-nav-link:hover {
  color: var(--text);
  background: var(--panel-2);
}
.lh-nav-link.is-active {
  color: #ffffff;
  background: var(--accent-soft);
  font-weight: 500;
}
.lh-nav-admin {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.lh-side-foot {
  padding: 14px 18px;
  font-size: 12px;
  border-top: 1px solid var(--line);
  color: var(--text-mute);
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.01));
}
.lh-muted { color: var(--text-dim); font-size: 12px; }

/* ───────── main + topbar ───────── */

.lh-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.lh-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 5;
}
.lh-page-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.1px;
  color: var(--text);
}
.lh-page-lead {
  margin: 4px 0 0 0;
  color: var(--text-mute);
  font-size: 14px;
}
.lh-topbar-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.lh-user { display: inline-flex; gap: 8px; align-items: center; }
.lh-user-name {
  color: var(--text);
  font-size: 13px;
  padding: 5px 11px;
  border-radius: var(--r-sm);
  background: var(--panel);
  border: 1px solid var(--line);
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lh-content {
  padding: 20px 24px 48px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ───────── pills ───────── */

.lh-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.2px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text-mute);
  white-space: nowrap;
}
.lh-pill--neutral { color: var(--text-mute); }
.lh-pill--info    { color: #b8eaff; border-color: #1c3e57; background: var(--cyan-soft); }
.lh-pill--ok      { color: #b6efd1; border-color: #1f4438; background: rgba(52, 211, 153, 0.10); }
.lh-pill--warn    { color: #f1dca5; border-color: #3f3823; background: rgba(240, 198, 116, 0.10); }
.lh-pill--danger  { color: #f4b9b1; border-color: #4a2a26; background: rgba(226, 92, 77, 0.10); }
.lh-pill--accent  { color: #cadcff; border-color: #2a3e6e; background: var(--accent-soft); }

.lh-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
}
.lh-dot--ok     { background: var(--ok); }
.lh-dot--warn   { background: var(--warn); }
.lh-dot--danger { background: var(--danger); }
.lh-dot--info   { background: var(--info); }
.lh-dot--accent { background: var(--accent); }

/* ───────── status strip ───────── */

.lh-status {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.lh-status > div {
  padding: 14px 18px;
  border-right: 1px solid var(--line);
}
.lh-status > div:last-child { border-right: 0; }
.lh-status .k { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.6px; }
.lh-status .v { font-size: 15px; margin-top: 4px; font-weight: 500; }

/* ───────── buttons ───────── */

.lh-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.lh-btn {
  display: inline-block;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  line-height: 1.3;
  border: 1px solid var(--line-2);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}
.lh-btn:hover {
  background: var(--panel-2);
  border-color: var(--line-2);
  color: var(--text);
}
.lh-btn--accent {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #ffffff;
  border-color: var(--accent-strong);
  box-shadow: 0 1px 0 rgba(255,255,255,0.10) inset, 0 4px 10px rgba(47,124,255,0.30);
}
.lh-btn--accent:hover {
  background: linear-gradient(180deg, var(--accent-2) 0%, var(--accent) 100%);
  border-color: var(--accent);
  color: #ffffff;
}
.lh-btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text-mute);
}
.lh-btn--ghost:hover {
  background: var(--panel-2);
  border-color: var(--line-2);
  color: var(--text);
}
.lh-btn--danger {
  color: #f4b9b1;
  border-color: #4a2a26;
  background: transparent;
}
.lh-btn--danger:hover {
  background: rgba(226, 92, 77, 0.10);
  border-color: #5c322c;
  color: #ffd9d2;
}

/* ───────── sections / grids ───────── */

.lh-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 18px 18px 18px;
}
.lh-section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}
.lh-section-title {
  font-size: 13px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-mute);
  font-weight: 600;
}
.lh-section-meta { font-size: 12px; color: var(--text-dim); }

.lh-grid { display: grid; gap: 14px; }
.lh-grid--kpi { grid-template-columns: repeat(4, 1fr); }
.lh-grid--two { grid-template-columns: repeat(2, 1fr); }
.lh-grid--three { grid-template-columns: repeat(3, 1fr); }
.lh-grid--four { grid-template-columns: repeat(4, 1fr); }
.lh-grid--six { grid-template-columns: repeat(6, 1fr); }
.lh-grid--seven { grid-template-columns: repeat(7, 1fr); }

@media (max-width: 1280px) {
  .lh-grid--six { grid-template-columns: repeat(3, 1fr); }
  .lh-grid--seven { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 980px) {
  .lh-app { grid-template-columns: 1fr; }
  /* Sidebar drawer rules are defined further below — do NOT redefine
     position here, or the v0.0.086 fixed/translate drawer breaks. */
  .lh-grid--kpi { grid-template-columns: repeat(2, 1fr); }
  .lh-grid--two { grid-template-columns: 1fr; }
  .lh-grid--three { grid-template-columns: 1fr; }
  .lh-grid--four { grid-template-columns: repeat(2, 1fr); }
  .lh-grid--six { grid-template-columns: repeat(2, 1fr); }
  .lh-grid--seven { grid-template-columns: repeat(2, 1fr); }
}

/* ───────── KPI cards ───────── */

.lh-kpi {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 120ms ease, background 120ms ease;
}
.lh-kpi:hover { border-color: var(--line-2); background: var(--panel-2); }
.lh-kpi-label { font-size: 12px; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.5px; }
.lh-kpi-value { font-size: 24px; font-weight: 600; letter-spacing: 0.1px; color: var(--text); }
.lh-kpi-hint { font-size: 12px; color: var(--text-dim); }

/* ───────── funnel ───────── */

.lh-funnel { display: flex; flex-direction: column; gap: 10px; }
.lh-funnel-row {
  display: grid;
  grid-template-columns: 150px 1fr 60px;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.lh-funnel-bar {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
  position: relative;
}
.lh-funnel-fill {
  background: linear-gradient(90deg, var(--accent) 0%, var(--cyan) 100%);
  height: 100%;
  min-width: 2px;
  border-radius: 999px;
}
.lh-funnel-row .lh-funnel-val { text-align: right; color: var(--text-mute); font-variant-numeric: tabular-nums; }

/* ───────── mode cards ───────── */

.lh-mode {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 150px;
  transition: border-color 120ms ease, background 120ms ease;
}
.lh-mode:hover { border-color: var(--line-2); background: var(--panel-2); }
.lh-mode-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.lh-mode-title { font-weight: 600; font-size: 14px; color: var(--text); }
.lh-mode-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 2px;
}
.lh-mode-stat {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  background: var(--panel);
}
.lh-mode-stat .k { color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
.lh-mode-stat .v { font-size: 14px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.lh-mode-goal { font-size: 13px; color: var(--text-mute); }
.lh-mode-progress { font-size: 12px; color: var(--text-dim); }

/* ───────── infection levels ───────── */

.lh-infect-cell {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lh-infect-cell .k { font-size: 12px; color: var(--text-mute); }
.lh-infect-cell .v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.lh-infect-cell.lvl-0 { border-left: 3px solid #364263; }
.lh-infect-cell.lvl-1 { border-left: 3px solid var(--accent); }
.lh-infect-cell.lvl-2 { border-left: 3px solid var(--cyan); }
.lh-infect-cell.lvl-3 { border-left: 3px solid var(--ok); }
.lh-infect-cell.lvl-4 { border-left: 3px solid var(--warn); }
.lh-infect-cell.lvl-5 { border-left: 3px solid var(--danger); }

/* ───────── tables ───────── */

.lh-table-wrap { overflow-x: auto; border-radius: var(--r-sm); }
.lh-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.5;
}
.lh-table th, .lh-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.lh-table th {
  font-size: 12px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  background: #0f1730;
  border-bottom: 1px solid var(--line-2);
  position: sticky;
  top: 0;
  z-index: 1;
}
.lh-table tbody tr { transition: background 100ms ease; }
.lh-table tbody tr:hover { background: var(--panel-2); }
.lh-table tbody tr:last-child td { border-bottom: 0; }
.lh-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.lh-table .lh-table-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 28px 14px;
  font-size: 14px;
}
.lh-table a { color: var(--accent-2); }
.lh-table a:hover { color: var(--cyan); }

/* ───────── filters ───────── */

.lh-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.lh-filters input[type="text"],
.lh-filters select {
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 7px 12px;
  font-size: 14px;
  min-height: 34px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.lh-filters input[type="text"] { min-width: 240px; }
.lh-filters input[type="text"]:focus,
.lh-filters select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.lh-filters input[type="text"]::placeholder { color: var(--text-dim); }

/* ───────── feeds / lists ───────── */

.lh-feed { display: flex; flex-direction: column; }
.lh-feed-item {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
}
.lh-feed-item:last-child { border-bottom: 0; }
.lh-feed-time { color: var(--text-dim); font-size: 12px; padding-top: 2px; }
.lh-feed-body strong { font-weight: 600; }
.lh-feed-kind { color: var(--text-mute); font-size: 12px; }

/* ───────── integrations ───────── */

.lh-int-card {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 120ms ease, background 120ms ease;
}
.lh-int-card:hover { border-color: var(--line-2); background: var(--panel-2); }
.lh-int-card .k { font-size: 14px; font-weight: 600; color: var(--text); }
.lh-int-card .v { font-size: 13px; color: var(--text-mute); }

/* ───────── focus block ───────── */

.lh-focus { display: flex; flex-direction: column; gap: 14px; }
.lh-focus-row .k { font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-mute); margin-bottom: 6px; }
.lh-focus-row .v { font-size: 14px; }
.lh-focus-list { padding-left: 20px; margin: 0; }
.lh-focus-list li { padding: 3px 0; }

/* ───────── lead detail ───────── */

.lh-lead-head {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}
.lh-lead-head h2 { margin: 0 0 4px 0; font-size: 19px; font-weight: 600; color: var(--text); }
.lh-lead-head .lh-lead-sub { color: var(--text-mute); font-size: 13px; }
.lh-lead-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.lh-kv {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 8px 16px;
  font-size: 14px;
  line-height: 1.6;
}
.lh-kv .k { color: var(--text-mute); font-size: 13px; }
.lh-kv .v { word-break: break-word; }

/* ───────── empty state ───────── */

.lh-empty {
  background: var(--bg-3);
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
  padding: 28px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.55;
}

/* ───────── utilities ───────── */
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.nowrap { white-space: nowrap; }

/* Scrollbars — calm navy */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 999px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: #2c3d5f; }

/* ───────── v0.0.033 — dark forms + mobile polish ───────── */

/* Native form controls — make every input/select/textarea match dark theme */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
select,
textarea {
  width: 100%;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  min-height: 38px;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

textarea {
  min-height: 88px;
  resize: vertical;
  line-height: 1.5;
  padding: 10px 12px;
}

select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-mute) 50%),
    linear-gradient(135deg, var(--text-mute) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 17px,
    calc(100% - 13px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
  cursor: pointer;
}

input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="number"]:hover,
input[type="tel"]:hover,
input[type="url"]:hover,
input[type="search"]:hover,
select:hover,
textarea:hover {
  border-color: var(--line-2);
  background: var(--panel);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="time"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input::placeholder,
textarea::placeholder { color: var(--text-dim); }

input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--panel);
  color: var(--text-mute);
}

/* Kill the bright Chrome/Safari yellow autofill */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--bg-3) inset;
  caret-color: var(--text);
  transition: background-color 5000s ease-in-out 0s;
}

/* Calendar / dropdown indicator color (dark UAs only) */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(0.8) brightness(0.8);
  cursor: pointer;
}

/* Checkboxes / radios */
input[type="checkbox"],
input[type="radio"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0 6px 0 0;
  border: 1px solid var(--line-2);
  background: var(--bg-3);
  vertical-align: middle;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
  position: relative;
  flex: 0 0 18px;
}
input[type="checkbox"] { border-radius: 4px; }
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]:hover,
input[type="radio"]:hover { border-color: var(--accent); }
input[type="checkbox"]:focus,
input[type="radio"]:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="checkbox"]:checked,
input[type="radio"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 5px;
  width: 5px;
  height: 10px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
input[type="radio"]:checked::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #ffffff;
}

/* Native button reset (fall back when .lh-btn isn't on the element) */
button,
input[type="submit"],
input[type="reset"],
input[type="button"] {
  font: inherit;
  cursor: pointer;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 8px 16px;
  min-height: 38px;
  font-size: 14px;
  line-height: 1.3;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}
button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
input[type="reset"]:hover {
  background: var(--panel-2);
  border-color: var(--line-2);
}
button:disabled { opacity: 0.55; cursor: not-allowed; }

/* ───────── form layout ───────── */

.lh-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 720px;
}
.lh-form > label,
.lh-form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-mute);
  letter-spacing: 0.2px;
}
.lh-form > label > input,
.lh-form > label > select,
.lh-form > label > textarea,
.lh-form-field > input,
.lh-form-field > select,
.lh-form-field > textarea {
  margin-top: 2px;
  color: var(--text);
}
.lh-form > label:has(> input[type="checkbox"]) {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 14px;
}
.lh-form-help, .lh-help {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.45;
}
.lh-form-error, .field-error {
  font-size: 12px;
  color: #f4b9b1;
  line-height: 1.45;
}

.lh-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
}
.lh-form-grid--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.lh-form-grid--full > label,
.lh-form-grid > .lh-form-field--full,
.lh-form-grid > label.lh-form-field--full {
  grid-column: 1 / -1;
}

.lh-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding-top: 6px;
}
.lh-form-actions--right { justify-content: flex-end; }

.lh-form-card {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Cards & lists used by v0.0.032 templates */
.lh-card {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.55;
}
.lh-card b { color: var(--text); font-weight: 600; }
.lh-card + .lh-card { margin-top: 12px; }

.lh-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.lh-list > li {
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
  line-height: 1.5;
}
.lh-list > li:last-child { border-bottom: 0; }

/* Button alias used by v0.0.032 templates: .lh-btn-primary */
.lh-btn-primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #ffffff;
  border-color: var(--accent-strong);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.10) inset, 0 4px 10px rgba(47, 124, 255, 0.30);
}
.lh-btn-primary:hover {
  background: linear-gradient(180deg, var(--accent-2) 0%, var(--accent) 100%);
  border-color: var(--accent);
  color: #ffffff;
}
.lh-btn--small,
.lh-btn-small {
  padding: 4px 10px;
  font-size: 12px;
  min-height: 28px;
}
.lh-btn--block,
.lh-btn-block { display: block; width: 100%; text-align: center; }
.lh-btn--muted {
  color: var(--text-mute);
  background: transparent;
  border-color: var(--line);
}
.lh-btn--muted:hover {
  background: var(--panel-2);
  color: var(--text);
}

/* Tables used inside form-heavy pages should scroll on narrow screens */
.lh-table th, .lh-table td {
  vertical-align: middle;
}
.lh-table input,
.lh-table select,
.lh-table textarea {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 13px;
}
.lh-table .lh-btn { padding: 5px 10px; font-size: 12px; min-height: 28px; }
.lh-table .lh-empty {
  background: transparent;
  border: 0;
  padding: 18px 8px;
  text-align: center;
  color: var(--text-dim);
}

/* ───────── staff sidebar — tighter spacing when expanded ───────── */

.lh-nav-staff > summary {
  cursor: pointer;
  list-style: none;
  margin-top: 14px;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  user-select: none;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.lh-nav-staff > summary::-webkit-details-marker { display: none; }
.lh-nav-staff[open] > summary { color: var(--text-mute); }
.lh-nav-staff-items {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.lh-nav-staff-items .lh-nav-link {
  font-size: 12.5px;
  padding: 6px 12px;
  color: var(--text-dim);
}
.lh-nav-staff-items .lh-nav-link:hover { color: var(--text); }
.lh-nav-staff-items .lh-nav-link.is-active { color: #ffffff; }

/* ───────── operator workspace polish ───────── */

.lh-task-card {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lh-task-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.lh-task-card-actions .lh-btn {
  flex: 1 1 140px;
  text-align: center;
  padding: 10px 14px;
  min-height: 40px;
}


/* ============================================================
   v0.0.088 — mobile operator shell (consolidated refactor)

   This single section replaces the layered patches from
   v0.0.084-v0.0.087 (burger drawer, mobile-safe utility,
   bot-warning, real-mobile-fix, frontend-design pass).
   Desktop styles above this section are unchanged.

   Layout:
     1. Global guards (overflow, box-sizing, width caps).
     2. Reusable utilities (.lh-mobile-safe).
     3. Class-level definitions (workspace shell, primary
        section, next-task, bot-warning, tasks-list, sidebar,
        chat shell, burger affordances, scoped operator tasks
        table).
     4. Desktop ≥1024 grid (workspace).
     5. ≤980 — burger drawer + topbar + form grids.
     6. ≤768 — chat shell + operator tasks card-mode.
     7. ≤600 — phone typography + safe-area + dropdowns.
     8. motion-reduced.
   ============================================================ */

/* ── 1. Global guards ─────────────────────────────────────── */

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
*, *::before, *::after { box-sizing: border-box; }

.lh-app, .lh-main, .lh-content,
.lh-section, .lh-card, .lh-form,
.lh-operator-workspace, .lh-operator-main, .lh-operator-sidebar,
.lh-next-task-compact, .lh-tasks-list,
.lh-chat-shell, .lh-chat-messages,
.lh-operator-tasks-table {
  min-width: 0;
  max-width: 100%;
}

/* ── 2. Utilities ─────────────────────────────────────────── */

.lh-mobile-safe {
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

/* ── 3a. Operator workspace shell ─────────────────────────── */

.lh-operator-workspace {
  display: flex; flex-direction: column;
  gap: 12px; margin-bottom: 14px;
}
.lh-operator-main,
.lh-operator-sidebar {
  display: flex; flex-direction: column;
  gap: 12px; min-width: 0;
}
.lh-operator-main > section,
.lh-operator-sidebar > section { margin: 0; }
.lh-operator-workspace .lh-section-head { margin-bottom: 8px; }

.lh-section--primary {
  position: relative;
  border-left: 3px solid var(--accent);
  background: linear-gradient(180deg, rgba(47,124,255,0.04), transparent 80px);
}
.lh-section--primary > .lh-section-head .lh-section-title {
  color: var(--text); font-weight: 600;
}

/* ── 3b. Next-task compact card ───────────────────────────── */

.lh-next-task-compact .lh-card { padding: 10px 12px; }
.lh-next-task-compact .lh-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
}
.lh-next-task-compact .lh-row + .lh-row { margin-top: 6px; }
.lh-next-task-compact .lh-pill { font-size: 12px; }
.lh-next-task-compact .lh-bio {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-mute);
  font-size: 13px;
  margin-top: 4px;
  overflow-wrap: anywhere; word-break: break-word;
}
.lh-next-task-compact details summary {
  cursor: pointer; color: var(--text-mute);
  font-size: 13px; padding: 4px 0; list-style: none;
}
.lh-next-task-compact details summary::-webkit-details-marker { display: none; }
.lh-next-task-compact details summary::before {
  content: "▸"; display: inline-block; width: 1em; transition: transform 0.15s;
}
.lh-next-task-compact details[open] summary::before { transform: rotate(90deg); }
.lh-next-task-compact .lh-analysis-grid {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}
.lh-next-task-compact .lh-draft { margin-top: 8px; }
.lh-next-task-compact .lh-draft pre {
  white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 10px 12px; margin: 6px 0 0;
  font-family: inherit; font-size: 13px; line-height: 1.5;
  max-height: 220px; overflow: auto;
  max-width: 100%;
}
.lh-next-task-compact .lh-task-actions {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px;
}
.lh-next-task-compact .lh-task-actions > * { min-height: 44px; }
.lh-next-task-compact .lh-task-actions .lh-btn { min-height: 44px; padding: 8px 14px; }
.lh-next-task-compact .lh-task-actions form { margin: 0; }

/* ── 3c. Bot warning (block, not pill) ───────────────────── */

.lh-bot-warning {
  display: block; width: 100%; max-width: 100%;
  white-space: normal; overflow-wrap: anywhere; word-break: break-word;
  box-sizing: border-box;
  padding: 8px 10px; border-radius: 8px;
  font-size: 14px; line-height: 1.4;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
}
.lh-bot-warning--ok {
  color: #b6efd1; border-color: #1f4438; background: rgba(52,211,153,0.10);
}
.lh-bot-warning--warn {
  color: #f1dca5; border-color: #3f3823; background: rgba(240,198,116,0.10);
}

/* ── 3d. My tasks compact list (workspace) ───────────────── */

.lh-tasks-list { padding: 4px 10px; font-size: 13px; line-height: 1.45; }
.lh-tasks-list .lh-tasks-row {
  display: flex; justify-content: space-between; gap: 8px;
  flex-wrap: wrap; padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.lh-tasks-list .lh-tasks-row:last-child { border-bottom: none; }
.lh-tasks-list a {
  color: inherit; text-decoration: none; display: block;
  overflow-wrap: anywhere; word-break: break-word;
}
.lh-tasks-list .mono { overflow-wrap: anywhere; word-break: break-word; }
.lh-tasks-list .lh-pill { font-size: 11px; }

/* ── 3e. Sidebar widgets (Текущая смена / Боты / Заряд) ── */

.lh-operator-sidebar .lh-section-head { margin-bottom: 6px; }
.lh-operator-sidebar .lh-section-title {
  font-size: 12px; letter-spacing: 0.4px;
  text-transform: uppercase; color: var(--text-mute);
}
.lh-operator-sidebar .lh-card {
  padding: 8px 10px; font-size: 13px; line-height: 1.45;
}
.lh-stat-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.lh-stat-chips .lh-pill { font-size: 11px; }

/* ── 3f. Operator chat shell (messenger-like) ───────────── */

.lh-chat-shell {
  display: flex; flex-direction: column; min-height: 0;
  border-radius: var(--r-sm); overflow: hidden;
  background: var(--panel); border: 1px solid var(--line);
}
.lh-chat-messages {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--panel);
}
.lh-chat-bubble {
  max-width: 82%; padding: 8px 12px; border-radius: 12px;
  line-height: 1.5; word-wrap: break-word; overflow-wrap: anywhere;
}
.lh-chat-bubble--mine {
  align-self: flex-end; background: var(--accent-soft); border: 1px solid #2a3e6e;
}
.lh-chat-bubble--theirs {
  align-self: flex-start; background: rgba(255,255,255,0.04); border: 1px solid var(--line);
}
.lh-chat-bubble img { max-width: 100%; height: auto; }
.lh-chat-composer {
  position: sticky; bottom: 0;
  display: flex; gap: 8px;
  padding: 10px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--panel);
  align-items: flex-end; flex-wrap: wrap;
}
.lh-chat-composer textarea {
  flex: 1 1 240px; min-width: 0; resize: vertical;
  padding: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  color: var(--text); font-family: inherit;
  font-size: 16px; /* prevents iOS Safari focus auto-zoom */
}
.lh-chat-composer .lh-btn { min-height: 44px; }
.lh-chat-section { display: flex; flex-direction: column; min-height: 0; }

/* ── 3g. Burger drawer affordances (base) ───────────────── */

.lh-mobile-menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--line); color: var(--text); border-radius: 6px;
  font-size: 18px; line-height: 1; padding: 6px 10px; cursor: pointer;
  margin-right: 8px;
}
.lh-mobile-menu-toggle:hover { background: rgba(255,255,255,0.04); }
.lh-mobile-menu-overlay[hidden] { display: none; }
.lh-mobile-menu-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55); z-index: 1190;
}
.lh-mobile-menu-close { display: none; }

/* ── 3h. Operator tasks list scope ─────────────────────── */

.lh-operator-tasks-table { width: 100%; }

/* ── 4. Desktop ≥1024 — workspace 2-column grid ────────── */

@media (min-width: 1024px) {
  .lh-operator-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 14px;
    align-items: start;
  }
  .lh-operator-sidebar {
    position: sticky; top: 12px;
    gap: 10px;
  }
}

@media (min-width: 768px) {
  .lh-chat-messages { max-height: 60vh; min-height: 320px; }
}

/* ── 5. ≤980 — burger drawer + topbar collapse ─────────── */

@media (max-width: 980px) {
  .lh-app { grid-template-columns: 1fr; }

  .lh-mobile-menu-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--panel-2, var(--panel));
    border-color: var(--accent);
    color: var(--text);
    font-weight: 600;
    min-height: 40px; min-width: 44px;
  }
  .lh-mobile-menu-toggle:hover { background: var(--accent-soft); }

  /* Drawer */
  .lh-side {
    position: fixed !important;
    top: 0; left: 0; bottom: 0;
    height: 100vh !important; height: 100dvh !important;
    max-height: none !important;
    width: min(86vw, 320px);
    z-index: 1200;
    transform: translateX(-105%);
    transition: transform 220ms ease;
    box-shadow: 0 12px 32px rgba(0,0,0,0.4);
    overflow-y: auto;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    background: var(--bg-2);
    padding-top: env(safe-area-inset-top, 0px);
  }
  .lh-side.is-open { transform: translateX(0) !important; }

  .lh-mobile-menu-close {
    display: inline-flex; align-items: center; justify-content: center;
    margin-left: auto;
    background: transparent;
    border: 1px solid var(--line); color: var(--text);
    border-radius: 6px;
    font-size: 18px; line-height: 1; padding: 4px 10px;
    cursor: pointer;
  }

  .lh-side .lh-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
  }
  .lh-side .lh-nav {
    flex-direction: column; flex-wrap: nowrap;
    overflow-x: visible;
    padding: 12px; gap: 4px;
  }
  .lh-side .lh-nav-link {
    padding: 12px 14px; font-size: 15px; line-height: 1.4;
    border-radius: 8px;
    white-space: normal; min-height: 40px;
  }
  .lh-side .lh-nav-link.is-active {
    background: var(--accent-soft); color: #fff;
    border: 1px solid #2a3e6e;
  }
  .lh-side .lh-nav-staff { width: 100%; }
  .lh-side .lh-nav-staff > summary {
    margin-top: 4px; padding-top: 8px; font-size: 11px;
  }
  .lh-side .lh-nav-staff-items {
    flex-direction: column; flex-wrap: nowrap; gap: 4px;
  }
  .lh-side .lh-nav-staff-items .lh-nav-link {
    font-size: 13px; padding: 8px 12px;
  }
  .lh-side .lh-side-foot {
    display: block; font-size: 12px; color: var(--text-mute);
  }

  body.lh-mobile-menu-open { overflow: hidden; }

  /* Topbar collapses to two clean rows: title row + chip row. */
  .lh-topbar {
    flex-direction: column; align-items: flex-start;
    gap: 10px; padding: 14px 16px 12px 16px;
    min-width: 0; max-width: 100%;
  }
  .lh-topbar-left {
    display: flex; align-items: center; flex-wrap: wrap;
    gap: 8px; min-width: 0; max-width: 100%;
  }
  .lh-topbar-right {
    width: 100%; min-width: 0; max-width: 100%;
    justify-content: flex-start; gap: 6px;
    flex-wrap: wrap; row-gap: 6px;
  }
  .lh-user {
    display: flex; flex-wrap: wrap;
    min-width: 0; max-width: 100%;
    gap: 6px; align-items: center;
  }
  .lh-user-name {
    max-width: 140px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }

  .lh-content { padding: 14px 16px 32px 16px; gap: 14px; }

  .lh-form-grid { grid-template-columns: 1fr; }
  .lh-form-grid--three { grid-template-columns: 1fr; }
}

/* ── 6. ≤768 — chat shell pinned + operator tasks cards ── */

@media (max-width: 768px) {
  .lh-chat-shell {
    height: calc(100vh - 180px);
    height: calc(100dvh - 180px);
    min-height: 360px;
  }
  .lh-chat-messages { padding: 10px; }
  .lh-chat-composer { padding: 8px 8px max(10px, env(safe-area-inset-bottom)) 8px; }
  .lh-chat-bubble { max-width: 88%; }

  /* Non-operator tables: fall back to horizontal scroll inside the
     wrapper so the page itself never overflows. The operator-tasks
     table opts out via its scoped class rule below. */
  .lh-section .lh-table:not(.lh-operator-tasks-table),
  .lh-form-card .lh-table:not(.lh-operator-tasks-table) {
    display: block; overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  .lh-section .lh-table:not(.lh-operator-tasks-table) thead,
  .lh-section .lh-table:not(.lh-operator-tasks-table) tbody,
  .lh-section .lh-table:not(.lh-operator-tasks-table) tr {
    display: table; width: 100%; table-layout: auto;
  }

  /* Operator tasks list: scoped mobile-card conversion. */
  .lh-operator-tasks-table,
  .lh-operator-tasks-table thead,
  .lh-operator-tasks-table tbody,
  .lh-operator-tasks-table tr,
  .lh-operator-tasks-table td,
  .lh-operator-tasks-table th {
    display: block !important;
    width: auto !important;
    max-width: 100%;
    white-space: normal;
  }
  .lh-operator-tasks-table thead { display: none !important; }
  .lh-operator-tasks-table tbody tr {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px; margin: 0 0 10px 0;
    display: grid !important;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "type    due"
      "patient patient"
      "bot     bot"
      "open    open";
    gap: 6px 8px; align-items: center;
  }
  .lh-operator-tasks-table tbody tr:hover { background: var(--panel); }
  .lh-operator-tasks-table td {
    border: none !important; padding: 0 !important;
    overflow-wrap: anywhere;
  }
  .lh-operator-tasks-table td:nth-of-type(1) {
    grid-area: type; color: var(--text-mute); font-size: 12px;
  }
  .lh-operator-tasks-table td:nth-of-type(1) .mono { font-size: 11px; }
  .lh-operator-tasks-table td:nth-of-type(2) {
    grid-area: patient; font-size: 16px; font-weight: 500;
  }
  .lh-operator-tasks-table td:nth-of-type(3) {
    grid-area: type; justify-self: start;
  }
  .lh-operator-tasks-table td:nth-of-type(4) {
    grid-area: due; color: var(--text-mute); font-size: 13px;
    text-align: right; justify-self: end;
  }
  .lh-operator-tasks-table td:nth-of-type(4)::before {
    content: "срок: "; opacity: 0.7;
  }
  .lh-operator-tasks-table td:nth-of-type(5) {
    grid-area: bot; color: var(--text-mute); font-size: 13px;
  }
  .lh-operator-tasks-table td:nth-of-type(5)::before {
    content: "бот: "; opacity: 0.7;
  }
  .lh-operator-tasks-table td:nth-of-type(6) { grid-area: open; }
  .lh-operator-tasks-table td:nth-of-type(6) .lh-btn {
    display: block; width: 100%; text-align: center;
    min-height: 44px; line-height: 1.2; padding: 10px 14px;
  }

  /* Old broad mobile-table conversion (v0.0.084 fallback) is
     intentionally not redefined here — non-operator tables fall
     through to the v0.0.033 .lh-section .lh-table rule above
     which gives them an inner horizontal scroll, not a body
     overflow. */
}

/* ── 7. ≤600 — phone typography, safe area, dropdowns ──── */

@media (max-width: 600px) {
  body { font-size: 15px; }

  .lh-page-title { font-size: 17px; }
  .lh-section-title { font-size: 14px; letter-spacing: 0.2px; }
  .lh-section { padding: 14px 14px 16px 14px; }
  .lh-section-head { flex-wrap: wrap; gap: 8px; }

  .lh-form { gap: 12px; max-width: 100%; }
  .lh-btn { padding: 10px 14px; min-height: 46px; }
  .lh-btn--small { min-height: 36px; }
  .lh-form-actions .lh-btn { flex: 1 1 calc(50% - 5px); text-align: center; }
  .lh-mobile-menu-toggle, .lh-mobile-menu-close { min-height: 46px; }

  .lh-next-task-compact .lh-card { padding: 12px 14px; }
  .lh-next-task-compact .lh-row b { font-size: 17px; }
  .lh-next-task-compact .lh-pill { font-size: 13px; }
  .lh-next-task-compact .lh-bio { font-size: 14px; line-height: 1.4; }
  .lh-next-task-compact .lh-draft pre { font-size: 15px; line-height: 1.55; }

  .lh-tasks-list { font-size: 14px; }
  .lh-tasks-list .lh-pill { font-size: 12px; }

  .lh-stat-chips .lh-pill { font-size: 12px; }
  .lh-chat-section { padding-bottom: 0; }

  .lh-operator-workspace,
  .lh-mobile-safe {
    padding-bottom: max(96px, calc(32px + env(safe-area-inset-bottom)));
  }

  .lh-next-task-compact .lh-task-actions {
    flex-direction: column; align-items: stretch;
  }
  .lh-next-task-compact .lh-task-actions > *,
  .lh-next-task-compact .lh-task-actions form,
  .lh-next-task-compact .lh-task-actions form .lh-btn { width: 100%; }

  .lh-user-name { max-width: 110px; font-size: 13px; }

  /* Notification bell dropdown: anchored inside viewport. */
  [data-notif-bell-dropdown] {
    position: fixed !important;
    top: calc(env(safe-area-inset-top, 0px) + 56px) !important;
    right: 12px !important; left: 12px !important;
    width: calc(100vw - 24px) !important;
    min-width: 0 !important; max-width: none !important;
    max-height: 60vh !important;
  }
  [data-lh-toast], [data-chat-toast] {
    top: calc(env(safe-area-inset-top, 0px) + 12px) !important;
    right: 8px !important; left: 8px !important;
    max-width: none !important;
  }

  .lh-content { padding: 12px 12px 24px 12px; gap: 12px; }
}

/* ── 8. motion-reduced ─────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ============================================================
   v0.0.107 — operator mobile final cleanup

   The v0.0.088 block above already consolidates the mobile shell.
   This final section is the *single* place that owns mobile
   guards going forward — no more layered patches. It strengthens
   the rules that production-tested as fragile:
     a. html/body horizontal overflow on iPhone Safari.
     b. drawer reliability (visible nav, real overlay, real close,
        100dvh height, safe-area top padding).
     c. long-text overflow: usernames, links, draft messages,
        bot warnings.
     d. operator workspace next-task readability.
     e. operator tasks: scoped card-mode (the broad
        `.lh-section .lh-table` rule does NOT touch
        `.lh-operator-tasks-table` so we never get stripe-mode
        regressions on the operator list).
     f. chat composer sticky + iPhone-zoom-prevention.
     g. topbar two-row collapse without horizontal scroll.
     h. notification dropdown anchored inside viewport.
   ============================================================ */

/* a. Hard global guards — repeated for specificity. */
html, body {
  overflow-x: hidden !important;
  max-width: 100% !important;
}
.lh-app, .lh-main, .lh-content {
  min-width: 0;
  max-width: 100%;
}

/* b. Drawer reliability (≤980). The v0.0.088 block already lays
   out width/transform; here we lock the always-visible affordances
   inside the drawer so an empty/blank drawer is impossible. */
@media (max-width: 980px) {
  .lh-side[data-mobile-menu] {
    display: flex !important;
    flex-direction: column;
    height: 100vh !important; height: 100dvh !important;
    padding-top: max(env(safe-area-inset-top, 0px), 0px);
  }
  .lh-side[data-mobile-menu] .lh-brand,
  .lh-side[data-mobile-menu] .lh-nav { display: flex !important; }
  .lh-side[data-mobile-menu] .lh-side-foot { display: block !important; }
  .lh-mobile-menu-overlay { z-index: 1190; }
  .lh-side[data-mobile-menu] { z-index: 1200; }

  /* Burger button is always visible on mobile, with a real touch
     target. v0.0.107: align with the 46px tap-target standard. */
  .lh-mobile-menu-toggle {
    display: inline-flex !important;
    min-height: 44px; min-width: 44px;
  }
}

/* c. Long-text overflow zones. */
.lh-bot-warning,
.lh-next-task-compact .lh-bio,
.lh-next-task-compact .lh-draft pre,
.lh-tasks-list a, .lh-tasks-list .mono,
.lh-chat-bubble, .lh-chat-bubble a {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.lh-bot-warning { white-space: normal; }
/* Long usernames / handles inside cards */
.lh-card .mono,
.lh-card a {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* d. Workspace next-task: sharper mobile typography per spec. */
@media (max-width: 600px) {
  .lh-next-task-compact .lh-row b { font-size: 18px; line-height: 1.3; }
  .lh-next-task-compact .lh-row .lh-muted { font-size: 13px; }
  .lh-next-task-compact .lh-draft pre { font-size: 15px; }
  .lh-next-task-compact .lh-bio { font-size: 14px; }
  .lh-next-task-compact .lh-task-actions {
    flex-direction: column; gap: 8px; align-items: stretch;
  }
  .lh-next-task-compact .lh-task-actions > *,
  .lh-next-task-compact .lh-task-actions form,
  .lh-next-task-compact .lh-task-actions form .lh-btn {
    width: 100%;
    min-height: 46px;
  }
  /* Safari toolbar safe space at the very bottom of the workspace. */
  .lh-operator-workspace {
    padding-bottom: max(96px, calc(40px + env(safe-area-inset-bottom)));
  }
}

/* e. Operator tasks: card-mode is scoped to .lh-operator-tasks-table.
   The broad `.lh-section .lh-table:not(.lh-operator-tasks-table)`
   selector in §6 above is intentional — body never overflows. */

/* f. Chat shell: 100dvh-safe height + iPhone safe-area. */
@media (max-width: 768px) {
  .lh-chat-shell {
    height: calc(100vh - 200px);
    height: calc(100dvh - 200px);
  }
  .lh-chat-composer {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .lh-chat-composer textarea {
    font-size: 16px; /* iOS Safari focus-zoom guard */
    min-height: 44px;
  }
  .lh-chat-composer .lh-btn { min-height: 46px; }
}

/* g. Topbar two-row collapse — make sure right-side chips never
   cause horizontal scroll on a 390px viewport. */
@media (max-width: 768px) {
  .lh-topbar {
    flex-direction: column; align-items: stretch;
    gap: 8px; padding: 12px 14px;
    min-width: 0; max-width: 100%;
  }
  .lh-topbar-left, .lh-topbar-right {
    min-width: 0; max-width: 100%;
    flex-wrap: wrap;
  }
  .lh-topbar-right { justify-content: flex-start; }
  .lh-user, .lh-user-name {
    min-width: 0; max-width: 100%;
    overflow: hidden; text-overflow: ellipsis;
  }
}

/* h. Notification dropdown — fixed inside viewport on phone. */
@media (max-width: 600px) {
  [data-notif-bell-dropdown] {
    position: fixed !important;
    top: calc(env(safe-area-inset-top, 0px) + 56px) !important;
    left: 12px !important; right: 12px !important;
    width: calc(100vw - 24px) !important;
    max-width: none !important;
  }

  /* Phone typography baseline — body 15px, primary labels never
     below 13px, tap targets 46px. */
  body { font-size: 15px; }
  .lh-section-title { font-size: 15px; }
  .lh-pill { font-size: 12px; }
  .lh-btn, .lh-btn-primary, .lh-btn--accent {
    min-height: 46px;
  }
  .lh-btn--small { min-height: 36px; }
  .lh-mobile-menu-toggle, .lh-mobile-menu-close {
    min-height: 46px; min-width: 46px;
  }
}

/* ── v0.0.133 — Collapsible operator sidebar ──────────────── */

/* Nav links become icon + label rows so collapse can hide the
   label without breaking layout. */
.lh-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
}
.lh-nav-icon {
  flex: 0 0 22px;
  width: 22px;
  text-align: center;
  font-size: 15px;
  line-height: 1;
  color: var(--text-mute);
}
.lh-nav-link.is-active .lh-nav-icon { color: #ffffff; }
.lh-nav-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lh-nav-staff > summary {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer;
}

/* Desktop collapse toggle button. Hidden on mobile (< 980px),
   where the existing burger drawer takes over. */
.lh-sidebar-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text-mute);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.lh-sidebar-toggle:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--accent);
}
@media (max-width: 980px) {
  .lh-sidebar-toggle { display: none; }
}

/* Collapsed-sidebar layout. Applied to <body class="lh-app">
   when localStorage flag is on. Mobile media query below
   resets the grid so the drawer keeps working there. */
.lh-app.is-sidebar-collapsed {
  grid-template-columns: 68px 1fr;
}
.lh-app.is-sidebar-collapsed .lh-side {
  overflow: hidden;
}
.lh-app.is-sidebar-collapsed .lh-brand {
  padding: 14px 0;
  justify-content: center;
}
.lh-app.is-sidebar-collapsed .lh-brand-name,
.lh-app.is-sidebar-collapsed .lh-brand-version,
.lh-app.is-sidebar-collapsed .lh-side-foot__text,
.lh-app.is-sidebar-collapsed .lh-nav-label {
  display: none;
}
.lh-app.is-sidebar-collapsed .lh-sidebar-toggle {
  /* Keep the toggle reachable but move it under the logo so it
     doesn't share a row in the narrow sidebar. */
  margin: 6px auto 0 auto;
  width: 32px; height: 32px;
}
.lh-app.is-sidebar-collapsed .lh-brand {
  flex-direction: column;
  gap: 4px;
}
.lh-app.is-sidebar-collapsed .lh-nav {
  padding: 10px 6px;
  align-items: stretch;
}
.lh-app.is-sidebar-collapsed .lh-nav-link {
  justify-content: center;
  gap: 0;
  padding: 10px 6px;
}
.lh-app.is-sidebar-collapsed .lh-nav-icon {
  flex: 0 0 auto;
  width: auto;
  font-size: 18px;
}
.lh-app.is-sidebar-collapsed .lh-nav-staff > summary {
  justify-content: center;
}
.lh-app.is-sidebar-collapsed .lh-side-foot {
  padding: 10px 0;
  text-align: center;
}

/* Mobile: collapsed mode reverts to the existing burger drawer
   layout (single-column grid, drawer pinned off-screen). */
@media (max-width: 980px) {
  .lh-app.is-sidebar-collapsed {
    grid-template-columns: 1fr;
  }
  .lh-app.is-sidebar-collapsed .lh-side {
    overflow-y: auto;
  }
  .lh-app.is-sidebar-collapsed .lh-brand-name,
  .lh-app.is-sidebar-collapsed .lh-brand-version,
  .lh-app.is-sidebar-collapsed .lh-side-foot__text,
  .lh-app.is-sidebar-collapsed .lh-nav-label {
    display: revert;
  }
  .lh-app.is-sidebar-collapsed .lh-brand {
    flex-direction: row;
    gap: 10px;
    padding: 12px 14px;
    justify-content: flex-start;
  }
  .lh-app.is-sidebar-collapsed .lh-nav-link {
    justify-content: flex-start;
    gap: 10px;
    padding: 12px 14px;
  }
}

/* ── v0.0.135 — Applications accordion in the operator sidebar ── */
.lh-nav-accordion {
  margin: 4px 0 0 0;
}
.lh-nav-accordion > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.lh-nav-accordion > summary::-webkit-details-marker { display: none; }
.lh-nav-accordion__arrow {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-mute);
  flex: 0 0 auto;
  transition: transform 0.12s;
}
.lh-nav-accordion[open] > summary .lh-nav-accordion__arrow { transform: rotate(0deg); }
.lh-nav-accordion__items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 4px 0 0 10px;
  padding-left: 8px;
  border-left: 1px solid var(--line);
}
.lh-nav-accordion__item {
  font-size: 13px;
  padding: 7px 10px;
}

/* Collapsed sidebar: hide the arrow + sub-list indentation so the
   accordion sits as a single centered icon. The submenu items are
   still in the DOM (and reachable via direct URL) but visually
   collapse along with the rest of the nav labels. */
.lh-app.is-sidebar-collapsed .lh-nav-accordion__arrow { display: none; }
.lh-app.is-sidebar-collapsed .lh-nav-accordion > summary {
  justify-content: center;
  padding: 10px 6px;
}
.lh-app.is-sidebar-collapsed .lh-nav-accordion__items {
  margin: 0;
  padding-left: 0;
  border-left: 0;
  align-items: stretch;
}
.lh-app.is-sidebar-collapsed .lh-nav-accordion__item {
  justify-content: center;
  padding: 9px 6px;
}
