:root {
  color-scheme: light;
  --bg: #eef3f1;
  --surface: #ffffff;
  --surface-strong: #e4ede9;
  --ink: #15201f;
  --muted: #64716f;
  --line: #c5d2cd;
  --primary: #0f6f65;
  --primary-ink: #ffffff;
  --accent: #c77b25;
  --danger: #b3261e;
  --shadow: 0 12px 28px rgba(15, 38, 35, 0.10);
  font-family: "Segoe UI", Arial, sans-serif;
  font-style: italic;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101614;
  --surface: #1c2824;
  --surface-strong: #22312d;
  --ink: #edf5f1;
  --muted: #aab8b3;
  --line: #405650;
  --primary: #38b7a8;
  --primary-ink: #061210;
  --accent: #e0a14f;
  --danger: #ffb4ab;
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  background: var(--surface-strong);
  color: var(--muted);
  border: 1px solid var(--line);
  opacity: 1;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  max-width: 540px;
  margin: 0 auto;
  background: var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 52px 1fr 44px;
  align-items: center;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.login-route .topbar {
  display: none;
}

.nav-slot {
  position: relative;
  width: 52px;
  height: 38px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.nav-slot > * {
  grid-area: 1 / 1;
}

.brand-mark {
  display: none;
  width: 42px;
  height: 32px;
  background-image: url("/assets/DelphisLogo.png");
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  align-self: center;
  justify-self: center;
}

.brand-mark.visible {
  display: block;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: 1.28rem;
  line-height: 1.2;
}

h2 {
  margin: 0;
  font-size: 1.05rem;
}

h3 {
  margin: 0 0 8px;
  font-size: 0.98rem;
}

.screen {
  padding: 12px;
  padding-bottom: 24px;
}

.login-screen {
  display: grid;
  align-content: start;
  gap: 18px;
  min-height: calc(100vh - 86px);
  padding-top: 26px;
}

.login-brand {
  display: grid;
  justify-items: center;
  gap: 6px;
  text-align: center;
}

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

.login-brand p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.login-brand h2 {
  font-size: 1.45rem;
}

.login-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
}

.primary,
.secondary,
.danger,
.ghost,
.pill-button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 650;
}

.primary {
  background: var(--primary);
  color: var(--primary-ink);
}

.secondary {
  background: var(--surface-strong);
  color: var(--ink);
}

.danger {
  background: #fde7e5;
  color: var(--danger);
}

.ghost {
  background: transparent;
  color: var(--primary);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 1.28rem;
}

.hidden {
  visibility: hidden;
}

.hidden-panel {
  display: none !important;
}

.toolbar,
.button-row,
.segmented {
  display: flex;
  gap: 6px;
}

.toolbar {
  align-items: end;
  margin-bottom: 10px;
}

.toolbar label {
  flex: 1;
}

.button-row {
  flex-wrap: wrap;
}

.button-row > * {
  flex: 1 1 126px;
}

.work-detail-actions {
  margin-bottom: 18px;
}

.work-detail-actions + .section {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 9px 10px;
}

textarea {
  min-height: 112px;
  resize: vertical;
}

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

.installation-results {
  max-height: 260px;
  overflow-y: auto;
  padding-right: 3px;
}

.assistant-picker-button {
  width: 100%;
  text-align: left;
  font-weight: 500;
}

.assistant-picker-panel {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.assistant-results {
  max-height: 240px;
  overflow-y: auto;
  padding-right: 3px;
}

.assistant-result {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  font-weight: 400;
}

.selection-input-row {
  display: grid;
  grid-template-columns: 1fr 38px;
  gap: 6px;
  align-items: center;
}

.card {
  display: grid;
  gap: 5px;
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: color-mix(in srgb, var(--surface) 94%, var(--surface-strong));
  color: inherit;
  text-align: left;
  box-shadow: none;
}

.card-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  font-weight: 750;
}

.card-title > span:first-child {
  flex: 1 1 auto;
  min-width: 0;
}

.tag {
  display: inline-flex;
  flex: 0 0 82px;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  height: 22px;
  width: 82px;
  min-width: 82px;
  max-width: 82px;
  border-radius: 5px;
  padding: 2px 8px;
  background: #fff2df;
  color: #7c420f;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  align-self: flex-start;
}

.installation-result-title {
  font-weight: 400;
}

.installation-result-tag {
  font-weight: 400;
}

.meta {
  color: var(--muted);
  font-size: 0.86rem;
}

.meta-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.84rem;
}

.card-assistant {
  margin-top: 2px;
}

.order-card {
  position: relative;
  padding-left: 16px;
}

.order-card::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 6px;
  width: 4px;
  border-radius: 4px;
}

.order-card.pending::before {
  background: #d92d20;
}

.order-card.active::before {
  background: #1a7f4f;
}

.order-card.closed::before {
  background: #ffffff;
  border: 1px solid var(--line);
}

html[data-theme="dark"] .order-card.closed::before {
  background: #f8faf9;
}

.section {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.info-grid {
  display: grid;
  gap: 6px;
}

.info-row {
  display: grid;
  grid-template-columns: minmax(110px, 36%) 1fr;
  gap: 8px;
  align-items: start;
  font-size: 0.92rem;
}

.info-row span:first-child {
  color: var(--muted);
}

.copy-info-row {
  border: 1px solid color-mix(in srgb, var(--primary) 42%, var(--line));
  border-radius: 8px;
  padding: 9px 10px;
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  color: var(--ink);
  text-align: left;
}

.copy-info-row span:last-child {
  color: var(--ink);
}

.copy-info-row:active {
  transform: translateY(1px);
}

.issue-preview {
  display: grid;
  gap: 10px;
}

.issue-preview-list {
  display: grid;
  gap: 8px;
  max-height: min(56vh, 520px);
  overflow: auto;
  padding-right: 4px;
}

.issue-preview-card {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface);
}

.status-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.status-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--surface);
}

.status-box strong {
  display: block;
  margin-bottom: 4px;
}

.small {
  color: var(--muted);
  font-size: 0.82rem;
}

.field-stack {
  display: grid;
  gap: 10px;
}

.field-hint {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.compact-section {
  gap: 8px;
  margin-bottom: 0;
  padding-bottom: 0;
}

.dynamic-list {
  display: grid;
  gap: 6px;
}

.dynamic-row {
  display: grid;
  grid-template-columns: 1fr 38px;
  gap: 6px;
  align-items: center;
}

.icon-mini {
  min-height: 38px;
  width: 38px;
  padding: 0;
  font-size: 1.25rem;
}

.segmented {
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.segmented button {
  flex: 1;
}

.segmented button.active {
  background: var(--primary);
  color: var(--primary-ink);
}

.counter {
  justify-self: end;
  color: var(--muted);
  font-size: 0.76rem;
}

.unit-picker {
  display: grid;
  gap: 8px;
}

.selected-units {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--surface);
}

.selected-unit-chip {
  display: grid;
  grid-template-columns: 1fr 30px;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 4px 6px 10px;
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  color: var(--ink);
  text-align: left;
  font-size: 0.9rem;
}

.selected-unit-chip span:first-child {
  min-width: 0;
}

.selected-unit-chip span:last-child {
  display: grid;
  place-items: center;
  width: 30px;
  height: 28px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 1.15rem;
}

.unit-options {
  max-height: 260px;
  overflow-y: auto;
}

.compact-empty {
  min-height: 44px;
}

.check-list {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.check-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 500;
}

.check-list input {
  width: auto;
}

dialog {
  width: min(92vw, 500px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.24);
}

dialog.signature-modal {
  width: min(calc(100vw - 8px), 560px);
  max-width: calc(100vw - 8px);
  max-height: calc(100dvh - 8px);
}

dialog::backdrop {
  background: rgba(16, 24, 23, 0.45);
}

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

#modalBody {
  padding: 16px;
}

dialog.signature-modal .modal-header {
  padding-inline: 12px;
}

dialog.signature-modal #modalBody {
  padding: 10px;
}

.notice-popover {
  position: fixed;
  z-index: 1000;
  top: 50%;
  left: 50%;
  width: min(320px, calc(100vw - 40px));
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  text-align: center;
}

.notice-popover p {
  margin: 0;
}

.signature-pad {
  width: 100%;
  height: 230px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(17, 24, 24, 0.08);
  touch-action: none;
}

.signature-pad-large {
  height: min(80dvh, 720px);
  min-height: min(520px, calc(100dvh - 150px));
}

.empty {
  display: grid;
  place-items: center;
  min-height: 120px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (min-width: 760px) {
  body {
    background: #e8eeeb;
  }

  .app-shell {
    min-height: calc(100vh - 32px);
    margin-block: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
  }
}

.contract-overview h2 { font-size: 1.1rem; margin: .4rem 0; }
.contract-overview h3 { font-size: 1rem;  margin: .6rem 0 .3rem; }
.contract-overview h4 { font-size: .95rem; margin: .5rem 0 .2rem; }
.contract-overview p  { margin: .3rem 0; }
.contract-overview hr { border: 0; border-top: 1px solid var(--line); margin: .6rem 0; }

table.ovw { width: 100%; border-collapse: collapse; margin: .4rem 0; font-size: .9rem; color: var(--ink); }
table.ovw th, table.ovw td { border: 1px solid var(--line); padding: 4px 6px; text-align: left; vertical-align: top; }
table.ovw th { background: var(--surface-strong); color: var(--ink); }

ul.notes { margin: .3rem 0 .6rem; padding-left: 1.1rem; }
ul.notes li { margin: .2rem 0; color: var(--ink); }

.contract-overview .muted, .notes .muted, .add-note .muted { color: var(--muted); font-size: .85rem; }

.add-note { border-top: 1px solid var(--line); margin-top: .6rem; padding-top: .5rem; display: flex; flex-direction: column; gap: .4rem; }
.add-note h4 { margin: 0 0 .2rem; color: var(--ink); }
.add-note select, .add-note input, .add-note textarea {
  width: 100%; padding: 6px; box-sizing: border-box; font: inherit;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 4px;
}
.add-note textarea { min-height: 60px; resize: vertical; }
.add-note button { align-self: flex-start; padding: 6px 14px; background: var(--primary); color: var(--primary-ink); border: 0; border-radius: 4px; }


table.ovw { width: 100%; border-collapse: collapse; margin: .4rem 0; font-size: .9rem; }
table.ovw th, table.ovw td { border: 1px solid #ddd; padding: 4px 6px; text-align: left; vertical-align: top; }
table.ovw th { background: #f4f4f4; }

ul.notes { margin: .3rem 0 .6rem; padding-left: 1.1rem; }
ul.notes li { margin: .2rem 0; }

.muted { color: #888; font-size: .85rem; }

.add-note { border-top: 1px solid #eee; margin-top: .6rem; padding-top: .5rem; display: flex; flex-direction: column; gap: .4rem; }
.add-note h4 { margin: 0 0 .2rem; }
.add-note select, .add-note input, .add-note textarea { width: 100%; padding: 6px; box-sizing: border-box; font: inherit; }
.add-note textarea { min-height: 60px; resize: vertical; }
.add-note button { align-self: flex-start; padding: 6px 14px; }
