/* ═══════════════════════════════════════════════════════════════════════════
   ИТ-Поддержка — панель специалиста
   Мягкий корпоративный UI · Bootstrap (формы/сетка) + своя тема
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

/* ─── Reset & base ─────────────────────────────────────────────────────── */

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

/* ─── Non-thematic tokens ────────────────────────────────────────────────── */

:root {
  --font-display: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-ui: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* Legacy font aliases — all UI/display use Plex Sans */
  --font: var(--font-ui);
  --mono: var(--font-mono);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --sidebar-width: 248px;
  --topbar-height: 52px;
  --transition-fast: 0.12s ease;
  --transition-base: 0.18s ease;
  --transition-slow: 0.28s ease;

  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%236f6f6f' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  /* Bootstrap bridge */
  --bs-border-radius: var(--radius);
  --bs-border-radius-sm: var(--radius-sm);
  --bs-border-radius-lg: var(--radius-lg);
  --bs-body-font-family: var(--font-ui);
}

/* ─── Theme: Light (default) ─────────────────────────────────────────────── */

:root,
[data-theme="light"] {
  color-scheme: light;

  --surface-base: #f4f4f4;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-sunken: #f4f4f4;
  --surface-muted: #e0e0e0;
  --surface-overlay: rgba(15, 98, 254, 0.06);

  --brand: #0f62fe;
  --brand-hover: #0353e9;
  --brand-soft: #4589ff;
  --brand-muted: rgba(15, 98, 254, 0.10);
  --brand-glow: rgba(15, 98, 254, 0.12);
  --brand-line: #0f62fe;
  --on-brand: #ffffff;

  --text: #161616;
  --text-muted: #525252;
  --text-subtle: #6f6f6f;
  --text-active: #0f62fe;
  --text-inverse: #ffffff;
  --text-link: #0f62fe;

  --border: #e0e0e0;
  --border-strong: #c6c6c6;

  --success: #198038;
  --success-dim: rgba(25, 128, 56, 0.12);
  --warning: #b28600;
  --warning-dim: rgba(178, 134, 0, 0.14);
  --danger: #da1e28;
  --danger-dim: rgba(218, 30, 40, 0.10);
  --info: #0072c3;
  --info-dim: rgba(0, 114, 195, 0.12);
  --violet: #8a3ffc;
  --violet-dim: rgba(138, 63, 252, 0.10);

  --shadow-sm: 0 1px 2px rgba(22, 22, 22, 0.04), 0 1px 3px rgba(22, 22, 22, 0.06);
  --shadow: 0 4px 14px rgba(22, 22, 22, 0.06), 0 1px 3px rgba(22, 22, 22, 0.04);
  --shadow-lg: 0 12px 40px rgba(22, 22, 22, 0.12), 0 4px 12px rgba(22, 22, 22, 0.06);
  --page-bg: #eef1f6;

  --overlay: rgba(22, 22, 22, 0.5);
  --scrollbar: #c6c6c6;
  --scrollbar-hover: #8d8d8d;
}

/* ─── Theme: Dark ────────────────────────────────────────────────────────── */

[data-theme="dark"] {
  color-scheme: dark;

  --surface-base: #161616;
  --surface: #262626;
  --surface-raised: #333333;
  --surface-sunken: #161616;
  --surface-muted: #393939;
  --surface-overlay: rgba(69, 137, 255, 0.10);

  --brand: #4589ff;
  --brand-hover: #78a9ff;
  --brand-soft: #78a9ff;
  --brand-muted: rgba(69, 137, 255, 0.16);
  --brand-glow: rgba(69, 137, 255, 0.16);
  --brand-line: #4589ff;
  --on-brand: #161616;

  --text: #f4f4f4;
  --text-muted: #c6c6c6;
  --text-subtle: #8d8d8d;
  --text-active: #78a9ff;
  --text-inverse: #161616;
  --text-link: #78a9ff;

  --border: #393939;
  --border-strong: #525252;

  --success: #42be65;
  --success-dim: rgba(66, 190, 101, 0.16);
  --warning: #f1c21b;
  --warning-dim: rgba(241, 194, 27, 0.16);
  --danger: #ff8389;
  --danger-dim: rgba(255, 131, 137, 0.16);
  --info: #33b1ff;
  --info-dim: rgba(51, 177, 255, 0.16);
  --violet: #be95ff;
  --violet-dim: rgba(190, 149, 255, 0.16);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.45);
  --page-bg: #121212;

  --overlay: rgba(0, 0, 0, 0.7);
  --scrollbar: #525252;
  --scrollbar-hover: #8d8d8d;

  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%23c6c6c6' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* ─── Theme: Contrast (accessibility) ────────────────────────────────────── */

[data-theme="contrast"] {
  color-scheme: dark;

  --surface-base: #000000;
  --surface: #000000;
  --surface-raised: #0a0a0a;
  --surface-sunken: #101010;
  --surface-muted: #1a1a1a;
  --surface-overlay: rgba(255, 255, 0, 0.10);

  --brand: #ffff00;
  --brand-hover: #ffff66;
  --brand-soft: #ffff99;
  --brand-muted: rgba(255, 255, 0, 0.18);
  --brand-glow: rgba(255, 255, 0, 0.20);
  --brand-line: #ffff00;
  --on-brand: #000000;

  --text: #ffffff;
  --text-muted: #ffff00;
  --text-subtle: #cfcf00;
  --text-active: #ffff00;
  --text-inverse: #000000;
  --text-link: #ffff00;

  --border: #ffffff;
  --border-strong: #ffffff;

  --success: #00ff66;
  --success-dim: rgba(0, 255, 102, 0.18);
  --warning: #ffd000;
  --warning-dim: rgba(255, 208, 0, 0.18);
  --danger: #ff5b5b;
  --danger-dim: rgba(255, 91, 91, 0.20);
  --info: #00e5ff;
  --info-dim: rgba(0, 229, 255, 0.18);
  --violet: #d49bff;
  --violet-dim: rgba(212, 155, 255, 0.18);

  --shadow-sm: 0 0 0 1px #ffffff;
  --shadow: 0 0 0 1px #ffffff;
  --shadow-lg: 0 0 0 2px #ffffff;
  --page-bg: #000000;

  --overlay: rgba(0, 0, 0, 0.85);
  --scrollbar: #ffffff;
  --scrollbar-hover: #ffff00;

  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%23ffff00' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* ─── Legacy color aliases (template compatibility) ────────────────────────── */

:root,
[data-theme] {
  --bg: var(--surface-base);
  --bg2: var(--surface);
  --bg3: var(--surface-raised);
  --bg4: var(--surface-sunken);
  --bg5: var(--surface-muted);
  --border2: var(--border-strong);
  --text2: var(--text-muted);
  --text3: var(--text-subtle);
  --white: var(--text-inverse);
  --accent: var(--brand);
  --accent-soft: var(--brand-soft);
  --accent-glow: var(--brand-glow);
  --accent-line: var(--brand-line);
  --on-accent: var(--on-brand);
  --green: var(--success);
  --green-dim: var(--success-dim);
  --amber: var(--warning);
  --amber-dim: var(--warning-dim);
  --red: var(--danger);
  --red-dim: var(--danger-dim);
  --teal: var(--info);
  --teal-dim: var(--info-dim);
}

/* ─── Theme switching: suppress transition flash ─────────────────────────── */

html.theme-switching,
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
  transition: none !important;
}

/* ─── Document ─────────────────────────────────────────────────────────────── */

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--transition-base), color var(--transition-base);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ─── Icon system ──────────────────────────────────────────────────────────── */

.ico {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  vertical-align: -0.25em;
}

.ico svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* ─── Brand mark ───────────────────────────────────────────────────────────── */

.brand-mark,
.sidebar-logo .mark {
  width: 28px;
  height: 28px;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.auth-logo.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* ─── Scrollbar ────────────────────────────────────────────────────────────── */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-hover);
}

/* ─── Auth overlay ─────────────────────────────────────────────────────────── */

#auth-overlay {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--brand) 18%, transparent), transparent 55%),
    radial-gradient(900px 500px at 110% 10%, color-mix(in srgb, var(--brand) 10%, transparent), transparent 50%),
    var(--page-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-height: 720px) {
  #auth-overlay {
    align-items: flex-start;
  }
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 36px 32px;
  width: 420px;
  max-width: 95vw;
  max-height: min(100dvh - 32px, 920px);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  margin: auto;
}

.auth-card .logo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 16px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  color: var(--brand);
}

.auth-card h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 2px;
  letter-spacing: 0;
  color: var(--text);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.auth-brand .auth-logo {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  object-fit: contain;
}

.auth-tagline {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.auth-card p.sub {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 28px;
}

.auth-view {
  display: none;
}

.auth-view.active {
  display: block;
}

.auth-error {
  background: var(--danger-dim) !important;
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent) !important;
  color: var(--danger) !important;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}

.auth-error[style*="display: block"],
.auth-error.is-visible {
  display: block !important;
}

.auth-link {
  display: block;
  text-align: center;
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-link a {
  color: var(--text-link);
  text-decoration: none;
  font-weight: 600;
}

.auth-link a:hover {
  text-decoration: underline;
}

/* ─── Form fields ──────────────────────────────────────────────────────────── */

.field {
  margin-bottom: 16px;
}

label.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 8px;
}

.field-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

input[type="text"],
input[type="password"],
input[type="tel"],
input[type="email"],
input[type="number"],
input[type="search"],
input[type="date"],
textarea,
select.input,
select.assign-select,
.kb-search,
.cab-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  padding: 11px 14px;
  outline: none;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

textarea,
.kb-textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.5;
}

input:focus,
textarea:focus,
select.input:focus,
select.assign-select:focus,
.kb-search:focus,
.cab-input:focus,
.kb-textarea:focus {
  border-color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand);
}

input::placeholder,
textarea::placeholder,
.search-bar::placeholder,
.kb-search::placeholder {
  color: var(--text-subtle);
}

/* Custom select arrow */
select.input,
select.assign-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
  cursor: pointer;
}

select.assign-select {
  width: auto;
  font-size: 12px;
  padding: 6px 32px 6px 9px;
}

/* ─── File upload ────────────────────────────────────────────────────────────── */

.file-upload {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--surface-sunken);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition-base), background var(--transition-base);
}

.file-upload:hover {
  border-color: var(--brand);
  background: var(--surface-overlay);
}

.file-upload-inline {
  padding: 6px 12px;
}

.file-upload input[type="file"] {
  position: absolute;
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  z-index: -1;
}

.file-upload-btn {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  background: var(--brand);
  color: var(--on-brand);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 600;
}

.file-upload-name {
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-upload:focus-within {
  border-color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand);
}

/* Legacy nested label variant */
.file-upload label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

/* ─── Buttons ────────────────────────────────────────────────────────────────── */

.btn-primary {
  width: 100%;
  background: var(--brand);
  color: var(--on-brand);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--transition-base);
  letter-spacing: 0;
  position: relative;
  z-index: 2;
  pointer-events: auto;
  display: block;
}

.btn-primary:hover {
  background: var(--brand-hover);
}

.btn-primary:active {
  opacity: 0.9;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sm {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--surface);
  color: var(--text);
}

.btn-sm:hover {
  background: var(--surface-sunken);
  border-color: var(--text-subtle);
}

.btn-sm.danger {
  background: var(--danger-dim);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
}

.btn-sm.danger:hover {
  background: var(--danger);
  color: var(--on-brand);
  border-color: var(--danger);
}

.btn-sm.success {
  background: var(--success-dim);
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 30%, transparent);
}

.btn-sm.success:hover {
  background: var(--success);
  color: var(--on-brand);
  border-color: var(--success);
}

.btn-ghost,
.btn-ghost-sm {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-ghost-sm:hover,
.btn-ghost:hover {
  background: var(--surface-sunken);
  border-color: var(--text-subtle);
}

.btn-save {
  background: var(--brand);
  color: var(--on-brand);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 18px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.btn-save:hover {
  background: var(--brand-hover);
}

.btn-refresh {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 12.5px;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-weight: 500;
}

.btn-refresh:hover {
  background: var(--surface-sunken);
  border-color: var(--text-subtle);
}

.btn-assign {
  background: var(--brand);
  color: var(--on-brand);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  cursor: pointer;
  transition: background var(--transition-fast);
  white-space: nowrap;
}

.btn-assign:hover {
  background: var(--brand-hover);
}

.btn-assign:disabled {
  background: var(--surface-muted);
  color: var(--text-subtle);
  cursor: not-allowed;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
}

.btn-danger:hover {
  background: var(--danger);
  color: var(--on-brand);
}

.btn-cancel {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.btn-cancel:hover {
  background: var(--surface-sunken);
}

.btn-confirm {
  background: var(--danger);
  color: var(--on-brand);
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.btn-confirm:hover {
  opacity: 0.9;
}

.btn-confirm.green {
  background: var(--success);
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text-subtle);
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-ui);
  transition: background var(--transition-fast), color var(--transition-fast);
  font-weight: 500;
}

.btn-logout:hover {
  background: var(--danger-dim);
  color: var(--danger);
}

.btn-reset {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-family: var(--font-ui);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-weight: 500;
}

.btn-reset:hover {
  background: var(--surface-sunken);
  color: var(--text);
}

/* Unified interactive feedback for controls */
.btn-primary,
.btn-sm,
.btn-ghost,
.btn-ghost-sm,
.btn-save,
.btn-refresh,
.btn-assign,
.btn-danger,
.btn-cancel,
.btn-confirm,
.btn-logout,
.btn-reset,
.icon-btn,
.hamburger,
.chip,
.kb-mini,
.cab-del,
.tm-close,
.cal-nav button,
.cal-today,
.seg button,
.notif-clear,
.notif-foot button {
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast),
    box-shadow var(--transition-fast),
    opacity var(--transition-fast),
    transform var(--transition-fast);
}

.btn-primary:active,
.btn-sm:active,
.btn-ghost:active,
.btn-ghost-sm:active,
.btn-save:active,
.btn-refresh:active,
.btn-assign:active,
.btn-danger:active,
.btn-cancel:active,
.btn-confirm:active,
.btn-reset:active,
.icon-btn:active,
.hamburger:active,
.chip:active,
.kb-mini:active,
.cab-del:active,
.tm-close:active,
.cal-nav button:active,
.cal-today:active,
.seg button:active {
  transform: translateY(1px) scale(0.98);
}

.btn-primary:focus-visible,
.btn-sm:focus-visible,
.btn-ghost:focus-visible,
.btn-ghost-sm:focus-visible,
.btn-save:focus-visible,
.btn-refresh:focus-visible,
.btn-assign:focus-visible,
.btn-danger:focus-visible,
.btn-cancel:focus-visible,
.btn-confirm:focus-visible,
.btn-reset:focus-visible,
.btn-logout:focus-visible,
.icon-btn:focus-visible,
.hamburger:focus-visible,
.chip:focus-visible,
.kb-mini:focus-visible,
.cab-del:focus-visible,
.tm-close:focus-visible,
.cal-nav button:focus-visible,
.cal-today:focus-visible,
.seg button:focus-visible,
.nav-item:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.btn-sm.danger:active,
.btn-confirm:active,
.btn-danger:active {
  filter: brightness(0.92);
}

.btn-save,
.btn-confirm.ok {
  background: var(--brand);
  color: var(--on-brand);
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-save:hover,
.btn-confirm.ok:hover {
  background: var(--brand-hover);
}

.icon-btn.is-open,
.hamburger.is-open,
.icon-btn[aria-expanded="true"] {
  background: var(--brand-muted);
  border-color: var(--brand);
  color: var(--brand);
}

.chip[aria-pressed="true"],
.chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
  font-weight: 600;
}

.chip i {
  transition: transform var(--transition-fast);
}

.chip:hover i,
.chip:active i {
  transform: scale(1.12);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.btn-icon .btn-label {
  display: none;
}

.btn-with-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  padding: 8px 14px;
}

.password-wrap {
  position: relative;
  display: block;
}

.password-wrap input {
  padding-right: 42px;
  width: 100%;
}

.password-wrap .pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.password-wrap .pw-toggle:hover {
  color: var(--text);
  background: var(--surface-sunken);
}

.password-wrap .pw-toggle:active {
  transform: translateY(-50%) scale(0.94);
}

.password-wrap .pw-toggle.is-on {
  color: var(--brand);
}

.btn-flash-ok i::before {
  content: "\f26b" !important; /* check-lg */
}

.kb-mini.is-on {
  color: var(--brand);
  border-color: var(--brand);
  background: var(--brand-muted);
}

.cab-del {
  min-width: 28px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hamburger {
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.hamburger:hover {
  background: var(--surface-sunken);
  border-color: var(--text-subtle);
}

.seg button i {
  font-size: 13px;
  margin-right: 2px;
}

.seg button.active i {
  transform: scale(1.1);
}

@media (max-width: 760px) {
  .seg-theme .btn-label {
    display: none;
  }
  .seg-theme button {
    min-width: 34px;
    padding-left: 8px;
    padding-right: 8px;
  }
}

/* ─── App shell ─────────────────────────────────────────────────────────────── */

#app {
  display: none;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  box-shadow: 4px 0 24px rgba(22, 22, 22, 0.04);
}

.sidebar-header {
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}

.sidebar-brand-text strong {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
}

.sidebar-brand-text small {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 400;
  color: var(--text-subtle);
  text-transform: none;
  letter-spacing: 0;
}

.sidebar-user {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
  overflow: hidden;
}

.avatar img,
.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-user .who {
  min-width: 0;
}

.sidebar-user .who b {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Subdued role badge — not a bright pill */
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-sunken);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  margin-top: 4px;
  text-transform: none;
  letter-spacing: 0.02em;
}

.role-badge.admin {
  background: var(--brand-muted);
  color: var(--text-active);
  border-color: color-mix(in srgb, var(--brand) 35%, var(--border));
}

.role-badge.worker {
  background: var(--success-dim);
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 30%, var(--border));
}

.role-badge.pending {
  background: var(--warning-dim);
  color: var(--warning);
}

nav {
  flex: 1;
  padding: 8px 8px;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 8px;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 12px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-muted);
  transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  position: relative;
  border: 1px solid transparent;
  border-left: 3px solid transparent;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-ui);
  font-weight: 500;
  margin-bottom: 2px;
}

.nav-item > i {
  font-size: 1.05rem;
  width: 1.25rem;
  text-align: center;
  opacity: 0.85;
  flex-shrink: 0;
}

.nav-item > span:not(.badge-count) {
  flex: 1;
  min-width: 0;
}

.nav-item:hover {
  background: var(--surface-sunken);
  color: var(--text);
}

.nav-item:hover > i {
  opacity: 1;
}

.nav-item.active {
  background: var(--brand-muted);
  color: var(--text-active);
  font-weight: 600;
  border-color: color-mix(in srgb, var(--brand) 22%, transparent);
  border-left-color: var(--brand);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 12%, transparent);
}

.nav-item.active > i {
  opacity: 1;
  color: var(--brand);
}

.nav-item.active::before {
  content: none;
}

.nav-item .badge-count {
  position: static;
  margin-left: auto;
  background: var(--danger);
  color: #ffffff;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  display: none;
}

.nav-item .badge-count.show {
  display: inline;
}

.sidebar-footer {
  padding: 10px 8px;
  border-top: 1px solid var(--border);
}

.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  padding: 16px 22px 28px;
  width: calc(100% - var(--sidebar-width));
  max-width: none;
  background: var(--page-bg);
  box-sizing: border-box;
}

.main-content > .page,
.main-content > .topbar,
.main-content > .setup-banner,
.main-content > #preview-banner {
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
}

.main-content > .topbar {
  max-width: 1280px;
}

/* ─── Topbar ─────────────────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0 10px;
  margin-bottom: 2px;
  background: var(--page-bg);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
  gap: 2px;
}

.topbar-eyebrow {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.topbar-title {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.hamburger {
  display: none;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  font-family: var(--font-ui);
}

.icon-btn:hover {
  background: var(--surface-sunken);
  border-color: var(--text-subtle);
}

.icon-btn .dot-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--danger);
  color: #ffffff;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 600;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 2px solid var(--page-bg);
}

.icon-btn .dot-badge.show {
  display: flex;
}

/* Theme segment switcher */
.seg {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 0;
}

.seg button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 11.5px;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.seg button:hover {
  color: var(--text);
  background: var(--surface-sunken);
}

.seg button.active {
  background: var(--brand);
  color: var(--on-brand);
}

/* Preview banner */
#preview-banner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--brand-muted);
  border-bottom: 1px solid var(--brand);
  color: var(--text);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
}

/* ─── Drawer ─────────────────────────────────────────────────────────────────── */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.drawer-overlay.show {
  opacity: 1;
  pointer-events: all;
}

/* ─── Notifications ──────────────────────────────────────────────────────────── */

.notif-panel {
  position: absolute;
  top: 48px;
  right: 0;
  width: 340px;
  max-width: 92vw;
  max-height: 70vh;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 120;
  display: none;
  flex-direction: column;
}

.notif-panel.open {
  display: flex;
  animation: fadeUp 0.15s ease;
}

.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.notif-head h4 {
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-ui);
}

.notif-clear {
  background: none;
  border: none;
  color: var(--text-subtle);
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font-ui);
}

.notif-clear:hover {
  color: var(--brand);
}

.notif-list {
  overflow-y: auto;
}

.notif-item {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.notif-item:hover {
  background: var(--surface-sunken);
}

.notif-item.unread {
  background: var(--brand-muted);
}

.notif-item .ni-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--info);
  margin-top: 5px;
  flex-shrink: 0;
}

.notif-item .ni-body {
  min-width: 0;
}

.notif-item .ni-title {
  font-size: 13px;
  font-weight: 600;
}

.notif-item .ni-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notif-item .ni-time {
  font-size: 11px;
  color: var(--text-subtle);
  margin-top: 3px;
}

.notif-foot {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}

.notif-foot button {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 7px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font-ui);
}

.notif-foot button:hover {
  color: var(--text);
  background: var(--surface-sunken);
}

/* ─── Pages ──────────────────────────────────────────────────────────────────── */

.page {
  display: none;
}

.page.active {
  display: block;
  animation: fadeUp var(--transition-slow) ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.page-header {
  margin-bottom: 14px;
}

.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.page-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}

.page-sub {
  color: var(--text-muted);
  font-size: 12.5px;
  margin-top: 2px;
  line-height: 1.4;
  max-width: 52ch;
}

/* ─── Stats ──────────────────────────────────────────────────────────────────── */

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--text-subtle);
  border-radius: var(--radius) var(--radius) 0 0;
}

.stat-card.c-blue::before { background: var(--info); }
.stat-card.c-yellow::before { background: var(--warning); }
.stat-card.c-green::before { background: var(--success); }
.stat-card.c-red::before { background: var(--danger); }

.stat-card .stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-subtle);
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 8px;
}

.stat-card .stat-val {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  font-family: var(--font-ui);
}

.stat-card.c-blue .stat-val { color: var(--info); }
.stat-card.c-yellow .stat-val { color: var(--warning); }
.stat-card.c-green .stat-val { color: var(--success); }
.stat-card.c-red .stat-val { color: var(--danger); }

/* ─── Cards ──────────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
}

.card-header h3 {
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-ui);
}

.card-header .muted {
  font-size: 12px;
  color: var(--text-subtle);
  font-weight: 400;
}

.card-body {
  padding: 16px;
}

/* ─── Tables ─────────────────────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
}

table,
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  padding: 12px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface-sunken);
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background var(--transition-fast);
}

tbody tr:hover td {
  background: var(--surface-sunken);
}

tr.ticket-row {
  cursor: pointer;
  transition: background var(--transition-fast);
}

tr.ticket-row:hover {
  background: var(--surface-sunken);
}

td .id-cell {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text);
  font-size: 12.5px;
}

td .date-cell {
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* ─── Badges ─────────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.badge::before {
  content: '\25CF';
  font-size: 7px;
  line-height: 1;
}

.badge.no-dot::before {
  content: none;
}

.badge.green  { background: var(--success-dim); color: var(--success); }
.badge.amber  { background: var(--warning-dim); color: var(--warning); }
.badge.red    { background: var(--danger-dim);  color: var(--danger); }
.badge.teal   { background: var(--info-dim);    color: var(--info); }
.badge.violet { background: var(--violet-dim);  color: var(--violet); }
.badge.gray   { background: var(--surface-muted); color: var(--text-muted); }

/* ─── Priority ───────────────────────────────────────────────────────────────── */

.prio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.prio-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.prio-dot.high {
  background: var(--danger);
}

.prio-dot.normal { background: var(--warning); }
.prio-dot.low { background: var(--success); }

.assign-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ─── Toolbar & search ───────────────────────────────────────────────────────── */

.toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.search-bar {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13.5px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.search-bar:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-muted);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.filter-group .fg-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 7px;
  display: block;
}

.chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.chip {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-weight: 500;
}

.chip:hover {
  border-color: var(--text-subtle);
  color: var(--text);
  background: var(--surface-sunken);
}

.chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
  font-weight: 600;
}

.filter-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-subtle);
}

.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

/* ─── Toggles ────────────────────────────────────────────────────────────────── */

.toggle-admin {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.toggle-switch {
  width: 36px;
  height: 18px;
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  position: relative;
  transition: background var(--transition-base);
  flex-shrink: 0;
}

.toggle-switch.on {
  background: var(--brand);
}

.toggle-switch::after {
  content: '';
  width: 12px;
  height: 12px;
  background: var(--text-inverse);
  border-radius: var(--radius-sm);
  position: absolute;
  top: 3px;
  left: 3px;
  transition: left var(--transition-base), background var(--transition-base);
}

.toggle-switch.on::after {
  left: 21px;
  background: var(--on-brand);
}

/* ─── Settings panel ─────────────────────────────────────────────────────────── */

.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.settings-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.settings-info {
  min-width: 0;
}

.settings-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.settings-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.45;
  max-width: 360px;
}

.seg-theme button {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  min-width: 44px;
}

/* ─── Profile ────────────────────────────────────────────────────────────────── */

.profile-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: start;
}

.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin: 0 auto 16px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
}

.avatar.has-photo,
.profile-avatar.has-photo {
  background-color: var(--surface-muted);
}

.photo-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: -4px 0 14px;
}

.profile-name {
  font-family: var(--font-ui);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0;
}

.profile-username {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 3px;
  font-family: var(--font-mono);
}

.profile-meta {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 11px;
  width: 100%;
}

.profile-meta-row,
.profile-meta .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
  margin: 0;
  flex-wrap: nowrap;
}

.profile-meta-row span,
.profile-meta .row span {
  color: var(--text-subtle);
}

.profile-meta-row b,
.profile-meta .row b {
  color: var(--text);
  font-weight: 600;
  text-align: right;
}

.profile-checklist {
  margin-top: 16px;
  padding: 12px;
  width: 100%;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  text-align: left;
}

.checklist-head {
  font-size: 12px;
  font-weight: 650;
  color: var(--text);
  margin-bottom: 8px;
}

.checklist-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.checklist-list li {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.35;
}

.checklist-list li.ok { color: var(--green, #198038); }
.checklist-list li.need { color: var(--text); font-weight: 550; }
.checklist-list li.soft { opacity: 0.85; }
.checklist-list .bi { flex-shrink: 0; margin-top: 1px; }

.setup-banner {
  display: none;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 12px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--brand) 28%, var(--border));
  background: color-mix(in srgb, var(--brand) 8%, var(--surface));
  color: var(--text);
  font-size: 13px;
}

.setup-banner-text {
  flex: 1;
  min-width: 180px;
  line-height: 1.4;
}

.setup-banner-more {
  color: var(--text-muted);
}

.setup-banner-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.setup-banner-close:hover {
  background: var(--surface);
  color: var(--text);
}

.btn-save.is-busy,
.btn-assign.is-busy,
.btn-confirm.is-busy,
button.is-busy {
  opacity: 0.7;
  pointer-events: none;
  cursor: wait;
}

.ticket-row:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

.modal-body-text {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

@media (max-width: 720px) {
  .topbar-right {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
  }
  .seg-theme .btn-label {
    display: none;
  }
  .topbar-title {
    font-size: 14px;
  }
  #preview-toggle {
    display: none !important;
  }
  .icon-btn,
  .hamburger {
    width: 44px;
    height: 44px;
  }
}

.profile-role-hint {
  margin-top: 14px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-muted);
  text-align: left;
  width: 100%;
}

.profile-panels {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* ─── Workers & ratings ──────────────────────────────────────────────────────── */

.workers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.worker-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.worker-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.worker-name {
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-ui);
}

.worker-stat {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 7px;
}

.worker-stat b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.worker-bar {
  height: 4px;
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  margin-top: 12px;
  overflow: hidden;
}

.worker-bar-fill {
  height: 4px;
  background: var(--brand);
  border-radius: var(--radius-sm);
  transition: width 0.4s ease;
}

.stars {
  color: var(--warning);
  font-size: 16px;
  letter-spacing: 2px;
}

.avg-rating {
  font-family: var(--font-ui);
  font-size: 40px;
  font-weight: 600;
  color: var(--warning);
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.rating-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
  font-size: 12px;
}

.rating-bar-bg {
  flex: 1;
  height: 6px;
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.rating-bar-fill {
  height: 6px;
  background: var(--warning);
  border-radius: var(--radius-sm);
  transition: width 0.4s;
}

.rating-bar-count {
  width: 26px;
  text-align: right;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ─── Locations ──────────────────────────────────────────────────────────────── */

.loc-card {
  margin-bottom: 16px;
}

.loc-floor {
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.loc-floor:first-child {
  border-top: none;
  padding-top: 0;
}

.loc-floor-head {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}

.cab-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.cab-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px 5px 11px;
  font-size: 12.5px;
  font-weight: 500;
}

.cab-del {
  background: transparent;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  font-size: 12px;
  padding: 0 2px;
  line-height: 1;
  border-radius: var(--radius-sm);
}

.cab-del:hover {
  color: var(--danger);
}

.cab-add {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ─── Knowledge base ─────────────────────────────────────────────────────────── */

.kb-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kb-panel-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.kb-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.kb-search {
  flex: 1 1 auto;
  width: auto !important;
  min-width: 0;
  padding: 8px 12px !important;
  font-size: 13.5px !important;
}

.kb-cat-select {
  flex: 0 0 200px;
  width: 200px !important;
  max-width: 40%;
  padding: 8px 32px 8px 12px !important;
  font-size: 13px !important;
}

.kb-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 0;
  padding-top: 2px;
  border-top: 1px solid var(--border);
}

.kb-filters .chip {
  padding: 4px 10px;
  font-size: 12px;
}

.kb-grid {
  column-width: 280px;
  column-gap: 12px;
}

.btn-inline,
.btn-primary.btn-inline {
  width: auto !important;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  white-space: nowrap;
}

/* Bootstrap grid inside our cards — не «уплывает» за края */
#app .row {
  --bs-gutter-x: 1rem;
  margin-left: 0;
  margin-right: 0;
}

#app .row > [class*="col-"] {
  padding-left: calc(var(--bs-gutter-x) * 0.5);
  padding-right: calc(var(--bs-gutter-x) * 0.5);
}

.stats-row {
  gap: 10px;
  margin-bottom: 14px;
}

.stat-card {
  padding: 12px 14px;
}

.card {
  margin-bottom: 12px;
}

.card-header {
  padding: 10px 14px;
}

.card-body {
  padding: 12px 14px;
}

@media (max-width: 720px) {
  .kb-panel-row {
    flex-direction: column;
    align-items: stretch;
  }
  .kb-cat-select {
    width: 100% !important;
    max-width: none;
    flex-basis: auto;
  }
}

.kb-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-left: 3px solid var(--border-strong);
  break-inside: avoid;
  margin: 0 0 12px;
  width: 100%;
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.kb-card:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow-sm);
}

.kb-card.kb-guide { border-left-color: var(--info); }
.kb-card.kb-pass  { border-left-color: var(--warning); }
.kb-card.kb-note  { border-left-color: var(--violet); }

.kb-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kb-kind {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.kb-actions {
  display: flex;
  gap: 4px;
}

.kb-mini {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.kb-mini:hover {
  color: var(--text);
  border-color: var(--text-subtle);
  background: var(--surface-sunken);
}

.kb-mini.danger:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.kb-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  word-break: break-word;
  font-family: var(--font-ui);
}

.kb-cat {
  display: inline-block;
  font-size: 12px;
  color: var(--text-muted);
}

.kb-content {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 160px;
  overflow-y: auto;
}

.kb-secret {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
}

.kb-secret-val {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  flex: 1;
  word-break: break-all;
  letter-spacing: 0.5px;
}

.kb-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.kb-tag {
  font-size: 11px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
}

.kb-textarea {
  width: 100%;
  min-height: 130px;
}

/* Rich editor */
.kb-rich-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.kb-rich {
  width: 100%;
  min-height: 170px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  padding: 11px 14px;
  outline: none;
  line-height: 1.6;
}

.kb-rich:focus {
  border-color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand);
}

.kb-rich:empty::before {
  content: attr(data-placeholder);
  color: var(--text-subtle);
  pointer-events: none;
}

.kb-rich img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: 8px 0;
  display: block;
  border: 1px solid var(--border);
}

/* Rich content view (rendered HTML) */
.kb-rich-view {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  margin: 6px 0 16px;
  white-space: normal;
  font-family: var(--font-ui);
}

.kb-rich-view h1,
.kb-rich-view h2,
.kb-rich-view h3,
.kb-rich-view h4,
.kb-rich-view h5,
.kb-rich-view h6 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text);
  margin: 1.2em 0 0.5em;
  line-height: 1.3;
}

.kb-rich-view h1 { font-size: 1.5em; }
.kb-rich-view h2 { font-size: 1.35em; }
.kb-rich-view h3 { font-size: 1.2em; }
.kb-rich-view h4 { font-size: 1.1em; }
.kb-rich-view h5 { font-size: 1em; }
.kb-rich-view h6 { font-size: 0.9em; color: var(--text-muted); }

.kb-rich-view h1:first-child,
.kb-rich-view h2:first-child,
.kb-rich-view h3:first-child,
.kb-rich-view h4:first-child,
.kb-rich-view h5:first-child,
.kb-rich-view h6:first-child,
.kb-rich-view p:first-child {
  margin-top: 0;
}

.kb-rich-view p {
  margin: 0.65em 0;
}

.kb-rich-view ul,
.kb-rich-view ol {
  margin: 0.65em 0;
  padding-left: 1.5em;
}

.kb-rich-view li {
  margin: 0.35em 0;
}

.kb-rich-view li > ul,
.kb-rich-view li > ol {
  margin: 0.25em 0;
}

.kb-rich-view code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.15em 0.4em;
  color: var(--brand);
}

.kb-rich-view pre {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
  margin: 0.85em 0;
  line-height: 1.5;
}

.kb-rich-view pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
}

.kb-rich-view blockquote {
  margin: 0.85em 0;
  padding: 10px 16px;
  border-left: 3px solid var(--brand);
  background: var(--brand-muted);
  color: var(--text-muted);
  font-style: italic;
  border-radius: var(--radius-sm);
}

.kb-rich-view a {
  color: var(--text-link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.kb-rich-view a:hover {
  color: var(--brand-hover);
}

.kb-rich-view img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: 10px 0;
  display: block;
  border: 1px solid var(--border);
}

.kb-rich-view table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13.5px;
}

.kb-rich-view th,
.kb-rich-view td {
  border: 1px solid var(--border-strong);
  padding: 8px 10px;
  vertical-align: top;
}

.kb-rich-view th {
  background: var(--surface-sunken);
  font-weight: 600;
}

/* TinyMCE — панель «Главная» в стиле Word */
.kb-ribbon {
  margin-bottom: 0;
}

.kb-ribbon-tabs {
  display: flex;
  gap: 4px;
  padding: 0 2px;
  margin-bottom: 0;
}

.kb-ribbon-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: transparent;
}

.kb-ribbon-tab.active {
  color: var(--brand);
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-color: var(--surface);
  margin-bottom: -1px;
  z-index: 2;
  position: relative;
}

#kb-editor-field .tox-tinymce {
  border-radius: 0 var(--radius) var(--radius) var(--radius) !important;
  border-color: var(--border-strong) !important;
  overflow: hidden;
}

#kb-editor-field .tox-editor-header {
  background: var(--surface-sunken) !important;
  border-bottom: 1px solid var(--border) !important;
  padding-top: 4px !important;
}

.kb-tox-home-label {
  font-size: 11px;
  font-weight: 650;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 10px 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

[data-theme="dark"] #kb-editor-field .tox-tinymce,
[data-theme="contrast"] #kb-editor-field .tox-tinymce {
  border-color: var(--border) !important;
}

#kb-modal .crm-modal-lg {
  max-width: 960px;
}

#kb-modal .tm-body {
  max-height: min(86vh, 900px);
}

/* ─── System actions ─────────────────────────────────────────────────────────── */

.sys-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sys-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-wrap: wrap;
}

.sys-action-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 3px;
}

.sys-action-desc {
  font-size: 12.5px;
  color: var(--text-muted);
}

.sys-log-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.sys-log-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--border);
}

.sys-log-row:last-child {
  border-bottom: none;
}

.sys-log-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.sys-log-src {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.sys-log-msg {
  font-size: 13px;
  color: var(--text);
}

.sys-log-ts {
  font-size: 11.5px;
  color: var(--text-subtle);
  white-space: nowrap;
}

/* ─── Danger zone ────────────────────────────────────────────────────────────── */

.danger-zone {
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  border-radius: var(--radius);
  padding: 16px 18px;
  background: var(--danger-dim);
  margin-bottom: 16px;
}

.danger-zone:last-child {
  margin-bottom: 0;
}

.danger-title {
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.danger-desc {
  color: var(--text-muted);
  font-size: 12.5px;
  margin-bottom: 14px;
  line-height: 1.55;
}

/* ─── Modals ─────────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.crm-modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 24px 28px;
  max-width: 440px;
  width: 95vw;
  transform: translateY(8px);
  transition: transform var(--transition-base);
  box-shadow: var(--shadow-lg);
}

.modal-overlay.open .crm-modal {
  transform: none;
}

.crm-modal.crm-modal-lg {
  max-width: 680px;
  padding: 0;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.crm-modal h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 10px;
}

.crm-modal p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 22px;
  line-height: 1.55;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.tm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.tm-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0;
  font-family: var(--font-ui);
}

.tm-close {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
}

.tm-close:hover {
  color: var(--text);
  background: var(--surface-sunken);
}

.tm-body {
  padding: 16px 20px;
  overflow-y: auto;
}

.tm-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-subtle);
  margin: 18px 0 8px;
}

.tm-section-title:first-child {
  margin-top: 0;
}

.tm-grid {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 8px 14px;
  font-size: 13px;
}

.tm-grid .k {
  color: var(--text-muted);
}

.tm-grid .v {
  color: var(--text);
  font-weight: 600;
  word-break: break-word;
}

.tm-comment {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.tm-files {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tm-file-img {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color var(--transition-fast);
  background: var(--surface-sunken);
}

.tm-file-img:hover {
  border-color: var(--brand);
}

.tm-file-doc {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  font-size: 12.5px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.tm-file-doc:hover {
  border-color: var(--brand);
}

/* ─── Toast ──────────────────────────────────────────────────────────────────── */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.2s ease;
  max-width: 340px;
}

.toast.success {
  border-left: 3px solid var(--success);
}

.toast.error {
  border-left: 3px solid var(--danger);
}

@keyframes slideIn {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ─── Empty & loading ────────────────────────────────────────────────────────── */

.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-subtle);
}

.empty .icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.7;
}

.empty p {
  font-size: 14px;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 36px auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.ban-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}

.ban-row:last-child {
  border-bottom: none;
}

/* ─── Calendar ───────────────────────────────────────────────────────────────── */

.cal-card .card-body {
  padding: 14px 16px 16px;
}

.cal-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}

.cal-month {
  min-width: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--border);
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 10px;
}

.cal-title {
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 650;
  text-transform: capitalize;
}

.cal-nav {
  display: flex;
  gap: 6px;
  align-items: center;
}

.cal-nav button,
.cal-today {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.cal-nav button:hover,
.cal-today:hover {
  background: var(--surface-sunken);
  border-color: var(--text-subtle);
}

.cal-grid {
  display: grid !important;
  grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
  gap: 0 !important;
  width: 100%;
  border: none;
  border-radius: 0;
  overflow: visible;
  background: transparent;
}

.cal-dow-row {
  border-bottom: 1px solid var(--border-strong);
}

.cal-dow {
  text-align: center;
  font-size: 11px;
  font-weight: 650;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 4px;
  background: var(--surface-sunken);
  border-right: 1px solid var(--border);
}

.cal-dow:last-child {
  border-right: none;
}

.cal-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
  min-height: 72px;
  aspect-ratio: 1 / 0.92;
  border: none;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  padding: 8px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
}

.cal-cell:nth-child(7n) {
  border-right: none;
}

.cal-cell.empty-cell {
  background: var(--surface-sunken);
  cursor: default;
  pointer-events: none;
  opacity: 0.55;
}

.cal-cell.has-tickets {
  background: color-mix(in srgb, var(--brand) 6%, var(--surface));
}

.cal-cell.has-tickets:hover,
.cal-cell:not(.empty-cell):hover {
  background: var(--brand-muted);
  z-index: 1;
}

.cal-cell.selected {
  background: var(--brand-muted);
  box-shadow: inset 0 0 0 2px var(--brand);
  z-index: 2;
}

.cal-cell.today .cal-num {
  background: var(--brand);
  color: var(--on-brand);
}

.cal-cell.today {
  background: color-mix(in srgb, var(--brand) 10%, var(--surface));
}

.cal-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
}

.cal-markers {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
}

.cal-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  flex-shrink: 0;
}

.cal-dot.has-high {
  background: var(--danger);
}

.cal-count {
  font-size: 11px;
  font-weight: 650;
  color: var(--text-muted);
}

.cal-side {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 280px;
  max-height: 520px;
  overflow: auto;
}

.cal-side h4 {
  font-size: 15px;
  font-weight: 650;
  margin-bottom: 4px;
}

.cal-side .cs-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.cal-ticket {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.cal-ticket:hover {
  border-color: var(--brand);
}

.cal-ticket .ct-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.cal-ticket .ct-id {
  font-weight: 650;
  font-size: 13px;
}

.cal-ticket .ct-cat {
  font-size: 13px;
  margin-bottom: 2px;
}

.cal-ticket .ct-meta {
  font-size: 12px;
  color: var(--text-muted);
}

@media (max-width: 900px) {
  .cal-wrap {
    grid-template-columns: 1fr;
  }
  .cal-cell {
    min-height: 56px;
    aspect-ratio: auto;
  }
}

/* ─── Contrast theme enhancements ────────────────────────────────────────────── */

[data-theme="contrast"] .card,
[data-theme="contrast"] .stat-card,
[data-theme="contrast"] .worker-card,
[data-theme="contrast"] .toolbar,
[data-theme="contrast"] .kb-card,
[data-theme="contrast"] .cal-side,
[data-theme="contrast"] .cal-cell:not(.empty-cell) {
  border-width: 2px;
}

/* ─── View modes: desktop / mobile ───────────────────────────────────────────── */

.view-desktop .sidebar {
  width: var(--sidebar-width);
  position: fixed;
  transform: none;
}

.view-desktop .main-content {
  margin-left: var(--sidebar-width);
}

.view-desktop .hamburger {
  display: none;
}

.view-desktop .drawer-overlay {
  display: none;
}

.view-mobile .sidebar {
  width: 270px;
  max-width: 84vw;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  transform: translateX(-100%);
  transition: transform 0.2s ease;
  box-shadow: var(--shadow-lg);
}

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

.view-mobile .main-content {
  margin-left: 0;
  width: 100%;
  padding: 14px 16px 28px;
}

.view-mobile .hamburger {
  display: flex;
}

.view-mobile .profile-grid {
  grid-template-columns: 1fr;
}

.view-mobile .stats-row {
  grid-template-columns: repeat(2, 1fr);
}

.view-mobile .page-title {
  font-size: 18px;
}

.view-mobile #page-ratings > div {
  grid-template-columns: 1fr !important;
}

.view-mobile .cal-grid .cal-cell {
  min-height: 46px;
}

.view-mobile .cal-wrap {
  grid-template-columns: 1fr;
}

.view-mobile .tm-grid {
  grid-template-columns: 1fr;
}

.view-mobile .filter-grid {
  grid-template-columns: 1fr;
}

/* ─── Reduced motion ─────────────────────────────────────────────────────────── */

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


/* Edit form grid */
.edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
  margin-bottom: 18px;
}
@media (max-width: 700px) {
  .edit-grid { grid-template-columns: 1fr; }
}
.sidebar-brand-text strong {
  font-family: var(--font-ui) !important;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
}
.auth-brand h2 {
  font-family: var(--font-ui) !important;
  font-weight: 600;
}
.page-title {
  font-family: var(--font-ui) !important;
  font-weight: 600;
  letter-spacing: -0.02em;
}


.nav-item .bi, .btn-logout .bi, .page-title .bi, .icon-btn .bi,
.btn-sm .bi, .btn-primary .bi, .btn-refresh .bi, .chip .bi,
.kb-mini .bi, .toast .bi, .empty .icon .bi, .auth-ico .bi,
.danger-title .bi, .field-label .bi {
  margin-right: 0.35em;
  vertical-align: -0.1em;
}
.icon-btn .bi { margin-right: 0; font-size: 1.1em; }
.hamburger .bi { margin: 0; font-size: 1.25em; }
.empty .icon { font-size: 1.75rem; opacity: 0.55; color: var(--text-subtle, var(--text3)); }
.empty .icon .bi { margin: 0; font-size: inherit; }
.auth-ico { font-size: 2rem; color: var(--brand, #0f62fe); margin-bottom: 12px; text-align: center; }
.stars .bi { color: var(--warning, #b45309); margin-right: 2px; }
.tm-close .bi { margin: 0; }

/* ─── Bootstrap bridge + security UX ─────────────────────────────────────────── */

:root,
[data-theme] {
  --bs-body-font-family: var(--font-ui);
  --bs-body-bg: var(--page-bg);
  --bs-body-color: var(--text);
  --bs-primary: var(--brand);
  --bs-border-color: var(--border);
  --bs-border-radius: var(--radius);
  --bs-link-color: var(--text-link);
  --bs-secondary-color: var(--text-muted);
}

.card {
  box-shadow: var(--shadow-sm);
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
  border-radius: var(--radius) !important;
}

.card-header {
  background: transparent !important;
  border-bottom-color: var(--border) !important;
  color: var(--text) !important;
}

.card-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-control {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: var(--radius) !important;
  font-size: 14px !important;
  padding: 0.55rem 0.75rem !important;
  box-shadow: none !important;
}

.form-control:focus {
  border-color: var(--brand) !important;
  box-shadow: 0 0 0 3px var(--brand-muted) !important;
}

.form-control::placeholder {
  color: var(--text-subtle) !important;
}

.auth-card form {
  margin: 0;
}

#auth-overlay .btn-primary {
  margin-top: 4px;
}

/* Bootstrap .modal is display:none — our dialogs use .crm-modal */
.crm-modal {
  display: block;
}

.auth-2fa-title { color: var(--text); font-weight: 700; margin-bottom: 4px; }
.auth-2fa-hint { color: var(--text-muted); font-size: 13px; margin: 0; line-height: 1.45; }

.security-block { display: flex; flex-direction: column; gap: 12px; }
.security-block-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.security-title { font-size: 14px; font-weight: 650; color: var(--text); display: flex; align-items: center; gap: 8px; }
.security-desc { margin-top: 4px; font-size: 12.5px; color: var(--text-muted); line-height: 1.45; }
.security-pill {
  flex-shrink: 0; font-size: 11px; font-weight: 650; padding: 4px 10px;
  border-radius: 999px; border: 1px solid var(--border);
  color: var(--text-muted); background: var(--surface-sunken);
}
.security-pill.on {
  color: var(--success); background: var(--success-dim);
  border-color: color-mix(in srgb, var(--success) 35%, var(--border));
}
.security-divider { margin: 20px 0; border: 0; border-top: 1px solid var(--border); opacity: 1; }
.security-ok { display: flex; align-items: center; gap: 8px; color: var(--success); font-size: 13px; margin: 0; }

.totp-setup {
  background: var(--surface-sunken); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.totp-steps { margin: 0 0 10px 18px; padding: 0; color: var(--text-muted); font-size: 12.5px; line-height: 1.5; }
.totp-qr-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.totp-qr-side { flex: 1; min-width: 180px; }
.totp-qr-wrap { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
.totp-qr {
  width: 180px; height: 180px; border-radius: var(--radius);
  border: 1px solid var(--border); background: #fff; padding: 8px;
  object-fit: contain;
}
.totp-qr-thumb {
  width: 112px;
  height: 112px;
  padding: 6px;
  flex-shrink: 0;
}
.totp-secret-box { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.totp-secret {
  display: block; font-family: var(--font-mono); font-size: 12.5px; letter-spacing: 0.06em;
  word-break: break-all; padding: 8px 10px; background: var(--surface);
  border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--text);
}
.totp-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn-ghost-sm.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.btn-ghost-sm.danger:hover { background: var(--danger-dim); }
.nav-item .bi { margin-right: 0 !important; }
.sidebar-nav { flex: 1; padding: 8px 8px; overflow-y: auto; }
