:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #eef3f7;
  --line: #d8e0e7;
  --text: #17202a;
  --muted: #667481;
  --primary: #1769aa;
  --primary-strong: #0f4f83;
  --accent: #2f8f5b;
  --danger: #b42318;
  --warning: #a15c07;
  --shadow: 0 14px 34px rgba(28, 39, 49, .12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
}

.brand img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.15;
  margin-bottom: 8px;
}

h2 {
  font-size: 18px;
  margin-bottom: 0;
}

.muted,
.status {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.login-grid {
  min-height: calc(100vh - 120px);
  display: grid;
  align-items: center;
  justify-items: center;
}

.login-panel {
  width: min(430px, 100%);
}

.mfa-setup-panel {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

.mfa-setup-panel h2 {
  margin: 0;
}

.mfa-qr {
  width: 220px;
  height: 220px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.mono {
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.stack {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: #344451;
  font-size: 14px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c9d4de;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 105, 170, .16);
}

.btn,
.icon-btn {
  min-height: 38px;
  border: 1px solid #b7c5d1;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 9px 13px;
  font-weight: 750;
}

.btn-primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-strong);
}

.btn-ghost {
  background: transparent;
}

.icon-btn {
  width: 38px;
  padding: 0;
}

.dashboard-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 16px 0 18px;
}

.flash {
  margin-bottom: 16px;
  border-radius: 8px;
  border: 1px solid #b8dcc9;
  background: #eaf7ef;
  color: #1f6b44;
  padding: 12px 14px;
}

.flash.error {
  border-color: #f1c0b8;
  background: #fff0ee;
  color: var(--danger);
}

.portal-inline-flash {
  display: inline-flex;
  align-items: center;
  max-width: min(420px, 100%);
  margin: 4px 0 4px 8px;
  padding: 7px 9px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.3;
  vertical-align: middle;
  white-space: normal;
  overflow-wrap: anywhere;
}

.portal-inline-flash-error {
  border: 1px solid #f1c0b8;
  background: #fff0ee;
  color: var(--danger);
}

.portal-inline-flash-ok {
  border: 1px solid #b8dcc9;
  background: #eaf7ef;
  color: #1f6b44;
}

.dialog-card footer .portal-inline-flash,
.comment-actions .portal-inline-flash,
.topbar-actions .portal-inline-flash {
  align-self: center;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metrics div {
  min-height: 76px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 14px;
  display: grid;
  align-content: center;
  gap: 2px;
}

.metrics strong {
  font-size: 26px;
}

.metrics span {
  color: var(--muted);
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head select,
.panel-head input {
  max-width: 230px;
}

.request-list,
.installation-list,
.report-list {
  display: grid;
  gap: 10px;
}

.request-row,
.installation-row,
.report-row {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  text-align: left;
}

.request-row,
.report-row {
  display: grid;
  gap: 8px;
}

.request-row.active,
.report-row.active {
  border-color: var(--primary);
  box-shadow: inset 3px 0 0 var(--primary);
}

.request-row-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 800;
}

.request-row-meta,
.request-row-sub {
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  background: #e8eef4;
  color: #334252;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.new {
  background: #fff6da;
  color: var(--warning);
}

.badge.accepted,
.badge.in_progress {
  background: #e6f0fb;
  color: var(--primary-strong);
}

.badge.resolved,
.badge.closed {
  background: #e8f6ee;
  color: var(--accent);
}

.badge.refused,
.badge.cancelled {
  background: #fff0ee;
  color: var(--danger);
}

.detail-panel {
  min-height: 460px;
}

.empty-state {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.detail-title {
  margin: 0;
}

.detail-grid,
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.detail-grid {
  margin-bottom: 16px;
}

.detail-field {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
}

.detail-field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 3px;
}

.timeline {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.timeline-item {
  border-left: 3px solid #b8c7d4;
  padding: 2px 0 2px 12px;
}

.timeline-item strong {
  display: block;
  margin-bottom: 4px;
}

.timeline-item p {
  margin-bottom: 4px;
  white-space: pre-wrap;
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 16px;
}

.attachments a {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--primary-strong);
  text-decoration: none;
  background: #fff;
  font-size: 13px;
}

.comment-box {
  display: grid;
  gap: 10px;
}

.comment-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.installations-panel {
  margin: 16px 0 36px;
}

.reports-panel {
  margin: 16px 0;
}

.reports-head {
  align-items: flex-start;
}

.reports-head p {
  margin: 6px 0 0;
}

.reports-filters {
  display: grid;
  grid-template-columns: 110px minmax(190px, 1fr) minmax(160px, 1fr) minmax(170px, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: min(100%, 860px);
}

.reports-filters select,
.reports-filters input {
  max-width: none;
}

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

.report-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.report-detail {
  min-height: 420px;
}

.portal-report-print-scope {
  color: #17202a;
}

.portal-report-screen-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.portal-report-paper {
  background: #fff;
  border: 1px solid #cfd8df;
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 10px 24px rgba(28, 39, 49, .10);
  font-family: Arial, Helvetica, sans-serif;
}

.portal-report-document-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  border-bottom: 3px solid #17202a;
  padding-bottom: 12px;
}

.portal-report-kicker {
  margin: 0;
  color: #526170;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.portal-report-title {
  margin: 4px 0 0;
  font-size: 24px;
  line-height: 1.05;
  text-transform: uppercase;
}

.portal-report-brand {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 10px;
  min-width: 190px;
  text-align: right;
}

.portal-report-brand img {
  width: 58px;
  height: 58px;
  object-fit: contain;
}

.portal-report-brand strong,
.portal-report-brand span {
  display: block;
}

.portal-report-brand strong {
  font-size: 15px;
  text-transform: uppercase;
}

.portal-report-brand span {
  margin-top: 4px;
  color: #667481;
  font-size: 12px;
}

.portal-report-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 16px 0 10px;
  border-top: 1px solid #9ba9b5;
  border-left: 1px solid #9ba9b5;
}

.portal-report-field {
  min-height: 66px;
  border-right: 1px solid #9ba9b5;
  border-bottom: 1px solid #9ba9b5;
  padding: 8px 10px;
  display: grid;
  align-content: start;
  gap: 7px;
}

.portal-report-field span,
.portal-report-strip strong {
  color: #526170;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.portal-report-field strong {
  min-width: 0;
  color: #17202a;
  font-size: 14px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.portal-report-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid #cfd8df;
  background: #f7f9fb;
}

.portal-report-strip span {
  min-width: 0;
  padding: 8px 10px;
  border-right: 1px solid #cfd8df;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.portal-report-strip span:last-child {
  border-right: 0;
}

.portal-report-strip strong {
  display: block;
  margin-bottom: 3px;
}

.portal-report-section {
  margin-top: 14px;
  break-inside: avoid;
}

.portal-report-section-title {
  margin: 0;
  padding: 6px 10px;
  border: 1px solid #17202a;
  background: #17202a;
  color: #fff;
  font-size: 12px;
  letter-spacing: .04em;
  line-height: 1.15;
  text-transform: uppercase;
}

.portal-report-checklist-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.portal-report-checklist-grid .portal-report-checklist-table:only-child {
  grid-column: 1 / -1;
}

.portal-report-checklist-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  border: 1px solid #9ba9b5;
  border-top: 0;
  font-size: 11px;
}

.portal-report-checklist-table th,
.portal-report-checklist-table td {
  border-right: 1px solid #cfd8df;
  border-bottom: 1px solid #d8e0e7;
  padding: 5px 6px;
  text-align: left;
  vertical-align: top;
}

.portal-report-checklist-table th {
  background: #eef3f7;
  color: #344451;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.portal-report-checklist-table th:nth-child(2),
.portal-report-checklist-table th:nth-child(3),
.portal-report-checklist-table td:nth-child(2),
.portal-report-checklist-table td:nth-child(3) {
  width: 46px;
  text-align: center;
}

.portal-report-checklist-table tr:last-child td {
  border-bottom: 0;
}

.portal-report-checklist-table small {
  display: block;
  margin-top: 3px;
  color: #667481;
  font-size: 10px;
  line-height: 1.25;
}

.portal-report-mark {
  font-weight: 800;
}

.portal-report-observations,
.portal-report-empty {
  min-height: 86px;
  border: 1px solid #9ba9b5;
  border-top: 0;
  padding: 10px;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.portal-report-empty {
  min-height: 0;
  margin: 0;
  color: #667481;
}

.portal-report-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.portal-report-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
  font-size: 13px;
}

.portal-report-table th,
.portal-report-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 9px;
  text-align: left;
  vertical-align: top;
}

.portal-report-table th {
  background: var(--surface-soft);
  color: #344451;
  font-weight: 800;
}

.portal-report-table tr:last-child td {
  border-bottom: 0;
}

.portal-report-photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.portal-report-photo {
  margin: 0;
  border: 1px solid #c6d0da;
  background: #fff;
  padding: 8px;
}

.portal-report-photo img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #f6f8fb;
  display: block;
}

.portal-report-photo figcaption {
  margin-top: 6px;
  color: #526170;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.portal-report-signatures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.portal-report-signature-box {
  min-height: 120px;
  border: 1px solid #9ba9b5;
  padding: 10px;
  display: grid;
  align-content: start;
  gap: 18px;
}

.portal-report-signature-box h3 {
  margin: 0;
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.portal-report-signature-box img {
  max-width: 100%;
  max-height: 70px;
  object-fit: contain;
  justify-self: start;
}

.portal-report-signature-box span {
  color: #526170;
  font-size: 12px;
}

.portal-report-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid #d8e0e7;
  color: #667481;
  font-size: 11px;
}

.installation-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.installation-row strong,
.installation-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

dialog {
  width: min(780px, calc(100% - 24px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(15, 31, 44, .3);
}

dialog::backdrop {
  background: rgba(17, 24, 39, .45);
}

.dialog-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  background: #fff;
}

.dialog-card header,
.dialog-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-card footer {
  justify-content: flex-end;
}

@media (max-width: 860px) {
  .shell {
    width: min(100% - 20px, 1320px);
  }

  .topbar {
    align-items: flex-start;
    padding-top: 12px;
  }

  .topbar-actions {
    flex-direction: column;
    align-items: flex-end;
  }

  .dashboard-head,
  .panel-head,
  .detail-header {
    flex-direction: column;
    align-items: stretch;
  }

  .metrics,
  .layout,
  .reports-layout,
  .portal-report-document-header,
  .portal-report-fields,
  .portal-report-strip,
  .portal-report-checklist-grid,
  .portal-report-signatures,
  .detail-grid,
  .form-grid,
  .installation-row,
  .reports-filters {
    grid-template-columns: 1fr;
  }

  .panel-head select,
  .panel-head input {
    max-width: none;
  }
}

@media print {
  @page {
    size: A4;
    margin: 10mm;
  }

  body.portal-print-report {
    background: #fff;
  }

  body.portal-print-report * {
    visibility: hidden;
  }

  body.portal-print-report #portalReportDetail,
  body.portal-print-report #portalReportDetail * {
    visibility: visible;
  }

  body.portal-print-report #portalReportDetail {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    min-height: 0;
    border: 0;
    box-shadow: none;
    padding: 0;
    background: #fff;
  }

  body.portal-print-report .portal-report-print-scope,
  body.portal-print-report .portal-report-paper {
    width: 100%;
  }

  body.portal-print-report .portal-report-paper {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
  }

  body.portal-print-report .no-print {
    display: none !important;
  }

  body.portal-print-report .portal-report-document-header {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    padding-bottom: 8px;
  }

  body.portal-print-report .portal-report-title {
    font-size: 21px;
  }

  body.portal-print-report .portal-report-brand img {
    width: 48px;
    height: 48px;
  }

  body.portal-print-report .portal-report-fields {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 10px 0 8px;
  }

  body.portal-print-report .portal-report-field {
    min-height: 48px;
    padding: 5px 7px;
    gap: 4px;
  }

  body.portal-print-report .portal-report-field strong,
  body.portal-print-report .portal-report-strip span {
    font-size: 10.5px;
  }

  body.portal-print-report .portal-report-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body.portal-print-report .portal-report-strip span {
    padding: 5px 7px;
  }

  body.portal-print-report .portal-report-section {
    margin-top: 9px;
  }

  body.portal-print-report .portal-report-section-title {
    padding: 4px 7px;
    font-size: 10px;
  }

  body.portal-print-report .portal-report-checklist-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  body.portal-print-report .portal-report-checklist-table {
    font-size: 8.8px;
  }

  body.portal-print-report .portal-report-checklist-table th,
  body.portal-print-report .portal-report-checklist-table td {
    padding: 3px 4px;
  }

  body.portal-print-report .portal-report-checklist-table small {
    font-size: 8px;
  }

  body.portal-print-report .portal-report-observations {
    min-height: 52px;
    padding: 6px 7px;
    font-size: 10px;
  }

  body.portal-print-report .portal-report-table-wrap {
    overflow: visible;
  }

  body.portal-print-report .portal-report-table {
    min-width: 0;
    font-size: 9.5px;
  }

  body.portal-print-report .portal-report-table th,
  body.portal-print-report .portal-report-table td {
    padding: 4px 5px;
  }

  body.portal-print-report .portal-report-signatures {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 9px;
  }

  body.portal-print-report .portal-report-signature-box {
    min-height: 74px;
    padding: 6px;
    gap: 12px;
  }

  body.portal-print-report .portal-report-footer {
    margin-top: 8px;
    padding-top: 5px;
    font-size: 9px;
  }
}
