:root {
  --petrol-950: #071d2e;
  --petrol-900: #0f2f46;
  --petrol-800: #174966;
  --petrol-700: #1d668b;
  --petrol-100: #dbe9ef;
  --petrol-050: #eef6f8;
  --ink: #111827;
  --muted: #667085;
  --line: #dfe5ea;
  --line-strong: #c7d0d8;
  --paper: #ffffff;
  --bg: #f4f7f9;
  --green: #128449;
  --green-soft: #e8f6ee;
  --yellow: #9a6700;
  --yellow-soft: #fff7df;
  --orange: #c45318;
  --orange-soft: #fff0e7;
  --red: #bf1d2d;
  --red-soft: #fee8ec;
  --pink-soft: #fff0f4;
  --blue-soft: #e7f1fb;
  --purple: #6b42b8;
  --purple-soft: #f1edfb;
  --shadow: 0 10px 24px rgba(15, 47, 70, 0.07);
  --radius: 8px;
  --sidebar-expanded: 270px;
  --sidebar-collapsed: 76px;
  --topbar-height: 68px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-expanded) minmax(0, 1fr);
  min-height: 100vh;
}

.app-shell.collapsed {
  grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #d8e7ee;
  background: var(--petrol-900);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  height: 86px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 18px 16px;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  box-shadow: none;
  text-align: left;
  appearance: none;
}

.brand:hover,
.brand:focus,
.brand:active {
  background: transparent;
  border: 0;
  outline: 0;
  box-shadow: none;
}

.brand-logo {
  width: 150px;
  max-width: calc(100% - 12px);
  height: 52px;
  padding: 0;
  border: 0;
  border-radius: 0;
  object-fit: contain;
  background: transparent;
  box-shadow: none;
  outline: 0;
}

.brand-kicker {
  color: #94acb8;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.brand-title {
  margin-top: 2px;
  color: #fff;
  font-size: 18px;
  font-weight: 850;
  font-family: "Montserrat", "Inter", "Segoe UI", sans-serif;
  white-space: nowrap;
}

.nav {
  display: grid;
  gap: 4px;
  padding: 14px 10px;
}

.nav-item {
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #bdd1da;
  font-size: 14px;
  font-weight: 760;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.nav-item.active {
  background: rgba(219, 233, 239, 0.18);
  color: #fff;
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.nav-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.project-box {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.project-box span,
.project-box small {
  color: #9db3be;
  font-size: 12px;
}

.project-box strong {
  color: #fff;
  font-size: 15px;
}

.profile-box {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--petrol-800);
  color: #fff;
  font-weight: 850;
}

.profile-name {
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}

.profile-role {
  margin-top: 2px;
  color: #9db3be;
  font-size: 12px;
}

.app-shell.collapsed .brand-text,
.app-shell.collapsed .nav-label,
.app-shell.collapsed .project-box,
.app-shell.collapsed .profile-details {
  display: none;
}

.app-shell.collapsed .brand {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.app-shell.collapsed .brand-logo {
  width: 44px;
  height: 44px;
}

.app-shell.collapsed .nav-item {
  justify-content: center;
  padding: 0;
}

.app-shell.collapsed .sidebar-footer {
  display: grid;
  place-items: center;
}

.main {
  min-width: 0;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-height);
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.topbar-left,
.topbar-actions,
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sidebar-toggle {
  display: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--petrol-900);
  font-size: 20px;
}

.title-block {
  min-width: 0;
}

.page-title {
  color: var(--petrol-900);
  font-size: 21px;
  font-weight: 880;
  line-height: 1.1;
}

.page-subtitle {
  max-width: 760px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search,
.role-switcher,
.table-select,
.field input,
.field select,
.field textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.search {
  width: 300px;
  height: 38px;
  padding: 0 12px;
}

.role-switcher,
.table-select {
  height: 38px;
  padding: 0 10px;
}

.content {
  min-height: calc(100vh - var(--topbar-height));
  padding: 18px 22px 18px;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.btn {
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 780;
  white-space: nowrap;
}

.btn-primary {
  color: #fff;
  background: var(--petrol-900);
}

.btn-primary:hover {
  background: var(--petrol-800);
}

.btn-secondary {
  color: var(--petrol-900);
  background: #fff;
  border-color: var(--line);
}

.btn-secondary:hover {
  background: var(--petrol-050);
}

.btn-danger {
  color: var(--red);
  background: var(--red-soft);
  border-color: #f6c4cb;
}

.btn-danger.subtle {
  color: #9f1d2b;
  background: #fff;
  border-color: #f0c7cd;
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.btn-sm {
  height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.auth-user {
  max-width: 220px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.auth-card {
  width: min(420px, 100%);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 16px 38px rgba(17, 39, 52, .12);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  color: var(--petrol-900);
  font-size: 13px;
  font-weight: 850;
}

.auth-brand img {
  width: 112px;
  height: 40px;
  object-fit: contain;
}

.auth-card h1 {
  margin: 0;
  color: var(--petrol-900);
  font-size: 24px;
}

.auth-card p {
  margin: 8px 0 18px;
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--petrol-900);
  font-size: 12px;
  font-weight: 800;
}

.auth-form input {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--petrol-900);
  font: inherit;
}

.auth-message {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid #c8dbe5;
  border-radius: 8px;
  background: var(--petrol-050);
  color: var(--petrol-900);
  font-size: 13px;
}

.auth-message.warning {
  border-color: #f3d49a;
  background: #fff8e8;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.badge-blue { background: var(--blue-soft); color: var(--petrol-800); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-yellow { background: var(--yellow-soft); color: var(--yellow); }
.badge-orange { background: var(--orange-soft); color: var(--orange); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-pink { background: var(--pink-soft); color: var(--red); }
.badge-gray { background: #eef1f4; color: #4f5b66; }
.badge-purple { background: var(--purple-soft); color: var(--purple); }

.home-layout {
  display: grid;
  gap: 16px;
}

.production-panel {
  min-height: 154px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(15, 47, 70, 0.96), rgba(23, 73, 102, 0.9)),
    var(--petrol-900);
  color: #fff;
}

.production-panel h2 {
  max-width: 780px;
  margin: 4px 0 8px;
  font-size: 28px;
  font-weight: 880;
  line-height: 1.15;
}

.production-panel p {
  margin: 0;
  color: #d4e5ed;
}

.eyebrow {
  margin: 0;
  color: #9fb7c2;
  font-size: 12px;
  font-weight: 820;
  text-transform: uppercase;
}

.model-stamp {
  min-width: 156px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.model-stamp span {
  display: block;
  color: #aac0cb;
  font-size: 12px;
}

.model-stamp strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

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

.metric-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric {
  min-height: 104px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--petrol-800);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
}

.metric strong {
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
}

.metric small {
  color: var(--muted);
}

.metric-green { border-left-color: var(--green); }
.metric-pink { border-left-color: var(--red); }
.metric-red { border-left-color: var(--red); }
.metric-yellow { border-left-color: var(--yellow); }
.metric-blue { border-left-color: var(--petrol-700); }

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

.quick-action {
  display: grid;
  gap: 5px;
  min-height: 86px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  text-align: left;
  box-shadow: var(--shadow);
}

.quick-action:hover {
  border-color: var(--petrol-100);
  background: var(--petrol-050);
}

.quick-action span {
  color: var(--petrol-900);
  font-weight: 850;
}

.quick-action small {
  color: var(--muted);
}

.active-analysis-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
}

.active-analysis-card h3 {
  margin: 0 0 4px;
  color: var(--petrol-900);
  font-size: 16px;
}

.active-analysis-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.analysis-switcher {
  width: min(520px, 100%);
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.sheet-toolbar,
.report-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.sheet-page {
  min-height: calc(100vh - var(--topbar-height) - 36px);
  display: flex;
  flex-direction: column;
}

.sheet-toolbar h2,
.report-header h2 {
  margin: 0;
  color: var(--petrol-900);
  font-size: 22px;
}

.sheet-toolbar p,
.report-header p {
  margin: 4px 0 0;
  color: var(--muted);
}

.document-header {
  display: grid;
  grid-template-columns: 168px minmax(280px, 1fr) 168px;
  border: 1px solid #000;
  border-radius: 0;
  overflow: hidden;
  background: #fff;
}

.doc-logo,
.doc-title {
  min-height: 72px;
  display: grid;
  place-items: center;
  padding: 8px;
  border-bottom: 1px solid #000;
}

.doc-logo {
  border: 0;
  background: #fff;
}

.logo-cell {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  color: var(--muted);
}

.logo-cell.selected,
.image-cell.selected {
  outline: 2px solid var(--petrol-700);
  outline-offset: -2px;
}

.doc-logo:first-child,
.doc-title {
  border-right: 1px solid #000;
}

.logo-preview {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  min-height: 54px;
}

.logo-preview img {
  max-width: var(--logo-fit, 78%);
  max-height: var(--logo-fit, 78%);
  object-fit: contain;
}

.logo-size-small {
  --logo-fit: 58%;
}

.logo-size-medium {
  --logo-fit: 72%;
}

.logo-size-large {
  --logo-fit: 88%;
}

.logo-cell.is-placeholder .logo-preview span {
  padding: 4px 8px;
  border: 1px dashed #c7d3da;
  border-radius: 6px;
  color: #71828d;
  font-size: 11px;
  font-weight: 760;
}

.logo-tools {
  position: absolute;
  right: 6px;
  bottom: 6px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity .15s ease;
}

.logo-cell:hover .logo-tools,
.logo-cell:focus .logo-tools,
.logo-cell.selected .logo-tools {
  opacity: 1;
}

.logo-size-select,
.logo-clear {
  height: 24px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(255, 255, 255, .94);
  color: var(--petrol-900);
  font-size: 10px;
  font-weight: 760;
}

.doc-title {
  gap: 6px;
  text-align: center;
  background: #fff;
}

.doc-title-input,
.doc-field-input {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  text-align: center;
  outline: none;
}

.doc-title-input:focus,
.doc-field-input:focus {
  border-color: var(--petrol-700);
  background: #fff;
}

.doc-title-input {
  color: var(--petrol-900);
  font-size: 18px;
  font-weight: 900;
  text-transform: uppercase;
}

.doc-title-input.scope {
  color: #29333d;
  font-size: 14px;
  font-weight: 820;
}

.doc-title strong {
  color: var(--petrol-900);
  font-size: 19px;
  font-weight: 900;
}

.doc-title span {
  margin-top: 4px;
  color: #29333d;
  font-size: 14px;
  font-weight: 820;
}

.contractor {
  border: 0;
  border-bottom: 1px solid #000;
  background: #f1f4f6;
  color: var(--muted);
}

.doc-band {
  grid-column: 1 / -1;
  height: 10px;
  background: var(--petrol-900);
  border-bottom: 1px solid #000;
}

.doc-band.dark {
  height: 8px;
  background: var(--petrol-950);
}

.contractor span {
  font-weight: 820;
}

.contractor small {
  display: block;
  margin-top: 4px;
}

.doc-fields {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
}

.doc-fields div {
  min-height: 38px;
  padding: 5px 8px;
  border-right: 1px solid #000;
  border-bottom: 1px solid #000;
  background: #fff;
}

.doc-fields div:nth-child(4n) {
  border-right: 0;
}

.doc-fields div:nth-last-child(-n + 4) {
  border-bottom: 0;
}

.doc-fields dt {
  color: var(--petrol-900);
  font-size: 11px;
  font-weight: 820;
  text-transform: uppercase;
}

.doc-fields dd {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 720;
}

.doc-field-input {
  padding: 1px 2px;
  text-align: left;
  font-size: 12px;
  font-weight: 720;
}

.sheet-countline {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 7px 10px;
  border-right: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
  background: #f9fbfc;
  color: var(--muted);
  font-size: 12px;
}

.sheet-countline span {
  padding-right: 10px;
  border-right: 1px solid var(--line);
}

.sheet-countline span:last-child {
  border-right: 0;
}

.sheet-wrap {
  flex: 1 1 auto;
  overflow: auto;
  min-height: 320px;
  max-height: none;
  border: 1px solid #000;
  border-top: 0;
  border-radius: 0;
  background:
    repeating-linear-gradient(0deg, #fff 0 37px, #edf2f5 37px 38px);
}

.issues-table {
  width: 100%;
  min-width: 1420px;
  border-collapse: collapse;
}

.issues-table th,
.issues-table td {
  border-right: 1px solid #000;
  border-bottom: 1px solid #000;
  vertical-align: top;
}

.issues-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 44px;
  padding: 6px 7px;
  background: #e8eef2;
  color: var(--petrol-900);
  font-size: 11px;
  font-weight: 880;
  text-align: center;
}

.issues-table td {
  height: 76px;
  padding: 5px 7px;
  background: #fff;
  color: #26313b;
  font-size: 13px;
}

.issues-table tr:hover td,
.issues-table tr.selected td {
  background: #f6fbfd;
}

.col-item { width: 56px; }
.col-local { width: 148px; }
.col-disc { width: 34px; }
.col-desc { width: 360px; }
.col-image { width: 136px; }
.col-class { width: 110px; }
.col-comments { width: 290px; }
.col-status { width: 166px; }

.item-cell {
  color: var(--petrol-900);
  font-weight: 900;
  text-align: center;
}

.disc-cell {
  padding: 4px !important;
  text-align: center;
  vertical-align: middle;
}

.disc-cell.checked {
  background: #edf6fb !important;
}

.disc-checkbox {
  display: grid;
  place-items: center;
  min-height: 34px;
}

.disc-checkbox input {
  position: absolute;
  opacity: 0;
}

.disc-checkbox span {
  width: 16px;
  height: 16px;
  display: block;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
}

.disc-checkbox input:checked + span {
  border-color: var(--petrol-800);
  background: var(--petrol-800);
  box-shadow: inset 0 0 0 4px #fff;
}

.cell-textarea {
  width: 100%;
  min-height: 68px;
  max-height: 128px;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: 0;
  resize: vertical;
  background: transparent;
  color: #26313b;
  line-height: 1.35;
  outline: none;
  white-space: pre-wrap;
}

.cell-textarea:focus {
  border-color: var(--petrol-700);
  background: #fbfdfe;
}

.text-preview {
  width: 100%;
  max-height: 46px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  padding: 0;
  border: 0;
  background: transparent;
  color: #26313b;
  line-height: 1.3;
  text-align: left;
  white-space: pre-line;
}

.text-preview:hover {
  color: var(--petrol-800);
  text-decoration: underline;
}

.table-select {
  width: 100%;
  min-width: 92px;
  height: 28px;
  border-radius: 3px;
  font-size: 12px;
}

.class-select,
.status-select {
  font-weight: 820;
  border-left-width: 4px;
}

.tone-baixo,
.tone-resolvido {
  background: var(--green-soft);
  color: var(--green);
  border-left-color: var(--green);
}

.tone-medio {
  background: var(--yellow-soft);
  color: var(--yellow);
  border-left-color: #d8ad36;
}

.tone-alto {
  background: var(--orange-soft);
  color: var(--orange);
  border-left-color: var(--orange);
}

.tone-critico,
.tone-pendente {
  background: var(--red-soft);
  color: var(--red);
  border-left-color: var(--red);
}

.tone-em-hold {
  background: #eef1f4;
  color: #4f5b66;
  border-left-color: #9aa6b2;
}

.tone-em-desenvolvimento {
  background: var(--blue-soft);
  color: var(--petrol-800);
  border-left-color: var(--petrol-700);
}

.image-thumb {
  width: 88px;
  height: 48px;
  display: grid;
  place-items: end center;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(15, 47, 70, 0.86), rgba(29, 102, 139, 0.18)),
    repeating-linear-gradient(45deg, transparent 0 12px, rgba(255, 255, 255, 0.22) 12px 14px),
    #c8d5dc;
  font-size: 10px;
  background-size: cover;
  background-position: center;
}

.image-thumb.has-image {
  text-shadow: 0 1px 2px rgba(0, 0, 0, .55);
}

.image-thumb span {
  max-width: 82px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-cell {
  position: relative;
  width: 122px;
  height: 72px;
  display: grid;
  place-items: end center;
  padding: 5px;
  border: 1px dashed #8796a1;
  border-radius: 0;
  overflow: hidden;
  color: var(--muted);
  background:
    repeating-linear-gradient(45deg, #fbfcfd 0 10px, #edf2f5 10px 12px),
    #f8fbfc;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  font-size: 10px;
  text-align: center;
}

.image-cell.has-image {
  border-style: solid;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.6);
}

.image-cell span {
  max-width: 98px;
  padding: 2px 4px;
  border-radius: 4px;
  background: rgba(255,255,255,.82);
  color: #52616d;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-cell.has-image span {
  background: rgba(15, 47, 70, .72);
  color: #fff;
}

.image-clear {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(15, 47, 70, .25);
  border-radius: 50%;
  background: rgba(255, 255, 255, .94);
  color: var(--red);
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
  opacity: 0;
  transition: opacity .15s ease;
}

.image-cell:hover .image-clear,
.image-cell.selected .image-clear,
.image-clear:focus {
  opacity: 1;
}

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

.report-grid.lower {
  align-items: start;
}

.report-card {
  padding: 16px;
}

.export-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  padding: 16px;
}

.export-panel h3 {
  margin: 0;
  color: var(--petrol-900);
  font-size: 16px;
}

.export-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.report-preview {
  margin-top: 14px;
}

.report-updated {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.report-card h3,
.adm-card h3,
.settings-card h3 {
  margin: 0 0 12px;
  color: var(--petrol-900);
  font-size: 16px;
}

.card-heading h3 {
  margin: 0;
}

.card-menu {
  position: relative;
}

.card-menu summary {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  font-size: 18px;
  line-height: 1;
}

.card-menu summary::-webkit-details-marker {
  display: none;
}

.card-menu-panel {
  position: absolute;
  top: 34px;
  right: 0;
  z-index: 20;
  min-width: 170px;
  display: grid;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(17, 39, 52, .14);
}

.card-menu-panel button {
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-size: 12px;
  font-weight: 760;
}

.card-menu-panel button:hover,
.card-menu-panel button.active {
  background: #eef5f8;
  color: var(--petrol-900);
}

.bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 150px minmax(120px, 1fr) 32px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.bar-row.hide-value {
  grid-template-columns: 150px minmax(120px, 1fr);
}

.bar-row .bar-fill {
  width: var(--value);
}

.chart-donut .bars {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.chart-donut .bar-row {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.chart-donut .bar-track {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: conic-gradient(var(--petrol-700) 0 var(--slice), #e8eef2 var(--slice) 100%);
}

.chart-donut .bar-fill {
  display: none;
}

.chart-table {
  display: grid;
  gap: 6px;
}

.chart-table div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.chart-table div:last-child {
  border-bottom: 0;
}

.chart-table strong {
  color: var(--petrol-900);
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f4;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--petrol-800);
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
}

.summary-table td {
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.summary-table td:last-child {
  color: var(--petrol-900);
  font-weight: 900;
  text-align: right;
}

.critical-list {
  display: grid;
  gap: 8px;
}

.critical-item {
  display: grid;
  gap: 6px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: left;
}

.critical-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.empty-note {
  margin: 0;
  color: var(--muted);
}

.adm-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.adm-tabs-wide {
  flex-wrap: wrap;
}

.adm-tab {
  padding: 10px 14px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 820;
}

.adm-tab.active {
  color: var(--petrol-900);
  border-bottom-color: var(--petrol-800);
}

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

.adm-card,
.settings-card {
  padding: 16px;
}

.adm-card.full {
  margin-top: 12px;
}

.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.notice {
  padding: 12px;
  border: 1px solid var(--petrol-100);
  border-radius: 8px;
  background: var(--petrol-050);
  color: var(--petrol-900);
  font-size: 13px;
  line-height: 1.45;
}

.notice.warning {
  margin-top: 14px;
  border-color: #f2d790;
  background: var(--yellow-soft);
  color: #795000;
}

.detail-list {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
}

.detail-list div {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 12px;
}

.detail-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
}

.detail-list dd {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
}

.version-list {
  display: grid;
  gap: 10px;
}

.version-list div {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.version-list span {
  color: var(--muted);
  font-size: 12px;
}

.admin-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
}

.admin-table th {
  background: #f5f7f9;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.admin-table .strong {
  color: var(--petrol-900);
  font-weight: 850;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.settings-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
}

.settings-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.subtle-danger {
  color: var(--red);
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 780;
}

.field input,
.field select {
  height: 38px;
  padding: 0 10px;
}

.field textarea {
  min-height: 100px;
  padding: 10px;
  resize: vertical;
}

.field.wide {
  grid-column: 1 / -1;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.issue-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.readonly-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.readonly-item span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 780;
}

.readonly-item strong {
  color: var(--petrol-900);
  font-size: 22px;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.check-grid label,
.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
}

.list-editor {
  display: grid;
  gap: 8px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.list-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 3px 7px 3px 10px;
  border: 1px solid var(--petrol-100);
  border-radius: 999px;
  background: var(--petrol-050);
  color: var(--petrol-900);
  font-size: 12px;
  font-weight: 850;
}

.list-chip button {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  line-height: 1;
}

.list-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.list-add-row input {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.dropzone {
  display: grid;
  place-items: center;
  min-height: 64px;
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #f9fbfc;
  color: var(--muted);
  text-align: center;
}

.image-upload-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.image-upload-row input[type="file"] {
  height: auto;
  padding: 8px;
  margin-bottom: 8px;
}

.image-upload-row small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.upload-preview {
  min-height: 132px;
  display: grid;
  place-items: end center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(15, 47, 70, 0.86), rgba(29, 102, 139, 0.18)),
    repeating-linear-gradient(45deg, transparent 0 12px, rgba(255, 255, 255, 0.22) 12px 14px),
    #c8d5dc;
  background-size: cover;
  background-position: center;
  font-size: 12px;
  text-align: center;
}

.upload-preview.has-image {
  text-shadow: 0 1px 2px rgba(0, 0, 0, .55);
}

.empty-sheet {
  display: grid;
  place-items: center;
  min-height: 220px;
  color: var(--muted);
}

.empty-sheet p {
  margin: 0;
}

.export-options {
  display: grid;
  gap: 9px;
}

.export-progress {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfc;
  color: var(--muted);
  font-size: 13px;
}

.export-progress.idle {
  color: var(--petrol-900);
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9eef2;
}

.progress-bar {
  height: 100%;
  border-radius: 999px;
  background: var(--petrol-800);
  transition: width .25s ease;
}

.export-progress ol {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 20px;
}

.export-progress li.active {
  color: var(--petrol-900);
  font-weight: 850;
}

.export-progress li.done {
  color: var(--green);
}

.export-file-ready {
  margin: 0;
  color: var(--green);
  font-size: 12px;
  font-weight: 850;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(7, 29, 46, 0.4);
}

.modal {
  width: min(760px, 100%);
  max-height: min(90vh, 900px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(7, 29, 46, 0.22);
}

.modal.modal-wide {
  width: min(940px, 100%);
}

.modal.modal-xwide {
  width: min(1180px, calc(100vw - 28px));
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal-footer-spacer {
  flex: 1;
}

.modal-header h2 {
  margin: 0;
  color: var(--petrol-900);
  font-size: 19px;
}

.modal-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 22px;
}

.modal-body {
  overflow: auto;
  padding: 18px;
}

.guide-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.guide-helper {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.guide-tab {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--petrol-900);
  font-size: 12px;
  font-weight: 820;
}

.guide-tab.active {
  background: var(--petrol-800);
  color: #fff;
  border-color: var(--petrol-800);
}

.guide-preview .document-header {
  border-radius: 8px 8px 0 0;
}

.guide-preview .sheet-wrap {
  max-height: 48vh;
}

.preview-image-large {
  height: 360px;
  display: grid;
  place-items: end center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(15, 47, 70, 0.88), rgba(29, 102, 139, 0.2)),
    repeating-linear-gradient(45deg, transparent 0 22px, rgba(255, 255, 255, 0.25) 22px 24px),
    #c8d5dc;
  background-size: cover;
  background-position: center;
}

.preview-image-large.has-image {
  text-shadow: 0 1px 2px rgba(0, 0, 0, .55);
}

.modal-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.confirm-text {
  margin: 0;
  color: var(--ink);
  line-height: 1.5;
}

.access-denied {
  max-width: 620px;
  margin: 60px auto;
  padding: 28px;
  text-align: center;
}

.access-denied h2 {
  margin: 0 0 8px;
  color: var(--petrol-900);
}

@media (max-width: 1280px) {
  .metric-grid,
  .metric-grid.compact,
  .quick-panel,
  .active-analysis-card,
  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .active-analysis-card {
    display: grid;
  }

  .document-header {
    grid-template-columns: 150px minmax(240px, 1fr) 150px;
  }

  .doc-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .doc-fields div:nth-child(4n) {
    border-right: 1px solid var(--line-strong);
  }

  .doc-fields div:nth-child(2n) {
    border-right: 0;
  }

  .doc-fields div:nth-last-child(-n + 4) {
    border-bottom: 1px solid var(--line-strong);
  }

  .doc-fields div:nth-last-child(-n + 2) {
    border-bottom: 0;
  }
}

@media (max-width: 920px) {
  .app-shell,
  .app-shell.collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar-footer {
    display: none;
  }

  .topbar,
  .sheet-toolbar,
  .report-header,
  .export-panel,
  .production-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    height: auto;
    padding: 14px;
  }

  .topbar-actions,
  .toolbar-actions {
    flex-wrap: wrap;
  }

  .search {
    width: 100%;
  }

  .content {
    padding: 16px;
  }

  .metric-grid,
  .metric-grid.compact,
  .quick-panel,
  .report-grid,
  .adm-grid,
  .settings-grid,
  .form-grid.two,
  .issue-form,
  .image-upload-row {
    grid-template-columns: 1fr;
  }

  .document-header {
    grid-template-columns: 1fr;
  }

  .doc-logo:first-child,
  .doc-title {
    border-right: 0;
  }

  .doc-fields {
    grid-template-columns: 1fr;
  }

  .doc-fields div,
  .doc-fields div:nth-child(2n),
  .doc-fields div:nth-child(4n) {
    border-right: 0;
    border-bottom: 1px solid var(--line-strong);
  }

  .doc-fields div:last-child {
    border-bottom: 0;
  }

  .check-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
