:root {
  color-scheme: light;
  --blue: #2fc6f6;
  --blue-dark: #1199c8;
  --ink: #202c36;
  --muted: #7e8b96;
  --line: #e9edf0;
  --canvas: #f4f7f9;
  --card: #fff;
  font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; min-height: 0; overflow: hidden; background: var(--canvas); color: var(--ink); }
body { height: 100vh; height: 100dvh; }
button, input, textarea, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.app-shell { display: flex; flex-direction: column; width: 100%; height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
.topbar {
  position: relative; z-index: 10; flex: 0 0 auto; display: flex; align-items: center; gap: 13px;
  min-height: calc(70px + env(safe-area-inset-top)); padding: calc(9px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 9px max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid #e7ecef; background: rgba(255,255,255,.96); backdrop-filter: blur(18px);
}
.icon-button { display: inline-grid; place-items: center; flex: 0 0 auto; width: 40px; height: 40px; border: 0; border-radius: 12px; background: transparent; color: #62727d; cursor: pointer; }
.icon-button:active { background: #f0f5f7; }
.icon-button svg, .section-icon svg, .search-box svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.topbar-title { min-width: 0; flex: 1; }
.crumb { display: block; margin-bottom: 2px; color: #96a1a9; font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.crumb span { margin: 0 3px; color: #c6cfd5; }
.topbar h1 { overflow: hidden; margin: 0; color: #17232d; font-size: 19px; font-weight: 700; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 18px; border: 0; border-radius: 11px; background: var(--blue); color: #fff; font-size: 13px; font-weight: 700; box-shadow: 0 4px 12px rgba(47,198,246,.2); cursor: pointer; transition: background .18s, transform .18s, opacity .18s; }
.primary-button:hover:not(:disabled) { background: var(--blue-dark); }
.primary-button:active:not(:disabled) { transform: translateY(1px); }
.primary-button:disabled { opacity: .48; cursor: not-allowed; box-shadow: none; }
.create-spinner { display: none; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.is-saving .create-spinner { display: block; }
.is-saving .create-label { opacity: .8; }
@keyframes spin { to { transform: rotate(360deg); } }

.page-scroll { width: 100%; height: 0; min-height: 0; flex: 1 1 0%; overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.content-column { width: min(100%, 760px); margin: 0 auto; padding: 22px 20px 26px; }
.page-intro { display: flex; align-items: center; gap: 14px; padding: 3px 3px 19px; }
.intro-mark { display: grid; place-items: center; width: 48px; height: 48px; flex: 0 0 auto; border-radius: 15px; background: #e3f8ff; color: #10a5d6; }
.intro-mark svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.eyebrow { margin: 0 0 3px; color: #a0abb3; font-size: 10px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.intro-copy { margin: 0; color: #6f7e89; font-size: 12px; line-height: 1.55; }
.form-card, .state-card { margin-bottom: 14px; padding: 20px; border: 1px solid #ebeff1; border-radius: 16px; background: var(--card); box-shadow: 0 2px 8px rgba(27,57,72,.025); }
.section-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 19px; }
.section-heading h2 { margin: 0; color: #25333d; font-size: 15px; font-weight: 700; line-height: 1.3; }
.section-heading p { margin: 3px 0 0; color: #8c99a2; font-size: 11px; line-height: 1.4; }
.section-icon { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto; border-radius: 12px; }
.section-icon svg { width: 20px; height: 20px; }
.blue-icon { background: #e7f8ff; color: #1da9d5; }
.lilac-icon { background: #f2edff; color: #8970dd; }
.amber-icon { background: #fff4e4; color: #df9633; }
.gray-icon { background: #eef2f4; color: #74848f; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px 14px; }
.field { min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.field.full-width { grid-column: 1 / -1; }
.field-label { display: flex; align-items: center; gap: 5px; min-height: 16px; color: #687781; font-size: 11px; font-weight: 600; line-height: 1.3; }
.field-label.is-required::after { content: ""; width: 4px; height: 4px; border-radius: 50%; background: #ee7b68; }
.field input, .field textarea, .field select, .search-box input {
  width: 100%; min-height: 44px; padding: 0 13px; border: 1px solid #e5eaed; border-radius: 10px; outline: 0; background: #fff; color: #2b3943; font-size: 13px; transition: border .18s, box-shadow .18s;
}
.field textarea { min-height: 92px; padding: 11px 13px; resize: vertical; line-height: 1.5; }
.field input::placeholder, .field textarea::placeholder { color: #b1bbc2; }
.field input:focus, .field textarea:focus, .field select:focus, .search-box:focus-within { border-color: #72d4f2; box-shadow: 0 0 0 3px rgba(47,198,246,.11); }
.field select { appearance: none; padding-right: 35px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b98a2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.field input:disabled, .field textarea:disabled, .field select:disabled { background: #f7f9fa; color: #9ba6ad; }
.boolean-field { display: flex; align-items: center; justify-content: space-between; min-height: 55px; padding: 9px 13px; border: 1px solid #e5eaed; border-radius: 10px; }
.boolean-field .field-label { margin: 0; }
.switch { position: relative; width: 42px; height: 24px; flex: 0 0 auto; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch span { position: absolute; inset: 0; border-radius: 20px; background: #dce3e7; transition: background .2s; }
.switch span::after { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px #0002; content: ""; transition: transform .2s; }
.switch input:checked + span { background: var(--blue); }
.switch input:checked + span::after { transform: translateX(18px); }

.client-pickers { display: flex; flex-direction: column; gap: 0; }
.client-picker-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 68px; padding: 9px 0; border-top: 1px solid #f0f2f4; }
.client-picker-row:first-child { border-top: 0; padding-top: 0; }
.client-kind { display: flex; align-items: center; gap: 11px; min-width: 0; }
.client-kind strong { display: block; color: #35434c; font-size: 12px; }
.client-kind small { display: block; margin-top: 3px; color: #98a4ac; font-size: 10px; }
.client-avatar { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto; border-radius: 12px; font-size: 14px; font-weight: 700; }
.contact-avatar { background: #f0edff; color: #8370d2; }
.company-avatar { background: #e8f7ef; color: #40a875; }
.outline-button { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 13px; border: 1px solid #dce5e9; border-radius: 9px; background: white; color: #267e9b; font-size: 11px; font-weight: 700; cursor: pointer; }
.outline-button:hover { border-color: #8edcf4; background: #f7fdff; }
.selected-entity { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: -1px 0 8px 49px; padding: 9px 11px; border: 1px solid #e1f3f8; border-radius: 10px; background: #f6fcfe; }
.selected-entity strong { display: block; color: #34434c; font-size: 11px; }
.selected-entity small { display: block; margin-top: 3px; color: #8c9ba4; font-size: 10px; }
.remove-entity { width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: #98a6ad; font-size: 20px; cursor: pointer; }
.remove-entity:hover { background: #fff0ed; color: #dc7869; }

.photo-dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 146px; padding: 17px; border: 1px dashed #b9dce8; border-radius: 13px; background: #f8fcfe; text-align: center; }
.photo-add-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: #e7f7fc; color: #31a9cf; }
.photo-add-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.photo-dropzone strong { color: #43545e; font-size: 12px; }
.photo-dropzone p { margin: -3px 0 3px; color: #92a0a9; font-size: 10px; }
.photo-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.photo-action { min-height: 34px; padding: 0 12px; border: 1px solid #dce8ec; border-radius: 9px; background: #fff; color: #3e7589; font-size: 10px; font-weight: 700; cursor: pointer; }
.photo-action.camera-action { border-color: #3db9de; background: #31b9e5; color: white; }
.photo-action:disabled { opacity: .45; cursor: not-allowed; }
.photo-field-select { margin: 0 0 10px; }
.photo-field-select select { min-height: 38px; font-size: 11px; }
.photo-preview-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.photo-thumb { position: relative; overflow: hidden; aspect-ratio: 1; border: 1px solid #e6ecef; border-radius: 10px; background: #f3f6f8; }
.photo-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-thumb button { position: absolute; top: 4px; right: 4px; display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 8px; background: rgba(26,38,45,.72); color: white; font-size: 17px; line-height: 1; cursor: pointer; }
.photo-thumb span { position: absolute; right: 5px; bottom: 5px; left: 5px; overflow: hidden; color: white; font-size: 8px; text-overflow: ellipsis; text-shadow: 0 1px 4px #000b; white-space: nowrap; }
.photo-footnote { display: flex; align-items: center; gap: 6px; margin: 12px 0 0; color: #8a999f; font-size: 10px; }
.checkmark { display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: #e8f7ef; color: #43a875; font-size: 10px; font-weight: 700; }
.photo-warning { margin: 0 0 10px; padding: 9px 10px; border-radius: 9px; background: #fff8ea; color: #9e7527; font-size: 10px; line-height: 1.5; }
.file-count { align-self: center; color: #8998a1; font-size: 10px; }

.more-fields { padding: 0 20px 20px; }
.more-fields > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 84px; list-style: none; cursor: pointer; }
.more-fields > summary::-webkit-details-marker { display: none; }
.compact-heading { margin: 0; }
.chevron { width: 19px; height: 19px; flex: 0 0 auto; fill: none; stroke: #8d9aa1; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
.more-fields[open] > summary .chevron { transform: rotate(180deg); }
.readonly-fields { margin-top: 15px; padding-top: 14px; border-top: 1px solid #eef1f3; }
.readonly-fields > details > summary { color: #84929a; font-size: 10px; cursor: pointer; }
.readonly-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 10px; }
.readonly-pill { overflow: hidden; padding: 7px 9px; border-radius: 8px; background: #f5f7f8; color: #85939a; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.form-end-note { display: flex; align-items: center; gap: 7px; margin: 6px 2px 20px; color: #91a0a8; font-size: 10px; }
.info-dot { display: grid; place-items: center; width: 15px; height: 15px; border: 1px solid #b6c2c8; border-radius: 50%; font-size: 9px; font-style: normal; font-weight: 700; }
.page-footer { padding: 4px 0 calc(10px + env(safe-area-inset-bottom)); color: #a1adb4; font-size: 9px; text-align: center; }
.page-footer span { margin: 0 4px; }

.state-card { display: flex; align-items: center; gap: 13px; min-height: 82px; }
.state-card strong { display: block; color: #40515b; font-size: 12px; }
.state-card p { margin: 4px 0 0; color: #93a0a8; font-size: 10px; line-height: 1.5; }
.loading-dot { width: 19px; height: 19px; flex: 0 0 auto; border: 2px solid #ddf3fa; border-top-color: #32bde5; border-radius: 50%; animation: spin .9s linear infinite; }
.error-state { align-items: flex-start; border-color: #f4e0db; background: #fffdfc; }
.state-icon { display: grid; place-items: center; width: 26px; height: 26px; flex: 0 0 auto; border-radius: 50%; background: #fff0ec; color: #cf7663; font-size: 14px; font-weight: 700; }
.text-button { margin-top: 9px; padding: 0; border: 0; background: none; color: #148aad; font-size: 11px; font-weight: 700; cursor: pointer; }

.modal { position: fixed; z-index: 30; inset: 0; display: flex; align-items: flex-end; justify-content: center; visibility: hidden; opacity: 0; transition: opacity .2s, visibility .2s; }
.modal.is-open { visibility: visible; opacity: 1; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(17,32,42,.42); backdrop-filter: blur(3px); }
.modal-panel { position: relative; display: flex; flex-direction: column; width: min(100%, 570px); max-height: min(88dvh, 760px); overflow: hidden; border-radius: 20px 20px 0 0; background: #fff; box-shadow: 0 -10px 40px rgba(16,43,57,.16); transform: translateY(22px); transition: transform .24s cubic-bezier(.2,.8,.2,1); padding-bottom: env(safe-area-inset-bottom); }
.modal.is-open .modal-panel { transform: translateY(0); }
.modal-handle { width: 34px; height: 4px; flex: 0 0 auto; margin: 9px auto 1px; border-radius: 5px; background: #dce2e5; }
.modal-header { display: flex; align-items: center; gap: 8px; padding: 13px 20px 16px; border-bottom: 1px solid #eef1f2; }
.modal-header > div { flex: 1; }
.modal-header h2 { margin: 0; color: #25333c; font-size: 16px; }
.modal-header p { margin: 3px 0 0; color: #92a0a8; font-size: 10px; }
.modal-back, .modal-close { width: 34px; height: 34px; }
.modal-view { min-height: 0; overflow: auto; padding: 15px 20px 20px; }
.search-box { display: flex; align-items: center; gap: 9px; min-height: 46px; padding: 0 11px; border: 1px solid #e1e8eb; border-radius: 11px; transition: border .18s, box-shadow .18s; }
.search-box svg { flex: 0 0 auto; color: #8c9ba4; }
.search-box input { min-width: 0; min-height: 42px; padding: 0; border: 0; box-shadow: none !important; font-size: 12px; }
.clear-search { width: 25px; height: 25px; border: 0; border-radius: 50%; background: #eef2f4; color: #77868f; font-size: 18px; line-height: 1; cursor: pointer; }
.entity-results { min-height: 132px; max-height: 42dvh; overflow: auto; padding: 6px 0; }
.search-hint { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 126px; color: #a2aeb5; text-align: center; }
.search-hint-icon { color: #cfdae0; font-size: 27px; line-height: 1; }
.search-hint p { max-width: 215px; margin: 7px 0 0; font-size: 10px; line-height: 1.5; }
.entity-result { display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px 2px; border: 0; border-bottom: 1px solid #f0f3f4; background: white; text-align: left; cursor: pointer; }
.entity-result:active { background: #f7fbfc; }
.result-avatar { display: grid; place-items: center; width: 37px; height: 37px; flex: 0 0 auto; border-radius: 12px; background: #eef7fa; color: #378ba6; font-size: 11px; font-weight: 700; }
.result-avatar.company { background: #eaf7ef; color: #49a274; }
.result-copy { min-width: 0; flex: 1; }
.result-copy strong { display: block; overflow: hidden; color: #35444e; font-size: 11px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.result-copy small { display: block; overflow: hidden; margin-top: 3px; color: #9aa7ad; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.result-check { color: #47b681; font-size: 17px; }
.results-loading { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 100px; color: #93a1a9; font-size: 10px; }
.results-loading .loading-dot { width: 15px; height: 15px; }
.new-entity-button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 50px; padding: 8px 0 0; border: 0; border-top: 1px solid #edf0f2; background: #fff; color: #43545e; font-size: 11px; text-align: left; cursor: pointer; }
.new-entity-button b { color: #148fb5; font-weight: 700; }
.new-entity-button > svg { width: 18px; height: 18px; margin-left: auto; fill: none; stroke: #a2afb5; stroke-width: 1.8; }
.plus-circle { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid #d4edf4; border-radius: 10px; color: #24a3c9; font-size: 19px; }
.entity-create-form { display: flex; flex-direction: column; gap: 13px; }
.entity-create-form .field-grid { display: flex; flex-direction: column; }
.entity-create-form > div { display: flex; flex-direction: column; gap: 13px; }
.modal-submit { width: 100%; margin-top: 6px; }
.modal-submit.is-saving { opacity: .7; }

.camera-modal { z-index: 40; align-items: center; padding: env(safe-area-inset-top) 14px env(safe-area-inset-bottom); }
.camera-modal .modal-backdrop { background: rgba(9,19,25,.83); backdrop-filter: blur(8px); }
.camera-panel { position: relative; display: flex; flex-direction: column; width: min(100%, 560px); overflow: hidden; border-radius: 18px; background: #10171c; color: white; box-shadow: 0 20px 60px #0008; }
.camera-header { display: flex; align-items: center; justify-content: space-between; padding: 13px 17px; }
.camera-header .eyebrow { color: #91a0a8; font-size: 9px; }
.camera-header h2 { margin: 2px 0 0; font-size: 15px; }
.camera-header .icon-button { color: #d2d9dc; }
.camera-view { position: relative; display: grid; place-items: center; overflow: hidden; min-height: 340px; max-height: 61dvh; background: #000; }
.camera-view video { display: block; width: 100%; height: 100%; min-height: 340px; max-height: 61dvh; object-fit: cover; }
.camera-fallback { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px; background: #10171c; text-align: center; }
.camera-fallback > span { margin-bottom: 10px; font-size: 28px; }
.camera-fallback strong { font-size: 13px; }
.camera-fallback p { max-width: 270px; color: #9ca8ae; font-size: 10px; line-height: 1.6; }
.camera-fallback .outline-button { margin-top: 8px; }
.camera-controls { display: grid; grid-template-columns: 1fr 60px 1fr; align-items: center; min-height: 78px; padding: 8px 17px 12px; }
.camera-count { display: flex; flex-direction: column; color: #8c999f; font-size: 9px; }
.camera-count strong { margin-bottom: 2px; color: white; font-size: 14px; }
.shutter-button { display: grid; place-items: center; width: 58px; height: 58px; border: 2px solid white; border-radius: 50%; background: transparent; cursor: pointer; }
.shutter-button span { width: 43px; height: 43px; border-radius: 50%; background: white; transition: transform .1s; }
.shutter-button:active span { transform: scale(.88); }
.camera-done { justify-self: end; min-height: 36px; padding: 0 13px; border: 0; border-radius: 9px; background: #2fc6f6; color: white; font-size: 11px; font-weight: 700; cursor: pointer; }
.toast { position: fixed; z-index: 60; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom)); left: 16px; width: fit-content; max-width: calc(100% - 32px); margin: auto; padding: 11px 15px; border-radius: 11px; background: #24333b; color: #fff; font-size: 11px; line-height: 1.45; box-shadow: 0 8px 28px #0f29354d; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (min-width: 780px) {
  .topbar { padding-right: max(calc((100vw - 720px) / 2), 26px); padding-left: max(calc((100vw - 720px) / 2), 26px); }
  .content-column { padding-top: 28px; }
  .modal { align-items: center; padding: 24px; }
  .modal-panel { max-height: min(80dvh, 700px); border-radius: 18px; padding-bottom: 0; }
  .modal-handle { display: none; }
  .camera-modal { align-items: center; }
}
@media (max-width: 560px) {
  .topbar { min-height: calc(62px + env(safe-area-inset-top)); gap: 8px; }
  .back-button { width: 35px; }
  .topbar h1 { font-size: 17px; }
  .primary-button { min-height: 38px; padding: 0 14px; }
  .content-column { padding: 16px 12px 18px; }
  .page-intro { padding: 2px 3px 14px; }
  .intro-mark { width: 42px; height: 42px; border-radius: 13px; }
  .form-card, .state-card { margin-bottom: 10px; padding: 16px; border-radius: 14px; }
  .section-heading { margin-bottom: 15px; }
  .section-icon { width: 35px; height: 35px; border-radius: 11px; }
  .field-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .field.full-width { grid-column: auto; }
  .photo-preview-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .more-fields { padding: 0 16px 16px; }
  .more-fields > summary { min-height: 75px; }
  .readonly-list { grid-template-columns: minmax(0, 1fr); }
  .camera-view, .camera-view video { min-height: 300px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
