:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #667085;
  --line: #d8dee8;
  --paper: #ffffff;
  --wash: #f4f6f8;
  --accent: #b0884f;
  --accent-dark: #76582f;
  --focus: #2563eb;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(17, 24, 39, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--wash);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

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

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 18px clamp(14px, 3vw, 34px) 38px;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(110deg, rgba(17, 24, 39, 0.92), rgba(17, 24, 39, 0.72)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='700' viewBox='0 0 1200 700'%3E%3Crect width='1200' height='700' fill='%23d9d2c4'/%3E%3Cg opacity='.45'%3E%3Cpath d='M0 438 1200 198v502H0z' fill='%238e795d'/%3E%3Cpath d='M0 535 1200 322v378H0z' fill='%23f3eee5'/%3E%3Cpath d='M80 590h1040' stroke='%23816b50' stroke-width='3'/%3E%3Cpath d='M160 552h880M210 515h780M260 478h680' stroke='%23816b50' stroke-width='2'/%3E%3C/g%3E%3C/svg%3E");
  background-position: center;
  background-size: cover;
}

.login-card {
  display: grid;
  gap: 15px;
  width: min(430px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  padding: clamp(22px, 5vw, 34px);
}

.login-card h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.15rem, 8vw, 3.2rem);
  font-weight: 500;
  letter-spacing: 0;
}

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

.login-error {
  color: var(--danger) !important;
  font-weight: 800;
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 18px;
  min-height: 230px;
  margin: 0 calc(clamp(14px, 3vw, 34px) * -1) 18px;
  padding: clamp(28px, 7vw, 78px) clamp(18px, 5vw, 54px) 30px;
  color: #fff;
  background:
    linear-gradient(110deg, rgba(17, 24, 39, 0.92), rgba(17, 24, 39, 0.7)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='700' viewBox='0 0 1200 700'%3E%3Crect width='1200' height='700' fill='%23d9d2c4'/%3E%3Cg opacity='.45'%3E%3Cpath d='M0 438 1200 198v502H0z' fill='%238e795d'/%3E%3Cpath d='M0 535 1200 322v378H0z' fill='%23f3eee5'/%3E%3Cpath d='M80 590h1040' stroke='%23816b50' stroke-width='3'/%3E%3Cpath d='M160 552h880M210 515h780M260 478h680' stroke='%23816b50' stroke-width='2'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  background-position: center;
}

.hero h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.8rem, 9vw, 5.8rem);
  font-weight: 500;
  line-height: 0.95;
  letter-spacing: 0;
}

.intro {
  max-width: 690px;
  margin: 16px 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: clamp(1rem, 2vw, 1.2rem);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero .eyebrow {
  color: #e3c088;
}

.status-card {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  width: max-content;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  white-space: nowrap;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.18);
}

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

.app-tile {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 16px;
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: clamp(16px, 4vw, 24px);
  text-align: left;
}

.app-tile:hover {
  background: #fffaf2;
  border-color: #c3a474;
}

.tile-icon {
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  font-size: 1.6rem;
  font-weight: 900;
}

.app-tile strong {
  display: block;
  font-size: clamp(1.35rem, 4vw, 1.95rem);
  letter-spacing: 0;
}

.app-tile small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
}

.view-stack {
  display: block;
}

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

.panel {
  margin-top: 16px;
  padding: clamp(16px, 3vw, 26px);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.heading-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

h2 {
  margin: 0;
  font-size: clamp(1.22rem, 2vw, 1.55rem);
  letter-spacing: 0;
}

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

.workflow-bar {
  display: grid;
  grid-template-columns: minmax(180px, 240px) 1fr;
  gap: 14px;
  align-items: end;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid #e3e7ee;
}

.workflow-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.save-state,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  width: max-content;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 850;
}

.send-button {
  background: var(--accent-dark);
}

.send-button:hover {
  background: #5d4322;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid #cfd6e1;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

input[type="file"] {
  display: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.legend {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.floors {
  display: grid;
  gap: 14px;
}

.archive-list {
  display: grid;
  gap: 12px;
}

.archive-item {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 14px;
  border: 1px solid #e3e7ee;
  border-radius: 8px;
  background: #fafbfc;
}

.archive-item strong {
  display: block;
  font-size: 1rem;
}

.archive-item span {
  color: var(--muted);
  font-size: 0.86rem;
}

.archive-meta,
.archive-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.archive-actions {
  justify-content: flex-end;
}

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

.floor-card {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid #e3e7ee;
  border-radius: 8px;
  background: #fafbfc;
}

.floor-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.photo-block {
  display: grid;
  gap: 12px;
  padding: 13px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #fff;
}

.photo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.photo-head strong {
  display: block;
  font-size: 0.95rem;
}

.photo-head span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.84rem;
}

.photo-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  width: max-content;
  border: 1px solid #c3a474;
  border-radius: 6px;
  background: #fffaf2;
  color: var(--accent-dark);
  padding: 9px 13px;
  font-size: 0.88rem;
  font-weight: 850;
  cursor: pointer;
  white-space: nowrap;
}

.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 10px;
}

.photo-thumb {
  margin: 0;
  overflow: hidden;
  border: 1px solid #e3e7ee;
  border-radius: 8px;
  background: #f8fafc;
}

.photo-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #e5e7eb;
}

.photo-thumb figcaption {
  overflow: hidden;
  padding: 8px 8px 0;
  color: #475467;
  font-size: 0.78rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-remove {
  width: calc(100% - 16px);
  min-height: 34px;
  margin: 8px;
  border: 1px solid #f2c7c2;
  background: #fff;
  color: var(--danger);
  padding: 6px 8px;
  font-size: 0.78rem;
}

.photo-remove:hover {
  background: #fff3f1;
}

.delivery-panel {
  border-color: #c3a474;
}

.delivery-checklist {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.check-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border: 1px solid #e3e7ee;
  border-radius: 8px;
  background: #fafbfc;
  padding: 10px 12px;
  color: var(--ink);
  font-weight: 750;
}

.check-row input {
  width: 20px;
  min-height: 20px;
  accent-color: var(--accent-dark);
}

.custom-rule {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.restpoint-block {
  display: grid;
  gap: 12px;
  margin: 18px 0;
  padding: 14px;
  border: 1px solid #e3e7ee;
  border-radius: 8px;
  background: #fbfaf7;
}

.restpoint-list {
  display: grid;
  gap: 12px;
}

.restpoint-card {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid #d9deea;
  border-radius: 8px;
  background: #fff;
}

.restpoint-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 12px;
}

.compact-photo-block {
  margin-top: 0;
  background: #f8fafc;
}

.mini-remove {
  min-height: 32px;
  border: 1px solid #f2c7c2;
  background: #fff;
  color: var(--danger);
  padding: 5px 8px;
  font-size: 0.76rem;
}

.signature-block {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 13px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #fff;
}

#signatureCanvas {
  display: block;
  width: 100%;
  height: 190px;
  border: 1px solid #cfd6e1;
  border-radius: 6px;
  background:
    linear-gradient(#fff, #fff),
    repeating-linear-gradient(0deg, transparent 0 37px, rgba(17, 24, 39, 0.06) 38px);
  touch-action: none;
}

.agreement-text {
  margin: 12px 0 0;
  color: #475467;
  font-size: 0.9rem;
}

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

.total-card {
  padding: 16px;
}

.total-card span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.total-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.45rem, 4vw, 2.15rem);
  font-weight: 850;
  letter-spacing: 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  font-weight: 800;
}

button:hover {
  background: #243041;
}

.secondary-button {
  border: 1px solid #c3a474;
  background: #fffaf2;
  color: var(--accent-dark);
}

.secondary-button:hover {
  background: #f6ebda;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  padding: 0;
}

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

.remove-floor {
  background: #fff;
  color: var(--danger);
  border: 1px solid #f2c7c2;
}

.remove-floor:hover {
  background: #fff3f1;
}

.hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

#summary {
  min-height: 250px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.88rem;
}

@media (max-width: 760px) {
  .hero {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .status-card {
    white-space: normal;
  }

  .form-grid,
  .measure-grid,
  .custom-rule,
  .workflow-bar,
  .totals-grid,
  .legend,
  .home-panel {
    grid-template-columns: 1fr;
  }

  .workflow-actions,
  .archive-actions,
  .photo-head {
    justify-content: stretch;
  }

  .photo-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .photo-button {
    width: 100%;
  }

  .workflow-actions button,
  .archive-actions button,
  .custom-rule button {
    flex: 1 1 100%;
  }

  .legend {
    display: none;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .heading-actions,
  .backHomeButton {
    width: 100%;
  }
}

@media (min-width: 761px) and (max-width: 1020px) {
  .totals-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (display-mode: standalone) {
  .shell {
    padding-top: max(18px, env(safe-area-inset-top));
  }
}
