:root {
  color-scheme: light;
  --navy: #142638;
  --navy-2: #1d3448;
  --teal: #18a999;
  --blue: #2d83b5;
  --orange: #e99a3c;
  --ink: #203244;
  --muted: #748392;
  --line: #e1e8ed;
  --page: #f3f6f8;
  --white: #fff;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.login-layout { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 0.9fr; background: #fff; }
.login-brand { padding: clamp(2rem, 8vw, 7rem); display: flex; flex-direction: column; justify-content: center; color: #fff; background: radial-gradient(circle at 85% 20%, #245271 0, transparent 33%), var(--navy); }
.eyebrow { margin: 0 0 1rem; color: #52d0be; font-size: .73rem; font-weight: 800; letter-spacing: .14em; }
.eyebrow.dark { color: var(--blue); }
.login-brand h1 { margin: 0; font-size: clamp(2.4rem, 5vw, 4.7rem); line-height: 1.04; letter-spacing: -.05em; }
.login-brand > p:not(.eyebrow) { margin-top: 1.7rem; color: #c9d6e0; font-size: 1.1rem; }
.brand-camera-list { display: grid; gap: .75rem; margin-top: 2rem; color: #d7e3eb; font-size: .9rem; }
.brand-camera-list span::before { content: ""; display: inline-block; width: .5rem; height: .5rem; margin-right: .7rem; border-radius: 100%; background: var(--teal); }
.login-card { width: min(390px, calc(100% - 3rem)); align-self: center; justify-self: center; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; color: #fff; background: var(--teal); font-weight: 900; font-size: 1.4rem; }
.login-card h2 { margin: 1.5rem 0 .4rem; color: var(--navy); }
.muted, .section-heading p, .welcome-row p { color: var(--muted); font-size: .9rem; }
label { display: block; margin: .95rem 0 .4rem; font-size: .82rem; font-weight: 700; }
input, select { width: 100%; padding: .77rem .83rem; border: 1px solid #d5dfe6; border-radius: 9px; color: var(--ink); background: #fff; outline: none; }
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px #18a99920; }
.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: .4rem; padding: .65rem 1rem; border: 0; border-radius: 9px; font-size: .84rem; font-weight: 750; transition: .15s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: #fff; background: var(--teal); }
.button.primary:hover { background: #128d80; }
.button.secondary { color: #31485b; background: #edf2f5; }
.button.full { width: 100%; margin-top: 1.2rem; }
.button.small { min-height: 34px; padding: .5rem .75rem; font-size: .75rem; }
.form-message { min-height: 1.2rem; color: #a53d36; font-size: .82rem; }
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 3; display: flex; width: 245px; flex-direction: column; padding: 1.45rem 1rem; color: #eaf0f4; background: var(--navy); }
.brand { display: flex; align-items: center; gap: .7rem; margin: 0 .45rem 2.8rem; color: #fff; text-decoration: none; }
.brand-mark.small { width: 38px; height: 38px; border-radius: 11px; font-size: 1rem; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: .82rem; letter-spacing: .08em; }
.brand small { margin-top: .18rem; color: #a9bac8; font-size: .7rem; letter-spacing: .14em; }
.sidebar-label { padding: 0 .55rem; color: #8194a4; font-size: .68rem; font-weight: 800; letter-spacing: .14em; }
.nav-link { display: flex; align-items: center; gap: .75rem; margin: .18rem 0; padding: .82rem .75rem; border: 0; border-radius: 8px; color: #b8c5cf; background: transparent; text-align: left; }
.nav-link:hover, .nav-link.active { color: #fff; background: #ffffff15; }
.nav-link.active { box-shadow: inset 3px 0 var(--teal); }
.sidebar-bottom { display: grid; grid-template-columns: 12px 1fr; align-items: center; gap: .4rem; margin-top: auto; padding: .8rem .35rem; color: #acbbc6; font-size: .72rem; }
.connection-dot { width: 8px; height: 8px; border-radius: 100%; background: #e99a3c; }
.logout-button { grid-column: 1 / -1; margin-top: .7rem; padding: .7rem; border: 1px solid #ffffff20; border-radius: 8px; color: #eaf0f4; background: transparent; }
.main-content { max-width: 1680px; margin-left: 245px; padding: 1.6rem clamp(1.2rem, 3vw, 3rem) 2rem; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.8rem; }
.topbar .eyebrow { margin-bottom: .35rem; font-size: .65rem; }
.topbar h1 { margin: 0; color: var(--navy); font-size: 1.55rem; }
.topbar-user { display: flex; align-items: center; gap: .65rem; color: #536475; font-size: .8rem; }
.user-avatar { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 50%; color: #14796f; background: #d9f2ee; font-weight: 800; }
.welcome-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; }
.welcome-row h2, .section-heading h2 { margin: 0; color: var(--navy); font-size: 1.15rem; }
.welcome-row p, .section-heading p { margin: .35rem 0 0; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1rem; }
.stat-card { display: flex; align-items: center; gap: .8rem; min-height: 94px; padding: 1.05rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.stat-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 12px; font-size: 1.2rem; font-weight: 800; }
.stat-icon.blue { color: var(--blue); background: #e7f2f9; }
.stat-icon.teal { color: var(--teal); background: #e2f5f1; }
.stat-icon.orange { color: var(--orange); background: #fff2df; }
.stat-card span:not(.stat-icon) { display: block; color: var(--muted); font-size: .75rem; }
.stat-card strong { display: block; margin-top: .25rem; color: var(--navy); font-size: 1.42rem; }
.section-card { margin-bottom: 1rem; padding: 1.2rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.status-badge { padding: .4rem .65rem; border-radius: 99px; font-size: .7rem; font-weight: 750; }
.status-badge.pending { color: #95601c; background: #fff3df; }
.status-badge.connected { color: #14796f; background: #e2f5f1; }
.camera-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .85rem; }
.camera-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; }
.camera-view { position: relative; display: grid; aspect-ratio: 16 / 8.5; place-items: center; overflow: hidden; color: #a8b8c5; background: #172a3a; font-size: .8rem; }
.camera-view img { width: 100%; height: 100%; object-fit: cover; }
.camera-view b { position: absolute; top: .55rem; left: .55rem; padding: .25rem .4rem; border-radius: 5px; color: #fff; background: #142638bb; font-size: .65rem; }
.camera-caption { display: flex; justify-content: space-between; gap: .5rem; padding: .65rem; font-size: .7rem; }
.camera-caption span { color: var(--muted); }
.hint { margin: .85rem 0 0; color: var(--muted); font-size: .76rem; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { padding: .72rem .6rem; color: #7a8a98; font-size: .67rem; text-align: left; text-transform: uppercase; letter-spacing: .05em; background: #fafcfd; }
td { padding: .75rem .6rem; border-top: 1px solid #edf1f4; color: #364a5c; font-size: .76rem; }
td strong { color: var(--navy); }
.pill { display: inline-flex; padding: .27rem .5rem; border-radius: 99px; font-size: .68rem; font-weight: 750; }
.pill.inside { color: #14796f; background: #e2f5f1; }
.pill.exited { color: #687786; background: #edf1f4; }
.pill.incomplete { color: #9a5c12; background: #fff2df; }
.text-button { padding: .4rem; border: 0; color: #168d82; background: transparent; font-size: .78rem; font-weight: 750; }
.button-row { display: flex; gap: .5rem; }
.filter-row { display: flex; gap: .6rem; margin-bottom: 1rem; }
.filter-row input { max-width: 440px; }
.resident-form { display: grid; grid-template-columns: 1fr 1.4fr 1.4fr auto; align-items: end; gap: .75rem; margin-bottom: 1.3rem; padding-bottom: 1.2rem; border-bottom: 1px solid var(--line); }
.resident-form label { margin-top: 0; }
.app-footer { padding: .7rem 0; color: #8a98a4; font-size: .7rem; text-align: center; }
.visit-dialog { width: min(680px, calc(100% - 1.2rem)); max-height: 92vh; padding: 1.5rem; border: 0; border-radius: 16px; color: var(--ink); box-shadow: 0 24px 90px #0e233a44; }
.photos-dialog { width: min(960px, calc(100% - 1.2rem)); max-height: 92vh; padding: 1.5rem; border: 0; border-radius: 16px; color: var(--ink); box-shadow: 0 24px 90px #0e233a44; }
.visit-dialog::backdrop { background: #10223599; backdrop-filter: blur(2px); }
.photos-dialog::backdrop { background: #10223599; backdrop-filter: blur(2px); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.dialog-heading h2 { margin: 0; color: var(--navy); }
.dialog-heading .eyebrow { margin-bottom: .3rem; font-size: .63rem; }
.close-button { width: 34px; height: 34px; border: 0; border-radius: 50%; color: #687786; background: #f0f3f5; font-size: 1.4rem; }
.license-banner { display: flex; align-items: center; gap: .7rem; margin-bottom: .5rem; padding: .8rem; border: 1px solid #ccece6; border-radius: 10px; background: #effaf8; }
.scanner-pulse { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 5px #18a99920; }
.license-banner > span:nth-child(2) { flex: 1; }
.license-banner strong, .license-banner small { display: block; }
.license-banner strong { color: #1b625b; font-size: .77rem; }
.license-banner small { margin-top: .2rem; color: #66817e; font-size: .66rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .8rem; }
.field-hint { display: block; margin-top: .35rem; color: var(--muted); font-size: .66rem; }
.full-row { grid-column: 1 / -1; }
.capture-summary { display: flex; justify-content: space-between; margin-top: 1rem; padding: .7rem; border-radius: 8px; color: var(--navy); background: #f2f5f7; font-size: .73rem; font-weight: 700; }
.capture-summary span:last-child { color: var(--muted); font-weight: 500; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .6rem; }
.empty-state { padding: 2rem; color: var(--muted); text-align: center; }
.saved-photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
.saved-photo-grid figure { min-width: 0; margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #172a3a; }
.saved-photo-grid img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: contain; }
.saved-photo-grid figcaption { padding: .6rem; color: var(--ink); background: #fff; font-size: .72rem; font-weight: 700; }
.toast { position: fixed; right: 1.2rem; bottom: 1.2rem; z-index: 5; max-width: min(440px, calc(100vw - 2rem)); padding: .85rem 1rem; border-radius: 9px; color: #fff; background: var(--navy); box-shadow: 0 8px 24px #10223530; font-size: .8rem; opacity: 0; pointer-events: none; transform: translateY(8px); transition: .2s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: #a53d36; }

@media (max-width: 1050px) {
  .sidebar { width: 205px; }
  .main-content { margin-left: 205px; }
  .resident-form { grid-template-columns: 1fr 1fr; }
  .resident-form button { margin-top: .8rem; }
}
@media (max-width: 740px) {
  .login-layout { grid-template-columns: 1fr; }
  .login-brand { min-height: 290px; padding: 2rem; }
  .login-brand h1 { font-size: 2.6rem; }
  .login-card { padding: 2rem 0; }
  .sidebar { position: static; width: auto; flex-direction: row; align-items: center; gap: .4rem; padding: .65rem; }
  .brand { margin: 0 auto 0 0; }
  .brand strong { font-size: .65rem; }
  .brand small { font-size: .58rem; }
  .brand-mark.small { width: 32px; height: 32px; }
  .sidebar-label, .sidebar-bottom, .nav-link:not(.active) span { display: none; }
  .nav-link { gap: .25rem; padding: .6rem; font-size: .75rem; }
  .nav-link span { display: inline; }
  .main-content { margin-left: 0; padding: 1rem; }
  .topbar { margin-bottom: 1.1rem; }
  .topbar-user { max-width: 45%; overflow: hidden; font-size: .68rem; }
  .topbar-user > span:last-child { overflow: hidden; text-overflow: ellipsis; }
  .stats-grid { grid-template-columns: 1fr; gap: .55rem; }
  .stat-card { min-height: 72px; }
  .camera-grid { grid-template-columns: 1fr; }
  .camera-view { aspect-ratio: 16 / 8; }
  .welcome-row { align-items: flex-start; flex-direction: column; }
  .filter-row { flex-direction: column; }
  .resident-form { grid-template-columns: 1fr; }
  .button-row { width: 100%; }
  .button-row .button { flex: 1; }
  .form-grid { grid-template-columns: 1fr; }
  .full-row { grid-column: auto; }
  .capture-summary { align-items: flex-start; flex-direction: column; gap: .3rem; }
  .license-banner { flex-wrap: wrap; }
  .saved-photo-grid { grid-template-columns: 1fr; }
}
