/* Design system: the One Workforce portal's «A · Тунгалаг» (2026-10-19) — IBM Plex, cool blue-grey
   surfaces, blue #245EDB primary; radii 10 (controls), 14 (cards), 999 (pills). The console keeps a
   dark theme the portal does not have, in the same family. */
:root {
  --bg: #F5F7FB;
  --surface: #FFFFFF;
  --surface-2: #F8FAFF;
  --border: #DCE4EF;
  --border-soft: #E9EEF6;
  --border-strong: #B8C8DC;
  --text: #192842;
  --text-2: #465C79;
  --muted: #61728B;
  --primary: #245EDB;
  --primary-hover: #194DBD;
  --primary-weak: #EAF0FF;
  --primary-line: #CFDCF8;
  --primary-disabled: #A9BEE9;
  /* Text on a primary-coloured fill. */
  --on-primary: #FFFFFF;
  --nav-active: #1D4FB8;
  --chip: #E9EEF6;
  --chip-text: #3C526F;
  --hover: #EDF2FA;
  --switch-off: #B8C6D9;
  --avatar: #E3ECFF;
  --avatar-text: #1D4DA8;
  /* Chat bubbles (2026-10-19): each speaker its own fill and edge, readable on the white chat card. */
  --bubble-user: #EEF2F7;
  --bubble-user-line: #D5DEEA;
  --bubble-ai: #E2EBFF;
  --bubble-ai-line: #BCD0FA;
  --bubble-team: #E3F4EA;
  --bubble-team-line: #B5DEC6;
  --green: #087452;
  --green-weak: #E5F5ED;
  --amber: #926005;
  --amber-weak: #FFF3DA;
  --red: #A12B21;
  --red-weak: #FDECEA;
  --code-bg: #15171C;
  --code-text: #E8EAF0;
  --shadow-sm: 0 1px 2px rgb(20 23 28 / 0.12);
  --radius: 14px;
  /* 10px padding top and bottom, 36px controls, 1px border. */
  --topbar-h: 57px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1420;
    --surface: #151D2B;
    --surface-2: #1A2333;
    --border: #2A3850;
    --border-soft: #222E42;
    --border-strong: #3B4D6B;
    --text: #E6EDF7;
    --text-2: #B9C6D9;
    --muted: #8FA0B9;
    --primary: #7DA2FF;
    --primary-hover: #A2BDFF;
    --primary-weak: #1B2A4C;
    --primary-line: #2C4378;
    --primary-disabled: #3A4F80;
    --on-primary: #0B1220;
    --nav-active: #A2BDFF;
    --chip: #222E42;
    --chip-text: #B9C6D9;
    --hover: #1D2840;
    --switch-off: #3B4D6B;
    --avatar: #1B2A4C;
    --avatar-text: #A2BDFF;
    --bubble-user: #1E2838;
    --bubble-user-line: #2E3C52;
    --bubble-ai: #1C2D52;
    --bubble-ai-line: #34508A;
    --bubble-team: #16302A;
    --bubble-team-line: #2A5446;
    --green: #6FD39A;
    --green-weak: #13291F;
    --amber: #F2C26B;
    --amber-weak: #2C2412;
    --red: #FF8A80;
    --red-weak: #321A19;
    --code-bg: #0A0F18;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.35);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0E1420;
  --surface: #151D2B;
  --surface-2: #1A2333;
  --border: #2A3850;
  --border-soft: #222E42;
  --border-strong: #3B4D6B;
  --text: #E6EDF7;
  --text-2: #B9C6D9;
  --muted: #8FA0B9;
  --primary: #7DA2FF;
  --primary-hover: #A2BDFF;
  --primary-weak: #1B2A4C;
  --primary-line: #2C4378;
  --primary-disabled: #3A4F80;
  --on-primary: #0B1220;
  --nav-active: #A2BDFF;
  --chip: #222E42;
  --chip-text: #B9C6D9;
  --hover: #1D2840;
  --switch-off: #3B4D6B;
  --avatar: #1B2A4C;
  --avatar-text: #A2BDFF;
  --bubble-user: #1E2838;
  --bubble-user-line: #2E3C52;
  --bubble-ai: #1C2D52;
  --bubble-ai-line: #34508A;
  --bubble-team: #16302A;
  --bubble-team-line: #2A5446;
  --green: #6FD39A;
  --green-weak: #13291F;
  --amber: #F2C26B;
  --amber-weak: #2C2412;
  --red: #FF8A80;
  --red-weak: #321A19;
  --code-bg: #0A0F18;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
button { font: inherit; }
code, pre, .mono { font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.boot { padding: 48px; color: var(--muted); text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; background: var(--primary); color: var(--on-primary);
  display: grid; place-items: center; font-weight: 700; font-size: 11px;
}
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand-sub { color: var(--muted); font-size: 13px; margin-left: 4px; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.period { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.period button {
  min-height: 36px; padding: 0 12px; border: 0; background: var(--surface); color: var(--text-2); cursor: pointer;
}
.period button + button { border-left: 1px solid var(--border); }
.period button[aria-pressed="true"] { background: var(--primary-weak); color: var(--primary); font-weight: 600; }
/* «Сүүлийн [7 | 30 | 90 хоног]» beside the numbers it changes (page head, the agent's tab row). */
.period-pick { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.tabs-row {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px;
  border-bottom: 1px solid var(--border);
}
.tabs-row .tabs { border-bottom: 0; }
.tabs-row .period-pick { margin-bottom: 6px; }
.avatar {
  width: 36px; height: 36px; border-radius: 999px; background: var(--text); color: var(--surface);
  display: grid; place-items: center; font-weight: 600; font-size: 14px; text-transform: uppercase;
}
.body { display: flex; flex-wrap: wrap; flex: 1 1 auto; }
.side {
  flex: 1 1 220px; padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px;
}
.side-company { padding: 8px 12px 16px; display: flex; flex-direction: column; gap: 2px; }
.side-company strong { font-weight: 600; font-size: 15px; }
.side-company span { font-size: 13px; color: var(--muted); }
.nav-link {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px;
  text-decoration: none; color: var(--text-2); font-size: 15px;
}
.nav-link[aria-current="page"] { background: var(--primary-weak); color: var(--primary); font-weight: 600; }
.link-button {
  border: 0; background: none; padding: 0; color: var(--primary); cursor: pointer; text-align: left; font-size: 14px;
}
.main { flex: 999 1 560px; min-width: 0; padding: 32px; }
.wrap { max-width: 1120px; margin: 0 auto; display: flex; flex-direction: column; gap: 28px; }
/* Inner columns: no auto margins, so they stretch to the column's width. */
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.stack.wide { gap: 24px; }

/* ---------- headings */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-head h1, .agent-head h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.lead { font-size: 15px; color: var(--muted); }
h2 { margin: 0; font-size: 18px; font-weight: 600; }
.section { display: flex; flex-direction: column; gap: 12px; }
.section-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px; }
.section-head .hint { font-size: 14px; color: var(--muted); }
.back { font-size: 14px; text-decoration: none; display: inline-flex; gap: 6px; align-items: center; }

/* ---------- cards */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.card {
  display: flex; flex-direction: column; gap: 16px; padding: 22px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text);
}
a.card:hover { border-color: var(--primary-line); }
.card-top { display: flex; align-items: flex-start; gap: 14px; }
.agent-icon {
  width: 48px; height: 48px; flex: none; border-radius: 14px; display: grid; place-items: center;
  background: var(--primary-weak); color: var(--primary);
}
.agent-icon.green { background: var(--green-weak); color: var(--green); }
.card-title { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.card-title strong { font-weight: 600; font-size: 17px; }
.card-title span { font-size: 13px; color: var(--muted); }
.badge {
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2);
}
.badge.ok { background: var(--green-weak); color: var(--green); }
.badge.warn { background: var(--amber-weak); color: var(--amber); }
.badge.off { background: var(--red-weak); color: var(--red); }
.badge.blue { background: var(--primary-weak); color: var(--primary); }
.note { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); font-size: 14px; color: var(--text-2); }
.note.warn { background: var(--amber-weak); color: var(--amber); }
.note.bad { background: var(--red-weak); color: var(--red); }
.card-foot {
  display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted);
  padding-top: 12px; border-top: 1px solid var(--border-soft);
}

/* ---------- agent page */
.agent-head { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.agent-head .card-title h1 { font-size: 28px; }
/* A page's own title, at the size of a section title (one h1 per page for screen readers). */
.title-h1 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: 0; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); }
.tab {
  min-height: 44px; display: inline-flex; align-items: center; padding: 0 14px; text-decoration: none;
  color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 15px;
}
.tab[aria-current="page"] { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kpi {
  padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.kpi span { font-size: 13px; color: var(--muted); }
.kpi strong { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.panel { padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding-top: 8px; }
.bar { flex: 1 1 0; min-width: 2px; background: var(--primary); border-radius: 3px 3px 0 0; opacity: 0.85; }
.bar.zero { background: var(--border); min-height: 2px; }
.chart-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.rows { display: flex; flex-direction: column; }
.row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 12px 0; border-bottom: 1px solid var(--border-soft);
}
.row:last-child { border-bottom: 0; }
.row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 260px; }
.row-main strong { font-weight: 600; }
.row-main small, .row small { color: var(--muted); font-size: 13px; }
.meter { height: 8px; border-radius: 999px; background: var(--border-soft); overflow: hidden; width: 120px; }
.meter > div { height: 100%; background: var(--primary); border-radius: 999px; }
.count { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 48px; text-align: right; white-space: nowrap; }
.count small, .muted { color: var(--muted); font-weight: 400; font-size: 12px; }

/* ---------- skills and tools */
.group-label { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; color: var(--muted); padding: 12px 0 4px; }
.skill { padding: 14px 0; border-bottom: 1px solid var(--border-soft); display: flex; flex-direction: column; gap: 8px; }
.skill:last-child { border-bottom: 0; }
.skill-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); }
.chip.mono { font-size: 12px; }
.btn {
  min-height: 36px; padding: 0 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  color: var(--text); cursor: pointer; font-size: 14px;
}
.btn:hover { border-color: var(--primary-line); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 600; min-height: 44px; }
.btn.primary:hover { background: var(--primary-hover); }
.btn:disabled { opacity: 0.6; cursor: default; }
.preview { border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.preview-head {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 10px 14px;
  background: var(--surface-2); font-size: 13px; color: var(--muted);
}
.preview pre {
  margin: 0; padding: 14px; background: var(--code-bg); color: var(--code-text); font-size: 12.5px;
  line-height: 1.55; white-space: pre-wrap; word-break: break-word; max-height: 420px; overflow: auto;
}
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow-x: auto; }
table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--muted); background: var(--surface-2); padding: 12px 16px; border-bottom: 1px solid var(--border-soft); }
td { padding: 14px 16px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.modes { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.modes span { padding: 6px 10px; font-size: 13px; color: var(--muted); }
.modes span + span { border-left: 1px solid var(--border); }
.modes span.on { background: var(--primary-weak); color: var(--primary); font-weight: 600; }
.modes span.on.block { background: var(--red-weak); color: var(--red); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 13px; color: var(--muted); }
.rule { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px 16px; padding: 14px 0; border-bottom: 1px solid var(--border-soft); }
.rule:last-child { border-bottom: 0; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }
.rule-edit { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
.rule-edit.new { border-bottom: 0; }
.rule-input {
  width: 100%; min-height: 56px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font: inherit; font-size: 14px; background: var(--surface); color: var(--text); resize: vertical;
}
.rule-input:focus { outline: 2px solid var(--primary-line); border-color: var(--primary); }
.rule-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.switch-label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; margin-right: auto; }

/* ---------- sign in */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
}
.login-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 28px; display: flex; flex-direction: column; gap: 18px;
}
.login-card h1 { margin: 0; font-size: 22px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; font-weight: 500; }
.field input {
  min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; font: inherit;
  background: var(--surface); color: var(--text);
}
.field input:focus { outline: 2px solid var(--primary-line); border-color: var(--primary); }
.error { color: var(--red); font-size: 14px; min-height: 20px; }
.login-card .error:empty { display: none; }
.login-card .notice { margin: 0; color: var(--green); font-size: 14px; }
.login-card .notice:empty { display: none; }

/* conversations */
.filters { display: flex; flex-direction: column; gap: 8px; }
.filter { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.filter-label { font-size: 13px; color: var(--muted); min-width: 64px; }
.filter-chip {
  min-height: 32px; padding: 0 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--text-2); cursor: pointer; font-size: 13px; display: inline-flex; gap: 6px; align-items: center;
}
.filter-chip[aria-pressed="true"] { background: var(--primary-weak); border-color: var(--primary-line); color: var(--primary); font-weight: 600; }
.filter-count { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 400; }
.link-row { text-decoration: none; color: inherit; }
.link-row:hover strong { color: var(--primary); }
.conv-when { min-width: 120px; text-align: right; }
.pager { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.bubble { padding: 10px 14px; border-radius: 12px; max-width: min(760px, 100%); }
.bubble p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble small { font-size: 12px; color: var(--muted); }
.bubble.q { background: var(--surface-2); align-self: flex-start; }
.bubble.a { background: var(--primary-weak); align-self: flex-end; }
.def dt { font-size: 12px; color: var(--muted); }
.def dd { margin: 2px 0 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; font-size: 14px; }
.def dd code { font-size: 12px; color: var(--muted); }

/* tickets */
.ticket-no { color: var(--muted); font-weight: 500; font-size: 13px; }
.ticket-side { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }
.select {
  min-height: 44px; padding: 0 10px; border: 1px solid var(--border); border-radius: 10px; font: inherit;
  background: var(--surface); color: var(--text);
}
.select:focus { outline: 2px solid var(--primary-line); border-color: var(--primary); }
.thread { gap: 8px; }
.thread .bubble { list-style: none; }
.bubble.team-bubble { border: 1px solid var(--primary-line); }
.chip-link { text-decoration: none; color: var(--primary); }
.skill-form { display: flex; flex-direction: column; gap: 10px; }
.rule-input.one-line { min-height: 44px; resize: none; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; }
.skill-text { margin: 0; font-size: 14px; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.ticket-desc { margin: 6px 0 0; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-2); }

/* knowledge */
.link-btn { display: inline-flex; align-items: center; text-decoration: none; }
.btn.primary.link-btn, .btn.primary.link-btn:hover { color: var(--on-primary); }
.search {
  min-height: 36px; width: min(260px, 100%); padding: 0 12px; border: 1px solid var(--border); border-radius: 10px;
  font: inherit; font-size: 14px; background: var(--surface); color: var(--text);
}
.search:focus, .field textarea:focus { outline: 2px solid var(--primary-line); border-color: var(--primary); }
.kb-form .field .muted { font-size: 13px; }
/* An empty message line takes no room (the sign-in card keeps its reserved line). */
.section > .error:empty { display: none; }
.kb-body { min-height: 320px; font-size: 14px; line-height: 1.55; }
.article-body {
  white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.6; padding: 14px 16px;
  background: var(--surface-2); border-radius: 12px; max-height: 70vh; overflow: auto;
}

/* Side by side (the side menu wraps above the page below ~800px): the top bar and the side menu stay
   put while the page scrolls, so the menu and «Гарах» are always in view. */
@media (min-width: 800px) {
  .topbar { position: sticky; top: 0; z-index: 10; height: var(--topbar-h); }
  .side {
    position: sticky; top: var(--topbar-h); align-self: flex-start;
    height: calc(100vh - var(--topbar-h)); overflow-y: auto;
  }
}

@media (max-width: 720px) {
  .conv-when { text-align: left; min-width: 0; }
  /* The switch wraps under the tabs: the line stays under the tabs, the switch below it. */
  .tabs-row { border-bottom: 0; }
  .tabs-row .tabs { flex-basis: 100%; border-bottom: 1px solid var(--border); }
  .tabs-row .period-pick { margin: 0; }
  .ticket-side { justify-content: flex-start; }
  .search { width: 100%; }
  .main { padding: 20px 16px; }
  .side { border-right: 0; border-bottom: 1px solid var(--border); }
  .topbar { padding: 10px 16px; }
  .page-head h1, .agent-head .card-title strong { font-size: 23px; }
}

/* Switches (role=switch): a toggle, not a checkbox (UI audit 2026-10-09). */
input[type="checkbox"][role="switch"] {
  appearance: none; -webkit-appearance: none; width: 36px; height: 20px; border-radius: 999px; margin: 0;
  background: var(--border); position: relative; cursor: pointer; flex: none; transition: background 0.15s;
}
input[type="checkbox"][role="switch"]::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform 0.15s;
}
input[type="checkbox"][role="switch"]:checked { background: var(--primary); }
input[type="checkbox"][role="switch"]:checked::before { transform: translateX(16px); }
input[type="checkbox"][role="switch"]:focus-visible { outline: 2px solid var(--primary-line); outline-offset: 2px; }
input[type="checkbox"][role="switch"]:disabled { opacity: 0.5; cursor: default; }

/* The «saved» notice. */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18); transition: opacity 0.2s, transform 0.2s; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--red); color: #fff; }

/* Phones: the side menu is a compact row above the page, not a 330px block (UI audit 2026-10-09).
   779px: below 220 + 560 the menu no longer fits beside the page and wraps above it. */
@media (max-width: 779px) {
  .side { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--border); }
  .side-company { display: none; }
  .nav-link { min-height: 40px; padding: 0 10px; gap: 8px; font-size: 14px; }
}
/* Narrow phones: text-only menu links, so the menu stays one row. */
@media (max-width: 459px) {
  .nav-link svg { display: none; }
  .nav-link { padding: 0 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .toast, input[type="checkbox"][role="switch"], input[type="checkbox"][role="switch"]::before { transition: none; }
}

/* One conversation (UI audit 2026-10-09): the chat, and the decision in a side panel. */
.conv-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
.chat { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.chat .msg { display: flex; flex-direction: column; gap: 6px; }
.chat .msg.user { align-items: flex-start; }
.chat .msg.agent, .chat .msg.team { align-items: flex-end; }
.chat .msg.selected .bubble { box-shadow: 0 0 0 2px var(--primary); }
.msg-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; justify-content: flex-end; font-size: 13px; max-width: min(760px, 100%); }
.msg-meta .link-button { font-size: 13px; }
.decision-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.decision-panel.empty { color: var(--muted); }
.dp-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.dp-head h3 { margin: 0; font-size: 16px; }
.dp-head h3:focus { outline: none; }
.dp-facts { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.dp-part h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: none; }
.dp-part p { margin: 2px 0; font-size: 14px; overflow-wrap: anywhere; }
.dp-quote { color: var(--text-2); }
.dp-sources { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.dp-sources li { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; font-size: 14px; }
.dp-sources li > :first-child { flex: 1 1 160px; }
.dp-tech { border-top: 1px solid var(--border-soft); padding-top: 8px; font-size: 13px; }
.dp-tech summary { cursor: pointer; color: var(--muted); }
.dp-tech dl { margin: 8px 0 0; display: flex; flex-direction: column; gap: 4px; }
.dp-tech dl > div { display: flex; gap: 8px; flex-wrap: wrap; }
.dp-tech dt { color: var(--muted); min-width: 110px; }
.dp-tech dd { margin: 0; overflow-wrap: anywhere; }
.dp-backdrop { display: none; }
@media (min-width: 1280px) {
  .conv-layout { grid-template-columns: minmax(0, 1fr) 360px; }
  .decision-panel { position: sticky; top: calc(var(--topbar-h) + 16px); max-height: calc(100vh - var(--topbar-h) - 32px); overflow: auto; }
  .dp-close { display: none; }
}
@media (max-width: 1279px) {
  /* A drawer over the page: opened from a reply's «Дэлгэрэнгүй», closed by ✕, the backdrop or Esc. */
  .decision-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100%); z-index: 41; border-radius: 0;
    overflow: auto; transform: translateX(100%); transition: transform 0.2s; visibility: hidden; }
  .decision-panel.open { transform: none; visibility: visible; }
  .dp-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 40; }
}
@media (prefers-reduced-motion: reduce) { .decision-panel { transition: none; } }
table.tools { min-width: 0; }

/* Workforce parity (2026-10-19, docs/specs/console-workforce-parity.md): the agent's tabs carry an
   icon and a count, each tab opens with a title card, sections carry a small label. */
.tab { gap: 8px; }
.tab svg { flex: none; }
.tab-count {
  min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted);
  font-size: 12px; font-weight: 500; text-align: center; font-variant-numeric: tabular-nums;
}
.tab[aria-current="page"] .tab-count { background: var(--primary-weak); color: var(--primary); }
.tab-card { display: flex; align-items: flex-start; gap: 16px; padding: 20px 24px; }
.tab-card h2 { margin: 0; font-size: 18px; font-weight: 600; }
.tab-card p { margin: 4px 0 0; }
.tab-card-icon {
  flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--primary-weak); color: var(--primary);
}
.eyebrow { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; }
.section-title { margin: 2px 0 2px; font-size: 18px; font-weight: 600; }
.search.wide { width: 100%; max-width: none; }
.skill-id { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row-main strong .badge { margin-left: 8px; vertical-align: 2px; }
pre.contract {
  margin: 0; padding: 14px; border-radius: 12px; background: var(--code-bg); color: var(--code-text); font-size: 12.5px;
  line-height: 1.55; white-space: pre-wrap; word-break: break-word; max-height: 420px; overflow: auto;
}
.rule.common { align-items: center; }
.sub-label { display: block; margin-top: 8px; font-weight: 600; }
.layers { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.layer { border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.layer-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; }
table.matrix { min-width: 0; }
table.matrix td.cell, table.matrix thead th.mono { text-align: center; }
table.matrix tbody th { text-align: left; background: none; color: var(--text); font-weight: 400; }
@media (max-width: 720px) {
  .tab-card { padding: 16px; }
  .tab-count { display: none; }
}
pre.contract:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ======================================================================================
   Design system: the One Workforce portal (2026-10-19, "just take the design system, but the
   content stays as the old one"). The look of its parts — values read from the live portal —
   over the console's own pages; no page, section or text changes here. Later rules win.
   ====================================================================================== */

/* Type */
h2 { line-height: 1.55; }
.page-head h1, .agent-head h1 { font-size: 32px; line-height: 1.25; letter-spacing: -0.01em; }
.lead, .hint, .section-head .hint { color: var(--muted); font-size: 14px; }
.group-label { font-size: 12px; font-weight: 600; letter-spacing: 0.3px; text-transform: uppercase; color: var(--muted); }

/* Shell: the header carries the brand and the light / dark switch at every width (2026-10-19). */
.side { padding: 20px 14px; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; font-size: 12px; }
.brand-name { font-size: 15px; }
.side-company { margin: 0 0 18px; padding: 12px; border: 1px solid var(--border-soft); border-radius: 14px; background: var(--surface-2); }
.side-company strong { font-size: 13px; }
.side-company span { font-size: 12px; }
.nav-link { font-size: 13px; font-weight: 500; color: var(--text-2); }
.nav-link:hover { background: var(--hover); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--primary-weak); color: var(--nav-active); font-weight: 600; }
.avatar { background: var(--avatar); color: var(--avatar-text); }
@media (max-width: 779px) {
  .side { padding: 8px 12px; }
  /* On a short page the wrapped flex lines shared the spare height, so the menu row grew: keep
     the lines at the top. */
  .body { align-content: flex-start; }
}

/* Cards */
.card, .panel, .kpi, .table-wrap { border-radius: var(--radius); border-color: var(--border); }
.panel { padding: 24px; }
.card { padding: 24px; }
.card:hover { border-color: var(--border-strong); }
.kpi { padding: 20px; }
.login-card { border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow-sm); }

/* Tabs: pills in a white strip, a count pill beside each */
.tabs-row { border-bottom: 0; align-items: center; gap: 12px; }
.tabs, .tabs-row .tabs {
  gap: 4px; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.tab { min-height: 44px; padding: 8px 14px; margin: 0; border: 0; border-radius: 10px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.tab:hover { background: var(--hover); color: var(--text); }
.tab[aria-current="page"] { background: var(--primary-weak); color: var(--primary); font-weight: 600; border: 0; }
.tab-count { font-size: 10px; font-weight: 600; padding: 2px 6px; background: var(--surface-2); color: var(--muted); }
.tab[aria-current="page"] .tab-count { background: var(--surface); color: var(--primary); }
.tabs-row .period-pick { margin: 0; }
@media (max-width: 720px) {
  .tabs-row .tabs { border-bottom: 1px solid var(--border); }
}

/* Buttons: 44px, radius 10; primary blue, secondary outlined; a disabled primary is the lighter blue */
.btn {
  min-height: 44px; padding: 8px 16px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text); font-size: 14px; font-weight: 500;
}
.btn:hover:not(:disabled) { background: var(--hover); }
.btn.primary { padding: 8px 20px; border-color: var(--primary); background: var(--primary); color: var(--on-primary); font-weight: 600; }
.btn.primary:hover:not(:disabled) { border-color: var(--primary-hover); background: var(--primary-hover); }
.btn.primary:disabled { border-color: var(--primary-disabled); background: var(--primary-disabled); opacity: 1; }

/* The period switch: a bordered group of small pills */
.period { gap: 2px; padding: 4px; border-radius: 10px; background: var(--surface); overflow: visible; }
.period button { min-height: 32px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; font-size: 13px; }
.period button + button { border-left: 0; }
.period button:hover:not([aria-pressed="true"]) { background: var(--hover); }

/* Fields */
.field input, .rule-input, .search, .select {
  min-height: 44px; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text); font-size: 14px;
}
.field input:focus-visible, .rule-input:focus-visible, .search:focus-visible, .select:focus-visible {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary);
}
.field label { font-size: 14px; font-weight: 500; }

/* Badges and chips: pills */
.badge { border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; background: var(--chip); color: var(--chip-text); }
.badge.ok { background: var(--green-weak); color: var(--green); }
.badge.warn { background: var(--amber-weak); color: var(--amber); }
.badge.off { background: var(--red-weak); color: var(--red); }
.badge.blue { background: var(--primary-weak); color: var(--primary); }
.chip { border: 0; border-radius: 999px; padding: 2px 10px; font-size: 12px; background: var(--chip); color: var(--chip-text); }
.filter-chip { min-height: 36px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: 13px; }
.filter-chip:hover:not([aria-pressed="true"]) { background: var(--hover); }
.filter-chip[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-weak); color: var(--primary); }

/* Switches: the portal's off track */
input[type="checkbox"][role="switch"]:not(:checked) { background: var(--switch-off); }
input[type="checkbox"][role="switch"]:focus-visible { outline: 2px solid var(--primary); }

/* Tables */
th { color: var(--muted); font-weight: 600; font-size: 13px; }
td { border-bottom-color: var(--border-soft); }

/* On the light-blue fill (#EAF0FF) the muted grey is 4.29:1 — the darker grey and the blue read at
   AA (axe color-contrast, 2026-10-19). */
.bubble.a small, .bubble.team-bubble small { color: var(--text-2); }
.filter-chip[aria-pressed="true"] .filter-count { color: var(--primary); }
.table-wrap:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* List items as the portal draws them: each in its own bordered box, a small gap between. */
.rows:has(> .rule), .rows:has(> .skill) { gap: 8px; }
.rows > .rule, .rows > .skill { padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; }
.rows > .rule:last-child, .rows > .skill:last-child { border-bottom: 1px solid var(--border); }
.rule.common { padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
/* The agent's icon: the portal's blue tint. */
.agent-icon.green { background: var(--primary-weak); color: var(--primary); }

/* The profile in the header: the avatar opens who is signed in and «Гарах» (2026-10-19). */
.profile { position: relative; }
.profile-button { border: 0; padding: 0; cursor: pointer; font: inherit; font-weight: 600; font-size: 14px; }
.profile-button:hover { box-shadow: 0 0 0 2px var(--border-strong); }
.profile-button[aria-expanded="true"] { box-shadow: 0 0 0 2px var(--primary); }
.profile-button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.profile-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 30; width: max-content;
  min-width: 220px; max-width: min(300px, calc(100vw - 32px)); padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 32px rgb(25 40 66 / 0.16);
}
.profile-panel[hidden] { display: none; }
.profile-who { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 12px; margin-bottom: 6px; border-bottom: 1px solid var(--border-soft); }
.profile-who strong { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-who span { font-size: 12px; color: var(--muted); }
.profile-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 12px;
  border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; font-size: 14px; cursor: pointer; text-align: left;
}
.profile-item:hover { background: var(--hover); }
.profile-item:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

/* The light / dark switch: an icon button in the header, and in a corner of the sign-in page. */
.theme-toggle {
  flex: none; width: 36px; height: 36px; display: grid; place-items: center; padding: 0;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text-2); cursor: pointer;
}
.theme-toggle:hover { background: var(--hover); color: var(--text); }
.theme-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.login { position: relative; }
.login-theme { position: absolute; top: 16px; right: 16px; }

/* ======================================================================================
   One layout for the agent's tabs (2026-10-19, "the rule, knowledge, skill etc have different
   layouts … make it align"): every tab opens with its title card; every section with the same head
   (label · title with its count · one line · actions on the right); every list item is the same
   bordered box; searches run full width under the head.
   ====================================================================================== */
.section-head { align-items: flex-start; gap: 12px 16px; }
.section-head-text { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.section-actions { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.agent-page .panel.section { gap: 16px; }
.agent-page .rows { gap: 8px; }
.agent-page .rows > .row,
.agent-page .rows > .link-row,
.agent-page .rows > .rule,
.agent-page .rows > .skill,
.agent-page .rows > .rule-edit {
  padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.agent-page .rows > .row:last-child,
.agent-page .rows > .rule:last-child,
.agent-page .rows > .skill:last-child,
.agent-page .rows > .rule-edit:last-child { border-bottom: 1px solid var(--border); }
.agent-page .rows > .link-row:hover { border-color: var(--border-strong); background: var(--hover); }
.agent-page .rows > .empty { margin: 0; padding: 14px 16px; border: 1px dashed var(--border); border-radius: 12px; }
.agent-page .rule-edit.new { padding: 14px 16px; border: 1px dashed var(--border-strong); border-radius: 12px; }
.agent-page .sub-label { margin-top: 4px; }
.search.wide { width: 100%; max-width: none; }

/* The decision panel shows only for a picked reply (2026-10-19): the chat takes the full width until
   then; on a wide screen the panel docks beside it, on a narrow one it is a drawer (as before). */
@media (min-width: 1280px) {
  .conv-layout { grid-template-columns: minmax(0, 1fr); }
  .conv-layout.has-panel { grid-template-columns: minmax(0, 1fr) 380px; }
  .decision-panel:not(.open) { display: none; }
  .dp-close { display: inline-flex; }
}
.bubble.pickable { cursor: pointer; }
.bubble.pickable:hover { box-shadow: 0 0 0 1px var(--primary-line); }

/* ======================================================================================
   The chat (2026-10-19, "the background and the message almost merges"): the messages sit on a white
   card; each speaker has its own fill and edge — the person grey-blue on the left, the AI blue and the
   team (a person from support) green on the right; the speaker's corner is the sharp one.
   ====================================================================================== */
.conv-chat, .thread {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px;
}
.chat { gap: 16px; }
.bubble {
  max-width: min(680px, 88%); padding: 12px 16px; border: 1px solid transparent; border-radius: 16px;
  color: var(--text); line-height: 1.55;
}
.bubble p { margin: 4px 0 0; }
.bubble small { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); }
.bubble.q { background: var(--bubble-user); border-color: var(--bubble-user-line); border-bottom-left-radius: 4px; }
.bubble.a { background: var(--bubble-ai); border-color: var(--bubble-ai-line); border-bottom-right-radius: 4px; }
.bubble.team-bubble { background: var(--bubble-team); border-color: var(--bubble-team-line); }
.bubble.a small, .bubble.team-bubble small { color: var(--text-2); }
.chat .msg .bubble { max-width: min(680px, 88%); }
.chat .msg.selected .bubble { box-shadow: 0 0 0 2px var(--primary); }
.bubble.pickable:hover { box-shadow: 0 0 0 2px var(--bubble-ai-line); }
.msg-meta { max-width: min(680px, 88%); }
@media (max-width: 720px) {
  .conv-chat, .thread { padding: 14px; }
  .bubble, .chat .msg .bubble, .msg-meta { max-width: 100%; }
}

/* «Интеграци → One HR» token dialog (2026-10-20): the native <dialog>, the portal's modal shape. */
.dialog {
  width: min(520px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm);
}
.dialog::backdrop { background: rgb(10 15 25 / 0.45); }
.dialog-form { display: flex; flex-direction: column; gap: 16px; }
.dialog-form h2 { margin: 0; font-size: 20px; font-weight: 600; }
.dialog-form .steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: var(--text-2); }
.dialog-form .field input.mono { font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.dialog-form .error:empty, .dialog-form .hint:empty { display: none; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dialog-form .dialog-body { margin: 0; font-size: 14px; color: var(--text-2); }
.btn.danger { border-color: var(--red); background: var(--red); color: var(--surface); font-weight: 600; }
.btn.danger:hover:not(:disabled) { filter: brightness(0.92); }
