/* IT Helpdesk - ink / steel / amber */
:root {
  --ink: #18233A; --ink-2: #22314F; --ink-3: #31446A;
  --steel: #2B6CB0; --steel-d: #235A93; --steel-l: #E6EFF8;
  --amber: #D4891A; --amber-l: #FBF0DF;
  --paper: #F3F5F8; --line: #DCE2EA; --text: #1E2733; --muted: #66727F;
  --ok: #2F855A; --ok-l: #E3F2EA; --bad: #C53030; --bad-l: #FBE7E7; --hold: #805AD5; --hold-l: #EFE9FB;
  --radius: 10px; --sidebar-w: 260px;
  --bs-body-font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --bs-body-color: var(--text); --bs-body-bg: var(--paper); --bs-border-color: var(--line);
  --bs-primary: var(--steel); --bs-primary-rgb: 43, 108, 176;
  --bs-link-color: var(--steel); --bs-link-color-rgb: 43, 108, 176; --bs-link-hover-color: var(--steel-d);
  --bs-focus-ring-color: rgba(43, 108, 176, .3);
}
body { font-size: .925rem; -webkit-font-smoothing: antialiased; }

.btn-primary {
  --bs-btn-bg: var(--steel); --bs-btn-border-color: var(--steel);
  --bs-btn-hover-bg: var(--steel-d); --bs-btn-hover-border-color: var(--steel-d);
  --bs-btn-active-bg: var(--steel-d); --bs-btn-active-border-color: var(--steel-d);
  --bs-btn-disabled-bg: var(--steel); --bs-btn-disabled-border-color: var(--steel);
}
.btn-outline-primary {
  --bs-btn-color: var(--steel); --bs-btn-border-color: var(--steel);
  --bs-btn-hover-bg: var(--steel); --bs-btn-hover-border-color: var(--steel); --bs-btn-active-bg: var(--steel-d);
}
.btn-light { --bs-btn-bg: #fff; --bs-btn-hover-bg: var(--paper); }
.nav-pills { --bs-nav-pills-link-active-bg: var(--steel); }
.nav-pills .nav-link { color: var(--text); }
.nav-pills .nav-link:not(.active):hover { background: #fff; }
.pagination { --bs-pagination-active-bg: var(--steel); --bs-pagination-active-border-color: var(--steel); --bs-pagination-color: var(--steel); }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: #8DB3DA; box-shadow: 0 0 0 .2rem rgba(43, 108, 176, .18); }
.form-check-input:checked { background-color: var(--steel); border-color: var(--steel); }
.form-label { font-weight: 500; font-size: .875rem; }
:focus-visible { outline: 2px solid var(--steel); outline-offset: 2px; }
.min-w-0 { min-width: 0; }
.text-truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar-wrap { width: var(--sidebar-w); flex-shrink: 0; }
.sidebar {
  background: var(--ink); color: #C9D3E3; height: 100%; min-height: 100vh;
  display: flex; flex-direction: column; position: sticky; top: 0; max-height: 100vh; overflow-y: auto;
}
@media (min-width: 992px) {
  .sidebar-wrap { position: relative; }
  .sidebar-wrap.offcanvas-lg { background: var(--ink); }
}
@media (max-width: 991.98px) {
  .sidebar-wrap.offcanvas-lg { --bs-offcanvas-width: var(--sidebar-w); background: var(--ink); }
  .sidebar { min-height: 100%; max-height: none; position: static; }
}
.brand { padding: 18px 16px 16px; display: flex; flex-direction: column; gap: 12px; border-bottom: 1px solid rgba(255,255,255,.07); position: relative; }
.brand .btn-close { position: absolute; top: 12px; right: 12px; }
.logo-plate {
  background: #fff; border-radius: 8px; height: 72px; display: flex; align-items: center; justify-content: center;
  padding: 10px 14px; box-shadow: 0 1px 0 rgba(0,0,0,.2);
}
.logo-plate img { max-height: 100%; max-width: 100%; object-fit: contain; }
.logo-fallback { font-weight: 700; font-size: 1.5rem; letter-spacing: .06em; color: var(--ink); }
.brand-company { color: #fff; font-weight: 600; line-height: 1.25; font-size: .95rem; }
.brand-app { font-size: .75rem; color: #8E9BB3; text-transform: uppercase; letter-spacing: .08em; margin-top: 2px; }
.nav-main { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-main a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 7px;
  color: #C9D3E3; text-decoration: none; font-weight: 500; position: relative;
}
.nav-main a i { font-size: 1.05rem; width: 20px; text-align: center; opacity: .85; }
.nav-main a:hover { background: var(--ink-2); color: #fff; }
.nav-main a.active { background: var(--ink-3); color: #fff; }
.nav-main a.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--amber); }
.nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: #6F7E99; padding: 16px 12px 6px; }
.sidebar-foot { padding: 14px 18px; font-size: .78rem; color: #8E9BB3; border-top: 1px solid rgba(255,255,255,.07); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: #fff;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1020;
}
.page-title { font-size: 1.15rem; font-weight: 600; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { padding: 24px 28px 48px; flex: 1; }
@media (max-width: 575.98px) { .topbar { padding: 10px 14px; } .content { padding: 16px 14px 40px; } }

.user-chip {
  display: flex; align-items: center; gap: 8px; background: none; border: 1px solid transparent; border-radius: 999px;
  padding: 3px 10px 3px 3px; color: var(--text); font-weight: 500;
}
.user-chip:hover, .user-chip[aria-expanded="true"] { border-color: var(--line); background: var(--paper); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  background: var(--amber-l); color: #8A5510; font-weight: 600; font-size: .78rem;
}
.avatar.staff { background: var(--steel-l); color: var(--steel-d); }

/* ---------- Panels ---------- */
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 13px 18px; border-bottom: 1px solid var(--line); font-weight: 600; }
.panel-body { padding: 18px; }
.panel-foot { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); background: #FAFBFC; border-radius: 0 0 var(--radius) var(--radius); }
.panel > .table-responsive > .table { --bs-table-bg: transparent; }
.panel .table > :not(caption) > * > * { padding: .7rem 1rem; }
.panel .table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: #FAFBFC; }
.panel .table tbody tr:last-child td { border-bottom: 0; }
a.panel:hover { border-color: #B9C6D6; }

/* ---------- Badges ---------- */
.badge-st, .badge-pr {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: .75rem; font-weight: 600; white-space: nowrap; line-height: 1.6;
}
.badge-st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-open { background: var(--steel-l); color: var(--steel-d); }
.st-progress { background: var(--amber-l); color: #93580C; }
.st-hold { background: var(--hold-l); color: #5B3BA8; }
.st-resolved { background: var(--ok-l); color: #276749; }
.st-closed { background: #EDF0F3; color: #55606C; }
.badge-pr { background: #fff; border: 1px solid var(--line); color: var(--muted); }
.pr-medium { color: var(--steel-d); border-color: #BFD3EA; }
.pr-high { color: #93580C; border-color: #F0CF9C; background: var(--amber-l); }
.pr-critical { color: #fff; border-color: var(--bad); background: var(--bad); }

/* ---------- Dashboard ---------- */
.queue-strip { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: #EDF0F3; margin: 16px 0 14px; gap: 2px; }
.queue-strip span { display: block; min-width: 4px; }
.qs-open { background: var(--steel); }
.qs-progress { background: var(--amber); }
.qs-hold { background: var(--hold); }
.qs-resolved { background: var(--ok); }
.qs-closed { background: #A0AAB6; }
.queue-legend { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.queue-legend .ql { text-decoration: none; color: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid transparent; }
.queue-legend .ql:hover { border-color: var(--line); background: var(--paper); }
.queue-legend .n { font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.queue-legend .l { font-size: .8rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
@media (max-width: 767.98px) { .queue-legend { grid-template-columns: repeat(3, 1fr); } }
.stat { padding: 16px 18px; height: 100%; }
.stat .n { font-size: 1.6rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .l { font-size: .8rem; color: var(--muted); margin-top: 4px; }

/* ---------- Tickets ---------- */
.tno { font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 600; font-size: .82rem; text-decoration: none; white-space: nowrap; }
.table-tickets td { vertical-align: middle; }
.filters .form-select, .filters .form-control { font-size: .875rem; }

.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 15px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { display: flex; gap: 14px; margin-bottom: 14px; position: relative; }
.tl-item .avatar { position: relative; z-index: 1; box-shadow: 0 0 0 4px var(--paper); }
.tl-card { flex: 1; min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.tl-card.internal { background: #FFFAF0; border-color: #F0D9AE; border-style: dashed; }
.tl-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .82rem; color: var(--muted); margin-bottom: 6px; }
.tl-meta strong { color: var(--text); }
.tl-body { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.tl-system { position: relative; padding: 2px 0 2px 40px; margin-bottom: 14px; font-size: .82rem; color: var(--muted); }
.tl-system::before { content: ""; position: absolute; left: 11px; top: 8px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid #A0AAB6; }
.chip-it, .chip-internal { font-size: .7rem; font-weight: 600; padding: 1px 7px; border-radius: 4px; }
.chip-it { background: var(--steel-l); color: var(--steel-d); }
.chip-internal { background: var(--amber-l); color: #93580C; }

.att-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.att {
  display: inline-flex; align-items: center; gap: 8px; max-width: 280px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 7px; background: #FAFBFC; text-decoration: none; color: var(--text); font-size: .82rem;
}
.att:hover { border-color: #9DB7D3; background: var(--steel-l); }
.att i { color: var(--steel); font-size: 1rem; }
.att .sz { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.file-pill {
  display: inline-flex; align-items: center; gap: 6px; margin: 6px 6px 0 0; padding: 3px 9px; border-radius: 999px;
  background: var(--paper); border: 1px solid var(--line); font-size: .78rem; max-width: 100%;
}
.file-pill.too-big { background: var(--bad-l); border-color: #F1B5B5; color: var(--bad); }
.file-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.details { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; margin: 0; font-size: .875rem; }
.details dt { color: var(--muted); font-weight: 500; }
.details dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Knowledge base ---------- */
.kb-row { display: flex; align-items: flex-start; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.kb-row:last-child { border-bottom: 0; }
.kb-icon {
  width: 42px; height: 42px; flex-shrink: 0; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; background: var(--paper); color: var(--muted);
}
.kb-icon.pdf { background: #FBE7E7; color: #B83232; }
.kb-icon.doc { background: var(--steel-l); color: var(--steel-d); }
.kb-icon.xls { background: var(--ok-l); color: #276749; }
.kb-icon.ppt { background: var(--amber-l); color: #A65E0A; }
.kb-icon.img { background: var(--hold-l); color: #5B3BA8; }

.viewer { position: relative; background: #E9EDF2; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-height: 60vh; overflow: auto; }
.viewer canvas { display: block; margin: 0 auto 16px; max-width: 100%; height: auto; background: #fff; box-shadow: 0 1px 4px rgba(24,35,58,.15); }
.viewer .docx-wrapper { background: transparent !important; padding: 0 !important; }
.viewer .docx-wrapper > section.docx { box-shadow: 0 1px 4px rgba(24,35,58,.15) !important; margin-bottom: 16px !important; max-width: 100%; }
.viewer.noselect { -webkit-user-select: none; user-select: none; }
.viewer.noselect img { pointer-events: none; }
.watermark { position: absolute; inset: 0; z-index: 5; pointer-events: none; background-repeat: repeat; }
.kb-text { background: #fff; padding: 16px; border-radius: 6px; white-space: pre-wrap; font-size: .82rem; max-width: 980px; margin: 0 auto; }
@media print { .viewer.noselect { display: none !important; } }

/* ---------- Forms / admin ---------- */
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 16px; }
.logo-thumb { height: 44px; max-width: 140px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; background: #fff; }
#accessTargets { transition: opacity .15s; }
#accessTargets.is-disabled { opacity: .45; pointer-events: none; }

/* ---------- Auth ---------- */
.auth-wrap { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: 100vh; }
.auth-side {
  background: var(--ink); color: #fff; padding: 56px; display: flex; align-items: center;
  background-image: linear-gradient(135deg, rgba(43,108,176,.18), transparent 55%);
}
.auth-side > div { max-width: 520px; }
.auth-kicker { color: var(--amber); text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; font-weight: 600; margin-bottom: 14px; }
.auth-title { font-size: 2rem; font-weight: 600; line-height: 1.25; margin-bottom: 32px; }
.auth-logos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.auth-logo {
  background: #fff; border-radius: 8px; height: 72px; display: flex; align-items: center; justify-content: center; padding: 10px 14px;
}
.auth-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.auth-logo span { color: var(--ink); font-weight: 600; font-size: .8rem; text-align: center; line-height: 1.25; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-applogo { max-height: 56px; max-width: 200px; object-fit: contain; margin-bottom: 20px; display: block; }
@media (max-width: 991.98px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { padding: 32px 24px; }
  .auth-title { font-size: 1.35rem; margin-bottom: 20px; }
  .auth-logos { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .auth-logo { height: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
