:root {
  --ink: #0d2638;
  --ink-soft: #29475a;
  --blue: #176ca4;
  --signal: #efb24f;
  --signal-soft: #fff1d8;
  --paper: #f7f8f5;
  --mist: #e9eff1;
  --white: #ffffff;
  --green: #25775f;
  --green-soft: #e7f4ef;
  --red: #a8433e;
  --red-soft: #fff1f0;
  --line: rgba(13, 38, 56, .13);
  --shadow: 0 18px 48px rgba(8, 31, 45, .14);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

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

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 10% 5%, rgba(239, 178, 79, .16), transparent 28rem),
    linear-gradient(135deg, #e4eced, #f6f3ec 56%, #dce7e9);
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid rgba(23, 108, 164, .3); outline-offset: 2px; }

.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(300px, 520px) minmax(360px, 520px);
  place-content: center;
  gap: clamp(40px, 8vw, 120px);
  padding: 42px;
}

.auth-intro { align-self: center; max-width: 500px; }
.eyebrow { display: flex; align-items: center; gap: 9px; margin-bottom: 23px; color: var(--ink-soft); font-size: 11px; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.eyebrow::before { width: 28px; height: 3px; content: ""; border-radius: 9px; background: var(--signal); }
.auth-intro h1 { max-width: 450px; margin: 0 0 19px; font-size: clamp(46px, 6vw, 74px); line-height: .94; letter-spacing: -.06em; }
.auth-intro > p { max-width: 470px; margin: 0; color: #4a606c; font-size: 17px; line-height: 1.65; }
.security-points { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 28px; }
.security-point { min-height: 92px; padding: 16px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,255,255,.62); backdrop-filter: blur(12px); }
.security-point strong { display: block; margin-bottom: 5px; font-size: 13px; }
.security-point span { color: #657780; font-size: 11px; line-height: 1.45; }

.auth-card {
  align-self: center;
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  border: 1px solid rgba(13,38,56,.12);
  border-radius: 30px;
  background: rgba(255,255,255,.94);
  box-shadow: var(--shadow);
}

.auth-card-head { position: relative; overflow: hidden; padding: 34px 30px 27px; color: white; background: var(--ink); }
.auth-card-head::after { position: absolute; top: -80px; right: -60px; width: 210px; height: 210px; content: ""; border: 28px solid rgba(255,255,255,.05); border-radius: 50%; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 22px; border-radius: 15px 5px 15px 5px; color: var(--ink); background: var(--signal); font-size: 16px; font-weight: 950; letter-spacing: -.05em; }
.auth-card-head h2 { position: relative; z-index: 1; margin: 0 0 6px; font-size: 28px; letter-spacing: -.04em; }
.auth-card-head p { position: relative; z-index: 1; margin: 0; color: #aac0ca; font-size: 12px; }
.auth-body { padding: 25px 30px 30px; }
.auth-body h3 { margin: 0 0 8px; font-size: 20px; letter-spacing: -.025em; }
.auth-body > p { margin: 0 0 20px; color: #657781; font-size: 12px; line-height: 1.55; }

.demo-warning { margin-bottom: 17px; padding: 13px 14px; border-left: 3px solid var(--signal); border-radius: 0 12px 12px 0; color: #644915; background: var(--signal-soft); font-size: 11px; line-height: 1.5; }
.terms-box { max-height: 210px; overflow-y: auto; margin-bottom: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: #f8faf9; color: #506570; font-size: 10px; line-height: 1.55; }
.terms-box strong { color: var(--ink); }
.check-row { display: flex; align-items: flex-start; gap: 10px; margin: 14px 0 18px; color: #425b68; font-size: 11px; line-height: 1.45; }
.check-row input { width: 19px; height: 19px; flex: 0 0 auto; margin: 0; accent-color: var(--green); }

.field { min-width: 0; }
.field + .field { margin-top: 11px; }
.field-grid { display: grid; gap: 11px; }
.field-grid .field + .field { margin-top: 0; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field label { display: block; margin: 0 0 5px 2px; color: #536974; font-size: 9px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 12px;
  border: 1px solid #cbd7db;
  border-radius: 12px;
  outline: none;
  color: var(--ink);
  background: white;
  font-size: 12px;
}
.field textarea { min-height: 100px; resize: vertical; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,108,164,.09); }
.field .help { display: block; margin: 5px 2px 0; color: #7a8a92; font-size: 9px; line-height: 1.4; }
.field-error { display: block; margin-top: 5px; color: var(--red); font-size: 10px; font-weight: 750; }
form > .primary-btn { margin-top: 16px; }

.primary-btn, .secondary-btn, .soft-btn, .danger-btn {
  min-height: 48px;
  padding: 0 17px;
  border-radius: 13px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  transition: transform .14s ease, filter .14s ease;
}
.primary-btn:active, .secondary-btn:active, .soft-btn:active, .danger-btn:active { transform: scale(.985); }
.primary-btn { border: 0; color: var(--ink); background: var(--signal); }
.secondary-btn { border: 0; color: white; background: var(--ink); }
.soft-btn { border: 1px solid var(--line); color: var(--ink); background: white; }
.danger-btn { border: 1px solid #e2b5b1; color: var(--red); background: var(--red-soft); }
.wide { width: 100%; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.text-btn { padding: 5px; border: 0; color: var(--blue); background: none; font-size: 10px; font-weight: 850; cursor: pointer; }

.app-shell { min-height: 100vh; background: var(--paper); }
.app-header { position: sticky; z-index: 20; top: 0; color: white; background: var(--ink); box-shadow: 0 7px 22px rgba(13,38,56,.13); }
.app-header-main { max-width: 1160px; min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) 24px 12px; }
.app-brand { display: flex; align-items: center; gap: 11px; }
.app-brand .brand-mark { width: 38px; height: 38px; margin: 0; border-radius: 12px 4px 12px 4px; font-size: 12px; }
.app-brand strong { display: block; font-size: 13px; letter-spacing: .02em; }
.app-brand small { display: block; margin-top: 2px; color: #94acb8; font-size: 9px; }
.header-actions { display: flex; align-items: center; gap: 9px; }
.local-pill { display: flex; align-items: center; gap: 7px; padding: 8px 10px; border: 1px solid rgba(255,255,255,.13); border-radius: 99px; color: #c7d6dd; background: rgba(255,255,255,.04); font-size: 9px; font-weight: 800; }
.local-pill::before { width: 7px; height: 7px; content: ""; border-radius: 50%; background: #5bd1a6; box-shadow: 0 0 0 4px rgba(91,209,166,.12); }
.lock-btn { width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.15); border-radius: 11px; color: white; background: rgba(255,255,255,.06); font-size: 15px; cursor: pointer; }
.demo-ribbon { padding: 7px 18px; border-bottom: 1px solid #efd69f; color: #674816; background: var(--signal-soft); font-size: 9px; font-weight: 950; letter-spacing: .09em; text-align: center; }

.app-layout { max-width: 1160px; display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 30px; margin: 0 auto; padding: 26px 24px 48px; }
.side-nav { position: sticky; top: 122px; align-self: start; display: grid; gap: 6px; }
.nav-btn { min-height: 46px; display: flex; align-items: center; gap: 11px; padding: 0 14px; border: 0; border-radius: 13px; color: #667a85; background: transparent; font-size: 11px; font-weight: 800; text-align: left; cursor: pointer; }
.nav-btn span { width: 25px; font-size: 17px; text-align: center; }
.nav-btn.active { color: var(--ink); background: white; box-shadow: 0 8px 24px rgba(13,38,56,.08); }
.nav-note { margin-top: 14px; padding: 13px; border: 1px solid #efd49f; border-radius: 13px; color: #735521; background: var(--signal-soft); font-size: 9px; line-height: 1.45; }
.main-content { min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.page-head small { color: #71838c; font-size: 10px; }
.page-head h1 { margin: 4px 0 0; font-size: clamp(27px, 4vw, 38px); letter-spacing: -.045em; }
.page-head p { max-width: 560px; margin: 7px 0 0; color: #6a7d86; font-size: 11px; line-height: 1.5; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(250px, .6fr); gap: 16px; }
.hero-card { position: relative; overflow: hidden; min-height: 270px; display: flex; flex-direction: column; justify-content: flex-end; padding: 25px; border-radius: 24px; color: white; background: linear-gradient(140deg, #173e56, #0d2638); box-shadow: var(--shadow); }
.hero-card::after { position: absolute; top: -55px; right: -60px; width: 230px; height: 230px; content: ""; border: 35px solid rgba(255,255,255,.045); border-radius: 50%; }
.hero-label { display: flex; align-items: center; gap: 8px; margin-bottom: auto; color: #9db9c6; font-size: 9px; font-weight: 950; letter-spacing: .13em; }
.hero-label::before { width: 7px; height: 7px; content: ""; border-radius: 50%; background: #5bd1a6; box-shadow: 0 0 0 5px rgba(91,209,166,.11); }
.hero-card h2 { position: relative; z-index: 1; margin: 25px 0 7px; font-size: 27px; letter-spacing: -.04em; }
.hero-card p { position: relative; z-index: 1; margin: 0 0 20px; color: #b8ccd5; font-size: 11px; }
.hero-card .primary-btn { position: relative; z-index: 1; align-self: flex-start; min-width: 220px; }
.metric-stack { display: grid; grid-template-rows: 1fr 1fr; gap: 12px; }
.metric-card { display: flex; flex-direction: column; justify-content: space-between; padding: 20px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.86); }
.metric-card strong { display: block; font-size: 39px; letter-spacing: -.055em; }
.metric-card span { color: #637781; font-size: 9px; font-weight: 850; text-transform: uppercase; }

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 27px 2px 11px; }
.section-title h2 { margin: 0; font-size: 15px; }
.empty-state { padding: 35px 20px; border: 1px dashed #b9c7cc; border-radius: 18px; color: #6e8089; background: rgba(255,255,255,.55); text-align: center; }
.empty-state strong { display: block; margin-bottom: 6px; color: var(--ink); font-size: 14px; }
.empty-state p { margin: 0; font-size: 10px; line-height: 1.5; }

.records { display: grid; gap: 9px; }
.record-card { width: 100%; display: grid; grid-template-columns: 45px minmax(0, 1fr) auto; align-items: center; gap: 13px; padding: 13px; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: white; text-align: left; cursor: pointer; }
.record-card:hover { border-color: rgba(23,108,164,.35); box-shadow: 0 7px 18px rgba(13,38,56,.06); }
.record-index { width: 45px; height: 45px; display: grid; place-items: center; border-radius: 13px; color: var(--blue); background: #e9f3f7; font-size: 11px; font-weight: 950; }
.record-card strong { display: block; overflow: hidden; margin-bottom: 4px; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.record-card small { display: block; overflow: hidden; color: #74858e; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.status-tag { padding: 6px 8px; border-radius: 8px; color: var(--green); background: var(--green-soft); font-size: 8px; font-weight: 950; text-transform: uppercase; }
.status-tag.draft { color: #795617; background: var(--signal-soft); }
.search-input { width: min(100%, 380px); min-height: 45px; padding: 0 14px; border: 1px solid #cad6da; border-radius: 13px; outline: none; background: white; font-size: 11px; }

.wizard-shell { max-width: 780px; margin: 0 auto; }
.wizard-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 12px; }
.wizard-head h1 { margin: 0; font-size: 27px; letter-spacing: -.04em; }
.wizard-head p { margin: 5px 0 0; color: #72838c; font-size: 10px; }
.steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 20px; }
.step { text-align: center; }
.step::before { height: 5px; display: block; margin-bottom: 6px; content: ""; border-radius: 99px; background: #d8e1e3; }
.step.done::before, .step.active::before { background: var(--signal); }
.step span { color: #778991; font-size: 8px; font-weight: 900; text-transform: uppercase; }
.step.active span { color: var(--ink); }
.wizard-card { padding: 23px; border: 1px solid var(--line); border-radius: 22px; background: rgba(255,255,255,.92); box-shadow: 0 14px 36px rgba(13,38,56,.08); }
.wizard-card > h2 { margin: 0 0 5px; font-size: 22px; letter-spacing: -.035em; }
.wizard-card > p { margin: 0 0 19px; color: #6c7f88; font-size: 10px; line-height: 1.5; }
.wizard-footer { display: grid; grid-template-columns: .7fr 1.3fr; gap: 9px; margin-top: 15px; }
.guardian-panel { display: none; margin-top: 14px; padding: 15px; border: 1px solid #eed39c; border-radius: 15px; background: var(--signal-soft); }
.guardian-panel.visible { display: block; }
.guardian-panel h3 { margin: 0 0 4px; font-size: 13px; }
.guardian-panel > p { margin: 0 0 12px; color: #74551f; font-size: 9px; }

.document-scan { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 13px; margin-bottom: 17px; padding: 14px; border: 1px solid #bdd2da; border-radius: 15px; background: #edf5f7; }
.document-scan strong { display: block; margin-bottom: 4px; font-size: 11px; }
.document-scan span { display: block; color: #647b86; font-size: 9px; line-height: 1.4; }
.document-scan-actions { display: flex; align-items: center; gap: 7px; }
.document-capture, .document-file { padding: 10px 12px; border-radius: 10px; font-size: 9px; font-weight: 900; cursor: pointer; white-space: nowrap; }
.document-capture { border: 0; color: white; background: var(--blue); }
.document-file { position: relative; overflow: hidden; border: 1px solid #adc5ce; color: var(--blue); background: white; }
.document-file input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.identity-scan-ok { display: flex; align-items: center; gap: 11px; margin: -7px 0 17px; padding: 11px 13px; border: 1px solid #9bcdbb; border-radius: 13px; color: #185b46; background: var(--green-soft); }
.identity-scan-ok > b { width: 29px; height: 29px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--green); font-size: 16px; }
.identity-scan-ok span { font-size: 9px; line-height: 1.4; }
.identity-scan-ok strong { display: block; margin-bottom: 2px; color: #124c3a; font-size: 10px; }

.scanner-open { overflow: hidden; }
.live-scanner { position: fixed; z-index: 200; inset: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; color: white; background: #07141c; }
.live-scanner header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: calc(15px + env(safe-area-inset-top)) 18px 15px; background: #0d2638; }
.live-scanner header small { color: #9db9c6; font-size: 8px; font-weight: 900; letter-spacing: .12em; }
.live-scanner header h2 { margin: 3px 0 0; font-size: 20px; }
.live-scanner header button { width: 40px; height: 40px; border: 1px solid rgba(255,255,255,.25); border-radius: 50%; color: white; background: rgba(255,255,255,.08); font-size: 25px; cursor: pointer; }
.live-camera { position: relative; min-height: 260px; overflow: hidden; background: #020608; }
.live-camera video { width: 100%; height: 100%; display: block; object-fit: cover; }
.document-guide { position: absolute; inset: 50% auto auto 50%; width: min(88vw, 760px); aspect-ratio: 1.586; transform: translate(-50%, -50%); border: 2px solid var(--signal); border-radius: 16px; box-shadow: 0 0 0 200vmax rgba(0,0,0,.42); }
.document-guide::after { position: absolute; right: 10px; bottom: 8px; content: "Mantenga el documento dentro del marco"; color: white; font-size: 9px; font-weight: 800; text-shadow: 0 1px 4px #000; }
.document-guide span, .document-guide span::before { position: absolute; display: block; content: ""; background: var(--signal); }
.document-guide span { top: 50%; left: 12%; width: 76%; height: 1px; opacity: .5; }
.document-guide span::before { top: -30px; left: 50%; width: 1px; height: 60px; }
.live-scan-feedback { padding: 14px 18px; color: #d7e2e7; background: #0d2638; }
.live-scan-feedback strong { display: block; color: white; font-size: 11px; }
.live-scan-feedback p { min-height: 29px; margin: 5px 0 0; color: #a9bdc6; font-size: 9px; line-height: 1.45; }
.live-scanner footer { display: grid; grid-template-columns: .8fr 1.2fr; gap: 9px; padding: 0 18px calc(14px + env(safe-area-inset-bottom)); background: #0d2638; }

.photo-box { position: relative; min-height: 245px; display: grid; place-items: center; overflow: hidden; margin-bottom: 15px; border: 1px dashed #a9bbc2; border-radius: 18px; background: linear-gradient(145deg, #eaf0f1, #dbe5e8); }
.photo-box input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.photo-box img { position: absolute; inset: 0; width: 100%; height: 100%; display: none; object-fit: cover; }
.photo-box img.visible { display: block; }
.photo-placeholder { position: relative; z-index: 1; color: #5e737d; text-align: center; }
.photo-placeholder b { width: 50px; height: 50px; display: grid; place-items: center; margin: 0 auto 8px; border-radius: 50%; color: white; background: var(--ink); font-size: 21px; }
.photo-placeholder span { display: block; font-size: 10px; font-weight: 850; }
.photo-capture { position: absolute; z-index: 2; right: 12px; bottom: 12px; padding: 10px 13px; border-radius: 11px; color: white; background: rgba(13,38,56,.9); box-shadow: 0 7px 18px rgba(13,38,56,.2); font-size: 10px; font-weight: 900; cursor: pointer; }
.photo-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 9px; margin-bottom: 15px; }
.photo-gallery figure { overflow: hidden; margin: 0; border: 1px solid var(--line); border-radius: 13px; background: white; }
.photo-gallery img { width: 100%; height: 100px; display: block; object-fit: cover; }
.photo-gallery figcaption { display: flex; align-items: center; justify-content: space-between; padding: 7px 9px; color: #60747e; font-size: 9px; font-weight: 800; }
.photo-gallery button { width: 24px; height: 24px; border: 0; border-radius: 50%; color: var(--red); background: var(--red-soft); font-size: 15px; cursor: pointer; }
.substance-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.substance-option { min-height: 72px; padding: 9px; border: 1px solid var(--line); border-radius: 13px; color: #657983; background: white; font-size: 9px; font-weight: 850; cursor: pointer; }
.substance-option strong { display: block; margin-bottom: 4px; color: var(--ink); font-size: 19px; }
.substance-option.selected { border-color: var(--blue); color: var(--blue); background: #edf6fa; box-shadow: inset 0 0 0 1px var(--blue); }

.envelope-box { padding: 28px 18px; border: 1px dashed #aebfc6; border-radius: 18px; background: #f8faf9; text-align: center; }
.envelope-box span { display: block; color: #788990; font-size: 9px; font-weight: 850; text-transform: uppercase; }
.envelope-box strong { display: block; margin: 11px 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: clamp(18px, 5vw, 28px); letter-spacing: .07em; }
.envelope-box small { color: var(--green); font-size: 9px; font-weight: 850; }

.summary-block { margin-bottom: 10px; padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: #fbfcfb; }
.summary-block header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.summary-block header strong { font-size: 12px; }
.summary-block header span { color: var(--green); font-size: 8px; font-weight: 950; }
.summary-row { display: flex; justify-content: space-between; gap: 20px; margin-top: 7px; color: #6e8089; font-size: 10px; }
.summary-row b { color: var(--ink); text-align: right; }
.photo-thumb { width: 100%; max-height: 220px; display: block; margin-top: 11px; border-radius: 12px; object-fit: cover; }
.summary-photos { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.summary-photos .photo-thumb { height: 170px; margin: 0; }
.facts-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin-top: 9px; }
.facts-tools .soft-btn { min-height: 38px; }
.facts-tools span { color: #71838c; font-size: 9px; }
.template-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.text-template { padding: 8px 10px; border: 1px solid #bfd1d8; border-radius: 9px; color: var(--blue); background: #edf6fa; font-size: 9px; font-weight: 850; cursor: pointer; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.detail-card { padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: white; }
.detail-card.wide-card { grid-column: 1 / -1; }
.detail-card h2 { margin: 0 0 13px; font-size: 15px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 16px; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.settings-card { padding: 19px; border: 1px solid var(--line); border-radius: 18px; background: white; }
.settings-card.wide-card { grid-column: 1 / -1; }
.settings-card h2 { margin: 0 0 6px; font-size: 15px; }
.settings-card p { margin: 0 0 16px; color: #6c7e87; font-size: 10px; line-height: 1.5; }
.data-stat { margin: 16px 0; padding: 13px; border-radius: 12px; background: var(--mist); font-size: 10px; }
.data-stat strong { display: block; margin-bottom: 3px; font-size: 21px; }
.legal-list { display: grid; gap: 9px; margin-top: 15px; }
.legal-item { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfb; color: #536974; font-size: 10px; line-height: 1.45; }
.legal-item strong { display: block; margin-bottom: 3px; color: var(--ink); }

.install-banner { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 18px; padding: 14px; border: 1px solid #b8d9ce; border-radius: 14px; color: #1f654f; background: var(--green-soft); font-size: 10px; line-height: 1.4; }
.install-banner button { flex: 0 0 auto; padding: 8px 11px; border: 0; border-radius: 9px; color: white; background: var(--green); font-size: 9px; font-weight: 900; cursor: pointer; }

.toast { position: fixed; z-index: 100; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); min-width: min(310px, calc(100vw - 32px)); max-width: 520px; padding: 13px 17px; transform: translate(-50%, 25px); border-radius: 13px; color: white; background: var(--ink); box-shadow: var(--shadow); font-size: 10px; font-weight: 800; text-align: center; opacity: 0; pointer-events: none; transition: .22s ease; }
.toast.visible { transform: translate(-50%, 0); opacity: 1; }
.loading { min-height: 100vh; display: grid; place-items: center; color: var(--ink); background: var(--paper); font-size: 12px; font-weight: 850; }
.loading::before { width: 32px; height: 32px; margin-right: 10px; content: ""; border: 3px solid #d2dde0; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.print-report { display: none; }

@media (max-width: 760px) {
  body { background: var(--paper); }
  .auth-page { display: block; padding: 0; background: var(--paper); }
  .auth-intro { display: none; }
  .auth-card { min-height: 100dvh; max-width: none; border: 0; border-radius: 0; box-shadow: none; }
  .auth-card-head { padding: calc(48px + env(safe-area-inset-top)) 22px 28px; }
  .auth-body { padding: 23px 20px calc(25px + env(safe-area-inset-bottom)); }
  .security-points { grid-template-columns: 1fr; }
  .app-header-main { min-height: 68px; padding-right: 15px; padding-left: 15px; }
  .local-pill { display: none; }
  .app-layout { display: block; padding: 19px 15px calc(100px + env(safe-area-inset-bottom)); }
  .side-nav { position: fixed; z-index: 30; right: 9px; bottom: max(9px, env(safe-area-inset-bottom)); left: 9px; top: auto; grid-template-columns: repeat(4, 1fr); gap: 3px; padding: 7px; border: 1px solid var(--line); border-radius: 21px; background: rgba(255,255,255,.95); box-shadow: 0 15px 40px rgba(13,38,56,.18); backdrop-filter: blur(18px); }
  .nav-btn { min-height: 57px; flex-direction: column; justify-content: center; gap: 3px; padding: 4px; border-radius: 14px; font-size: 8px; text-align: center; }
  .nav-btn span { width: auto; font-size: 15px; }
  .nav-note { display: none; }
  .page-head { align-items: flex-start; flex-direction: column; gap: 12px; }
  .page-head h1 { font-size: 28px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .metric-stack { grid-template-columns: 1fr 1fr; grid-template-rows: auto; }
  .metric-card { min-height: 110px; }
  .hero-card { min-height: 260px; padding: 21px; }
  .hero-card .primary-btn { width: 100%; min-width: 0; }
  .wizard-card { padding: 18px 15px; border-radius: 18px; }
  .wizard-head h1 { font-size: 23px; }
  .step span { display: none; }
  .field-grid.two, .field-grid.three { grid-template-columns: 1fr; }
  .photo-box { min-height: 210px; }
  .document-scan { grid-template-columns: 1fr; }
  .document-scan-actions { display: grid; grid-template-columns: 1.2fr .8fr; }
  .document-capture, .document-file { text-align: center; }
  .detail-grid, .settings-grid { grid-template-columns: 1fr; }
  .detail-card.wide-card { grid-column: auto; }
  .settings-card.wide-card { grid-column: auto; }
  .record-card { grid-template-columns: 41px minmax(0, 1fr) auto; gap: 10px; }
  .record-index { width: 41px; height: 41px; }
  .substance-options { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 390px) {
  .app-brand small { display: none; }
  .wizard-footer { grid-template-columns: .8fr 1.2fr; }
  .record-card { grid-template-columns: 38px minmax(0, 1fr); }
  .record-card .status-tag { display: none; }
}

@media print {
  @page { size: A4; margin: 16mm; }
  body { color: #101820; background: white; font-family: Arial, sans-serif; }
  #app, .toast { display: none !important; }
  .print-report { position: relative; display: block; color: #101820; font-size: 10pt; line-height: 1.42; }
  .print-watermark { position: fixed; z-index: -1; inset: 40% 0 auto; color: rgba(168,67,62,.1); font-size: 48pt; font-weight: 900; text-align: center; transform: rotate(-24deg); }
  .print-head { display: flex; align-items: end; justify-content: space-between; padding-bottom: 9mm; border-bottom: 2px solid #0d2638; }
  .print-head h1 { margin: 0 0 2mm; font-size: 20pt; }
  .print-head p, .print-head strong { margin: 0; font-size: 8pt; }
  .print-warning { margin: 7mm 0; padding: 4mm; border: 1px solid #d8a13f; background: #fff7e8; font-weight: 700; }
  .print-section { margin-top: 6mm; break-inside: avoid; }
  .print-section h2 { margin: 0 0 3mm; padding-bottom: 2mm; border-bottom: 1px solid #aab6bc; color: #0d2638; font-size: 12pt; }
  .print-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2mm 8mm; }
  .print-row { display: flex; gap: 3mm; }
  .print-row span:first-child { min-width: 34mm; color: #53656f; }
  .print-photo { width: auto; max-width: 100%; height: auto; max-height: 90mm; margin-top: 4mm; border: 1px solid #8999a1; object-fit: contain; }
  .print-photo-item { display: inline-block; max-width: 48%; margin: 3mm 3mm 0 0; break-inside: avoid; vertical-align: top; }
  .print-photo-item figcaption { color: #53656f; font-size: 8pt; }
  .print-footer { margin-top: 12mm; padding-top: 4mm; border-top: 1px solid #aab6bc; color: #5d6c74; font-size: 8pt; }
}
