:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #edf3fb;
  --text: #172b48;
  --muted: #52647c;
  --border: #cbd7e6;
  --brand: #2458cf;
  --brand-strong: #1947ae;
  --navy: #0b1733;
  --success: #087f5b;
  --warning: #9a5b00;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(15, 36, 71, .12);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #07101f;
  --surface: #101c31;
  --surface-soft: #162640;
  --text: #f4f7fb;
  --muted: #b7c5d8;
  --border: #334660;
  --brand: #6fa0ff;
  --brand-strong: #8bb2ff;
  --navy: #030918;
  --success: #55d6a7;
  --warning: #ffc66d;
  --danger: #ff8a80;
  --shadow: 0 18px 50px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-family: Inter, Arial, sans-serif; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
a { color: var(--brand); }
.skip-link { position: fixed; left: 1rem; top: -4rem; z-index: 1000; padding: .75rem 1rem; background: var(--surface); border-radius: .75rem; }
.skip-link:focus { top: 1rem; }
.site-header { position: sticky; top: 0; z-index: 500; min-height: 76px; padding: .75rem clamp(1rem, 4vw, 4rem); display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: color-mix(in srgb, var(--surface) 92%, transparent); border-bottom: 1px solid var(--border); backdrop-filter: blur(14px); }
.brand { display: inline-flex; align-items: center; gap: .75rem; color: var(--text); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: linear-gradient(135deg, #2458cf, #4b3eff); color: white; font-weight: 800; box-shadow: 0 10px 24px rgba(36, 88, 207, .28); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1rem; }
.brand small { color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
.header-actions { display: flex; align-items: center; gap: .7rem; }
.header-actions form { margin: 0; }
.icon-button, .quiet-button, .secondary-button, .primary-button, .danger-button { min-height: 44px; border-radius: 12px; border: 1px solid var(--border); padding: .7rem 1rem; cursor: pointer; font-weight: 700; }
.icon-button { width: 44px; padding: 0; background: var(--surface-soft); color: var(--text); }
.quiet-button, .secondary-button { background: var(--surface); color: var(--text); }
.primary-button { border-color: transparent; background: var(--brand); color: white; box-shadow: 0 10px 24px rgba(36, 88, 207, .22); }
.primary-button:hover { background: var(--brand-strong); }
.danger-button { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); color: var(--danger); }
.text-link { font-weight: 700; text-decoration: none; }
.user-chip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: .55rem .8rem; border-radius: 999px; background: var(--surface-soft); color: var(--muted); font-size: .82rem; font-weight: 700; }
.user-chip span { color: var(--success); }
.page-shell { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding: clamp(1.5rem, 4vw, 3rem) 0 4rem; }
.hero { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(250px, .6fr); align-items: center; gap: 2rem; margin-bottom: 1.5rem; padding: clamp(1.5rem, 4vw, 3rem); border-radius: 28px; background: linear-gradient(125deg, #071b35, #10285f); color: white; box-shadow: var(--shadow); }
.eyebrow { margin: 0 0 .6rem; color: #9fc0ff; font-size: .75rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.hero h1, .auth-copy h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.6rem); line-height: 1.04; letter-spacing: -.045em; }
.hero p { max-width: 62ch; margin: .9rem 0 0; color: #d3def0; }
.identity-card { padding: 1.2rem; border: 1px solid rgba(255,255,255,.16); border-radius: 18px; background: rgba(255,255,255,.08); }
.identity-card small, .identity-card strong, .identity-card span { display: block; }
.identity-card small { color: #a9bddd; text-transform: uppercase; letter-spacing: .1em; font-size: .68rem; font-weight: 800; }
.identity-card strong { margin: .35rem 0; }
.identity-card span { color: #d3def0; font-size: .86rem; }
.messages { display: grid; gap: .5rem; margin-bottom: 1rem; }
.message { padding: .9rem 1rem; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); font-weight: 650; }
.message-success { border-color: color-mix(in srgb, var(--success) 40%, var(--border)); color: var(--success); }
.message-warning { border-color: color-mix(in srgb, var(--warning) 40%, var(--border)); color: var(--warning); }
.message-danger { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); color: var(--danger); }
.panel { padding: clamp(1.2rem, 3vw, 2rem); border: 1px solid var(--border); border-radius: 24px; background: var(--surface); box-shadow: 0 8px 28px rgba(15,36,71,.06); }
.form-stack { display: grid; gap: 1.25rem; }
.form-section { border: 0; margin: 0; padding: 0; }
.form-section + .form-section { padding-top: 1.5rem; border-top: 1px solid var(--border); }
.section-heading { display: flex; align-items: flex-start; gap: .85rem; margin-bottom: 1rem; }
.step { display: grid; flex: 0 0 auto; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: var(--surface-soft); color: var(--brand); font-weight: 800; }
.section-heading h2 { margin: 0; font-size: 1.15rem; }
.section-heading p { margin: .15rem 0 0; color: var(--muted); font-size: .87rem; }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1rem; }
.field { grid-column: span 6; }
.field-full { grid-column: 1 / -1; }
.field-third { grid-column: span 4; }
.field label { display: block; margin-bottom: .4rem; color: var(--text); font-size: .82rem; font-weight: 750; }
.field input, .field select, .field textarea { width: 100%; min-height: 48px; padding: .75rem .85rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 15%, transparent); }
.field input[readonly] { background: var(--surface-soft); color: var(--muted); }
.field-hint { margin: .35rem 0 0; color: var(--muted); font-size: .76rem; }
.segmented { display: flex; gap: .6rem; flex-wrap: wrap; }
.segmented label { min-height: 44px; display: flex; align-items: center; gap: .5rem; padding: .65rem .85rem; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; }
.action-row { display: flex; justify-content: flex-end; gap: .75rem; flex-wrap: wrap; }
#mapa { height: 390px; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: var(--surface-soft); }
.map-toolbar { position: relative; display: grid; grid-template-columns: 1fr auto; gap: .75rem; margin-bottom: .85rem; }
#autocomplete-results { position: absolute; z-index: 450; left: 0; right: 0; top: calc(100% + .25rem); max-height: 240px; overflow: auto; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.autocomplete-item { padding: .75rem .85rem; border-bottom: 1px solid var(--border); cursor: pointer; }
.autocomplete-item:hover { background: var(--surface-soft); }
.auth-shell { min-height: calc(100vh - 190px); display: grid; grid-template-columns: 1.05fr .95fr; border-radius: 28px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--border); }
.auth-copy { padding: clamp(2rem, 5vw, 4rem); display: flex; flex-direction: column; justify-content: center; background: linear-gradient(145deg, #06172e, #15347c); color: white; }
.auth-copy p { max-width: 50ch; color: #d3def0; }
.auth-points { display: grid; gap: .7rem; margin: 1.4rem 0 0; padding: 0; list-style: none; color: #d3def0; }
.auth-points li::before { content: '✓'; margin-right: .6rem; color: #62dcaf; font-weight: 800; }
.auth-form { padding: clamp(2rem, 5vw, 4rem); display: flex; flex-direction: column; justify-content: center; }
.auth-form h2 { margin: 0; font-size: 1.5rem; }
.auth-form > p { margin: .45rem 0 1.5rem; color: var(--muted); }
.auth-form .field { margin-bottom: 1rem; }
.auth-form .primary-button { width: 100%; }
.table-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.table-head h1, .table-head h2 { margin: 0; }
.table-head p { margin: .35rem 0 0; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { padding: 1.2rem; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); }
.stat small { color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.stat strong { display: block; margin-top: .25rem; font-size: 1.9rem; }
.report-form { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: .75rem; margin-bottom: 1.2rem; padding: 1rem; border-radius: 16px; background: var(--surface-soft); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; min-width: 800px; }
th, td { padding: .85rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: var(--surface-soft); color: var(--muted); font-size: .74rem; letter-spacing: .06em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
.table-actions { display: flex; gap: .5rem; }
.table-actions .secondary-button, .table-actions .danger-button { min-height: 38px; padding: .45rem .7rem; font-size: .78rem; text-decoration: none; }
.empty-state { padding: 2rem; text-align: center; color: var(--muted); }
.success-card, .error-card { width: min(620px, 100%); margin: 6vh auto; padding: clamp(2rem, 6vw, 4rem); text-align: center; border: 1px solid var(--border); border-radius: 28px; background: var(--surface); box-shadow: var(--shadow); }
.success-icon, .error-code { display: grid; place-items: center; margin: 0 auto 1rem; width: 64px; height: 64px; border-radius: 20px; background: color-mix(in srgb, var(--success) 15%, var(--surface)); color: var(--success); font-size: 1.7rem; font-weight: 800; }
.error-code { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--surface)); }
.site-footer { padding: 1.5rem; border-top: 1px solid var(--border); color: var(--muted); text-align: center; font-size: .75rem; }

@media (max-width: 800px) {
  .site-header { align-items: flex-start; }
  .header-actions { justify-content: flex-end; flex-wrap: wrap; }
  .user-chip, .text-link { display: none; }
  .hero, .auth-shell { grid-template-columns: 1fr; }
  .auth-copy { padding-bottom: 2rem; }
  .field, .field-third { grid-column: 1 / -1; }
  .map-toolbar, .report-form { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .page-shell { width: min(100% - 1rem, 1180px); }
  .site-header { padding: .65rem .75rem; }
  .brand small { display: none; }
  .quiet-button { padding-inline: .7rem; font-size: .78rem; }
  .hero, .panel { border-radius: 20px; }
  #mapa { height: 320px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
