/* ===== CSS VARIABLES ===== */
:root {
  --bg:              #f9fafb;
  --bg-nav:          #ffffff;
  --bg-card:         #ffffff;
  --bg-table-header: #f9fafb;
  --bg-hover:        #f0f4ff;
  --bg-input:        #ffffff;
  --bg-auth:         linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  --text:            #1a1a2e;
  --text-muted:      #888888;
  --text-subtle:     #555555;
  --border:          #eeeeee;
  --border-input:    #e2e8f0;
  --border-light:    #f0f0f0;
  --shadow-sm:       rgba(0,0,0,0.05);
  --shadow-md:       rgba(0,0,0,0.15);
  --comment-internal-bg: #fffbeb;
  --comment-border-bottom: #f0f0f0;
}

html.dark {
  --bg:              #0f172a;
  --bg-nav:          #1e293b;
  --bg-card:         #1e293b;
  --bg-table-header: #162032;
  --bg-hover:        #1e3a5f;
  --bg-input:        #0f172a;
  --bg-auth:         linear-gradient(135deg, #0a1628 0%, #1e3a5f 100%);
  --text:            #e2e8f0;
  --text-muted:      #94a3b8;
  --text-subtle:     #94a3b8;
  --border:          #334155;
  --border-input:    #334155;
  --border-light:    #253347;
  --shadow-sm:       rgba(0,0,0,0.25);
  --shadow-md:       rgba(0,0,0,0.4);
  --comment-internal-bg: #2a2010;
  --comment-border-bottom: #253347;
}

/* ===== BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: var(--text); line-height: 1.6; background: var(--bg); transition: background 0.2s, color 0.2s; }

/* ===== NAV ===== */
nav { display: flex; align-items: center; gap: 1.5rem; padding: .75rem 2rem; border-bottom: 1px solid var(--border); background: var(--bg-nav); }
.logo { font-size: 1.25rem; font-weight: 700; text-decoration: none; color: var(--text); }
.nav-brand { display: flex; align-items: center; gap: 0.6rem; }
.nav-links { display: flex; gap: 1rem; align-items: center; margin: 0 auto; }
.nav-links a { text-decoration: none; color: var(--text-subtle); font-size: 0.9rem; }
.nav-links a:hover { color: #2563eb; }
.nav-right { display: flex; align-items: center; }
.nav-user { color: var(--text-muted); font-size: 0.85rem; }

/* Theme toggle (standalone, kept for compat) */
.theme-toggle { background: none; border: 1px solid var(--border-input); border-radius: 6px; padding: 0.2rem 0.55rem; cursor: pointer; font-size: 1rem; color: var(--text-subtle); line-height: 1; transition: background 0.15s; }
.theme-toggle:hover { background: var(--bg-hover); }

/* ===== USER HOVER MENU ===== */
.user-menu-wrap {
  position: relative;
  display: inline-block;
  padding-bottom: 8px; /* bridge: keeps hover active while moving to menu */
}
.user-menu-trigger {
  display: flex; align-items: center;
  padding: .2rem;
  border-radius: 50%;
  cursor: default; user-select: none;
  position: relative;
}

/* avatar circle */
.uhm-ava {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #1e3a5f, #2563eb);
  color: #fff; font-size: .7rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: .02em;
  transition: box-shadow .15s;
  flex-shrink: 0;
}
.user-menu-wrap:hover .uhm-ava {
  box-shadow: 0 0 0 3px rgba(37,99,235,.2);
}

/* green online ring */
.uhm-ava-ring {
  position: absolute; bottom: 2px; right: 2px;
  width: 9px; height: 9px; border-radius: 50%;
  background: #22c55e;
  border: 2px solid var(--bg-nav);
}

/* profile header inside dropdown */
.uhm-profile {
  display: flex; align-items: center; gap: .75rem;
  padding: .85rem 1rem .8rem;
}
.uhm-profile-ava {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #1e3a5f, #2563eb);
  color: #fff; font-size: .78rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; letter-spacing: .02em;
}
.uhm-profile-name {
  font-size: .87rem; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.uhm-profile-info { display: flex; flex-direction: column; min-width: 0; }
.uhm-profile-role {
  font-size: .72rem; color: var(--text-muted); margin-top: .08rem;
}

/* dropdown panel */
.user-hover-menu {
  display: none;
  flex-direction: column;
  position: absolute; right: 0; top: calc(100% - 8px);
  z-index: 500;
  min-width: 195px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px var(--shadow-md);
  overflow: hidden;
}
.user-menu-wrap:hover .user-hover-menu { display: flex; }

/* sections */
.uhm-section {
  padding: .45rem 1rem .2rem;
  font-size: .7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted);
}
.uhm-langs {
  display: flex; gap: .3rem; flex-wrap: wrap;
  padding: .3rem 1rem .5rem;
}
.uhm-lang-pill {
  padding: .2rem .5rem; border-radius: 5px;
  font-size: .78rem; font-weight: 700;
  letter-spacing: .03em; text-decoration: none; text-transform: uppercase;
  color: var(--text-subtle);
  border: 1.5px solid var(--border-input);
  transition: background .12s, color .12s, border-color .12s;
}
.uhm-lang-pill:hover { color: #2563eb; border-color: #2563eb; background: #eff6ff; }
.uhm-lang-pill.active { background: #eff6ff; color: #2563eb; border-color: #2563eb; }
html.dark .uhm-lang-pill.active { background: #1e3a5f; }
html.dark .uhm-lang-pill:hover { background: #1e3a5f; }

.uhm-divider { height: 1px; background: var(--border-light); margin: .2rem 0; }

.uhm-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: .5rem 1rem;
  font-size: .85rem; color: var(--text);
}
.uhm-theme-btn {
  border: 1px solid var(--border-input);
  border-radius: 6px; padding: .1rem .45rem;
  cursor: pointer; font-size: .95rem;
  color: var(--text-subtle); background: none;
  line-height: 1.4;
}
.uhm-theme-btn:hover { background: var(--bg-hover); }

.uhm-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem 1rem;
  font-size: .85rem; color: var(--text);
  text-decoration: none; background: none;
  border: none; cursor: pointer; width: 100%; text-align: left;
  transition: background .12s, color .12s;
}
.uhm-item:hover { background: var(--bg-hover); color: #2563eb; }
.uhm-item-danger { color: #dc2626 !important; }
.uhm-item-danger:hover { background: #fef2f2 !important; color: #dc2626 !important; }
html.dark .uhm-item-danger:hover { background: #2a1515 !important; }

/* Settings — two-column grid for Profile/Security/Org cards */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.settings-grid > .card { margin-bottom: 0; }
.settings-grid > .card-full { grid-column: 1 / -1; }

/* ===== MODAL (confirm + form) ===== */
.s-modal-backdrop { display:none; position:fixed; inset:0; background:rgba(0,0,0,.48); z-index:900; align-items:center; justify-content:center; }
.s-modal-backdrop.is-open { display:flex; }
.s-modal-box { background:var(--bg-card); border-radius:14px; padding:1.75rem 2rem; max-width:440px; width:90%; box-shadow:0 12px 48px rgba(0,0,0,.22); border:1px solid var(--border); }
.s-modal-title { font-size:1rem; font-weight:600; margin:0 0 .6rem; color:var(--text); }
.s-modal-msg { margin:0 0 1.25rem; font-size:.9rem; line-height:1.6; color:var(--text-subtle); }
.s-modal-actions { display:flex; gap:.6rem; justify-content:flex-end; margin-top:1rem; }
.s-modal-box .form-group:last-of-type { margin-bottom:0; }

/* Card header with title left + action button right */
.card-header-row { display:flex; align-items:flex-start; justify-content:space-between; gap:1rem; margin-bottom:.75rem; }
.card-header-row > div { min-width:0; flex:1; }
.card-header-row h2 { margin:0 0 .15rem; }
.card-header-row .card-subtitle { margin:0; color:var(--text-muted); font-size:.875rem; }
.card-header-row .btn { flex-shrink:0; }

/* Uniform button size inside .settings-grid */
.settings-grid .btn:not(.btn-icon) { padding:.45rem 1rem; font-size:.875rem; border-radius:8px; }

/* Demo data card */
.demo-data-card { border: 1.5px solid var(--border-light); display: flex; flex-direction: column; }
.demo-data-card.demo-locked { opacity: .7; }
.demo-head-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .4rem; }
.demo-head-row h2 { margin: 0; }
.demo-desc { margin-bottom: .9rem; }
.mail-permissions-note { padding: .75rem 1rem; background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 8px; margin-bottom: .25rem; }
.mail-permissions-note code { background: #e0f2fe; padding: .1rem .4rem; border-radius: 4px; font-size: .82rem; }
html.dark .mail-permissions-note { background: #0c1f2e; border-color: #0369a1; }
html.dark .mail-permissions-note code { background: #0a2233; }
.demo-locked-msg { display: flex; align-items: center; gap: .5rem; padding: .6rem .85rem; background: #fef3c7; border: 1px solid #fde68a; border-radius: 8px; font-size: .875rem; color: #92400e; }
.demo-badge { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .75rem; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 99px; font-size: .8rem; color: #1e40af; white-space: nowrap; }
.demo-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: auto; padding-top: .5rem; }
.demo-actions button:disabled { opacity: .45; cursor: not-allowed; }

/* Demo "what's included" feature list */
.demo-features { background: var(--bg); border: 1px solid var(--border-light); border-radius: 8px; padding: .85rem 1rem; margin: 0 0 .9rem; }
.demo-features-heading { font-size: .68rem; font-weight: 700; color: var(--text-muted); margin: 0 0 .6rem; text-transform: uppercase; letter-spacing: .08em; }
.demo-features-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.demo-features-list li { display: flex; align-items: flex-start; gap: .55rem; font-size: .85rem; color: var(--text); line-height: 1.45; }
.demo-features-list li svg { flex-shrink: 0; margin-top: 2px; color: #2563eb; }

/* Read-only inputs rendered as quiet text (no "disabled" look) */
.input-readonly, input[readonly].input-readonly { background: transparent; color: var(--text-muted); border-color: var(--border-light); cursor: text; }
.input-readonly:focus { outline: none; border-color: var(--border-input); color: var(--text); }

/* Usage bars (org card) */
.usage-list { display: flex; flex-direction: column; gap: .6rem; margin-top: .5rem; }
.usage-label { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: .15rem; }
.usage-bar { height: .45rem; background: var(--border-light); border-radius: 999px; overflow: hidden; }
.usage-fill { height: 100%; border-radius: 999px; transition: width .2s, background .2s; }
.usage-fill.usage-ok { background: #10b981; }
.usage-fill.usage-warn { background: #f59e0b; }
.usage-fill.usage-danger { background: #ef4444; }

/* Password field: eye toggle and live hints */
.pw-wrap { position: relative; display: flex; align-items: center; }
.pw-wrap input { flex: 1; padding-right: 2.25rem; }
.pw-toggle { position: absolute; right: .25rem; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: 1rem; padding: .25rem .4rem; line-height: 1; color: var(--text-muted); }
.pw-toggle:hover { color: var(--text); }
.pw-hint { display: block; margin-top: .25rem; font-size: .8rem; color: var(--text-muted); }
.pw-hint.pw-hint-ok { color: #059669; }
.pw-hint.pw-hint-bad { color: #dc2626; }

/* Categories table */
.categories-table .cat-inline { width: 100%; border: 1px solid transparent; background: transparent; padding: .35rem .5rem; border-radius: 6px; color: var(--text); }
.categories-table .cat-inline:hover { border-color: var(--border-light); }
.categories-table .cat-inline:focus { border-color: var(--border-input); background: var(--bg-card); outline: none; }
.categories-table tr.cat-is-default { background: linear-gradient(90deg, rgba(37,99,235,0.06), transparent 40%); }
.categories-table .cat-actions { text-align: right; white-space: nowrap; }
.btn-icon { background: none; border: 1px solid transparent; border-radius: 6px; padding: .2rem .45rem; cursor: pointer; font-size: 1rem; line-height: 1; color: var(--text-muted); transition: background .15s, color .15s, border-color .15s; }
.btn-icon:hover { background: var(--bg-hover); color: var(--text); }
.btn-icon.is-active { color: #f59e0b; cursor: default; }
.btn-icon.btn-icon-primary { color: #2563eb; }
.btn-icon.btn-icon-primary:hover { background: rgba(37,99,235,0.1); }
.btn-icon.btn-icon-danger { color: #dc2626; }
.btn-icon.btn-icon-danger:hover { background: rgba(220,38,38,0.1); }
.btn-icon[disabled] { opacity: 0.35; cursor: not-allowed; }
@media (max-width: 720px) { .settings-grid { grid-template-columns: 1fr; } }

/* Fixed lang/theme pill on auth pages */
.auth-pill { position: fixed; top: 1rem; right: 1rem; z-index: 10; display: flex; gap: .4rem; align-items: center; font-size: .8rem; background: var(--bg-card); color: var(--text); padding: .4rem .6rem; border-radius: 999px; box-shadow: 0 1px 4px var(--shadow-sm); border: 1px solid var(--border-input); }
.auth-pill a { color: var(--text-muted); text-decoration: none; text-transform: uppercase; }
.auth-pill a:hover { color: #2563eb; }
.auth-pill .active { font-weight: 700; color: #2563eb; text-transform: uppercase; }
.auth-pill .sep { color: var(--border-input); }
.auth-pill button { background: none; border: none; cursor: pointer; padding: 0 .1rem; font-size: 1rem; line-height: 1; color: var(--text-muted); }
.auth-pill button:hover { color: #2563eb; }

/* ===== LAYOUT ===== */
main { padding: 2rem; max-width: 1200px; margin: 0 auto; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.5rem; }

/* ===== BUTTONS ===== */
.btn { display: inline-block; padding: 0.5rem 1.25rem; border-radius: 8px; text-decoration: none; font-weight: 500; border: 1px solid var(--border); color: var(--text); cursor: pointer; font-size: 0.9rem; background: var(--bg-card); }
.btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { background: #ef4444; color: #fff; border-color: #ef4444; }
.btn-sm { padding: 0.25rem 0.75rem; font-size: 0.8rem; }
.btn-full { width: 100%; text-align: center; }
.btn-active { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-subtle); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border); }

/* ===== AUTH ===== */
.auth-page { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: var(--bg-auth); }
.auth-card { background: var(--bg-card); padding: 2.5rem; border-radius: 16px; box-shadow: 0 25px 50px var(--shadow-md); width: 100%; max-width: 400px; }
.auth-logo { text-align: center; font-size: 1.5rem; font-weight: 800; color: var(--text); letter-spacing: -0.03em; margin-bottom: 0.25rem; }
.auth-subtitle { text-align: center; color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.75rem; }
.auth-card h1 { margin-bottom: 1.5rem; text-align: center; }
.auth-link { text-align: center; margin-top: 1rem; color: var(--text-muted); font-size: 0.9rem; }
.auth-link a { color: #2563eb; text-decoration: none; }
.auth-link a:hover { text-decoration: underline; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.25rem; font-weight: 500; font-size: 0.9rem; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 0.625rem 0.75rem; border: 1px solid var(--border-input); border-radius: 8px; font-size: 0.95rem; font-family: inherit; outline: none; transition: border-color 0.15s, box-shadow 0.15s; background: var(--bg-input); color: var(--text); }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.form-group input::placeholder { color: var(--text-muted); }
.form-group textarea { resize: vertical; }
.field-hint { margin-top: .35rem; font-size: .78rem; color: var(--text-muted); }
.form-card { background: var(--bg-card); padding: 1.5rem; border-radius: 8px; max-width: 600px; box-shadow: 0 1px 3px var(--shadow-sm); }
.form-card--wide { max-width: none; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* Sidebar inline edit (ticket detail) */
.sidebar-edit { margin: .3rem 0; }
.btn-edit-sm { cursor: pointer; font-size: .8rem; color: #2563eb; list-style: none; display: inline-block; }
.btn-edit-sm::-webkit-details-marker { display: none; }
.btn-edit-sm:hover { text-decoration: underline; }
.sidebar-form { display: flex; gap: .4rem; align-items: center; margin-top: .3rem; }
.sidebar-form select { flex: 1; padding: .3rem .5rem; border: 1px solid var(--border-input); border-radius: 6px; font-size: .85rem; background: var(--bg-input); color: var(--text); }

/* Watcher chips */
.watcher-list { display: flex; flex-wrap: wrap; gap: .3rem; margin: .3rem 0; }
.watcher-chip { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .5rem; border: 1px solid var(--border-input); border-radius: 999px; font-size: .8rem; background: var(--bg-card); color: var(--text); }
.watcher-remove { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1rem; line-height: 1; padding: 0; }
.watcher-remove:hover { color: #ef4444; }

/* Agent category picker (users page) */
details.cat-edit { display: inline-block; }
details.cat-edit > summary { cursor: pointer; padding: 0.15rem 0.55rem; border: 1px solid var(--border-input); border-radius: 999px; font-size: 0.85rem; color: var(--text-muted); background: var(--bg-card); list-style: none; user-select: none; }
details.cat-edit > summary::-webkit-details-marker { display: none; }
details.cat-edit > summary:hover { color: var(--text); }
details.cat-edit[open] > summary { color: #2563eb; border-color: #2563eb; }
.cat-form { position: relative; margin-top: .4rem; padding: .6rem .75rem; background: var(--bg-card); border: 1px solid var(--border-input); border-radius: 8px; box-shadow: 0 4px 10px var(--shadow-sm); display: flex; flex-direction: column; gap: .3rem; min-width: 220px; z-index: 5; }
.cat-form .cat-option { display: flex; align-items: center; gap: .45rem; font-size: .9rem; cursor: pointer; }
.cat-form .cat-option input { margin: 0; }
.cat-form button { align-self: flex-start; margin-top: .4rem; }

/* Drag-and-drop dropzone (ticket create form) */
.dropzone { border: 2px dashed var(--border-input); border-radius: 8px; padding: 1.5rem; text-align: center; cursor: pointer; transition: border-color 0.15s, background 0.15s, color 0.15s; color: var(--text-subtle); outline: none; }
.dropzone:hover, .dropzone:focus { border-color: #2563eb; color: var(--text); }
.dropzone--active { border-color: #2563eb; background: var(--bg-hover); color: var(--text); }
.dropzone-hint { margin: 0; font-size: 0.9rem; }
.file-chips { list-style: none; margin: 0.5rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.file-chips li { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.25rem 0.6rem; border: 1px solid #bbf7d0; border-left: 3.5px solid #22c55e; border-radius: 999px; font-size: 0.85rem; background: #f0fdf4; color: #166534; }
html.dark .file-chips li { background: #052e16; border-color: #166534; border-left-color: #22c55e; color: #86efac; }
.file-chips button { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1rem; line-height: 1; padding: 0; }
.file-chips button:hover { color: #ef4444; }
.file-error { margin: 0.4rem 0 0; padding: 0.35rem 0.7rem; font-size: 0.84rem; color: #b91c1c; background: #fef2f2; border: 1px solid #fecaca; border-radius: 6px; line-height: 1.4; }
html.dark .file-error { color: #fca5a5; background: #2a0f0f; border-color: #7f1d1d; }
.form-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }
.inline-form { display: flex; gap: 0.5rem; margin-top: 1rem; align-items: center; }
.inline-form input { padding: 0.4rem 0.75rem; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-input); color: var(--text); }

/* ===== STATS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--bg-card); padding: 1.25rem; border-radius: 8px; text-align: center; box-shadow: 0 1px 3px var(--shadow-sm); }
.stat-number { font-size: 2rem; font-weight: 700; }
.stat-label { color: var(--text-muted); font-size: 0.85rem; }
.stat-warning .stat-number { color: #f59e0b; }
.stat-success .stat-number { color: #10b981; }

/* ===== BADGES ===== */
.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.75rem; font-weight: 500; background: #e5e7eb; color: #374151; }
.badge-lg { font-size: 0.9rem; padding: 0.25rem 0.75rem; }
.badge-new { background: #dbeafe; color: #1e40af; }
.badge-assigned { background: #fef3c7; color: #92400e; }
.badge-in_progress { background: #e0e7ff; color: #3730a3; }
.badge-in_review { background: #ede9fe; color: #5b21b6; }
.badge-waiting_client { background: #fef3c7; color: #92400e; }
.badge-resolved { background: #d1fae5; color: #065f46; }
.badge-closed { background: #f3f4f6; color: #6b7280; }
.badge-reopened { background: #fee2e2; color: #991b1b; }
.badge-priority-low      { background: #dcfce7; color: #15803d; }
.badge-priority-medium   { background: #f1f5f9; color: #64748b; }
.badge-priority-high     { background: #ffedd5; color: #c2410c; }
.badge-priority-critical { background: #fee2e2; color: #991b1b; }
.badge-internal { background: #fef3c7; color: #92400e; }
.badge-role { background: #e0e7ff; color: #3730a3; }
.badge-role-user { background: #e5e7eb; color: #374151; }
.badge-role-agent { background: #dbeafe; color: #1e40af; }
.badge-role-org_admin { background: #e0e7ff; color: #3730a3; }
.badge-role-superadmin { background: #fce7f3; color: #9d174d; }
.badge-active { background: #d1fae5; color: #065f46; }
.badge-inactive { background: #fee2e2; color: #991b1b; }

/* Role filter buttons */
.filter-badge { display: inline-block; padding: 0.25rem 0.75rem; border-radius: 4px; font-size: 0.8rem; font-weight: 500; text-decoration: none; opacity: 0.65; transition: opacity 0.15s; }
.filter-badge:hover, .filter-selected { opacity: 1; }
.filter-user { background: #e5e7eb; color: #374151; }
.filter-agent { background: #dbeafe; color: #1e40af; }
.filter-org_admin { background: #e0e7ff; color: #3730a3; }
.filter-deleted { background: #fee2e2; color: #991b1b; }

/* ===== TICKETS PAGE HEADER ===== */
.tkt-page-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tkt-page-header h1 { margin: 0; font-size: 1.5rem; font-weight: 700; }
.tkt-header-actions { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }

/* Filter button + panel (variant B) */
.tkt-filter-wrap { position: relative; }
/* Match "Новая заявка" height to filter/view-toggle buttons */
.tkt-header-actions .btn { padding: .38rem .9rem; font-size: .84rem; border-radius: 8px; }
.tkt-filter-btn { display: flex; align-items: center; gap: .4rem; border: 1.5px solid var(--border-input); border-radius: 8px; background: var(--bg-card); padding: .38rem .8rem; font-size: .84rem; color: var(--text-subtle); cursor: pointer; font-family: inherit; transition: border-color .12s, color .12s; }
.tkt-filter-btn:hover { border-color: #93c5fd; color: #2563eb; }
.tkt-filter-btn.has-filter { border-color: #2563eb; color: #2563eb; background: #eff6ff; }
html.dark .tkt-filter-btn.has-filter { background: #1e3a5f; }
.tkt-filter-cnt { background: #2563eb; color: #fff; border-radius: 99px; font-size: .65rem; font-weight: 700; padding: .05rem .38rem; min-width: 1rem; text-align: center; }

/* Filter panel dropdown */
.tkt-filter-panel { position: absolute; top: calc(100% + 6px); left: 0; width: 310px; background: var(--bg-card); border: 1.5px solid var(--border); border-radius: 12px; box-shadow: 0 8px 28px var(--shadow-md); z-index: 200; padding: 1rem; }
.tkt-filter-panel.hidden { display: none; }
.tfp-group { margin-bottom: .85rem; }
.tfp-group:last-of-type { margin-bottom: 0; }
.tfp-label { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: .5rem; }
.tfp-checks { display: flex; flex-wrap: wrap; gap: .3rem; }
.tfp-check { display: inline-flex; align-items: center; gap: .3rem; border: 1.5px solid var(--border-input); border-radius: 6px; padding: .22rem .6rem; font-size: .8rem; cursor: pointer; transition: .12s; user-select: none; color: var(--text-muted); }
.tfp-check input[type=checkbox] { display: none; }
.tfp-check.on { border-color: #2563eb; background: #eff6ff; color: #2563eb; font-weight: 600; }
html.dark .tfp-check.on { background: #1e3a5f; color: #93c5fd; border-color: #3b82f6; }
.tfp-check:hover:not(.on) { border-color: #93c5fd; color: #2563eb; }
/* ── Terminal-status toggles inside filter panel ── */
.tfp-toggles { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border-light, #f0f0f0); }
.tfp-toggle-row { display: flex; align-items: center; justify-content: space-between; }
.tfp-toggle-row span { font-size: .82rem; color: var(--text-subtle, #555); }
.fp-toggle { position: relative; width: 34px; height: 19px; display: inline-block; flex-shrink: 0; }
.fp-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.fp-slider { position: absolute; inset: 0; border-radius: 20px; background: #cbd5e1; transition: background .18s; cursor: pointer; }
.fp-slider::before { content: ''; position: absolute; width: 13px; height: 13px; border-radius: 50%; background: #fff; left: 3px; top: 3px; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.fp-toggle input:checked + .fp-slider { background: #2563eb; }
.fp-toggle input:checked + .fp-slider::before { transform: translateX(15px); }
html.dark .fp-slider { background: #475569; }
html.dark .fp-toggle input:checked + .fp-slider { background: #3b82f6; }

.tfp-footer { display: flex; align-items: center; justify-content: space-between; margin-top: .85rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.tfp-reset { background: none; border: none; color: var(--text-muted); font-size: .82rem; cursor: pointer; font-family: inherit; }
.tfp-reset:hover { color: #ef4444; }
.tfp-apply { background: #2563eb; color: #fff; border: none; border-radius: 7px; padding: .35rem .9rem; font-size: .82rem; font-weight: 600; cursor: pointer; font-family: inherit; }
.tfp-apply:hover { background: #1d4ed8; }

/* Category tabs (chip switcher for ticket category) */
.tkt-cat-tabs { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: .85rem; padding-bottom: .85rem; border-bottom: 1px solid var(--border-light); }
.tkt-cat-chip { display: inline-flex; align-items: center; gap: .4rem; background: var(--bg-card); border: 1.5px solid var(--border); color: var(--text-muted); border-radius: 99px; padding: .3rem .85rem; font-size: .82rem; font-weight: 600; text-decoration: none; transition: .12s; cursor: pointer; }
.tkt-cat-chip:hover { color: var(--text); border-color: var(--text-muted); }
.tkt-cat-chip.on { background: #2563eb; border-color: #2563eb; color: #fff; }
.tkt-cat-chip.on:hover { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.tkt-cat-cnt { background: var(--bg-hover); color: var(--text-muted); border-radius: 99px; padding: .04rem .42rem; font-size: .72rem; font-weight: 700; min-width: 1.4rem; text-align: center; }
.tkt-cat-chip.on .tkt-cat-cnt { background: rgba(255,255,255,.22); color: #fff; }
html.dark .tkt-cat-chip { background: var(--bg-card); }
html.dark .tkt-cat-chip.on { background: #3b82f6; border-color: #3b82f6; }
html.dark .tkt-cat-chip.on:hover { background: #2563eb; border-color: #2563eb; }

/* Active filter chips */
.tkt-active-chips { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin-bottom: .85rem; }
.tkt-achip { display: inline-flex; align-items: center; gap: .3rem; background: #eff6ff; border: 1.5px solid #93c5fd; color: #1d4ed8; border-radius: 99px; padding: .18rem .65rem; font-size: .78rem; font-weight: 600; text-decoration: none; transition: .12s; }
.tkt-achip:hover { background: #dbeafe; border-color: #2563eb; }
html.dark .tkt-achip { background: #1e3a5f; border-color: #3b82f6; color: #93c5fd; }
.tkt-achip-x { font-size: .85rem; opacity: .7; }
.tkt-achip-reset { font-size: .78rem; color: var(--text-muted); text-decoration: none; padding: .18rem .4rem; }
.tkt-achip-reset:hover { color: #ef4444; }

/* View segmented control */
.tkt-view-seg { display: flex; background: var(--bg-hover); border-radius: 8px; padding: 3px; gap: 2px; }
.tkt-vseg-btn { display: flex; align-items: center; gap: .32rem; border: none; background: none; border-radius: 6px; padding: .28rem .75rem; font-size: .8rem; font-weight: 600; color: var(--text-muted); cursor: pointer; text-decoration: none; transition: .12s; white-space: nowrap; }
.tkt-vseg-btn.on { background: var(--bg-card); color: var(--text); box-shadow: 0 1px 4px var(--shadow-md); }
.tkt-vseg-btn:hover:not(.on) { color: var(--text); }

/* ===== TICKET TABLE (list view) ===== */
.tkt-table { display: flex; flex-direction: column; background: var(--bg-card); border-radius: 8px; box-shadow: 0 1px 3px var(--shadow-sm); margin-bottom: 1rem; overflow: hidden; }
.tkt-thead { display: flex; align-items: center; gap: .75rem; padding: .35rem .5rem; font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); border-bottom: 2px solid var(--border); margin-bottom: .15rem; }
.tkt-trow { display: flex; align-items: center; gap: .75rem; padding: .65rem .5rem; border-bottom: 1px solid var(--border-light, var(--border)); text-decoration: none; color: var(--text); border-radius: 6px; transition: background .1s; font-size: .87rem; }
.tkt-trow:hover { background: var(--bg-hover); }
.tc-num    { min-width: 2.8rem; flex-shrink: 0; }
.tc-title  { flex: 1; min-width: 0; display: flex; align-items: center; }
.tc-title-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.tc-assignee { min-width: 5.5rem; flex-shrink: 0; display: flex; align-items: center; gap: .4rem; position: relative; }
.tc-assignee-empty { color: var(--text-muted); font-size: .82rem; }
.tkt-ava { width: 1.4rem; height: 1.4rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: .58rem; font-weight: 700; color: #fff; flex-shrink: 0; position: relative; cursor: default; }
.tkt-ava:hover .tkt-ava-tooltip { display: block; }
.tkt-ava-tooltip { display: none; position: absolute; bottom: 140%; left: 50%; transform: translateX(-50%); background: #1e293b; color: #fff; font-size: .72rem; padding: .25rem .55rem; border-radius: 5px; white-space: nowrap; pointer-events: none; z-index: 10; }
.tkt-ava-tooltip::after { content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 4px solid transparent; border-top-color: #1e293b; }
.tkt-ava-org_admin { background: #7c3aed; }
.tkt-ava-agent     { background: #059669; }
.tkt-ava-user      { background: #6b7280; }
.tc-status { min-width: 7rem; flex-shrink: 0; }
.tc-date   { min-width: 5.5rem; flex-shrink: 0; color: var(--text-muted); font-size: .8rem; text-align: right; }

/* ── Relative date + tooltip ── */
.rdate { position: relative; cursor: default; white-space: nowrap; }
.rdate::after {
  content: attr(data-d);
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  background: #1e293b;
  color: #f1f5f9;
  font-size: .71rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 5px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .15s;
  pointer-events: none;
  z-index: 20;
}
.rdate:hover::after { opacity: 1; }
.rdate.rdate-warn { color: #f97316; }
.rdate.rdate-old  { color: #ef4444; }
html.dark .rdate::after { background: #e2e8f0; color: #0f172a; }

/* ── Sortable column headers ── */
.tkt-sort-btn { display: inline-flex; align-items: center; gap: 3px; text-decoration: none; color: inherit; font-weight: inherit; letter-spacing: inherit; text-transform: inherit; font-size: inherit; white-space: nowrap; }
.tkt-sort-btn:hover { color: var(--primary, #3b82f6); }
.tkt-sort-btn.active { color: var(--primary, #3b82f6); }
.sort-icon { opacity: .4; font-size: .75em; line-height: 1; }
.tkt-sort-btn.active .sort-icon { opacity: .9; }

/* ── Priority pip + tooltip (variant B: colored) ── */
.pip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  margin-right: 10px;
  cursor: default;
}
.pip { display: inline-block; width: 3px; height: 16px; border-radius: 2px; }
.pip-critical .pip { background: #ef4444; }
.pip-high     .pip { background: #f97316; }
.pip-medium   .pip { background: #cbd5e1; }
.pip-low      .pip { background: #22c55e; }

.pip-tt {
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 20;
  color: #fff;
  font-size: .72rem;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 5px;
}
.pip-tt::after {
  content: '';
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
}
.pip-critical .pip-tt { background: #ef4444; }
.pip-critical .pip-tt::after { border-top-color: #ef4444; }
.pip-high     .pip-tt { background: #f97316; }
.pip-high     .pip-tt::after { border-top-color: #f97316; }
.pip-medium   .pip-tt { background: #94a3b8; }
.pip-medium   .pip-tt::after { border-top-color: #94a3b8; }
.pip-low      .pip-tt { background: #22c55e; }
.pip-low      .pip-tt::after { border-top-color: #22c55e; }
.pip-wrap:hover .pip-tt { opacity: 1; }
.tkt-num   { color: #2563eb; font-weight: 700; }

/* ===== KANBAN BOARD ===== */
.kanban-board { display: flex; gap: .85rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; margin-top: .25rem; }
.kanban-board::-webkit-scrollbar { height: 6px; }
.kanban-board::-webkit-scrollbar-track { background: var(--bg); border-radius: 3px; }
.kanban-board::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.kanban-col { flex: 0 0 210px; border-radius: 10px; background: var(--bg-hover); transition: box-shadow .15s; }
.kanban-col--over { box-shadow: 0 0 0 2px #2563eb; background: #eff6ff; }
html.dark .kanban-col--over { background: #1e3a5f; }

.kanban-col-head { display: flex; align-items: center; justify-content: space-between; padding: .6rem .85rem; border-bottom: 1px solid var(--border); }
.kanban-col-label { font-size: .78rem; font-weight: 700; color: var(--text-subtle); }
.kanban-cnt { background: var(--border); color: var(--text-muted); border-radius: 99px; font-size: .65rem; font-weight: 700; padding: .05rem .4rem; min-width: 1.2rem; text-align: center; }

/* Column accent colours */
.kst-new .kanban-col-head         { border-top: 3px solid #3b82f6; border-radius: 10px 10px 0 0; }
.kst-assigned .kanban-col-head    { border-top: 3px solid #f59e0b; border-radius: 10px 10px 0 0; }
.kst-in_progress .kanban-col-head { border-top: 3px solid #8b5cf6; border-radius: 10px 10px 0 0; }
.kst-waiting_client .kanban-col-head { border-top: 3px solid #ec4899; border-radius: 10px 10px 0 0; }
.kst-in_review .kanban-col-head   { border-top: 3px solid #06b6d4; border-radius: 10px 10px 0 0; }
.kst-resolved .kanban-col-head    { border-top: 3px solid #22c55e; border-radius: 10px 10px 0 0; }
.kst-closed .kanban-col-head      { border-top: 3px solid #94a3b8; border-radius: 10px 10px 0 0; }

.kanban-col-body { padding: .5rem .45rem .65rem; display: flex; flex-direction: column; gap: .4rem; min-height: 80px; }

/* Kanban card */
.kanban-card { background: var(--bg-card); border-radius: 8px; padding: .45rem .65rem .45rem .55rem; box-shadow: 0 1px 2px var(--shadow-md); cursor: grab; border-left: 4px solid #cbd5e1; transition: box-shadow .15s; user-select: none; }
.kanban-card:hover { box-shadow: 0 3px 10px var(--shadow-md); }
.kanban-card:active { cursor: grabbing; }
.kcard-dragging { opacity: .45; transform: rotate(2deg); }
.kp-critical { border-left-color: #ef4444; }
.kp-high     { border-left-color: #f97316; }
.kp-medium   { border-left-color: #94a3b8; }
.kp-low      { border-left-color: #22c55e; }

.kanban-card-num   { font-size: .65rem; color: var(--text-muted); margin-bottom: .15rem; font-weight: 600; }
.kanban-card-title { font-size: .8rem; color: var(--text); line-height: 1.35; margin-bottom: .35rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kanban-card-meta  { display: flex; align-items: center; justify-content: space-between; gap: .4rem; border-top: 1px solid var(--border); padding-top: .3rem; }
.kanban-card-date  { font-size: .65rem; color: var(--text-muted); white-space: nowrap; }
.kanban-card-noava { width: 1.2rem; height: 1.2rem; border-radius: 50%; border: 1.5px dashed var(--border); flex-shrink: 0; }

/* Error toast */
.kb-toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); background: #dc2626; color: #fff; border-radius: 8px; padding: .6rem 1.2rem; font-size: .85rem; font-weight: 600; z-index: 9999; box-shadow: 0 4px 16px rgba(0,0,0,.2); pointer-events: none; }

/* ===== TICKETS (legacy list — kept for detail page refs) ===== */
.ticket-list { display: flex; flex-direction: column; gap: 0.25rem; }
.ticket-row { display: flex; align-items: center; gap: 1rem; padding: 0.75rem 1rem; background: var(--bg-card); border-radius: 6px; text-decoration: none; color: var(--text); transition: background 0.15s; }
.ticket-row:hover { background: var(--bg-hover); }
.ticket-number { font-weight: 600; color: #2563eb; min-width: 50px; }
.ticket-title { flex: 1; }
.ticket-date { color: var(--text-muted); font-size: 0.85rem; }
.filters { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }

/* Ticket detail — header */
.tkt-detail-header { display:flex; align-items:center; justify-content:space-between; gap:1rem; padding:.5rem 0 1rem; flex-wrap:wrap; }
.tkt-detail-header-left { display:flex; align-items:center; gap:.6rem; flex-wrap:wrap; min-width:0; }
.tkt-detail-num { color:var(--text-muted); font-weight:600; font-size:.9rem; white-space:nowrap; }
.tkt-detail-title { font-size:1.2rem; font-weight:700; margin:0; line-height:1.3; }

/* Status banner inside description card */
.status-banner { display:flex; align-items:center; gap:.75rem; padding:.6rem 1.25rem; margin:-1.25rem -1.25rem 1.25rem; border-radius:8px 8px 0 0; border-bottom:1.5px solid; flex-wrap:wrap; }
.status-banner-new            { background:#eff6ff; border-color:#bfdbfe; }
.status-banner-assigned       { background:#f5f3ff; border-color:#ddd6fe; }
.status-banner-in_progress    { background:#fefce8; border-color:#fde68a; }
.status-banner-in_review      { background:#fff7ed; border-color:#fed7aa; }
.status-banner-waiting_client { background:#fdf4ff; border-color:#f0abfc; }
.status-banner-resolved       { background:#f0fdf4; border-color:#bbf7d0; }
.status-banner-closed         { background:#f8fafc; border-color:#e2e8f0; }
.status-banner-reopened       { background:#fff7ed; border-color:#fed7aa; }
.status-banner-label { font-size:.72rem; font-weight:700; text-transform:uppercase; letter-spacing:.07em; color:var(--text-muted); white-space:nowrap; }
.status-banner .sidebar-form { margin:0; margin-left:auto; }

/* Ticket detail — grid & common */
.ticket-detail-grid { display: grid; grid-template-columns: 1fr 300px; gap: 1.5rem; }
@media (max-width: 768px) { .ticket-detail-grid { grid-template-columns: 1fr; } }
.ticket-description p { white-space: pre-wrap; }
.ticket-meta { margin-top: 1rem; color: var(--text-muted); font-size: 0.85rem; display: flex; gap: 1rem; }
.detail-row { display: flex; justify-content: space-between; padding: 0.25rem 0; font-size: 0.9rem; }
.sidebar-form { margin-top: 0.5rem; display: flex; gap: 0.5rem; }
.sidebar-form select { flex: 1; padding: 0.3rem; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-input); color: var(--text); }

/* ===== COMMENTS ===== */
.comment { padding: .85rem .75rem; border-bottom: 1px solid var(--comment-border-bottom); }
.comment:last-child { border-bottom: none; }
.comment-internal { background: var(--comment-internal-bg); border-left: 3px solid #f59e0b; }
.comment-header { display: flex; gap: .65rem; align-items: flex-start; margin-bottom: .5rem; }
/* Avatar */
.comment-ava { width: 2rem; height: 2rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .68rem; font-weight: 700; flex-shrink: 0; color: #fff; margin-top: .05rem; }
.comment-ava-user     { background: #6b7280; }
.comment-ava-agent    { background: #059669; }
.comment-ava-org_admin { background: #7c3aed; }
/* Meta */
.comment-meta { display: flex; flex-direction: column; gap: .15rem; flex: 1; min-width: 0; }
.comment-author-row { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.comment-author-name { font-weight: 600; font-size: .875rem; }
.comment-role-badge { font-size: .7rem; padding: .1rem .5rem; border-radius: 99px; font-weight: 500; line-height: 1.4; }
.comment-role-user      { background: #f1f5f9; color: #475569; }
.comment-role-agent     { background: #d1fae5; color: #065f46; }
.comment-role-org_admin { background: #ede9fe; color: #5b21b6; }
.comment-time { font-size: .75rem; color: var(--text-muted); }
/* Count badge next to section heading */
.comment-count { display: inline-flex; align-items: center; justify-content: center; min-width: 1.4rem; height: 1.4rem; padding: 0 .4rem; background: var(--bg-table-header); border-radius: 99px; font-size: .73rem; font-weight: 600; color: var(--text-muted); vertical-align: middle; margin-left: .25rem; }
.comment-body { white-space: pre-wrap; font-size: .9rem; padding-left: 2.65rem; }
.comment-form { margin-top: 1rem; }
.comment-form textarea { width: 100%; padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px; font-family: inherit; margin-bottom: 0.5rem; background: var(--bg-input); color: var(--text); }
.checkbox-label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; margin-bottom: 0.5rem; }

/* ===== CARDS ===== */
.card { background: var(--bg-card); padding: 1.25rem; border-radius: 8px; box-shadow: 0 1px 3px var(--shadow-sm); margin-bottom: 1rem; }
.card h2, .card h3 { margin-bottom: 0.75rem; }

/* ===== TABLES ===== */
.usr-table-card { background: var(--bg-card); border-radius: 8px; box-shadow: 0 1px 3px var(--shadow-sm); margin-bottom: 1rem; overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; background: var(--bg-card); font-size: .82rem; }
.data-table th { text-align: left; padding: 0.65rem 1rem; background: var(--bg-table-header); font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); border-bottom: 2px solid var(--border); white-space: nowrap; }
.data-table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border-light); font-size: .87rem; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg-hover); }

/* ===== ALERTS ===== */
.alert { padding: 1rem; border-radius: 6px; margin-bottom: 1rem; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-warning { background: #fefce8; color: #854d0e; border: 1px solid #fde68a; }

/* API key reveal — code + copy button row */
.api-key-row { display: flex; gap: .5rem; align-items: stretch; margin: 0 0 .5rem; }
.api-key-row .api-key-display { flex: 1; margin: 0; font-family: 'SF Mono', 'Fira Code', monospace; font-size: .85rem; padding: .55rem .7rem; }
.api-key-row .btn { flex-shrink: 0; }
.btn.btn-copied { background: #16a34a; color: #fff; border-color: #16a34a; }
.btn.btn-copied:hover { background: #16a34a; color: #fff; border-color: #16a34a; }
.api-key-display { display: block; margin-top: 0.5rem; padding: 0.5rem; background: var(--bg-input); border: 1px solid var(--border); border-radius: 4px; word-break: break-all; }

/* ===== MISC ===== */
.empty-state { color: var(--text-muted); text-align: center; padding: 2rem; }
.text-muted { color: var(--text-muted); }
.text-success { color: #10b981; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.5rem; }

/* ===== PAGINATION (variant D) ===== */
.pag { display: flex; align-items: center; justify-content: space-between; padding: .75rem .85rem; border-top: 1px solid var(--border); flex-wrap: wrap; gap: .5rem; font-size: .82rem; }
.pag-left { display: flex; align-items: center; gap: .45rem; color: var(--text-subtle); }
.pag-select { padding: .28rem .55rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-card); font-size: .82rem; color: var(--text); font-family: inherit; cursor: pointer; -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .4rem center; padding-right: 1.4rem; }
.pag-select:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.pag-center { font-size: .82rem; color: var(--text-subtle); }
.pag-center strong { color: var(--text); font-weight: 600; }
.pag-right { display: flex; align-items: center; gap: .3rem; }
.pag-arrow { display: inline-flex; align-items: center; justify-content: center; width: 1.9rem; height: 1.9rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-card); color: var(--text-subtle); cursor: pointer; font-size: .85rem; text-decoration: none; transition: background .12s, border-color .12s, color .12s; }
.pag-arrow:hover { background: var(--bg-hover); border-color: #93c5fd; color: #2563eb; }
.pag-arrow.disabled { opacity: .35; cursor: not-allowed; pointer-events: none; }
.attachment-row { display: flex; justify-content: space-between; padding: 0.25rem 0; font-size: 0.9rem; }

/* ===== NOTIFICATION BELL ===== */
.nav-bell-slot { display: inline-flex; align-items: center; margin-right: .5rem; }
.nav-bell-wrap {
  position: relative;
  display: inline-block;
  padding-bottom: 8px; /* hover bridge */
}
.nav-bell {
  background: transparent;
  border: 1px solid transparent;
  width: 2rem; height: 2rem;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-subtle);
  position: relative;
  transition: background .15s, border-color .15s, color .15s;
}
.nav-bell:hover {
  background: var(--bg-hover);
  border-color: var(--border);
  color: var(--text);
}
.nav-bell-badge {
  position: absolute; top: -2px; right: -2px;
  min-width: 1.05rem; height: 1.05rem;
  padding: 0 .25rem;
  border-radius: 99px;
  background: #ef4444; color: #fff;
  font-size: .62rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg-nav);
  line-height: 1;
}
.nav-bell-dropdown {
  display: none;
  position: absolute; right: 0; top: calc(100% - 8px);
  z-index: 500;
  width: 22rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px var(--shadow-md);
  overflow: hidden;
}
.nav-bell-wrap:hover .nav-bell-dropdown { display: block; }
.nav-bell-head {
  padding: .65rem .9rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg);
}
.nav-bell-head h4 {
  font-size: .85rem; font-weight: 700; color: var(--text); margin: 0;
}
.nav-bell-head button {
  background: transparent; border: 0; padding: 0;
  color: #2563eb;
  font-size: .72rem; font-weight: 500;
  cursor: pointer;
}
.nav-bell-head button:hover { text-decoration: underline; }
.nav-bell-list { max-height: 22rem; overflow-y: auto; }
.nav-bell-empty {
  padding: 2rem 1rem; text-align: center;
  color: var(--text-muted); font-size: .82rem;
}
.nav-bell-item {
  display: flex; gap: .65rem; padding: .65rem .9rem .65rem 1.05rem;
  border-bottom: 1px solid var(--border-light);
  text-decoration: none; color: inherit;
  position: relative;
}
.nav-bell-item:hover { background: var(--bg); }
.nav-bell-item:last-child { border-bottom: 0; }
.nav-bell-item.unread { background: #f5f9ff; }
.nav-bell-item.unread:hover { background: #eef4ff; }
.nav-bell-item.unread::before {
  content: ''; position: absolute; top: 50%; left: 4px; transform: translateY(-50%);
  width: .35rem; height: .35rem; border-radius: 50%; background: #2563eb;
}
.nav-bell-ava {
  width: 2rem; height: 2rem; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .65rem; font-weight: 700; color: #fff;
  background: #6b7280;
}
.nav-bell-ava.role-agent      { background: #059669; }
.nav-bell-ava.role-user       { background: #6b7280; }
.nav-bell-ava.role-org_admin  { background: #7c3aed; }
.nav-bell-ava.role-superadmin { background: #7c3aed; }
.nav-bell-ava.role-system     { background: #f1f5f9; color: #475569; }
.nav-bell-text {
  flex: 1; min-width: 0;
  font-size: .8rem; color: var(--text); line-height: 1.4;
}
.nav-bell-msg strong { color: var(--text); font-weight: 600; }
.nav-bell-ref { color: #2563eb; font-weight: 600; margin-left: .15rem; }
.nav-bell-ref-title { color: var(--text-muted); }
.nav-bell-meta {
  display: block; margin-top: .15rem;
  font-size: .72rem; color: var(--text-muted);
}
.nav-bell-quote {
  margin-top: .25rem; padding-left: .5rem;
  border-left: 2px solid var(--border);
  font-size: .76rem; color: var(--text-muted);
  font-style: italic;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-bell-time {
  margin-top: .2rem;
  font-size: .68rem; color: var(--text-muted);
}

/* ===== CHART KPI STRIP (Динамика заявок) ===== */
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.chart-head h2 { margin: 0; font-size: 1.05rem; font-weight: 700; }
.chart-head .sub { font-size: .8rem; color: var(--text-muted); margin-top: .15rem; }
.chart-kpi {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 1rem; padding: .75rem;
  background: var(--bg); border: 1px solid var(--border-light);
  border-radius: 8px; margin-bottom: 1rem;
}
.chart-kpi-cell { padding: 0 .25rem; min-width: 0; }
.chart-kpi-label { font-size: .68rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.chart-kpi-row { display: flex; align-items: baseline; gap: .5rem; margin-top: .2rem; flex-wrap: wrap; }
.chart-kpi-value { font-size: 1.35rem; font-weight: 700; color: var(--text); line-height: 1.1; }
.chart-kpi-delta { font-size: .76rem; font-weight: 600; }
.chart-kpi-delta.up      { color: #16a34a; }
.chart-kpi-delta.down    { color: #ef4444; }
.chart-kpi-delta.neutral { color: var(--text-muted); }
@media (max-width: 640px) {
  .chart-kpi { grid-template-columns: 1fr; }
}
