:root {
  color-scheme: light;
  --ink: #17324d;
  --muted: #667789;
  --surface: #ffffff;
  --surface-2: #f6f9fc;
  --surface-3: #eaf2f9;
  --page: #f2f5f8;
  --line: #d7e2ec;
  --primary: #1d6fae;
  --primary-dark: #12395f;
  --primary-deep: #0d2a46;
  --primary-soft: #e5f0f9;
  --primary-pale: #f0f7fc;
  --green: #1f7f54;
  --red: #b43f38;
  --amber: #bd7a13;
  --blue: #1d6fae;
  --shadow: 0 14px 45px rgba(23, 50, 77, .09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--page); }
body { min-width: 320px; min-height: 100vh; margin: 0; color: var(--ink); background: radial-gradient(circle at 8% 0%, rgba(91, 157, 207, .12), transparent 28rem), var(--page); }
button, input, select, textarea { font: inherit; }
button, .button { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 11px 17px; border: 1px solid transparent; border-radius: 10px; color: #fff; background: var(--primary); font-weight: 850; text-decoration: none; cursor: pointer; transition: transform .18s ease, filter .18s ease, border-color .18s ease, background .18s ease; }
button:hover, .button:hover { filter: brightness(1.05); transform: translateY(-1px); }
button:focus-visible, .button:focus-visible, a:focus-visible { outline: 3px solid rgba(29, 111, 174, .24); outline-offset: 2px; }
button:disabled { opacity: .55; cursor: wait; transform: none; }
button.secondary, .button.secondary { border-color: #cbdce9; color: var(--primary-dark); background: var(--primary-soft); }
button.ghost, .button.ghost { border-color: #cfdbe6; color: var(--ink); background: #fff; }
button.danger, .button.danger { border-color: var(--red); color: #fff; background: var(--red); }
a { color: var(--primary); }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0 0 14px; font-size: clamp(2rem, 6vw, 4.1rem); font-weight: 900; line-height: 1.03; letter-spacing: -.035em; }
h2 { margin: 0 0 12px; font-size: clamp(1.45rem, 3vw, 2.25rem); font-weight: 850; line-height: 1.12; }
h3 { margin: 0; font-size: 1rem; }
p { line-height: 1.6; }
[hidden] { display: none !important; }
.app-shell { width: min(1220px, 100%); min-height: 100vh; margin: auto; padding: max(28px, env(safe-area-inset-top)) 20px max(48px, env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 74px; padding: 14px 20px; border-radius: 16px; background: var(--primary-dark); box-shadow: 0 10px 28px rgba(18, 57, 95, .12); }
.brand { display: inline-flex; align-items: center; gap: 12px; color: #fff; font-weight: 900; letter-spacing: .06em; text-decoration: none; text-transform: uppercase; }
.brand-logo { position: relative; flex: 0 0 118px; width: 118px; height: 40px; overflow: hidden; border: 1px solid rgba(255,255,255,.28); border-radius: 10px; background: #fff; }
.brand-logo img { position: absolute; top: -96%; left: -54.4%; width: 223%; max-width: none; height: auto; }
.brand-name { white-space: nowrap; }
.topbar .button, .topbar button { min-height: 44px; }
.topbar .button.secondary, .topbar button.secondary { border-color: rgba(255,255,255,.22); color: var(--primary-dark); background: #edf4f8; }
.topbar .button.ghost, .topbar button.ghost { border-color: rgba(255,255,255,.22); color: #fff; background: rgba(255,255,255,.07); }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.eyebrow { margin: 0 0 10px; color: var(--primary); font-size: .76rem; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.hero { display: block; min-height: auto; }
.hero-card { width: min(780px, 100%); margin: 64px auto; padding: clamp(30px, 6vw, 58px); border: 1px solid rgba(215, 226, 236, .9); border-radius: 22px; background: #fff; box-shadow: var(--shadow); }
.hero-card p { max-width: 680px; color: var(--muted); font-size: 1.04rem; }
.hero-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 28px 0; }
.hero-grid article { padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: var(--primary-pale); }
.hero-grid span { display: block; margin-bottom: 8px; color: var(--primary); font-size: 1.4rem; }
.hero-grid p { margin-bottom: 0; font-size: .92rem; }
.notice, .success-message { padding: 13px 15px; border-radius: 10px; }
.notice { border: 1px solid #edc1bd; color: #7d2e28; background: #fbebe9; }
.success-message { border: 1px solid #b9dfca; color: #17613e; background: #e7f6ed; }
.panel { padding: clamp(24px, 4vw, 42px); border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: var(--shadow); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.full { grid-column: 1 / -1; }
.form-section { grid-column: 1 / -1; margin-top: 10px; padding-top: 23px; border-top: 1px solid var(--line); }
.form-section:first-child { margin-top: 0; padding-top: 0; border: 0; }
.form-section p { margin: 5px 0 0; }
label { display: grid; align-content: start; gap: 7px; color: #27445f; font-size: .88rem; font-weight: 750; }
input, select, textarea { width: 100%; min-height: 46px; padding: 12px 13px; border: 1px solid #c9d6e2; border-radius: 9px; outline: none; color: var(--ink); background: #fff; }
input::placeholder, textarea::placeholder { color: #8a98a6; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29,111,174,.12); }
textarea { min-height: 104px; resize: vertical; }
input[type="color"] { padding: 5px; }
input[type="checkbox"], input[type="radio"] { width: 19px; min-height: 19px; accent-color: var(--primary); }
.check-row { display: flex; align-items: flex-start; gap: 10px; }
.check-row span { line-height: 1.5; }
.required-tag, .optional-tag { display: inline-flex; width: fit-content; margin-left: 5px; padding: 2px 7px; border-radius: 999px; font-size: .64rem; font-weight: 900; letter-spacing: .03em; vertical-align: middle; }
.required-tag { color: #174d7f; background: #dfeefa; }
.optional-tag { color: #647485; background: #edf1f5; }
.activation-guide { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin: 22px 0; padding: 18px; border: 1px solid #b8d5e9; border-radius: 14px; color: #27445f; background: var(--primary-pale); }
.activation-guide strong { grid-column: 1 / -1; color: var(--primary-dark); }
.activation-guide span { padding: 9px 11px; border-radius: 9px; background: #fff; }
.optional-details, .privacy-details { padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.optional-details summary, .privacy-details summary { color: var(--primary-dark); font-weight: 900; cursor: pointer; }
.optional-details[open] summary, .privacy-details[open] summary { margin-bottom: 14px; }
.optional-details-body { margin-top: 16px; }
.password-fields { display: grid; gap: 11px; padding: 17px; border: 1px solid #b8d5e9; border-radius: 14px; background: var(--primary-pale); }
.password-fields > .form-grid { gap: 12px; }
.show-password-row { width: fit-content; color: #27445f; cursor: pointer; }
.password-feedback { margin: 0; }
.password-feedback[data-state="valid"] { color: #17613e; font-weight: 800; }
.password-feedback[data-state="invalid"] { color: #8b2f25; font-weight: 800; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: #b8493f; box-shadow: 0 0 0 3px rgba(184,73,63,.13); }
.form-error-summary ul { margin: 8px 0 0; padding-left: 20px; }
.recovery-help { grid-column: 1 / -1; margin: 4px 0; padding: 16px 18px; border-left: 4px solid var(--primary); border-radius: 10px; color: #27445f; background: #eef6fb; }
.recovery-help p { margin: 7px 0 0; }
.recovery-help a { color: var(--primary-dark); font-weight: 850; }
.type-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.type-option { position: relative; display: grid; min-height: 145px; place-items: center; padding: 18px; border: 1px solid var(--line); border-radius: 15px; text-align: center; background: var(--surface-2); cursor: pointer; transition: border-color .18s ease, background .18s ease, transform .18s ease; }
.type-option:hover { border-color: #aac7de; transform: translateY(-1px); }
.type-option input { position: absolute; opacity: 0; }
.type-option:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.type-icon { color: var(--primary); font-size: 2rem; }
.type-option strong { display: block; margin: 8px 0 4px; font-size: 1.05rem; }
.public-warning { padding: 16px; border: 1px solid #ebcf9a; border-radius: 11px; color: #75500d; background: #fff7e7; }
.upload-box { display: grid; gap: 12px; padding: 17px; border: 1px dashed #9bbcd5; border-radius: 14px; background: var(--primary-pale); }
.upload-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.crop-editor { display: grid; gap: 12px; width: min(440px, 100%); padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.crop-editor canvas { width: 100%; aspect-ratio: 1; border-radius: 14px; background: #dce9f3; cursor: grab; touch-action: none; }
.crop-editor canvas:active { cursor: grabbing; }
.image-preview { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; }
.photo-item { display: grid; width: 132px; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: 0 8px 22px rgba(23,50,77,.06); }
.photo-item img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.photo-item div { display: grid; gap: 8px; padding: 10px; }
.photo-item button { min-height: 38px; padding: 7px 10px; }
.document-list { display: grid; gap: 8px; }
.document-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.document-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.privacy-box { grid-column: 1 / -1; max-height: 280px; overflow: auto; padding: 18px; border: 1px solid var(--line); border-radius: 13px; color: var(--muted); background: var(--surface-2); font-size: .86rem; }
.privacy-box h3 { color: var(--primary-dark); }
.dashboard { padding-top: 12px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 22px; margin: 28px 0 22px; }
.toolbar h1 { font-size: clamp(2.2rem, 5vw, 3.8rem); }
.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin: 22px 0; }
.stats-grid article { padding: 17px; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: 0 7px 20px rgba(23,50,77,.04); }
.stats-grid span { display: block; min-height: 35px; color: var(--muted); font-size: .79rem; }
.stats-grid strong { display: block; color: var(--primary-dark); font-size: 1.7rem; }
.workflow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 20px 0; padding: 16px; border: 1px solid #c7dce9; border-radius: 15px; background: var(--primary-pale); }
.workflow span { padding: 4px; color: var(--muted); font-size: .84rem; }
.workflow b { color: var(--primary); }
.list-controls { display: grid; grid-template-columns: 1fr 230px; gap: 12px; margin: 20px 0 12px; }
.tag-list { display: grid; gap: 11px; }
.tag-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
.tag-main { min-width: 0; }
.tag-main h3 { margin: 7px 0 4px; }
.tag-main p { margin: 2px 0; color: var(--muted); font-size: .87rem; }
.status-line { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.tag-code { color: var(--primary-dark); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-weight: 800; letter-spacing: .1em; }
.badge { display: inline-flex; padding: 5px 9px; border-radius: 999px; font-size: .72rem; font-weight: 900; text-transform: uppercase; }
.status-inventory { color: #44525d; background: #e9edf0; }
.status-sold { color: #765400; background: #fff1c9; }
.status-active { color: #17623a; background: #dcf4e3; }
.status-lost, .status-emergency { color: #8b2f25; background: #f7deda; }
.status-found { color: #174d7f; background: #dfeefa; }
.status-suspended { color: #5e5360; background: #ece8ed; }
.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 18px; background: rgba(13,42,70,.58); backdrop-filter: blur(8px); }
.modal-card { width: min(960px, 100%); max-height: 94vh; overflow: auto; padding: clamp(22px, 4vw, 38px); border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: 0 24px 70px rgba(13,42,70,.22); }
.public-wrap { width: min(680px, 100%); margin: 34px auto; }
.public-card { overflow: hidden; border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: var(--shadow); }
.public-cover { min-height: 130px; background: linear-gradient(135deg, color-mix(in srgb, var(--profile-color, #1d6fae) 88%, #17324d), color-mix(in srgb, var(--profile-color, #1d6fae) 42%, white)); }
.public-body { padding: clamp(24px, 6vw, 46px); }
.profile-photo { width: 132px; height: 132px; margin-top: -98px; margin-bottom: 18px; border: 5px solid #fff; border-radius: 26px; object-fit: cover; background: var(--primary-soft); box-shadow: 0 8px 24px rgba(23,50,77,.16); }
.profile-placeholder { display: grid; place-items: center; color: var(--profile-color, var(--primary)); font-size: 3rem; font-weight: 900; }
.public-title { color: var(--ink); font-size: clamp(2.1rem, 7vw, 3.7rem); }
.alert-grid { display: grid; gap: 9px; margin: 22px 0; }
.alert-card { padding: 14px 15px; border-left: 4px solid var(--amber); border-radius: 9px; color: #724a08; background: #fff6e5; }
.incident-banner { margin: 18px 0; padding: 15px; border: 1px solid; border-radius: 10px; }
.incident-banner strong { display: block; margin-bottom: 5px; }
.incident-banner p { margin: 0; }
.incident-banner.lost { color: #7a4b08; border-color: #e7bd67; background: #fff6e5; }
.incident-banner.emergency { color: #7d2e28; border-color: #edc1bd; background: #fbebe9; }
.public-gallery { margin: 22px 0; }
.public-gallery h3 { margin-bottom: 10px; color: var(--primary-dark); }
.public-gallery > div { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.public-gallery a { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-3); }
.public-gallery img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; transition: transform .18s ease; }
.public-gallery a:hover img { transform: scale(1.03); }
.emergency-actions { display: grid; gap: 10px; margin: 24px 0; }
.emergency-actions a, .emergency-actions button { width: 100%; min-height: 55px; }
.call-primary { color: #fff !important; background: var(--green) !important; }
.call-911 { color: #fff !important; background: #b43f38 !important; }
.detail-groups { display: grid; gap: 16px; margin-top: 28px; }
.detail-group { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.detail-group h3 { margin-bottom: 10px; color: var(--primary-dark); }
.detail-group dl { display: grid; grid-template-columns: minmax(100px, .7fr) 1.3fr; gap: 8px 14px; margin: 0; }
.detail-group dt { color: var(--muted); }
.detail-group dd { margin: 0; white-space: pre-line; }
.location-panel { margin-top: 20px; padding: 17px; border: 1px solid #b8d3e8; border-radius: 14px; background: var(--primary-pale); }
.owner-link { display: block; margin-top: 28px; color: var(--muted); font-size: .86rem; text-align: center; }
.qr-sheet { max-width: 860px; margin: 28px auto; padding: 40px; border: 1px solid var(--line); border-radius: 22px; color: var(--ink); background: #fff; text-align: center; box-shadow: var(--shadow); }
.qr-sheet .eyebrow { color: var(--primary); }
.qr-sheet .muted { color: var(--muted); }
.qr-production { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 26px 0; }
.qr-box { padding: 20px; border: 2px dashed #5f8fb3; border-radius: 14px; }
.qr-code img, .qr-code canvas { margin: auto; }
.qr-url { overflow-wrap: anywhere; color: #53677a; font-size: .75rem; }
.activation-card { max-width: 560px; margin: 25px auto 0; padding: 22px; border: 2px solid var(--primary); border-radius: 14px; background: var(--primary-pale); }
.recovery-card { border-color: #b87920; background: #fff8e9; }
.login-card, .manage-card { width: min(900px, 100%); margin: 34px auto; }
.footer-note { margin-top: 28px; color: var(--muted); font-size: .78rem; text-align: center; }
.center-actions { justify-content: center; margin-top: 25px; }

@media (max-width: 920px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .workflow { grid-template-columns: repeat(2, 1fr); }
  .tag-row { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 650px) {
  .app-shell { padding: 14px; }
  .topbar, .toolbar { align-items: flex-start; flex-direction: column; }
  .topbar { padding: 14px; }
  .brand { gap: 10px; letter-spacing: .05em; }
  .brand-logo { flex-basis: 106px; width: 106px; height: 36px; }
  .hero-card { margin: 24px auto; padding: 26px; }
  .hero-grid, .type-picker, .form-grid, .qr-production, .list-controls, .activation-guide { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .workflow { grid-template-columns: 1fr; }
  .panel, .public-body { padding: 22px; }
  .document-item { align-items: flex-start; flex-direction: column; }
  .public-wrap { margin: 24px auto; }
  .public-gallery > div { grid-template-columns: repeat(2, 1fr); }
  .detail-group dl { grid-template-columns: 1fr; gap: 2px; }
  .detail-group dd { margin-bottom: 9px; }
  .modal { padding: 8px; }
}

@media print {
  .no-print, .topbar { display: none !important; }
  body, .app-shell { background: #fff; }
  .app-shell { width: 100%; max-width: none; padding: 0; }
  .qr-sheet { max-width: none; margin: 0; border: 0; box-shadow: none; }
  .qr-box, .activation-card { border-color: #000; break-inside: avoid; }
}
