:root {
  --paper: #f5f5f3;
  --ink: #202020;
  --muted: #6b6b68;
  --line: #d8d8d4;
  --panel: #ffffff;
  --accent: #202020;
  --accent-dark: #000000;
  --gold: #202020;
  --soft: #f0f0ed;
  --shadow: 0 24px 70px rgba(18, 18, 18, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #ffffff 0%, var(--paper) 58%, #e9e9e5 100%);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 44px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  gap: 14px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-logo {
  width: 218px;
  max-width: 48vw;
  height: auto;
  display: block;
}

.brand small {
  display: block;
}

.brand small,
.session-chip,
.eyebrow,
.panel-heading p {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
}

.session-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.78);
}

.session-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.48);
}

.dialog-backdrop[hidden] {
  display: none;
}

.dialog-panel {
  width: min(100%, 460px);
  padding: 24px;
}

.dialog-panel label + label {
  margin-top: 16px;
}

.view {
  display: none;
  padding: 46px 0 0;
}

.view.active {
  display: block;
}

.login-grid,
.scan-layout,
.form-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(330px, 0.75fr);
  gap: 42px;
  align-items: center;
  min-height: calc(100vh - 140px);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(40px, 6vw, 76px);
  line-height: 0.98;
  letter-spacing: 0;
  margin-bottom: 20px;
}

h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 26px;
  line-height: 1.14;
  margin-bottom: 18px;
}

.lead {
  max-width: 620px;
  color: #4b4b48;
  font-size: 18px;
  line-height: 1.55;
}

.eyebrow,
.panel-heading p {
  margin-bottom: 8px;
  text-transform: uppercase;
  font-weight: 700;
}

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

.login-panel,
.calc-form {
  padding: 28px;
}

label {
  display: grid;
  gap: 8px;
  color: #33312c;
  font-weight: 700;
}

input,
select {
  width: 100%;
  border: 1px solid #cfc7b8;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 13px 14px;
}

.login-panel label + label {
  margin-top: 16px;
}

.primary-action,
.secondary-action,
.ghost-action {
  min-height: 46px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 18px;
  font-weight: 800;
}

.primary-action {
  background: var(--accent);
  color: white;
}

.primary-action:hover {
  background: var(--accent-dark);
}

.secondary-action {
  background: #fff;
  border-color: var(--accent);
  color: var(--accent-dark);
}

.ghost-action {
  background: transparent;
  border-color: var(--line);
  color: #3f3b33;
}

.login-panel .primary-action {
  width: 100%;
  margin-top: 24px;
}

.scan-layout {
  grid-template-columns: minmax(300px, 0.78fr) minmax(0, 1fr);
}

.scan-frame {
  display: grid;
  place-items: center;
}

.phone-bezel {
  width: min(330px, 88vw);
  aspect-ratio: 0.58;
  padding: 16px;
  border-radius: 34px;
  background: #1d1d1d;
  box-shadow: var(--shadow);
}

.camera-view {
  position: relative;
  display: grid;
  place-items: center;
  height: 100%;
  overflow: hidden;
  border-radius: 22px;
  background:
    linear-gradient(rgba(15, 111, 120, 0.08), rgba(15, 111, 120, 0.08)),
    repeating-linear-gradient(90deg, #f9f7f2 0 28px, #eee8dc 28px 56px);
}

.qr-code {
  display: grid;
  grid-template-columns: repeat(6, 22px);
  grid-auto-rows: 22px;
  gap: 8px;
  padding: 18px;
  background: white;
  border: 1px solid var(--line);
}

.qr-code span {
  background: #111;
}

.qr-code span:nth-child(4n),
.qr-code span:nth-child(7n),
.qr-code span:nth-child(11n) {
  background: transparent;
}

.scan-line {
  position: absolute;
  left: 36px;
  right: 36px;
  top: 50%;
  height: 2px;
  background: var(--gold);
  box-shadow: 0 0 18px rgba(181, 138, 58, 0.8);
}

.report-header,
.table-heading,
.request-row {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
}

.report-header {
  margin-bottom: 24px;
}

.report-header h1 {
  font-size: clamp(36px, 4.4vw, 58px);
}

.report-meta,
.total-loss {
  display: grid;
  gap: 8px;
  min-width: 260px;
  padding: 18px;
  border-left: 4px solid var(--gold);
  background: rgba(255, 255, 255, 0.82);
}

.total-loss span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.total-loss strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 32px;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.summary-grid .panel,
.results-panel {
  padding: 24px;
}

.recalc-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 20px;
  padding: 24px;
  background: linear-gradient(90deg, #ffffff 0%, #f0f0ed 100%);
}

.recalc-callout h2 {
  margin-bottom: 8px;
}

.recalc-callout p:last-child {
  max-width: 720px;
  margin-bottom: 0;
  color: #4d4a43;
  line-height: 1.5;
}

.details-list {
  margin: 0;
}

.details-list div {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

dt {
  color: var(--muted);
  font-weight: 700;
}

dd {
  margin: 0;
  font-weight: 700;
}

.contingency-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.contingency-grid div {
  min-height: 96px;
  display: grid;
  align-content: space-between;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
}

.contingency-grid span {
  color: var(--muted);
  font-weight: 700;
}

.contingency-grid strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
  white-space: normal;
}

thead th {
  color: #4e4e4a;
  font-size: 13px;
  text-transform: uppercase;
  background: #ededeb;
}

tbody tr.loss-row td {
  border-top: 2px solid #1d1d1d;
  border-bottom: 0;
  background: #eeeeeb;
  color: var(--accent-dark);
  font-weight: 900;
}

tbody tr.total-row td {
  font-weight: 800;
}

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

.date-field,
.input-grid label {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f7f5;
}

.scenario-picker {
  min-width: 210px;
}

.scenario-picker select {
  padding: 10px 12px;
  background: #fff;
  font-weight: 800;
}

.date-field {
  margin-bottom: 16px;
}

.input-grid span {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.date-field input,
.input-grid input {
  font-size: 24px;
  font-weight: 800;
}

.form-actions,
.request-row {
  margin-top: 22px;
}

.comparison-panel {
  margin-top: 20px;
}

.request-row {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.toast {
  min-height: 24px;
  color: var(--accent-dark);
  font-weight: 800;
  text-align: right;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.42fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.admin-users-table {
  min-width: 680px;
}

.admin-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.login-toast {
  margin: 14px 0 0;
  text-align: left;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 22px, 1180px);
    padding-top: 14px;
  }

  .topbar,
  .report-header,
  .table-heading,
  .request-row,
  .recalc-callout {
    align-items: stretch;
    flex-direction: column;
  }

  .session-chip {
    width: fit-content;
  }

  .login-grid,
  .scan-layout,
  .form-layout,
  .summary-grid,
  .admin-grid,
  .input-grid {
    grid-template-columns: 1fr;
  }

  .login-grid,
  .scan-layout,
  .form-layout {
    min-height: unset;
  }

  h1 {
    font-size: 42px;
  }

  .details-list div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .contingency-grid {
    grid-template-columns: 1fr;
  }
}
