:root {
  color-scheme: light;
  --navy: #24347b;
  --navy-dark: #15255f;
  --navy-soft: #eef1fb;
  --red: #bf2b2b;
  --green: #26724d;
  --amber: #a56700;
  --ink: #172033;
  --muted: #657086;
  --bg: #f3f6fb;
  --surface: #ffffff;
  --line: #dbe0e8;
  --soft-red: #fbecec;
  --soft-green: #e9f5ee;
  --soft-amber: #fff4de;
  --radius: 7px;
  --shadow: 0 8px 24px rgba(27, 48, 94, 0.08);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button,
input,
select,
textarea { font: inherit; }

button {
  min-height: 40px;
  border: 1px solid var(--navy);
  border-radius: var(--radius);
  background: var(--navy);
  color: #fff;
  cursor: pointer;
  padding: 8px 15px;
}

button:hover { background: var(--navy-dark); }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(36, 52, 123, 0.2);
  outline-offset: 1px;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.button-secondary {
  background: #fff;
  color: var(--navy);
}

.button-secondary:hover,
.button-quiet:hover {
  background: var(--navy-soft);
  color: var(--navy-dark);
}

.button-quiet {
  border-color: var(--line);
  background: transparent;
  color: var(--ink);
}

.button-danger {
  border-color: #e4b5b5;
  background: #fff;
  color: var(--red);
}

.button-danger:hover { background: var(--soft-red); }

label {
  display: grid;
  gap: 6px;
  color: #354057;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cbd2df;
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

textarea { resize: vertical; }

fieldset {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

legend {
  color: #354057;
  font-size: 13px;
  font-weight: 700;
  padding: 0 6px;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(390px, 480px);
  background: #dceefe;
}

.login-visual {
  min-width: 0;
  background: #dceefe url("assets/login-landscape.png") center center / cover no-repeat;
}

.login-panel {
  display: grid;
  align-content: center;
  gap: 22px;
  min-height: 100vh;
  border-left: 1px solid #d5deeb;
  border-top: 7px solid var(--navy);
  background: #fff;
  box-shadow: -16px 0 40px rgba(15, 38, 81, .12);
  padding: clamp(36px, 5vw, 64px);
}

.login-panel h1 {
  margin: 8px 0 4px;
  font-size: 28px;
  letter-spacing: 0;
}

.login-panel p { margin: 0; color: var(--muted); }

.environment-label {
  display: inline-block;
  color: var(--navy);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.login-form { display: grid; gap: 15px; }

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.app-header { background: #eaf4fe; }
.brand-banner { position: relative; height: clamp(160px, 12.5vw, 220px); display: flex; align-items: center; overflow: hidden; background: #eaf4fe url("assets/banner-landscape.png") center / cover no-repeat; }
.brand-banner > img { position: relative; z-index: 1; display: block; width: auto; max-width: min(620px, 48vw); height: calc(100% - 28px); margin-left: max(20px, calc((100% - 1320px) / 2)); object-fit: contain; }
.banner-controls { position: absolute; z-index: 2; right: max(18px, calc((100% - 1320px) / 2)); bottom: 10px; max-width: min(660px, calc(100% - 36px)); border: 1px solid rgba(145, 169, 204, .58); border-radius: 8px; background: rgba(255, 255, 255, .9); box-shadow: 0 8px 24px rgba(15, 38, 81, .14); padding: 9px 11px; backdrop-filter: blur(8px); }

.header-tools,
.tabs-inner,
.section-title,
.split,
.form-actions,
.user-summary {
  display: flex;
  align-items: center;
}

.header-tools { justify-content: flex-end; gap: 9px; }
.button-icon { width: 17px; height: 17px; object-fit: contain; filter: brightness(0) saturate(100%) invert(19%) sepia(34%) saturate(2594%) hue-rotate(201deg) brightness(88%) contrast(93%); }
.user-summary { display: grid; text-align: right; margin-right: 4px; }
.user-summary strong { font-size: 14px; }
.user-summary span { color: var(--muted); font-size: 12px; }
.sync-message { max-width: 220px; color: #b42318; font-size: 12px; line-height: 1.25; }
.sync-message:empty { display: none; }
.sync-message.success { color: #167a4b; }

.tabs { background: var(--navy-dark); box-shadow: 0 3px 10px rgba(15, 31, 82, .2); }

.tabs-inner {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs-inner::-webkit-scrollbar { display: none; }

.tab {
  min-width: max-content;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-bottom: 4px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #fff;
  font-weight: 700;
}
.tab > img { width: 19px; height: 19px; flex: 0 0 auto; object-fit: contain; }

.tab:hover,
.tab.active {
  border-bottom-color: #fff;
  background: rgba(255, 255, 255, 0.11);
}
.nav-menu { flex: 0 0 auto; }
.report-menu-toggle .menu-chevron { font-size: 12px; transition: transform .16s ease; }
.report-menu-toggle[aria-expanded="true"] .menu-chevron { transform: rotate(180deg); }
.report-menu {
  position: fixed;
  z-index: 100;
  display: grid;
  width: min(300px, calc(100vw - 16px));
  overflow: hidden;
  border: 1px solid #cbd5e3;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(15, 31, 82, .22);
}
.report-menu[hidden] { display: none; }
.report-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  border: 0;
  border-bottom: 1px solid #e4e9f1;
  border-radius: 0;
  background: #fff;
  color: var(--navy-dark);
  text-align: left;
  font-weight: 700;
}
.report-menu-item:last-child { border-bottom: 0; }
.report-menu-item:hover,
.report-menu-item:focus-visible,
.report-menu-item.active { background: #eef4ff; }
.report-menu-item > img { width: 19px; height: 19px; flex: 0 0 auto; object-fit: contain; filter: brightness(0) saturate(100%) invert(18%) sepia(46%) saturate(1878%) hue-rotate(202deg) brightness(88%) contrast(93%); }

main {
  width: min(1320px, calc(100% - 32px));
  margin: 22px auto 54px;
}

#dashboardView { gap: 14px; }
#dashboardView .page-heading { min-height: 54px; padding-bottom: 8px; }

.view { display: none; }
.view.active { display: grid; gap: 16px; }

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  border-bottom: 2px solid var(--navy);
  padding-bottom: 10px;
}

.page-heading h1 { margin: 0; font-size: 25px; letter-spacing: 0; }
.eyebrow { margin: 0 0 2px; color: var(--navy); font-size: 12px; font-weight: 700; }
.scope-label { color: var(--muted); font-size: 13px; font-weight: 700; }

.file-warning {
  display: none;
  margin-bottom: 16px;
  border: 1px solid #d79e3c;
  border-radius: var(--radius);
  background: var(--soft-amber);
  color: #604000;
  padding: 12px 14px;
  font-weight: 700;
}

.is-file .file-warning,
.file-warning.visible { display: block; }

.runtime-error { border-color: #dc9a9a; background: var(--soft-red); color: var(--red); }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.metric {
  min-width: 0;
  min-height: 142px;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  grid-template-rows: auto auto auto 1fr;
  align-content: start;
  column-gap: 14px;
  row-gap: 4px;
  border: 1px solid var(--line);
  border-top: 0;
  border-left: 4px solid var(--navy);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  box-shadow: var(--shadow);
  padding: 15px;
}
.metric-top { display: contents; }
.metric-top > span { min-width: 0; grid-column: 2; grid-row: 1; align-self: end; }
.metric-top > .kpi-icon { grid-column: 1; grid-row: 1 / span 2; display: grid; width: 48px; min-width: 48px; height: 48px; place-items: center; overflow: hidden; border-radius: 8px; background: #eef3ff; }
.metric-top > .kpi-icon > img { display: block; width: 30px; min-width: 30px; max-width: 30px; height: 30px; min-height: 30px; max-height: 30px; object-fit: contain; flex-shrink: 0; }
.metric.danger .metric-top > .kpi-icon { background: var(--soft-red); }
.metric.warning .metric-top > .kpi-icon { background: var(--soft-amber); }
.metric.neutral .metric-top > .kpi-icon { background: #edf0f4; }
.metric .kpi-change { grid-column: 2; grid-row: 3; display: inline-flex; width: max-content; align-items: center; min-height: 23px; border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 800; }
.kpi-change.positive { background: var(--soft-green); color: var(--green); }
.kpi-change.negative { background: var(--soft-red); color: var(--red); }
.kpi-change.warning { background: var(--soft-amber); color: var(--amber); }
.kpi-change.neutral { background: #edf0f4; color: var(--muted); }

.metric:hover,
.metric.active { border-color: var(--navy); background: #f7f9ff; color: var(--ink); transform: translateY(-1px); }
.metric.danger { border-left-color: var(--red); }
.metric.warning { border-left-color: var(--amber); }
.metric.neutral { border-left-color: #657086; }
.metric[hidden] { display: none; }
.metric span { color: var(--muted); font-size: 13px; font-weight: 700; }
.metric strong { grid-column: 2; grid-row: 2; font-size: 32px; line-height: 1.05; }
.metric small { grid-column: 2; grid-row: 4; align-self: end; margin-top: 3px; color: var(--navy); font-size: 12px; }

.detail-panel,
.surface {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
}

.detail-panel { border-left: 5px solid var(--navy); }
.detail-panel h2 { margin: 0 0 14px; font-size: 18px; }
.detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

.detail-stat {
  min-width: 0;
  border-left: 3px solid var(--navy);
  background: #f7f8fb;
  padding: 10px 12px;
}

.detail-stat span { display: block; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.detail-stat strong { display: block; margin-top: 3px; font-size: 23px; }

.dashboard-analytics-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.trend-card { grid-column: span 2; }
.schedule-card { grid-column: 1 / -1; min-height: 0; }
.chart-card { min-height: 330px; }
.card-eyebrow { margin: 0 0 3px; color: #73809a; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.compact-filter { display: flex; grid-template-columns: auto 96px; align-items: center; gap: 7px; font-size: 12px; }
.compact-filter select { width: 96px; min-height: 34px; padding: 5px 28px 5px 9px; }
.monthly-trend { min-height: 245px; display: grid; place-items: center; }
.monthly-trend svg { display: block; width: 100%; height: auto; overflow: visible; }
.monthly-trend line { stroke: #e3e8f1; stroke-width: 1; }
.monthly-trend polyline { fill: none; stroke: #244a9b; stroke-linecap: round; stroke-linejoin: round; stroke-width: 4; }
.monthly-trend circle { fill: #fff; stroke: #244a9b; stroke-width: 3; }
.monthly-trend text { fill: #758096; font-size: 11px; }
.monthly-trend .trend-value { fill: #24347b; font-weight: 800; }
.monthly-trend .trend-month { font-weight: 700; }
.donut-layout { min-height: 235px; display: grid; grid-template-columns: minmax(126px, .8fr) minmax(150px, 1.2fr); align-items: center; gap: 20px; }
.donut-chart { display: block; width: min(180px, 100%); margin: auto; overflow: visible; }
.donut-base, .donut-segment { fill: none; stroke-width: 15; }
.donut-base { stroke: #e1e7f0; }
.donut-segment { transform: rotate(-90deg); transform-origin: 50% 50%; stroke-linecap: butt; }
.donut-total { fill: var(--navy-dark); font-size: 18px; font-weight: 800; text-anchor: middle; }
.donut-caption { fill: var(--muted); font-size: 7px; font-weight: 700; text-anchor: middle; }
.donut { position: relative; width: min(180px, 100%); aspect-ratio: 1; margin: auto; border-radius: 50%; background: var(--donut-segments, conic-gradient(#dfe5ee 0 100%)); }
.donut::after { position: absolute; inset: 24%; border-radius: 50%; background: #fff; content: ""; }
.donut > span { position: absolute; inset: 28%; z-index: 1; display: grid; place-content: center; text-align: center; }
.donut strong { color: var(--navy-dark); font-size: 28px; line-height: 1; }
.donut small { margin-top: 4px; color: var(--muted); font-size: 11px; font-weight: 700; }
.empty-donut { opacity: .75; }
.donut-legend { display: grid; align-content: center; gap: 3px; max-height: 245px; overflow: auto; }
.legend-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 38px; align-items: center; gap: 9px; border-bottom: 1px solid #edf0f5; padding: 6px 0; }
.legend-row:last-child { border-bottom: 0; }
.legend-row > .donut-legend-marker { display: block; width: 10px; min-width: 10px; max-width: 10px; height: 10px; min-height: 10px; max-height: 10px; justify-self: center; overflow: visible; flex-shrink: 0; }
.legend-row strong { overflow-wrap: anywhere; font-size: 12px; }
.legend-row > span { color: var(--ink); font-size: 12px; font-weight: 800; }
.legend-row small { color: var(--muted); font-size: 11px; text-align: right; }
.section-title { justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-title h2 { margin: 0; font-size: 18px; letter-spacing: 0; }
.section-title h3 { margin: 0; font-size: 16px; letter-spacing: 0; }
.split { justify-content: space-between; }
.subsection-title { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 18px; }

.badge,
.status-pill,
.severity {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 27px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
}

.badge { background: var(--soft-red); color: var(--red); }
.badge.online { background: var(--soft-green); color: var(--green); }
.badge.soft { background: var(--navy-soft); color: var(--navy); }
.status-pill.unresolved { background: var(--soft-amber); color: var(--amber); }
.status-pill.resolved { background: var(--soft-green); color: var(--green); }
.severity.low { background: var(--soft-green); color: var(--green); }
.severity.medium { background: var(--soft-amber); color: var(--amber); }
.severity.high { background: var(--soft-red); color: var(--red); }
.severity.variable,
.severity.unknown { background: var(--navy-soft); color: var(--navy); }

.bars,
.schedule-overview,
.defect-list,
.detail-list { display: grid; gap: 10px; }

.bar-row { display: grid; grid-template-columns: minmax(145px, 230px) 1fr 38px; align-items: center; gap: 12px; }
.bar-row strong { overflow-wrap: anywhere; font-size: 13px; }
.bar-track { height: 11px; overflow: hidden; border-radius: 999px; background: #eaedf2; }
.bar-fill { height: 100%; background: var(--navy); }
.bar-fill.resolved { background: var(--green); }
.bar-fill.unresolved { background: var(--amber); }

.schedule-line,
.detail-list-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) auto;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 7px 0;
}

.schedule-line:last-child,
.detail-list-row:last-child { border-bottom: 0; }
.schedule-line span,
.detail-list-row span { color: var(--muted); font-size: 13px; }
.schedule-line strong,
.detail-list-row strong { overflow-wrap: anywhere; }

.grid-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.grid-form .wide { grid-column: span 2; }
.resolution-number-control { display: flex; align-items: stretch; gap: 8px; }
.resolution-number-control input { min-width: 0; flex: 1; }
.resolution-number-control button { flex: 0 0 auto; white-space: nowrap; }
.grid-form .form-actions,
.grid-form .message { grid-column: 1 / -1; }
.form-actions { justify-content: flex-end; gap: 9px; }
.defect-entry-form { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px 12px; align-items: start; }
.defect-entry-form > label:has(#defectGroup) { grid-column: span 3; }
.defect-entry-form > label:has(#defectType) { grid-column: span 6; }
.defect-entry-form > label:has(#defectPosition) { grid-column: span 3; }
.defect-entry-form > label:has(#circuit),
.defect-entry-form > label:has(#defectTowerStart),
.defect-entry-form > label:has(#defectTowerEnd),
.defect-entry-form > label:has(#defectPhase),
.defect-entry-form > label:has(#severity) { grid-column: span 3; }
.defect-entry-form > label:has(#defectNote),
.defect-entry-form > .photo-fieldset { grid-column: span 6; min-height: 132px; }
.defect-entry-form textarea { min-height: 104px; }
.defect-entry-form > .form-actions,
.defect-entry-form > .message,
.defect-entry-form > .duplicate-warning { grid-column: 1 / -1; }
.message { min-height: 20px; margin: 0; color: var(--red); font-weight: 700; }
.message.success { color: var(--green); }
.message.warning { color: var(--amber); }
.resolution-job-hint:empty { display: none; }
#resolutionBrigadeMembers[readonly],
#resolutionMachineryUsed[readonly] { background: #eef2f8; color: var(--muted); }

.phase-readout[readonly] {
  border-color: #aebbe1;
  background: var(--navy-soft);
  color: var(--navy-dark);
  font-weight: 700;
}

.field-hint,
.section-note { color: var(--muted); font-size: 12px; font-weight: 400; }
.field-hint.warning { color: var(--amber); font-weight: 700; }
.section-note { margin: 2px 0 0; }

.inspection-workspace { display: grid; gap: 16px; }
.active-inspection-summary { border-left: 5px solid var(--green); }
.active-inspection-summary .eyebrow { margin-bottom: 3px; }
.inspection-context {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 16px;
}
.inspection-context div { border-left: 3px solid var(--navy); background: #f7f8fb; padding: 9px 11px; }
.inspection-context dt { color: var(--muted); font-size: 12px; font-weight: 700; }
.inspection-context dd { margin: 3px 0 0; overflow-wrap: anywhere; font-weight: 700; }
.inspection-history-detail { margin-top: 18px; }
.inspection-history-table { min-width: 760px; }

.photo-fieldset { align-self: end; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.photo-action {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  overflow: hidden;
  border: 1px solid var(--navy);
  border-radius: var(--radius);
  background: var(--navy);
  color: #fff;
  cursor: pointer;
  padding: 8px 14px;
}
.photo-action.secondary { background: #fff; color: var(--navy); }
.photo-action input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.photo-selection { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; color: var(--muted); font-size: 12px; }
.photo-selection-item { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #f7f8fb; padding: 5px 7px; }
.photo-selection-item button { min-height: 24px; width: 24px; border-color: var(--line); background: transparent; color: var(--red); padding: 0; }

.filter-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.filter-row .form-actions { grid-column: 1 / -1; }

.table-wrap { min-width: 0; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; min-width: 820px; border-collapse: collapse; background: #fff; }
th,
td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; vertical-align: top; }
th { position: sticky; top: 0; z-index: 1; background: #edf0f6; color: #2d3852; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
.compact-table { margin-top: 18px; }

.permission-table { min-width: 1080px; }
.permission-table th:not(:first-child),
.permission-table td:not(:first-child) { text-align: center; }

.permission-value {
  display: inline-flex;
  min-width: 48px;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.permission-value.yes { background: var(--soft-green); color: var(--green); }
.permission-value.no { background: #eef0f4; color: var(--muted); }
.permission-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; }
.permission-toggle input { width: 18px; min-height: 18px; }

.report-status-select {
  min-width: 120px;
  min-height: 34px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 700;
}

.report-status-select.unresolved { border-color: #d29a3c; color: var(--amber); }
.report-status-select.resolved { border-color: #6ba889; color: var(--green); }

.defect-item {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) minmax(130px, auto);
  gap: 13px;
  align-items: start;
  border: 1px solid var(--line);
  border-left: 4px solid var(--navy);
  border-radius: var(--radius);
  padding: 10px;
}

.thumb { width: 96px; height: 72px; object-fit: cover; border-radius: 4px; background: #edf0f4; }
.defect-item h3 { margin: 0 0 4px; font-size: 15px; }
.defect-item p { margin: 2px 0; color: var(--muted); font-size: 13px; }
.defect-controls { display: grid; justify-items: end; gap: 8px; }
.defect-controls select { min-width: 130px; min-height: 34px; padding: 5px 8px; font-size: 12px; }

.resolution-list { display: grid; gap: 10px; }
.resolution-list-item {
  display: grid;
  grid-template-columns: 96px minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  padding: 10px;
}
.resolution-list-item p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.resolution-defect-detail { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.resolution-defect-detail > div:not(.resolution-source-photos) { border-left: 3px solid var(--navy); background: #f4f6fa; padding: 9px 11px; }
.resolution-defect-detail span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.resolution-defect-detail .wide-detail { grid-column: 1 / -1; }
.resolution-source-photos { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.resolution-source-photos img { width: 150px; height: 110px; object-fit: cover; border: 1px solid var(--line); border-radius: 4px; }
.compact-filters { margin-bottom: 16px; }
.resolution-list-action { display: grid; justify-items: end; gap: 8px; }
.resolution-badges { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.resolution-summary { max-width: 340px; text-align: left; }
.resolution-summary summary { color: var(--navy); cursor: pointer; font-size: 12px; font-weight: 700; }
.resolution-summary p { margin: 5px 0; color: var(--text); font-size: 12px; }
.resolution-inline-photos { display: flex; flex-wrap: wrap; gap: 6px; }
.resolution-inline-photos img { width: 72px; height: 54px; object-fit: cover; border: 1px solid var(--line); }
.report-photo-links { display: flex; gap: 7px; white-space: nowrap; }
.photo-preview-button { border: 0; background: transparent; padding: 0; min-height: 0; cursor: pointer; }
.photo-preview-button img { display: block; }
.photo-preview-button.photo-load-failed { min-width: 110px; min-height: 72px; border: 1px dashed var(--line); }
.photo-preview-button.photo-load-failed img { display: none; }
.photo-preview-button.photo-load-failed::after { color: var(--muted); font-size: 11px; content: "Зураг олдсонгүй"; }
.photo-missing { display: grid; width: 100%; aspect-ratio: 4 / 3; place-items: center; border: 1px dashed var(--line); color: var(--muted); font-size: 12px; }
.photo-unavailable { color: var(--muted); font-size: 12px; }
.defect-photo-group { display: flex; flex-wrap: wrap; gap: 8px; }
.defect-item > .defect-photo-group { width: 196px; }
.defect-item > .defect-photo-group .evidence-photo { width: 92px; }
.status-pill.pending { background: #eef2ff; color: var(--navy); }
.review-layout { display: grid; grid-template-columns: minmax(280px, .8fr) minmax(0, 1.5fr); gap: 16px; align-items: start; }
.review-list { display: grid; gap: 8px; }
.review-list-item { display: grid; gap: 5px; width: 100%; min-height: 0; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 12px; text-align: left; }
.review-list-item:hover { border-color: var(--navy); background: #f7f9ff; }
.review-list-item span, .review-list-item small { color: var(--muted); }
.review-reason { display: grid; gap: 6px; margin-top: 16px; font-weight: 700; }
.review-history { margin: 14px 0; }
.review-history h3 { font-size: 15px; }
.review-timeline:empty { display: none; }
.duplicate-warning { border: 1px solid #d29a3c; border-left: 4px solid var(--amber); background: #fff8e8; padding: 13px; }
.duplicate-warning h3 { margin: 0 0 5px; font-size: 15px; }
.duplicate-warning > p { margin: 0 0 10px; color: #6e531f; }
.duplicate-match { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(220px, 2fr) auto; gap: 9px; align-items: center; border-top: 1px solid #ead6a7; padding: 9px 0; }
.duplicate-match span { color: var(--muted); font-size: 13px; }
.link-button { min-height: 0; border: 0; background: transparent; color: var(--navy); padding: 0; text-align: left; text-decoration: underline; }
.defect-timeline { max-width: 420px; text-align: left; }
.defect-timeline summary { color: var(--navy); cursor: pointer; font-size: 12px; font-weight: 700; }
.timeline-list { border-left: 2px solid var(--line); margin: 10px 0 0 6px; padding-left: 15px; }
.timeline-event { position: relative; padding: 0 0 16px; }
.timeline-event::before { position: absolute; top: 5px; left: -21px; width: 10px; height: 10px; border-radius: 50%; background: var(--navy); content: ""; }
.timeline-event time { display: block; color: var(--muted); font-size: 11px; }
.timeline-event strong { display: block; margin: 2px 0; font-size: 13px; }
.timeline-event p { margin: 2px 0; color: var(--muted); font-size: 12px; }
.timeline-photos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.timeline-photos img { width: 76px; height: 56px; border: 1px solid var(--line); object-fit: cover; }
.legacy-history-note, .offline-note { color: var(--amber); font-size: 12px; font-weight: 700; }
.tower-history-content > h3 { margin: 18px 0 8px; font-size: 16px; }
.tower-defect-list { display: grid; gap: 10px; }
.tower-defect-card { border: 1px solid var(--line); border-left: 4px solid var(--navy); padding: 12px; }
.tower-defect-card > p { color: var(--muted); font-size: 13px; }
.tower-defect-heading { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.tab-count { display: inline-grid; min-width: 20px; min-height: 20px; place-items: center; margin-left: 5px; border-radius: 10px; background: rgba(255, 255, 255, .18); font-size: 11px; }
.sync-summary { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.sync-summary > div { border-top: 4px solid var(--navy); background: #fff; box-shadow: var(--shadow); padding: 13px; }
.sync-summary span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.sync-summary strong { display: block; margin-top: 5px; color: var(--navy); font-size: 27px; }
.sync-offline-notice { margin-bottom: 14px; border-left: 4px solid var(--amber); background: #fff7df; padding: 12px 14px; color: #72550b; font-weight: 700; }
.sync-center-status { display: flex; flex-wrap: wrap; gap: 18px 42px; margin-bottom: 14px; }
.sync-center-status > div { display: grid; gap: 4px; }
.sync-center-status span { color: var(--muted); }
.sync-status-value { display: inline-flex; align-items: center; gap: 7px; }
.sync-status-icon { display: block; width: .82em; height: .82em; flex: 0 0 auto; object-fit: contain; }
.sync-status-icon.success { width: 1em; height: 1em; }
.sync-queue-list { display: grid; gap: 10px; }
.sync-queue-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; border: 1px solid var(--line); border-left: 5px solid #8d98a9; padding: 13px; }
.sync-queue-item.sync-state-failed { border-left-color: var(--red); }
.sync-queue-item.sync-state-conflict { border-left-color: var(--amber); }
.sync-queue-item.sync-state-syncing { border-left-color: var(--navy); }
.sync-queue-item.sync-state-waiting { border-left-color: #7b8799; }
.sync-item-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.sync-item-main p { margin: 4px 0; color: var(--muted); font-size: 13px; }
.sync-item-main small { color: var(--muted); overflow-wrap: anywhere; }
.sync-state-badge { display: inline-block; border-radius: 10px; padding: 3px 8px; background: #edf0f5; color: #4b5565; font-size: 11px; font-weight: 800; }
.sync-state-badge.synced { background: #e2f4e9; color: #16743c; }
.sync-state-badge.failed { background: #fde8e7; color: var(--red); }
.sync-state-badge.conflict { background: #fff0c7; color: #785407; }
.sync-state-badge.syncing { background: #e5ebff; color: var(--navy); }
.sync-state-badge.waiting { background: #edf0f4; color: #53657e; }
.sync-error { display: grid; gap: 3px; margin-top: 9px; border-left: 3px solid var(--red); background: #fff5f4; padding: 8px 10px; color: var(--red); font-size: 12px; }
.sync-state-waiting .sync-error { border-left-color: #7b8799; background: #f4f6f8; color: #53657e; }
.sync-item-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.sync-item-actions .danger { border-color: var(--red); background: #fff; color: var(--red); }
.evidence-photo { display: grid; gap: 5px; width: min(160px, 100%); margin: 0; align-content: start; }
.evidence-photo img { display: block; width: 100%; aspect-ratio: 4 / 3; border: 1px solid var(--line); object-fit: cover; }
.evidence-photo figcaption { color: var(--muted); font-size: 11px; }
.evidence-photo figcaption a { color: var(--navy); }
.defect-item > .evidence-photo { width: 92px; }
.annotation-dialog { width: min(1100px, calc(100% - 24px)); max-height: calc(100vh - 24px); border: 0; padding: 0; background: #fff; box-shadow: 0 18px 55px rgba(0, 0, 0, .28); }
.annotation-dialog::backdrop { background: rgba(5, 16, 45, .72); }
.photo-viewer-dialog { width: min(1100px, calc(100% - 24px)); max-height: calc(100vh - 24px); border: 0; padding: 0; background: #fff; box-shadow: 0 18px 55px rgba(0, 0, 0, .28); }
.photo-viewer-dialog::backdrop { background: rgba(5, 16, 45, .72); }
.photo-viewer-dialog header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 12px 16px; }
.photo-viewer-dialog h2 { margin: 0; font-size: 18px; }
.photo-viewer-stage { display: grid; min-height: 240px; max-height: calc(100vh - 100px); place-items: center; overflow: auto; padding: 14px; background: #20242c; color: #fff; }
.photo-viewer-stage img { display: block; max-width: 100%; max-height: calc(100vh - 130px); object-fit: contain; }
.annotation-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); padding: 14px 18px; }
.annotation-header h2 { margin: 2px 0 0; font-size: 20px; }
.annotation-header small { color: var(--muted); }
.annotation-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 18px; background: #f5f7fb; }
.annotation-tools { display: flex; flex-wrap: wrap; gap: 4px; margin-right: auto; }
.annotation-tool { min-height: 36px; border: 1px solid var(--line); background: #fff; color: var(--navy); padding: 6px 11px; }
.annotation-tool.active { background: var(--navy); color: #fff; }
.annotation-text-field { display: flex; align-items: center; gap: 6px; color: var(--navy); font-size: 13px; font-weight: 700; }
.annotation-text-field input { width: min(240px, 42vw); min-height: 36px; }
.annotation-text-field.hidden { display: none; }
.annotation-stage { display: grid; place-items: center; min-height: 260px; max-height: calc(100vh - 250px); overflow: auto; padding: 12px; background: #20242c; touch-action: none; }
.annotation-stage canvas { display: block; max-width: 100%; max-height: calc(100vh - 280px); background: #fff; touch-action: none; }
.annotation-dialog > .message { margin: 8px 18px; }
.annotation-actions { display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); padding: 12px 18px; }
.before-after { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 10px; }
.before-after > section { border-top: 3px solid var(--navy); background: #f7f8fb; padding: 10px; }
.before-after h4 { margin: 0 0 3px; }
.before-after time { color: var(--muted); font-size: 12px; }
.comparison-photos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.toggle-label {
  grid-template-columns: 20px 1fr;
  align-content: center;
  align-items: center;
  min-height: 42px;
  margin-top: 19px;
}

.toggle-label input,
.check-option input { width: 18px; min-height: 18px; margin: 0; }
.check-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 14px; }
.month-grid { display: grid; grid-template-columns: repeat(6, minmax(74px, 1fr)); gap: 8px; }
.check-option { display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: center; gap: 7px; font-size: 13px; }
.month-fieldset { grid-column: 1 / -1; }
.admin-tool { display: grid; gap: 2px; }
.table-action { min-height: 32px; padding: 4px 10px; font-size: 12px; }
.empty { margin: 0; padding: 8px 0; color: var(--muted); }
.overdue-text { color: var(--red); font-weight: 700; }
.print-document { display: none; }
.expense-dialog { width: min(1180px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 0; border-radius: 6px; }
.expense-dialog::backdrop { background: rgb(8 20 48 / 55%); }
.expense-dialog form { display: grid; gap: 16px; padding: 20px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.dialog-heading h2, .dialog-heading p { margin: 3px 0 0; }
.expense-section { display: grid; gap: 8px; }
.expense-section h3 { margin: 0; }
.expense-table { min-width: 720px; }
.expense-table input { min-width: 90px; }
.expense-table input[type="text"] { min-width: 160px; }
.expense-table .expense-delete { width: 34px; min-height: 34px; padding: 0; }
.expense-attachment { display: grid; gap: 7px; border-top: 1px solid var(--line); padding-top: 14px; }
.expense-total { display: flex; justify-content: flex-end; align-items: baseline; gap: 18px; color: var(--navy); }
.expense-total strong { font-size: 22px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.report-filter-summary { margin: 0 0 8px; border: .6pt solid #9aaac2; padding: 6px 8px; font-size: 8pt; }

@media print {
  html, body { background: #fff !important; width: 100%; min-width: 0; }
  body > * { display: none !important; }
  body.printing-inspection #inspectionPrintDocument,
  body.printing-resolution #resolutionPrintDocument { display: block !important; }
  .print-document { color: #111827; font-family: Arial, "Noto Sans", sans-serif; }
  .print-title { position: relative; text-align: center; border-bottom: 2px solid #17377c; margin-bottom: 10px; padding-bottom: 7px; }
  .print-title p { margin: 0 0 3px; color: #17377c; font-size: 8pt; font-weight: 700; }
  .print-title h1 { margin: 0; font-size: 15pt; letter-spacing: 0; }
  .print-title span { position: absolute; right: 0; bottom: 7px; font-size: 7.5pt; }
  .print-summary { margin: 0 0 8px; text-align: right; font-size: 8pt; }
  .print-document table { width: 100%; border: .8pt solid #5f6f86; border-collapse: collapse; border-spacing: 0; table-layout: fixed; }
  .print-document thead { display: table-header-group; }
  .print-document tr { break-inside: avoid; page-break-inside: avoid; }
  .print-document th, .print-document td { border: .8pt solid #5f6f86; padding: 3px 4px; vertical-align: middle; overflow-wrap: anywhere; word-break: break-word; }
  .print-document th { background: #dce9f7 !important; color: #102a63; font-weight: 700; text-align: center; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .inspection-print-table { font-size: 7.5pt; }
  .inspection-print-table th:nth-child(1) { width: 3%; }
  .inspection-print-table th:nth-child(2) { width: 12%; }
  .inspection-print-table th:nth-child(3) { width: 7%; }
  .inspection-print-table th:nth-child(4) { width: 11%; }
  .inspection-print-table th:nth-child(5) { width: 9%; }
  .inspection-print-table th:nth-child(6) { width: 16%; }
  .inspection-print-table th:nth-child(7) { width: 7%; }
  .inspection-print-table th:nth-child(8) { width: 8%; }
  .inspection-print-table th:nth-child(9) { width: 8%; }
  .inspection-print-table th:nth-child(10) { width: 5%; }
  .inspection-print-table th:nth-child(11) { width: 7%; }
  .inspection-print-table th:nth-child(12) { width: 7%; }
  .print-detail-row td { background: #f7f9fc !important; font-size: 7pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .inspection-print-detail { margin-bottom: 10px; }
  .inspection-print-photos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; margin-top: 5px; }
  .inspection-print-photos figure { margin: 0; }
  .inspection-print-photos img { width: 100%; height: 55mm; object-fit: contain; border: .6pt solid #c4cfdd; }
  .resolution-print-job { font-size: 8.5pt; }
  .print-job-break { break-before: page; page-break-before: always; }
  .job-number { display: flex; align-items: baseline; justify-content: center; gap: 10px; margin: 8px 0 12px; }
  .job-number span { color: #53657e; font-size: 9pt; }
  .job-number strong { color: #102a63; font-size: 14pt; }
  .job-summary { display: grid; grid-template-columns: 1fr 1fr; margin: 0 0 12px; border-top: .8pt solid #5f6f86; border-left: .8pt solid #5f6f86; }
  .job-summary > div { display: grid; grid-template-columns: 42% 58%; border-right: .8pt solid #5f6f86; border-bottom: .8pt solid #5f6f86; }
  .job-summary > div.wide { grid-column: 1 / -1; grid-template-columns: 21% 79%; }
  .job-summary dt, .job-summary dd { margin: 0; padding: 5px; }
  .job-summary dt { border-right: .8pt solid #5f6f86; background: #eef4fb !important; color: #102a63; font-weight: 700; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-section-heading { margin: 12px 0 6px; color: #102a63; font-size: 11pt; border-bottom: 1pt solid #17377c; padding-bottom: 3px; }
  .resolution-print-table { font-size: 7.2pt; }
  .resolution-print-table th:nth-child(1) { width: 4%; }
  .resolution-print-table th:nth-child(2) { width: 14%; }
  .resolution-print-table th:nth-child(3) { width: 9%; }
  .resolution-print-table th:nth-child(4) { width: 10%; }
  .resolution-print-table th:nth-child(5) { width: 18%; }
  .resolution-print-table th:nth-child(6) { width: 8%; }
  .resolution-print-table th:nth-child(7) { width: 9%; }
  .resolution-print-table th:nth-child(8) { width: 6%; }
  .resolution-print-table th:nth-child(9) { width: 9%; }
  .resolution-print-table th:nth-child(10) { width: 13%; }
  .defect-photo-report { break-inside: avoid; page-break-inside: avoid; margin: 0 0 12px; border: .6pt solid #9aaac2; padding: 7px; }
  .defect-photo-report h3 { margin: 0 0 4px; color: #102a63; font-size: 10pt; }
  .defect-photo-report p { margin: 0 0 7px; line-height: 1.4; }
  .before-after-print { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .before-after-print h4 { margin: 0 0 4px; padding: 3px; background: #dce9f7 !important; color: #102a63; text-align: center; font-size: 9pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-photo-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
  .print-photo-list figure { margin: 0; }
  .print-photo-list img { display: block; width: 100%; height: 52mm; object-fit: contain; border: .6pt solid #c4cfdd; }
  .print-photo-list figcaption { margin-top: 2px; color: #53657e; font-size: 7pt; text-align: center; }
  .print-photo-missing { display: grid; place-items: center; height: 52mm; border: .6pt dashed #9aaac2; color: #6b7280; }
  .print-expense-table { margin-bottom: 8px; font-size: 7.5pt; }
  .print-expense-total { margin: 8px 0 12px; text-align: right; font-size: 10pt; }
  .print-signature { width: 72mm; margin: 12mm 0 4mm auto; break-inside: avoid; page-break-inside: avoid; }
  .print-signature h2 { margin: 0 0 5mm; color: #102a63; font-size: 10pt; text-align: left; }
  .print-signature p { display: grid; grid-template-columns: 25mm 1fr; gap: 3mm; margin: 0 0 5mm; }
  .print-signature strong { min-height: 5mm; border-bottom: .8pt solid #111827; }
  .requisition-print { break-before: page; page-break-before: always; }
  .requisition-print-page { break-after: page; page-break-after: always; text-align: center; }
  .requisition-print-page:last-child { break-after: auto; page-break-after: auto; }
  .requisition-print-page img, .requisition-print-page canvas { display: block; max-width: 100%; max-height: 250mm; margin: 0 auto; object-fit: contain; }
  .print-empty { text-align: center; padding: 40mm 0; }
}

@media (max-width: 1050px) {
  .brand-banner { height: 246px; align-items: flex-start; background-position: center; }
  .brand-banner > img { width: auto; max-width: none; height: min(168px, calc(64vw / 3)); margin-left: 14px; }
  .banner-controls { top: auto; right: 14px; bottom: 14px; transform: none; }
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-analytics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trend-card { grid-column: 1 / -1; }
  .grid-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .defect-entry-form { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .defect-entry-form > label:has(#defectGroup),
  .defect-entry-form > label:has(#defectPosition),
  .defect-entry-form > label:has(#circuit),
  .defect-entry-form > label:has(#defectTowerStart),
  .defect-entry-form > label:has(#defectTowerEnd),
  .defect-entry-form > label:has(#defectPhase),
  .defect-entry-form > label:has(#severity) { grid-column: span 2; }
  .defect-entry-form > label:has(#defectType) { grid-column: span 4; }
  .defect-entry-form > label:has(#defectNote),
  .defect-entry-form > .photo-fieldset { grid-column: span 3; }
  .filter-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .month-grid { grid-template-columns: repeat(4, minmax(74px, 1fr)); }
}

@media (max-width: 760px) {
  .review-layout { grid-template-columns: 1fr; }
  .defect-item > .defect-photo-group { width: 100%; }
  .login-screen { min-height: 100svh; grid-template-columns: 1fr; }
  .login-visual { min-height: 42svh; background-position: center center; }
  .login-panel { align-content: start; min-height: 58svh; border-left: 0; border-top-width: 5px; box-shadow: 0 -12px 32px rgba(15, 38, 81, .12); padding: 26px 20px 34px; }
  .login-panel h1 { font-size: 23px; }
  .brand-banner { height: 226px; }
  .brand-banner > img { width: calc(100% - 20px); height: auto; max-height: 150px; margin-left: 10px; }
  .banner-controls { right: 10px; bottom: 10px; left: 10px; max-width: none; padding: 8px 9px; }
  .header-tools { width: 100%; justify-content: flex-end; flex-wrap: wrap; }
  .user-summary { margin-right: auto; text-align: left; }
  .sync-message { order: 5; flex-basis: 100%; max-width: none; text-align: right; }
  .tabs-inner,
  main { width: min(100% - 20px, 1320px); }
  .tabs { padding: 0 10px; }
  .tabs-inner { width: 100%; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .page-heading h1 { font-size: 22px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-analytics-grid { grid-template-columns: 1fr; }
  .trend-card { grid-column: auto; }
  .donut-layout { grid-template-columns: minmax(120px, .8fr) minmax(150px, 1.2fr); }
  .chart-card { min-height: 0; }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inspection-context { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inspection-picker-row { align-items: stretch; flex-direction: column; }
  .defect-item { grid-template-columns: 76px minmax(0, 1fr); }
  .thumb { width: 76px; height: 64px; }
  .defect-controls { grid-column: 1 / -1; grid-template-columns: auto minmax(130px, 1fr); justify-items: stretch; align-items: center; }
  .resolution-list-item { grid-template-columns: 76px minmax(0, 1fr); align-items: start; }
  .resolution-list-item > .resolution-list-action { grid-column: 2; justify-self: start; justify-items: start; }
  .resolution-badges { justify-content: flex-start; }
  .resolution-defect-detail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .duplicate-match { grid-template-columns: 1fr; }
  .sync-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sync-queue-item { grid-template-columns: 1fr; }
  .sync-queue-item > button { justify-self: start; }
  .before-after { grid-template-columns: 1fr; }
  .annotation-dialog { width: calc(100% - 12px); max-height: calc(100vh - 12px); }
  .annotation-stage { max-height: calc(100vh - 290px); padding: 6px; }
}

@media (max-width: 520px) {
  .resolution-number-control { flex-direction: column; }
  body { font-size: 14px; }
  main { margin-top: 14px; }
  .metric-grid,
  .grid-form,
  .filter-row,
  .detail-grid { grid-template-columns: 1fr; }
  .grid-form .wide { grid-column: 1; }
  .defect-entry-form { grid-template-columns: 1fr; }
  .defect-entry-form > label:has(#defectGroup),
  .defect-entry-form > label:has(#defectType),
  .defect-entry-form > label:has(#defectPosition),
  .defect-entry-form > label:has(#circuit),
  .defect-entry-form > label:has(#defectTowerStart),
  .defect-entry-form > label:has(#defectTowerEnd),
  .defect-entry-form > label:has(#defectPhase),
  .defect-entry-form > label:has(#severity),
  .defect-entry-form > label:has(#defectNote),
  .defect-entry-form > .photo-fieldset { grid-column: 1; }
  .inspection-context { grid-template-columns: 1fr; }
  .photo-actions { display: grid; }
  .metric { min-height: 122px; }
  .metric strong { font-size: 28px; }
  .surface,
  .detail-panel { padding: 13px; }
  .bar-row { grid-template-columns: minmax(110px, 1fr) minmax(70px, 1fr) 28px; gap: 7px; }
  .check-grid { grid-template-columns: 1fr; }
  .month-grid { grid-template-columns: repeat(3, minmax(70px, 1fr)); }
  .header-tools button { min-height: 36px; padding: 6px 10px; }
  .brand-banner { height: 238px; }
  .donut-layout { grid-template-columns: 1fr; }
  .donut, .donut-chart { width: 150px; }
  .monthly-trend { min-height: 190px; overflow-x: auto; }
  .monthly-trend svg { min-width: 560px; }
  .resolution-defect-detail { grid-template-columns: 1fr; }
  .resolution-source-photos { grid-column: 1; }
  .resolution-defect-detail .wide-detail { grid-column: 1; }
  .sync-summary { grid-template-columns: 1fr 1fr; }
}
