:root {
  --nav: #111827;
  --nav-soft: #1f2937;
  --blue: #2389dc;
  --primary: #0f766e;
  --orange: #d97706;
  --line: #d9e2ec;
  --paper: #eef3f8;
  --panel: #ffffff;
  --soft: #f5f8fb;
  --thead: #e7f4f1;
  --text: #172033;
  --muted: #64748b;
  --radius: 6px;
  --app-font-size: 14px;
  --app-font-size-sm: 13px;
  --app-font-size-xs: 12px;
  --app-label-size: 11px;
  --app-control-height-sm: 28px;
  --app-table-cell-y: .28rem;
  --app-table-cell-x: .38rem;
  --app-shadow: 0 8px 22px rgba(15,23,42,.045);
  --app-shadow-strong: 0 14px 38px rgba(15,23,42,.22);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif; background: var(--paper); color: var(--text); letter-spacing: 0; font-size: var(--app-font-size); }
a { text-decoration: none; }
img[src*="thkomp-logo"] { max-width: 320px; height: auto; }
.app-shell { min-height: 100vh; display: flex; }
.sidebar { width: 238px; background: linear-gradient(180deg, var(--nav), var(--nav-soft)); color: #fff; display: flex; flex-direction: column; padding: 12px 9px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 23px; padding: 0 8px 12px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand img { width: 112px; height: 46px; object-fit: contain; object-position: left center; border-radius: 5px; }
.sidebar nav { display: grid; gap: 6px; }
.sidebar a { border: 0; color: #dbe7f7; background: transparent; display: flex; align-items: center; gap: 11px; min-height: 38px; padding: 0 10px; border-radius: var(--radius); font-size: 14px; width: 100%; }
.sidebar a.active, .sidebar a:hover { background: var(--blue); color: #fff; }
.sidebar i { width: 22px; font-size: 17px; text-align: center; }
.main { flex: 1; min-width: 0; }
.topbar { min-height: 62px; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 18px; max-width: 100%; box-sizing: border-box; overflow: hidden; }
.main:has(.module-layout) .topbar { width: calc(100% - 292px); margin-left: 292px; border-left: 1px solid var(--line); }
.topbar > div:first-child { min-width: 0; overflow: hidden; }
.eyebrow { color: #53657f; text-transform: uppercase; font-weight: 800; font-size: 11px; }
.topbar h1 { margin: 0; font-size: 21px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.host-data { text-align: right; color: var(--muted); }
.host-data strong { display: block; color: var(--text); }
.topbar-user { position: relative; z-index: 5; display: flex; align-items: center; gap: 4px; flex: 0 1 auto; max-width: min(420px, 100%); padding: 4px; border: 1px solid #c2d2e4; border-radius: 8px; background: #edf4fb; box-shadow: 0 8px 20px rgba(15,23,42,.075); }
.topbar-user form { position: relative; z-index: 6; display: flex; flex: 0 0 auto; margin: 0; }
.profile-trigger { flex: 1 1 auto; min-width: 0; border: 1px solid rgba(82,107,143,.16); background: #f8fbff; padding: 6px 12px; border-radius: 6px; line-height: 1.25; text-align: right; min-height: 42px; }
.profile-trigger strong { display: block; color: var(--text); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-trigger span { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-trigger:hover { background: #fff; border-color: #aebfd4; }
.logout-icon { position: relative; z-index: 7; width: 42px; min-height: 42px; flex: 0 0 42px; border: 1px solid #8f1d1d; border-radius: 6px; background: #9f1d1d; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; pointer-events: auto; }
.logout-icon:hover { background: #7f1717; color: #fff; border-color: #6f1212; }
.content { padding: 12px 14px; }
.main:has(.module-layout) .content { padding: 0; }
.app-toast-container { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 1090; width: min(440px, calc(100vw - 28px)); }
.app-toast { box-shadow: var(--app-shadow-strong); border: 1px solid rgba(15,23,42,.16); border-radius: var(--radius); overflow: hidden; background: #fff; color: var(--text); }
.app-toast .toast-header { background: #111827; color: #fff; border-bottom: 0; font-size: var(--app-font-size-xs); font-weight: 800; }
.app-toast .toast-header .btn-close { filter: invert(1) grayscale(100%) brightness(200%); opacity: .9; }
.app-toast .toast-body { display: flex; align-items: center; gap: 8px; font-weight: 700; line-height: 1.25; font-size: var(--app-font-size-sm); }
.app-toast.is-success .toast-header { background: #0f766e; }
.app-toast.is-danger .toast-header { background: #9f1d1d; }
.module-layout { display: grid; grid-template-columns: 292px minmax(0, 1fr); gap: 0; align-items: stretch; min-height: calc(100vh - 62px); }
.main:has(.module-layout) .module-layout { margin-top: -62px; min-height: 100vh; }
.module-layout:has(.module-sections.is-collapsed) { grid-template-columns: 74px minmax(0, 1fr); }
.main:has(.module-layout:has(.module-sections.is-collapsed)) .topbar { width: calc(100% - 74px); margin-left: 74px; }
.module-sections { position: sticky; top: 0; min-height: 100vh; background: #f8fbff; border-right: 1px solid var(--line); padding: 14px 12px; transition: width .18s ease; }
.module-sections-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 7px 4px 12px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.module-sections-head span { display: block; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.module-sections-head strong { display: block; color: var(--text); font-size: 20px; font-weight: 700; }
.module-section-link { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 9px; min-height: 42px; padding: 7px 8px; border-radius: var(--radius); color: var(--text); }
.module-section-link i { color: #526b8f; font-size: 17px; text-align: center; }
.module-section-link span { font-size: 15px; font-weight: 700; }
.module-section-link small { color: #8a9ab2; font-size: 11px; font-weight: 700; }
.module-section-link.active, .module-section-link:hover { background: #e6edf5; color: var(--text); }
.module-section-link.active i { color: var(--blue); }
.module-sections.is-collapsed { width: 58px; min-width: 58px; }
.module-sections.is-collapsed .module-sections-head div, .module-sections.is-collapsed .module-section-link span, .module-sections.is-collapsed .module-section-link small { display: none; }
.module-sections.is-collapsed .module-sections-head { justify-content: center; padding-bottom: 6px; }
.module-sections.is-collapsed .module-sections-toggle i { transform: rotate(180deg); }
.module-sections.is-collapsed .module-section-link { grid-template-columns: 1fr; justify-items: center; padding: 8px 5px; }
.module-stage { min-width: 0; padding: 74px 14px 14px 14px; }
.module-section { display: none; }
.module-section.active { display: block; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 10px; box-shadow: var(--app-shadow); overflow: hidden; }
.panel-title { display: flex; align-items: center; justify-content: flex-start; gap: 8px; color: #fff; font-size: 15px; font-weight: 800; margin: -10px -10px 10px; padding: 10px 12px; border-bottom: 1px solid #0e5f59; background: #0f766e; }
.panel-title i { color: rgba(255,255,255,.92); font-size: 15px; }
label, .form-label { color: var(--muted); font-weight: 700; margin-top: 4px; margin-bottom: 3px; font-size: var(--app-label-size); }
.form-control, .form-select { border-color: #d7e0ec; border-radius: var(--radius); font-size: var(--app-font-size-sm); }
.form-control:focus, .form-select:focus { border-color: #9bc4ff; box-shadow: 0 0 0 .18rem rgba(35,137,220,.14); }
.form-control-sm, .form-select-sm { min-height: var(--app-control-height-sm); font-size: var(--app-font-size-xs); padding-top: .2rem; padding-bottom: .2rem; }
.btn { border-radius: var(--radius); }
.btn-primary { --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: #0b625c; --bs-btn-hover-border-color: #0b625c; }
.btn-sm { --bs-btn-padding-y: .18rem; --bs-btn-padding-x: .46rem; --bs-btn-font-size: .78rem; }
.table-responsive { border: 1px solid var(--line); border-radius: var(--radius); }
.table-compact { margin-bottom: 0; font-size: var(--app-font-size-xs); }
.table-compact.table, .panel .table { --bs-table-striped-bg: #f3f6f9; --bs-table-hover-bg: #eaf3fb; border-color: var(--line); }
.table-compact > :not(caption) > * > *, .panel .table > :not(caption) > * > * { padding: var(--app-table-cell-y) var(--app-table-cell-x); vertical-align: middle; border-color: var(--line); }
.table-compact thead th, .panel .table thead th { color: #0f4b49; font-size: var(--app-font-size-xs); font-weight: 800; text-align: center; background: var(--thead); border-color: #bfd5d0; }
.table-compact td, .table-compact th { overflow-wrap: anywhere; }
.mailing-table thead tr:first-child th { background: #cfe5df; color: #083f3d; border-color: #a8c8c0; }
.mailing-table thead .table-add-row th,
.admin-data-table thead .table-add-row th { background: #f8fbff; border-color: #c8d7e6; }
.dashboard-ticket-panel { border-left: 3px solid var(--primary); }
.ticket-form { background: #f8fbff; border: 1px solid #d7e4ef; border-radius: var(--radius); padding: 10px; }
.dashboard-table thead th { background: #d9ebe7; color: #083f3d; border-color: #b5d1cb; }
.dashboard-table .service-row td { background: #f6f9fc !important; border-top: 2px solid #c8d7e6; }
.dashboard-filters { padding: 10px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: #f8fbff; }
.dashboard-service-form { background: #fff; border: 1px solid #dbe5ef; border-radius: var(--radius); padding: 7px; }
.dashboard-service-form .form-control-sm, .dashboard-service-form .form-select-sm { min-height: 25px; }
.table-compact tbody td, .panel .table tbody td { color: #101828; }
.table-compact input.form-control-sm, .table-compact select.form-select-sm { min-height: 26px; padding-left: .4rem; padding-right: .4rem; }
.table-sort { appearance: none; border: 0; background: transparent; color: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 4px; font: inherit; font-weight: 800; padding: 0; text-decoration: none; }
.table-sort span { color: #526b8f; font-size: 11px; }
.table-sort.active span { color: var(--primary); }
.table-sort:not(a)::after { content: "↕"; display: inline-block; color: #6b7f99; font-size: 10px; margin-left: 5px; }
.table-sort.is-sorted::after { content: "↓"; color: var(--primary); }
.table-sort.is-sorted[data-direction="asc"]::after { content: "↑"; }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 2px 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.table-footer nav { margin-left: auto; }
.table-footer .pagination { margin: 0; }
.permissions-table { min-width: 1180px; }
.permissions-table .permission-cell { min-width: 124px; }
.permissions-table .permission-cell .form-select-sm { font-size: 11px; min-height: 24px; padding-top: .15rem; padding-bottom: .15rem; }
.is-readonly-control:disabled { opacity: .72; background-color: #eef3f8; }
.dense-form .row { align-items: end; }
.compact-checks { display: flex; align-items: end; gap: 12px; padding-bottom: 2px; }
.compact-checks .form-check { margin: 0; white-space: nowrap; }
.mail-buttons { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.mail-composer { background: #f8fbff; border: 1px solid #d7e4ef; border-radius: var(--radius); padding: 10px; }
.html-editor { min-height: 220px; font-family: Consolas, "Courier New", monospace; line-height: 1.35; }
.html-editor-sm { min-height: 94px; }
.quill-source { display: none; }
.quill-shell { border-radius: var(--radius); }
.quill-app-controls { display: flex; justify-content: flex-end; gap: 6px; margin-bottom: 5px; }
.quill-variable-select { max-width: 260px; }
.quill-shell .ql-toolbar.ql-snow { display: block; border-color: #d7e0ec; border-radius: var(--radius) var(--radius) 0 0; background: #f8fbff; padding: 5px 6px; }
.quill-shell .ql-toolbar.ql-snow .ql-formats { margin-right: 9px; }
.quill-shell .ql-container.ql-snow { border-color: #d7e0ec; border-radius: 0 0 var(--radius) var(--radius); background: #fff; font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif; font-size: 13px; }
.quill-shell-lg .ql-editor { min-height: 220px; }
.quill-shell-sm .ql-editor { min-height: 90px; max-height: 150px; overflow-y: auto; }
.quill-shell-sm .ql-toolbar.ql-snow { padding: 3px 4px; }
.quill-shell-sm .ql-toolbar.ql-snow .ql-formats { margin-right: 4px; }
.quill-shell-sm .ql-toolbar.ql-snow .ql-picker { font-size: 11px; }
.subject-variable-wrap { margin-top: 4px; }
.subject-variable-select { max-width: 260px; font-size: 11px; min-height: 25px; margin-left: auto; }
.report-actions { display: flex; align-items: end; gap: 6px; flex-wrap: wrap; }
.panel-count { display: inline-grid; place-items: center; min-width: 24px; height: 20px; padding: 0 7px; margin-left: auto; border-radius: 999px; background: rgba(255,255,255,.18); color: #fff; font-size: var(--app-font-size-xs); font-weight: 800; }
.system-health-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.system-health-card { border: 1px solid var(--line); border-radius: var(--radius); background: #f8fbff; padding: 10px; min-height: 68px; }
.system-health-card span { display: block; color: var(--muted); font-size: 11px; font-weight: 800; margin-bottom: 5px; }
.system-health-card strong { display: block; color: var(--text); font-size: 20px; line-height: 1.1; }
.system-box { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; padding: 10px; height: 100%; }
.system-box-title { display: flex; align-items: center; gap: 7px; color: #0f4b49; font-weight: 800; margin-bottom: 8px; }
.system-box-title i { color: #526b8f; }
.system-info-list { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 6px 10px; margin: 0; font-size: 12px; }
.system-info-list dt { color: var(--muted); font-weight: 800; }
.system-info-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; color: var(--text); }
.ticket-summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.ticket-summary-grid div { border: 1px solid #d7e4ef; border-radius: var(--radius); background: #f8fbff; padding: 8px; }
.ticket-summary-grid span { display: block; color: var(--muted); font-size: 11px; font-weight: 800; }
.ticket-summary-grid strong { display: block; color: var(--text); font-size: 18px; overflow-wrap: anywhere; }
.status-strip { display: flex; flex-wrap: wrap; gap: 6px; }
.disk-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.disk-card { border: 1px solid #d7e4ef; border-radius: var(--radius); background: #f8fbff; padding: 9px; }
.disk-card-head { display: flex; align-items: start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.disk-card-head strong { display: block; color: var(--text); }
.disk-card-head small { display: block; color: var(--muted); overflow-wrap: anywhere; }
.system-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 56px; border-radius: 999px; padding: 3px 8px; font-size: 11px; font-weight: 800; background: #eef2f6; color: #334155; white-space: nowrap; }
.system-state-ok { border-color: #b8dfd4; background: #e7f7f1; color: #0f766e; }
.system-state-warning { border-color: #f3d29a; background: #fff7e6; color: #945c00; }
.system-state-danger { border-color: #efb4b4; background: #fdecec; color: #a61b1b; }
.system-state-unknown { border-color: #d7e0ec; background: #eef3f8; color: #526b8f; }
.disk-meter { height: 8px; border-radius: 999px; overflow: hidden; background: #e2e8f0; margin-bottom: 8px; }
.disk-meter span { display: block; height: 100%; max-width: 100%; border-radius: inherit; background: var(--primary); }
.disk-values { display: flex; flex-wrap: wrap; gap: 8px 12px; color: var(--muted); font-size: 11px; }
.disk-values strong { color: var(--text); }
.auth-page { min-height: calc(100vh - 48px); display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: -24px; background: #fff; }
.auth-visual { background: #eef4fb; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 48px; text-align: center; }
.auth-logo { width: min(320px, 76vw); height: auto; border-radius: 8px; margin-bottom: 24px; box-shadow: 0 18px 38px rgba(17,24,39,.12); }
.auth-card { width: min(520px, calc(100vw - 32px)); background: #fff; padding: 26px; border: 1px solid var(--line); border-radius: 8px; align-self: center; justify-self: center; }
.auth-card h2 { margin-bottom: 18px; }
.auth-links { display: flex; justify-content: space-between; margin-top: 16px; }
.host-strip { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); margin-bottom: 10px; font-size: 13px; }
.badge { font-size: 13px; }
.status-new { background: #e9f3ff; color: #0b65bd; }
.status-in_progress { background: #fff5dc; color: #945c00; }
.status-done { background: #e3f8ee; color: #0f766e; }
.status-rejected { background: #fde7e7; color: #a61b1b; }
.service-row { background: #f8fbff; }
.modal-header { background: #111827; color: #fff; border-bottom: 0; }
.modal-header .btn-close { filter: invert(1) grayscale(100%) brightness(200%); opacity: .9; }
.modal-title { display: flex; align-items: center; gap: 8px; font-size: 1rem; font-weight: 800; }
.modal-footer { background: #f8fbff; border-top: 1px solid var(--line); }
.alert.app-inline-note { border-color: #bfd5d0; background: #eef8f5; color: #0f4b49; font-size: var(--app-font-size-sm); }
@media (max-width: 900px) {
  .app-shell { display: block; }
  .sidebar { width: 100%; min-height: auto; }
  .topbar { padding: 8px; gap: 8px; }
  .main:has(.module-layout) .topbar, .main:has(.module-layout:has(.module-sections.is-collapsed)) .topbar { width: 100%; margin-left: 0; border-left: 0; }
  .topbar-user { max-width: min(100%, 340px); }
  .profile-trigger { padding-left: 8px; padding-right: 8px; }
  .profile-trigger span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .module-layout { grid-template-columns: 1fr; }
  .module-sections { position: static; min-height: auto; }
  .system-health-grid, .disk-grid { grid-template-columns: 1fr; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
}

/* Tickets pagination */
.tickets-footer { flex-wrap: wrap; }
.tickets-footer .pagination { gap: 4px; }
.tickets-footer .page-link { border-radius: 4px; white-space: nowrap; }
@media (max-width: 575.98px) {
  .tickets-footer { align-items: flex-start; }
  .tickets-footer nav { width: 100%; margin-left: 0; }
}
