@import url('components.css');

/* Matrix v0.5 tokens and shared components are copied from the user's standard.
   These rules adapt the existing asset registry, native window and dialogs. */
body { min-width: 0; }
button { min-height: var(--control); padding: 6px 12px; border: 1px solid var(--ink); border-radius: var(--radius); background: var(--normal); line-height: 20px; }
button:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 4px; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--normal); }
button:disabled { opacity: 1; border-style: dashed; color: var(--ink); background: var(--normal); cursor: not-allowed; }
button.quiet, button.link { background: transparent; border-color: transparent; }
button.link { padding: 6px; }
button.icon-button { width: 34px; padding: 0; flex-shrink: 0; }
input, select, textarea { min-height: var(--control); padding: 6px 10px; border: 1px solid var(--ink); border-radius: var(--radius); background: var(--normal); min-width: 0; max-width: 100%; line-height: 20px; }
input::placeholder, textarea::placeholder { color: var(--ink); opacity: 1; }
input:disabled, select:disabled, textarea:disabled { border-style: dashed; opacity: 1; color: var(--ink); -webkit-text-fill-color: var(--ink); background: var(--normal); }
input[aria-invalid=true], select[aria-invalid=true], textarea[aria-invalid=true] { border-color: var(--accent); }
select { padding-right: 28px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%23190300' d='m1 1 5 5 5-5'/%3E%3C/svg%3E"); background-position: right 9px center; background-repeat: no-repeat; }
.select-wrap select { background-image: none; }
textarea { resize: vertical; min-height: 88px; }
input[type=checkbox] { appearance: none; -webkit-appearance: none; display: inline-grid; place-content: center; width: 18px; height: 18px; min-height: 18px; padding: 0; margin: 7px; border-radius: 3px; vertical-align: middle; cursor: pointer; }
input[type=checkbox]:checked, input[type=checkbox]:indeterminate { background: var(--accent); border-color: var(--accent); }
input[type=checkbox]:checked::after { content: '✓'; color: var(--normal); line-height: 16px; }
input[type=checkbox]:indeterminate::after { content: '−'; color: var(--normal); line-height: 16px; }
input[type=file] { width: 100%; overflow: hidden; }
.mono { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.small, .hint, .muted { font-size: 14px; color: var(--ink); line-height: 22px; }
.spaced { margin-top: 16px; }
.nowrap { white-space: nowrap; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.skip-link { position: fixed; z-index: 1000; top: -90px; left: 16px; padding: 12px; background: var(--normal); border: 2px solid var(--ink); }
.skip-link:focus { top: 4px; }

/* Native shell; system window buttons remain real Electron window controls. */
.titlebar { -webkit-app-region: drag; user-select: none; padding-right: 154px; }
.titlebar button { -webkit-app-region: no-drag; }
.brand img.brand-mark { width: 42px; height: 28px; }
.mode-switch { margin-left: auto; padding: 6px 0; min-width: 0; }
.workspace { min-height: calc(100dvh - 48px); }
.sidebar { position: sticky; top: 0; height: calc(100dvh - 48px); }
#navigation { flex: 1; min-height: 0; overflow-y: auto; }
.nav-link { text-decoration: none; }
.sidebar-footer { flex-shrink: 0; }
.main-shell { display: flex; flex-direction: column; min-width: 0; }
.page-head { flex-shrink: 0; }
.page-identity { min-width: 0; }
.page-identity h1 { overflow-wrap: anywhere; }
.head-actions { min-width: 0; flex-wrap: wrap; }
.login-button { flex-shrink: 0; }
.search-wrap { min-width: 0; }
#main-content { flex: 1; min-width: 0; }
#main-content:focus { outline: none; }
.loading { padding: 32px 0; }
.work-empty { padding: 28px 12px; }
.work-empty h3 { margin-bottom: 12px; }
.work-empty p { max-width: 500px; line-height: 24px; margin-bottom: 20px; }
.progress-eight { width: 66.6667%; }
.progress-three { width: 37.5%; }
.inspector .timeline { list-style: none; }
.device-button { min-height: 0; border-radius: 0; }
.filter { border-radius: 0; }

/* Existing asset list retains all eleven fields and bulk selection. */
.summary { display: flex; align-items: center; flex-wrap: wrap; gap: 16px 24px; padding: 0 0 20px; border-bottom: 1px solid var(--boundary); margin-bottom: 28px; }
.summary-total { display: flex; align-items: baseline; gap: 8px; }
.summary-total strong { font-size: 32px; line-height: 40px; font-weight: 600; font-variant-numeric: tabular-nums; }
.summary-item { display: inline-flex; align-items: baseline; gap: 10px; }
.summary-item b { font-size: 18px; font-weight: 600; }
.tone-danger, .tone-warning { color: var(--accent); }
.asset-filters { align-items: end; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.filter-field { display: grid; gap: 8px; flex: 1; min-width: 120px; }
.filter-field.search-field { flex: 2; min-width: 220px; }
.filter-field input, .filter-field select { width: 100%; }
.filter-active { border-color: var(--accent); color: var(--accent); }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; min-height: 40px; margin-bottom: 12px; }
.table-toolbar b { font-weight: 600; }
.filter-breakdown { margin-left: 16px; }
.selected-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.selected-tools>span { color: var(--accent); }
.table-region { width: 100%; overflow: auto; padding: 2px; border-top: 1px solid var(--boundary); scrollbar-gutter: stable; }
table { width: 100%; font-size: 14px; text-align: left; }
.asset-table { min-width: 1660px; border-collapse: separate; border-spacing: 0 4px; }
.asset-table th { height: 32px; padding: 4px 10px; font-weight: 400; white-space: nowrap; }
.asset-table td { height: 60px; padding: 8px 10px; border-top: 1px solid var(--normal); border-bottom: 1px solid var(--normal); line-height: 20px; background: var(--normal); vertical-align: middle; }
.asset-table td:first-child { border-left: 1px solid var(--normal); border-radius: 6px 0 0 6px; }
.asset-table td:last-child { border-right: 1px solid var(--normal); border-radius: 0 6px 6px 0; }
.asset-table .is-selected td { border-top-color: var(--accent); border-bottom-color: var(--accent); }
.asset-table .is-selected td:first-child { border-left-color: var(--accent); }
.asset-table .is-selected td:last-child { border-right-color: var(--accent); }
.asset-table .is-selected .asset-name a { color: var(--accent); font-weight: 600; }
.asset-table th:first-child, .asset-table td:first-child { width: 40px; padding-left: 0; padding-right: 0; text-align: center; }
.asset-table .department { min-width: 110px; max-width: 160px; }
.asset-table .type { min-width: 100px; }
.asset-table .asset-name { min-width: 180px; max-width: 220px; font-weight: 500; }
.asset-table .asset-brand, .asset-table .model { min-width: 100px; max-width: 160px; overflow-wrap: anywhere; }
.asset-table .serial { min-width: 145px; max-width: 180px; overflow-wrap: anywhere; }
.asset-table .code, .asset-table .hospital-code { min-width: 140px; max-width: 180px; overflow-wrap: anywhere; }
.asset-table .row-actions { position: sticky; right: 0; min-width: 280px; white-space: nowrap; background: var(--normal); border-left: 1px solid var(--boundary); }
.row-actions button { padding: 6px; font-size: 14px; }
.pill { display: inline; font-size: 14px; line-height: 20px; white-space: nowrap; background: transparent; }
.asset-name a { text-decoration: none; }
.asset-name a:hover { text-decoration: underline; }
.pagination select { min-height: 32px; }
.empty { padding: 40px 16px; }
.empty h2 { margin-bottom: 12px; }
.empty p { max-width: 600px; margin: 0 auto 20px; line-height: 24px; }
.empty .actions { justify-content: center; }
.empty-icon { display: none; }

/* Full equipment file keeps the approved overview / facts / history structure. */
.detail-heading h1 { font-size: 24px; line-height: 32px; }
.back-link { display: inline-block; margin-bottom: 20px; }
.detail-layout { display: grid; grid-template-columns: 200px minmax(280px,1fr) 240px; gap: 28px; align-items: start; }
.detail-overview, .detail-center, .detail-right { min-width: 0; }
.asset-photo { width: 100%; aspect-ratio: 4/3; display: block; object-fit: contain; border: 1px solid var(--boundary); border-radius: 6px; background: var(--normal); }
.photo-placeholder { aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--ink); border-radius: 6px; }
.photo-placeholder>span { display: none; }
.overview-name { font-weight: 600; margin: 16px 0 8px; overflow-wrap: anywhere; }
.overview-meta { line-height: 24px; overflow-wrap: anywhere; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.tag { padding: 3px 6px; border: 1px solid var(--boundary); border-radius: 4px; overflow-wrap: anywhere; }
.detail-overview .detail-actions { margin-top: 16px; }
.detail-links { display: grid; gap: 2px; border-top: 1px solid var(--boundary); margin-top: 20px; padding-top: 12px; }
.detail-links button { display: flex; align-items: center; justify-content: space-between; text-align: left; padding: 8px 0; }
.detail-center>.detail-section { margin: 0 0 28px; scroll-margin-top: 16px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; margin-bottom: 16px; border-bottom: 1px solid var(--boundary); }
.fields-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px 24px; }
.datum dt { margin-bottom: 6px; }
.datum dd { line-height: 24px; white-space: pre-wrap; overflow-wrap: anywhere; }
.datum.wide { grid-column: 1/-1; }
.detail-right { padding: 20px; border: 1px solid var(--boundary); border-radius: 8px; }
.detail-right>h2 { margin-bottom: 8px; }
.detail-right .timeline { margin-top: 20px; gap: 20px; }
.detail-right .timeline li { display: block; }
.detail-right .timeline time { display: block; margin-bottom: 8px; }
.detail-right .timeline h3 { margin-bottom: 8px; }
.detail-right .timeline p { line-height: 22px; overflow-wrap: anywhere; }
.detail-right details { margin-top: 8px; }
.detail-right summary { cursor: pointer; min-height: 32px; }
.detail-right .change { padding: 8px 0; border-bottom: 1px solid var(--boundary); overflow-wrap: anywhere; }
.photo-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.photo-card { min-width: 0; overflow: hidden; padding: 0; border: 1px solid var(--boundary); }
.photo-card img { display: block; width: 100%; height: 108px; object-fit: cover; }
.photo-card span { display: block; padding: 8px; text-align: left; }
.note { line-height: 24px; }
.notice, .required { color: var(--accent); }
.required { margin-left: 4px; }
.module-empty { max-width: 800px; }
.module-empty h2 { margin: 20px 0 12px; }
.module-empty p { line-height: 24px; }
.workflow { list-style: none; margin: 20px 0; padding: 16px 0; border-top: 1px solid var(--boundary); }
.workflow li { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.workflow span { display: inline-grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--boundary); border-radius: 50%; }

/* Shared forms and dialogs. Scope login to the standard's compact 480px width. */
dialog { width: min(840px,calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; overflow: hidden; }
dialog[data-kind=login] { width: 480px; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 24px 16px; }
.dialog-header h2 { font-size: 18px; line-height: 26px; margin: 0; }
.dialog-body { padding: 0 24px 20px; max-height: calc(100dvh - 190px); overflow: auto; }
.dialog-footer { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--boundary); }
.dialog-footer .footer-note { margin-right: auto; }
.dialog-footer button { min-width: 80px; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px 24px; }
.form-field { display: grid; gap: 8px; min-width: 0; }
.form-field.wide { grid-column: 1/-1; }
.form-field input, .form-field select, .form-field textarea { width: 100%; }
.form-field input[type=checkbox] { width: 18px; }
.form-section { border: 0; border-top: 1px solid var(--boundary); padding-top: 16px; margin-top: 20px; }
.form-section:first-of-type { border: 0; margin: 0; padding: 0; }
.form-section>summary { font-size: 18px; font-weight: 600; line-height: 26px; min-height: 34px; cursor: pointer; margin-bottom: 12px; }
.form-hint { margin-bottom: 20px; }
.form-error { color: var(--accent); padding: 0 0 16px; line-height: 24px; }
.preview-table { margin-top: 16px; border-top: 1px solid var(--boundary); overflow: auto; max-height: 310px; }
.preview-table th, .preview-table td { padding: 10px 12px; border-bottom: 1px solid var(--boundary); vertical-align: top; line-height: 22px; }
.preview-table .error-row { color: var(--accent); }
.import-summary { margin-top: 16px; line-height: 24px; }
.qr-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.qr-label { border: 1px solid var(--ink); border-radius: 6px; padding: 14px; display: flex; align-items: center; gap: 12px; break-inside: avoid; }
.qr-label svg { width: 112px; height: 112px; stroke: none; flex-shrink: 0; }
.qr-label strong { display: block; line-height: 24px; overflow-wrap: anywhere; }
.qr-label p, .qr-label small { font-size: 14px; line-height: 22px; overflow-wrap: anywhere; }
.photo-large { max-width: 100%; max-height: 64vh; display: block; margin: 0 auto; }
.backup-actions>section { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--boundary); }
.backup-actions h3 { margin-bottom: 8px; }
.backup-actions p { margin-bottom: 12px; line-height: 24px; }
.toast { position: fixed; bottom: 24px; right: 24px; max-width: min(700px,calc(100vw - 32px)); z-index: 1001; background: var(--normal); color: var(--ink); border: 1px solid var(--ink); border-radius: 6px; padding: 12px 16px; font-size: 14px; line-height: 24px; }
.toast.error { color: var(--accent); border-color: var(--accent); }
.print-area { display: none; }

@media (max-width:1280px) {
  .detail-layout { grid-template-columns: 180px minmax(260px,1fr); gap: 24px; }
  .detail-right { grid-column: 2; }
  .filter-field { min-width: 140px; }
  .filter-breakdown { display: block; margin: 8px 0 0; }
}
@media (max-width:1120px) {
  .page-head { flex-wrap: wrap; gap: 16px; }
  .sidebar-bottom { margin-top: auto; }
}
@media (max-width:760px) {
  .sidebar { position: static; height: auto; flex-direction: row; align-items: flex-start; gap: 8px; padding: 8px 16px 16px; }
  #navigation { display: flex; align-items: flex-start; gap: 16px; overflow-x: auto; }
  #navigation>.nav-link { flex-shrink: 0; width: auto; }
  .sidebar-footer { display: block; padding: 0; margin: 0; }
  .sidebar-footer .nav-link { min-width: auto; }
  .titlebar { padding-right: 150px; gap: 8px; }
  .brand { font-size: 24px; }
  .mode-switch { display: none; }
  .main-shell { padding-top: 12px; }
  .head-actions { width: auto; max-width: 100%; }
  .page-head>.head-actions { width: 100%; justify-content: flex-start; }
  #page-tools { flex-wrap: wrap; }
  #page-tools:has(.search-wrap) { flex: 1; }
  .summary { gap: 12px 20px; margin-bottom: 20px; }
  .summary-total { width: 100%; }
  .filter-field { flex: 1 1 calc(50% - 12px); min-width: 0; }
  .filter-field.search-field { flex-basis: 100%; min-width: 0; }
  .asset-filters { display: flex; }
  .asset-table { min-width: 1660px; }
  .detail-layout { display: block; }
  .detail-overview { display: grid; grid-template-columns: 130px minmax(0,1fr); gap: 0 16px; margin-bottom: 24px; }
  .detail-overview>.asset-photo, .detail-overview>.photo-placeholder { grid-row: 1/6; }
  .detail-overview>.detail-links, .detail-overview>.detail-actions { grid-column: 1/-1; }
  .overview-name { margin-top: 0; }
  .detail-links { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .detail-right { margin-top: 24px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-field.wide { grid-column: auto; }
  .qr-grid { grid-template-columns: 1fr; }
  .photo-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .dialog-header { padding: 16px; }
  .dialog-body { padding: 0 16px 16px; max-height: calc(100dvh - 205px); }
  .dialog-footer { padding: 12px 16px; }
}
@media (pointer:coarse),(max-width:520px) {
  button, input:not([type=checkbox]), select, textarea { min-height: 48px; }
  .device-button { min-height: 48px; }
  .row-actions button { min-height: 48px; }
  .fields-grid { grid-template-columns: 1fr; }
  .dialog-footer .footer-note { width: 100%; }
}
.connection-status { margin: 0 28px 12px; padding: 9px 12px; border: 1px solid #E5E5E5; background: #FFF; font-size: 14px; overflow-wrap: anywhere; }
.server-address { overflow-wrap: anywhere; }
@media (max-width: 760px) { .connection-status { margin: 0 16px 12px; } }
@media print {
  body>*:not(.print-area) { display: none!important; }
  .print-area { display: block; }
  .print-area h1 { font-size: 18px; margin-bottom: 12px; }
  .print-area .qr-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .qr-label svg { width: 28mm; height: 28mm; }
  @page { size: A4; margin: 12mm; }
}
