:root {
  --page: #f6f7f4;
  --text: #18211e;
  --link: #185844;
  --muted: #64706b;
  --line: #d8dfda;
  --panel: #ffffff;
  --soft: #eef3f0;
  --primary: #185844;
  --primary-2: #28745f;
  --danger: #9f2f2f;
  --shadow: rgba(22, 33, 29, 0.10);
}
:root[data-theme="dark"] {
  --page: #050407;
  --text: #f8eef7;
  --link: #ff65cb;
  --muted: #c8a9c1;
  --line: #3b2235;
  --panel: #100a11;
  --soft: #1b101b;
  --primary: #d61f8c;
  --primary-2: #ff65cb;
  --danger: #e05270;
  --shadow: rgba(214, 31, 140, 0.18);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--page);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}
.doc-popup-body {
  min-width: 0;
  min-height: 100vh;
  overflow: hidden;
  background: #0b0b10;
  color: #f8eef7;
}
a { color: var(--link); font-weight: 700; }
.shell { width: min(1500px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 42px; }
.viewer-shell { width: min(1800px, calc(100% - 24px)); }
.doc-popup-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}
.doc-popup-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 16px 20px;
  border-bottom: 1px solid #332334;
  background: rgba(10, 8, 14, 0.96);
}
.doc-popup-meta { min-width: 0; }
.doc-popup-meta h2, .doc-popup-meta .muted { color: #f8eef7; }
.doc-popup-meta .muted { opacity: 0.82; }
.doc-popup-viewer {
  display: grid;
  min-height: 0;
  padding: 0;
  width: 100vw;
}
.topbar { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: end; margin-bottom: 18px; }
.brand { display: grid; grid-template-columns: 72px 1fr; gap: 14px; align-items: center; }
.logo { display: grid; place-items: center; width: 72px; height: 72px; overflow: hidden; border-radius: 8px; background: #a00022; }
.logo img { width: 100%; height: 100%; object-fit: cover; }
.eyebrow { margin: 0 0 5px; color: var(--primary-2); font-size: 12px; font-weight: 700; text-transform: uppercase; }
h1, h2, h3 { margin: 0; line-height: 1.1; }
h1 { font-size: 32px; }
h2 { font-size: 22px; }
h3 { font-size: 16px; }
.nav { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.nav a, button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text);
  background: var(--soft);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.nav a.active, .primary { color: white; background: var(--primary); border-color: var(--primary); }
:root[data-theme="dark"] .nav a.active, :root[data-theme="dark"] .primary { color: #ffffff; }
.danger { color: white; background: var(--danger); border-color: var(--danger); }
.userbar { color: var(--muted); font-size: 13px; }
.grid { display: grid; gap: 16px; }
.summary { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.two { grid-template-columns: minmax(300px, 390px) 1fr; align-items: start; }
.dashboard-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; }
.form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.filter-grid { grid-template-columns: 2fr repeat(3, minmax(160px, 1fr)); align-items: end; }
.panel, .metric, .card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 30px var(--shadow);
}
.panel { padding: 20px; margin-bottom: 16px; }
.metric, .card { padding: 16px; }
.metric strong { display: block; margin-top: 6px; font-size: 24px; }
.chart-card { display: grid; grid-template-columns: 150px 1fr; gap: 16px; align-items: center; margin-top: 18px; }
.donut {
  display: grid;
  place-items: center;
  width: 150px;
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
}
.donut span {
  display: grid;
  place-items: center;
  width: 86px;
  aspect-ratio: 1;
  border-radius: 50%;
  color: var(--text);
  background: var(--panel);
  font-size: 16px;
  font-weight: 800;
  text-align: center;
  padding: 8px;
  box-shadow: 0 0 0 1px var(--line);
}
.donut span small {
  max-width: 72px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.15;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
}
.donut span strong {
  max-width: 72px;
  font-size: 14px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.legend { display: grid; gap: 8px; }
.legend div, .compact-list div, .snapshot-list div {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.legend div[data-label] {
  cursor: pointer;
  border-radius: 6px;
  padding-inline: 8px;
}
.legend div[data-label]:hover,
.legend div[data-label]:focus,
.legend div[data-label].active {
  background: var(--soft);
  outline: 2px solid transparent;
}
.legend div[data-label].active {
  box-shadow: inset 3px 0 0 var(--primary);
}
.legend div:last-child, .compact-list div:last-child, .snapshot-list div:last-child { border-bottom: 0; }
.legend i { width: 10px; height: 10px; border-radius: 999px; }
.legend span, .compact-list span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compact-list, .snapshot-list { margin-top: 14px; }
.compact-list div, .snapshot-list div { grid-template-columns: 1fr auto; }
.asset-hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}
.asset-list-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.photo-tile {
  display: grid;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
}
.photo-tile img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}
.photo-tile span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-frame {
  margin-top: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #111118;
  min-height: calc(100vh - 110px);
  width: 100vw;
}
.doc-pdf-wrap,
.doc-image-frame {
  position: fixed;
  top: 110px;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: calc(100vh - 110px);
}
.viewer-panel { padding-bottom: 12px; }
.viewer-meta-grid { grid-template-columns: minmax(300px, 480px) 1fr; align-items: start; }
.doc-frame iframe,
.doc-pdf-frame {
  display: block;
  width: 100vw;
  height: calc(100vh - 110px);
  min-height: calc(100vh - 110px);
  border: 0;
  background: #ffffff;
}
.doc-image {
  display: block;
  width: 100vw;
  height: calc(100vh - 110px);
  max-height: calc(100vh - 110px);
  min-height: calc(100vh - 110px);
  object-fit: contain;
  background: #111118;
}
.doc-empty {
  display: grid;
  gap: 10px;
  place-items: center;
  align-content: center;
  min-height: calc(100vh - 110px);
  padding: 24px;
  border: 0;
  border-radius: 0;
  background: #111118;
}
.asset-map-frame {
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}
.asset-map-frame iframe {
  display: block;
  width: 100%;
  min-height: 320px;
  border: 0;
}
.location-picker-panel {
  margin-bottom: 16px;
}
.location-shortcuts {
  margin: 12px 0 10px;
}
.asset-location-map {
  width: 100%;
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.asset-map-empty {
  margin-top: 14px;
  min-height: 160px;
  place-items: center;
  align-content: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--soft);
}
.detail-list { display: grid; gap: 0; margin-top: 14px; }
.detail-list div {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.detail-list div:last-child { border-bottom: 0; }
.detail-list span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.detail-list strong {
  min-width: 0;
  overflow-wrap: anywhere;
}
.depreciation-chart {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}
.dep-row {
  display: grid;
  grid-template-columns: 70px 1fr minmax(110px, auto);
  gap: 12px;
  align-items: center;
}
.dep-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.dep-row strong {
  text-align: right;
}
.dep-track {
  min-height: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
}
.dep-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
}
.muted { color: var(--muted); font-size: 13px; }
label { display: grid; gap: 7px; margin-bottom: 12px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--soft);
  font: inherit;
}
select {
  -webkit-appearance: menulist;
  appearance: auto;
  cursor: pointer;
  color-scheme: light;
}
select option {
  color: #18211e;
  background: #ffffff;
}
:root[data-theme="dark"] select {
  color-scheme: dark;
}
:root[data-theme="dark"] select option {
  color: #f8eef7;
  background: #100a11;
}
textarea { min-height: 96px; resize: vertical; }
table { width: 100%; min-width: 980px; border-collapse: collapse; }
.assets-table { min-width: 1280px; table-layout: fixed; }
.assets-table th:nth-child(1), .assets-table td:nth-child(1) { width: 130px; }
.assets-table th:nth-child(2), .assets-table td:nth-child(2) { width: 34%; }
.assets-table th:nth-child(3), .assets-table td:nth-child(3) { width: 22%; }
.assets-table th:nth-child(4), .assets-table td:nth-child(4) { width: 16%; }
.assets-table th:nth-child(5), .assets-table td:nth-child(5) { width: 120px; }
.assets-table th:nth-child(6), .assets-table td:nth-child(6) { width: 170px; }
.assets-table th:nth-child(7), .assets-table td:nth-child(7) { width: 110px; text-align: right; }
.assets-table td { overflow-wrap: anywhere; }
th, td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); background: var(--soft); font-size: 12px; text-transform: uppercase; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.notice { margin: 0 0 14px; padding: 10px 12px; border-left: 4px solid var(--primary-2); background: var(--soft); }
.error { border-left-color: var(--danger); }
.site-credit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 22px 0 0;
  padding: 14px 0 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.site-credit img {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
}
.site-credit strong {
  color: var(--text);
  font-size: 13px;
}
.login-shell { min-height: 100vh; display: grid; place-items: center; }
.login-panel { width: min(520px, 100%); }
.check-row { display: flex; grid-template-columns: none; align-items: center; gap: 8px; }
.check-row input { width: auto; min-height: 0; }
.column-picker { margin-top: 8px; }
.report-builder { padding-bottom: 18px; }
.report-intro { margin-top: 8px; max-width: 760px; }
.report-columns-head,
.report-results-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.report-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.report-inline-actions,
.report-main-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
}
.report-inline-actions .button,
.report-inline-actions button,
.report-main-actions .button,
.report-main-actions button {
  white-space: nowrap;
}
.report-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.report-chip strong { color: var(--text); }
.column-picker > div {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px 12px;
  margin: 8px 0 14px;
}
.column-picker .check-row {
  min-height: 32px;
  margin: 0;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
}
@media (max-width: 900px) {
  .topbar, .summary, .two, .dashboard-grid, .form-grid, .filter-grid, .chart-card { grid-template-columns: 1fr; }
  .viewer-meta-grid { grid-template-columns: 1fr; }
  .doc-popup-toolbar { display: grid; }
  .donut { margin: 0 auto; }
  .asset-hero { display: grid; }
  .asset-list-head { display: grid; }
  .report-columns-head,
  .report-results-head,
  .report-inline-actions,
  .report-main-actions { display: grid; }
  .detail-list div { grid-template-columns: 1fr; gap: 4px; }
  .dep-row { grid-template-columns: 1fr; gap: 6px; }
  .dep-row strong { text-align: left; }
  .site-credit { flex-wrap: wrap; }
}
