:root {
  --brand-blue: #008fd3;
  --brand-deep: #006da8;
  --brand-ink: #16364a;
  --brand-pale: #eaf8fe;
  --brand-border: #b7e7fa;
  --muted: #557486;
  --line: #d6eaf4;
  --bg: #f4f9fc;
  --danger: #b91c1c;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--brand-ink);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
.hidden { display: none !important; }
.layout { min-height: 100vh; }
aside {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 260px;
  background: #fff;
  border-right: 1px solid var(--brand-border);
  padding: 8px 12px 24px;
  overflow: auto;
  z-index: 40;
}
main {
  margin-left: 260px;
  width: calc(100% - 260px);
  min-width: 0;
  padding: 0 24px 32px;
}
.omni-brand, .topbar-brand { display: flex; align-items: center; gap: 10px; color: var(--brand-deep); font-weight: 800; }
.omni-brand { padding: 14px 8px 18px; font-size: 15px; line-height: 1.25; }
.sidebar-logo { width: 42px; height: 50px; object-fit: contain; }
.topbar-logo { width: 34px; height: 42px; object-fit: contain; }
.nav-label { font-size: 10px; font-weight: 800; letter-spacing: 1.2px; color: #94a3b8; padding: 12px 12px 6px; }
.nav {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  background: transparent; color: #475569; border: 0; border-radius: 9px; padding: 12px; margin: 2px 0;
}
.nav.active { background: var(--brand-pale); color: var(--brand-deep); }
.nav span { width: 20px; text-align: center; }
.side-note { margin: 22px 8px 0; padding: 13px; border-radius: 11px; background: #f1f5f9; color: #64748b; font-size: 12px; }
.app-topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 12px 0; margin: 0 0 18px; background: #fff; border-bottom: 1px solid var(--line);
}
.topbar-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
#currentUserLabel { font-size: 13px; color: var(--muted); font-weight: 650; }
.menu-btn, .nav-backdrop { display: none; }
.pagehead, .panel-head, .filters, .toolbar, .form-actions, .view-tabs, .modal-actions {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
}
.pagehead { justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.pagehead h2, .login-card h1 { margin: 0 0 4px; color: var(--brand-ink); }
.pagehead p, .panel-head p { margin: 0; color: var(--muted); font-size: 13px; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.card, .panel, .site-card, .call-card, .login-card {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
}
.card { padding: 18px; }
.metric-top { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; font-weight: 650; }
.metric { font-size: 29px; font-weight: 800; letter-spacing: -.8px; margin: 8px 0 2px; }
.metric-sub, .subtext, .filter-note { color: #64748b; font-size: 12px; }
.panel { overflow: hidden; margin-bottom: 18px; }
.panel-head { justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 15px; }
.filters, .toolbar, .form-actions, .view-tabs, .stack, .prose { padding: 14px 18px; }
.view-tabs { padding-top: 0; }
.filters > * { flex: 1 1 180px; }
.grow { flex: 1 1 240px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label, .filters label { font-size: 12px; font-weight: 700; color: #33566c; }
input, select, textarea {
  width: 100%; color: var(--brand-ink); background: #fff; border: 1px solid #b7c9d6;
  border-radius: 8px; padding: 10px 11px; outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-blue); box-shadow: 0 0 0 3px #008fd322; }
button, .btn { border: 0; border-radius: 9px; padding: 10px 13px; font-weight: 700; }
.primary { background: var(--brand-blue); color: #fff; }
.primary:hover { background: var(--brand-deep); }
.secondary, .outline { background: #fff; color: var(--brand-deep); border: 1px solid var(--brand-border); }
.danger { background: #fee2e2; color: var(--danger); }
.linkbtn, .link-btn { background: none; border: 0; padding: 0; color: var(--brand-deep); font-weight: 800; text-decoration: underline; }
.mini-btn { padding: 8px 10px; }
.icon-btn { border: 0; background: #f1f5f9; border-radius: 8px; padding: 8px 10px; }
.table-wrap { overflow: auto; }
table { border-collapse: collapse; width: 100%; min-width: 760px; }
th { text-align: left; background: #f8fafc; color: #64748b; font-size: 10px; text-transform: uppercase; letter-spacing: .7px; padding: 12px 14px; }
td { padding: 12px 14px; border-top: 1px solid #edf1f6; vertical-align: middle; }
.ticket-id, .site-name { font-weight: 800; }
.ticket-id { color: var(--brand-deep); }
.pill, .badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; padding: 4px 8px; font-size: 11px; font-weight: 750; }
.status-open, .status-new { background: #e0f2fe; color: #075985; }
.status-progress { background: #fff7ed; color: #c2410c; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-resolved, .status-closed { background: #dcfce7; color: #166534; }
.priority-critical, .priority-high { color: #b91c1c; background: #fee2e2; }
.priority-medium { color: #1d4ed8; background: #dbeafe; }
.priority-low { color: #475569; background: #f1f5f9; }
.grid2, .formgrid, .admin-grid, .detail-grid { display: grid; gap: 14px; }
.grid2, .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.formgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 18px; }
.admin-grid { grid-template-columns: 1fr 1fr; padding: 18px; }
.field.full, .form-actions { grid-column: 1 / -1; }
.admin-form { display: grid; gap: 12px; align-content: start; }
.admin-list { border: 1px solid var(--line); border-radius: 10px; max-height: 360px; overflow: auto; }
.admin-list-row, .queue-row, .status-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 11px 12px; border-bottom: 1px solid #edf1f6; }
.admin-list-row small { display: block; color: #64748b; margin-top: 3px; }
.sitegrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 16px; }
.site-card, .call-card { padding: 14px; }
.site-card h4 { margin: 0 0 6px; }
.site-stats { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; color: var(--muted); font-size: 12px; }
.report-filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; padding: 18px; }
.report-search { grid-column: span 2; }
.report-filter-actions { grid-column: 1 / -1; display: flex; gap: 10px; justify-content: flex-end; align-items: center; }
.report-clear { background: none; border: 0; color: var(--brand-deep); font-weight: 700; min-height: 44px; }
.report-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.report-chips:empty { display: none; }
.report-chip { border: 1px solid var(--brand-border); background: var(--brand-pale); color: var(--brand-deep); border-radius: 99px; padding: 6px 10px; font-weight: 700; }
.report-summary { margin: 0; padding: 0 18px 16px; font-weight: 750; color: var(--brand-deep); }
.report-row { cursor: pointer; }
.report-row:hover td { background: #f8fbfd; }
.report-col-detail { width: 1%; white-space: nowrap; }
.report-issue { display: block; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report-download-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 0 18px 8px; }
.report-download-groups h4 { margin: 0 0 4px; }
.report-download-groups p { margin: 0 0 8px; color: var(--muted); }
.report-download-groups .toolbar { padding: 0 0 12px; }
.report-filter-toggle, .report-download-toggle { display: none; }
.report-history { margin: 8px 0 0; padding-left: 18px; }
.report-history li { margin: 4px 0; }
.notice, .report-required { background: var(--brand-pale); border: 1px solid var(--brand-border); color: var(--brand-ink); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }
.login-screen { position: fixed; inset: 0; z-index: 80; background: linear-gradient(135deg, #10233b, #1d477a); display: grid; place-items: center; padding: 18px; overflow: auto; }
.login-card { width: min(440px, 100%); padding: 28px; border-top: 4px solid var(--brand-blue); box-shadow: 0 18px 48px #008fd322; }
.login-logo { width: 104px; height: 124px; object-fit: contain; margin: 0 auto 14px; display: block; }
.login-subtitle, .login-help { color: #64748b; }
.login-card .field { margin-bottom: 12px; }
.login-card .primary { width: 100%; }
.form-error { color: var(--danger); min-height: 1.2em; margin-top: 10px; font-size: 13px; }
.modal { position: fixed; inset: 0; z-index: 70; background: rgba(15, 23, 42, .55); display: grid; place-items: center; padding: 18px; }
.modal-card, .editor-modal { background: #fff; color: var(--brand-ink); border-radius: 14px; padding: 20px; width: min(860px, 100%); max-height: min(88vh, 900px); overflow: auto; }
.modal-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 12px; }
.modal-head h3 { margin: 0; }
.call-detail-head { position: sticky; top: 0; z-index: 1; background: #fff; margin: -20px -20px 16px; padding: 20px 20px 12px; border-bottom: 1px solid var(--line); }
.detail-item { padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.detail-item small, .detail-grid label { display: block; color: #64748b; font-size: 12px; margin-bottom: 4px; }
.timeline-item { padding: 10px 12px; border-left: 3px solid #cbd5e1; margin: 8px 0; background: #f8fafc; }
.empty { padding: 16px; color: #64748b; }
.footer { color: #64748b; font-size: 12px; padding: 8px 0 20px; }
.toast-wrap, #toastRoot { position: fixed; right: 16px; bottom: 16px; z-index: 90; }
.toast { background: #16364a; color: #fff; padding: 12px 14px; border-radius: 10px; max-width: min(360px, calc(100vw - 32px)); }
.engineer-identity { font-weight: 800; color: var(--brand-deep); padding: 10px 0; }
.call-card-top, .card-actions { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.call-card p { margin: 8px 0; }
.mobile-list { display: none; }
.menu-btn { background: var(--brand-pale); color: var(--brand-deep); border: 1px solid var(--brand-border); min-width: 44px; min-height: 44px; }

@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sitegrid, .report-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  aside { transform: translateX(-105%); width: min(300px, 88vw); }
  aside.open { transform: none; }
  .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 35; }
  .nav-backdrop[hidden] { display: none !important; }
  main { margin-left: 0; width: 100%; padding: 0 16px 28px; }
  .admin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .table-wrap { display: none; }
  .mobile-list { display: grid; gap: 10px; padding: 12px; }
  .cards, .grid2, .formgrid, .detail-grid, .report-filters, .sitegrid, .profile-form { grid-template-columns: 1fr; }
  .report-search { grid-column: auto; }
  .pagehead h2 { font-size: 22px; }
  .metric { font-size: 24px; }
  .report-filter-actions, .toolbar, .form-actions { flex-direction: column; align-items: stretch; }
  .call-detail-head { flex-direction: column; align-items: stretch; }
  .report-filter-toggle, .report-download-toggle { display: inline-flex; }
  #reportFilterPanel:not(.open) { display: none; }
  #reportDownloadGroups:not(.open) { display: none; }
  .report-download-groups { grid-template-columns: 1fr; }
  .report-issue { max-width: none; white-space: normal; }
  button, .nav, input, select, textarea { min-height: 44px; }
  .linkbtn, .link-btn { min-height: 44px; display: inline-flex; align-items: center; }
  .app-topbar { flex-wrap: wrap; }
  #currentUserLabel { width: 100%; }
}
@page report {
  size: A4 landscape;
  margin: 10mm;
}
@media print {
  aside, .app-topbar, .pagehead button, .filters, .form-actions, .nav, .notice, .menu-btn, .toolbar, .view-tabs { display: none !important; }
  main { margin: 0 !important; width: 100% !important; padding: 0 !important; }
  .table-wrap { display: block !important; overflow: visible !important; }
  .mobile-list { display: none !important; }
  table { min-width: 0; }
  body::before {
    content: "";
    position: fixed;
    top: 50%;
    left: 50%;
    width: 46%;
    height: 46%;
    transform: translate(-50%, -50%);
    background: url("/logo.png") center / contain no-repeat;
    opacity: .08;
    z-index: 0;
    pointer-events: none;
  }
  body.report-printing #page-reports { display: block !important; }
  body.report-printing #page-reports .report-filter-panel,
  body.report-printing #page-reports .pagehead,
  body.report-printing #page-reports .report-chips,
  body.report-printing #page-reports .report-downloads,
  body.report-printing #page-reports .report-danger,
  body.report-printing #page-reports .mobile-list { display: none !important; }
  body.report-printing { page: report; }
  body.report-printing #filteredReportTable { display: table !important; width: 100% !important; min-width: 0 !important; table-layout: fixed; font-size: 11px; }
  body.report-printing #filteredReportTable th,
  body.report-printing #filteredReportTable td { padding: 5px 6px; white-space: normal !important; overflow-wrap: anywhere; word-break: break-word; }
  body.report-printing #filteredReportTable thead { display: table-header-group; }
  body.report-printing #filteredReportTable tr { break-inside: avoid; }
  body.report-printing #reportResultPanel,
  body.report-printing .table-wrap { overflow: visible !important; max-width: 100% !important; }
  body.report-printing #reportSummary { display: block !important; }
  body.report-printing .report-issue { display: block !important; max-width: none !important; overflow: visible !important; text-overflow: unset !important; white-space: normal !important; }
  body.report-printing .report-col-detail { display: none !important; width: 0 !important; padding: 0 !important; border: 0 !important; }
  body.call-printing .layout,
  body.call-printing #loginScreen,
  body.call-printing #navBackdrop,
  body.call-printing #toastRoot,
  body.call-printing #customerComplaintModal { display: none !important; }
  body.call-printing #modalRoot .modal { position: static; background: #fff; padding: 0; display: block !important; }
  body.call-printing .editor-modal { max-height: none !important; overflow: visible !important; width: 100% !important; box-shadow: none; }
  body.call-printing .modal-actions,
  body.call-printing .icon-btn { display: none !important; }
}
