* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f0f2f5; color: #1e1e2d; }
#app { max-width: 480px; margin: 0 auto; min-height: 100vh; background: #f8f9fb; padding-bottom: 72px; overflow-x: hidden; }

/* Auth */
.auth-screen { padding: 48px 24px; text-align: center; }
.auth-logo { width: 64px; height: 64px; border-radius: 16px; background: linear-gradient(135deg, #2d5a7b 0%, #1a3a52 100%); color: #fff; font-weight: 700; font-size: 20px; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.auth-screen h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.auth-sub { font-size: 14px; color: #8e92a4; margin-bottom: 24px; }
.auth-link { margin-top: 20px; font-size: 13px; color: #8e92a4; }
.auth-link a { color: #2d5a7b; text-decoration: none; font-weight: 600; }

/* Header */
.header { padding: 16px 16px 12px; }
.header-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.header h2 { font-size: 20px; font-weight: 700; }
.header p { font-size: 13px; color: #8e92a4; margin-top: 2px; }
.header-icon { width: 36px; height: 36px; border-radius: 10px; background: #eef3f8; display: flex; align-items: center; justify-content: center; cursor: pointer; color: #2d5a7b; }
.back-btn { font-size: 14px; color: #2d5a7b; font-weight: 600; cursor: pointer; }

/* Form */
.form-group { margin: 0 16px 12px; }
.form-label { font-size: 13px; font-weight: 600; color: #4a5568; margin-bottom: 4px; display: block; }
.form-input { width: 100%; padding: 10px 12px; border: 1px solid #dde3ea; border-radius: 10px; font-size: 14px; font-family: inherit; color: #1e1e2d; background: #fff; transition: border-color .2s; resize: none; }
.form-input:focus { outline: none; border-color: #2d5a7b; }
textarea.form-input { min-height: 72px; }
textarea.form-input.tall { min-height: 110px; }
textarea.form-input.sm { min-height: 52px; margin-top: 8px; font-size: 13px; }
.titulo-input { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }
.titulo-input:focus { border-color: rgba(255,255,255,.6); }
.titulo-input::placeholder { color: rgba(255,255,255,.5); }

/* Buttons */
.btn-primary { width: 100%; padding: 13px; border: none; border-radius: 12px; font-size: 15px; font-weight: 600; cursor: pointer; background: #2d5a7b; color: #fff; font-family: inherit; }
.btn-primary.dark { background: linear-gradient(135deg, #2d5a7b 0%, #1a3a52 100%); }
.btn-secondary { padding: 10px 18px; border: 1px solid #dde3ea; border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer; background: #fff; color: #4a5568; font-family: inherit; }
.btn-sm { padding: 6px 14px; border: 1px solid #dde3ea; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer; background: #eef3f8; color: #2d5a7b; font-family: inherit; }
.nav-buttons { display: flex; gap: 8px; margin: 20px 16px; }
.nav-buttons .btn-primary { flex: 1; }

/* Chips */
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.chip-group.vertical { flex-direction: column; }
.chip { padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 500; border: 1px solid #dde3ea; background: #fff; color: #4a5568; cursor: pointer; transition: all .2s; user-select: none; text-align: center; }
.chip.wide { padding: 10px 14px; font-size: 12px; text-align: left; border-radius: 10px; }
.chip.selected, .chip:active { background: #2d5a7b; color: #fff; border-color: #2d5a7b; }
.chip.risk-green.selected { background: #38a169; border-color: #38a169; }

/* Defense chips */
.defense-grid { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 16px 16px; }
.defense-chip { padding: 6px 12px; border-radius: 8px; font-size: 12px; font-weight: 500; border: 1px solid #dde3ea; background: #fff; color: #4a5568; cursor: pointer; transition: all .2s; user-select: none; }
.defense-chip.sel { background: #2d5a7b; color: #fff; border-color: #2d5a7b; }

/* Tags */
.tag { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; background: #eef3f8; color: #2d5a7b; margin-right: 4px; }
.tag.alert { background: #fde8e8; color: #c0392b; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 10px; font-weight: 600; margin-right: 4px; }
.badge.blue { background: #dbeafe; color: #1e3a5f; }
.badge.amber { background: #fef3c7; color: #92400e; }
.badge.green { background: #dcfce7; color: #166534; }
.badge.red { background: #fde8e8; color: #c0392b; }

/* Cards */
.card { background: #fff; border-radius: 12px; padding: 14px; margin: 0 16px 12px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.card-sm { background: #fff; border-radius: 10px; padding: 12px 14px; margin: 0 16px 8px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.card-title { font-size: 14px; font-weight: 700; margin-bottom: 8px; color: #1e1e2d; }
.card-sub { font-size: 12px; color: #8e92a4; margin-bottom: 6px; }
.titulo-card { background: linear-gradient(135deg, #2d5a7b 0%, #1a3a52 100%); }
.titulo-card .card-title { color: #fff; }

/* Info / Alert */
.info-box { font-size: 12px; color: #5a7896; background: #eef3f8; border-radius: 8px; padding: 10px 14px; margin: 12px 16px; line-height: 1.5; }
.alert-box { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; margin: 12px 16px; border-radius: 10px; background: #fff8e1; }
.alert-icon-text { width: 22px; height: 22px; border-radius: 6px; background: #f6c543; color: #fff; font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.alert-text { font-size: 12px; color: #6b5a00; line-height: 1.5; }

/* Section title */
.section-title { font-size: 13px; font-weight: 700; color: #8e92a4; text-transform: uppercase; letter-spacing: .5px; margin: 16px 16px 8px; }

/* Patient list */
.list-container { margin: 0 16px; }
.patient-item { display: flex; align-items: center; gap: 12px; padding: 12px; background: #fff; border-radius: 12px; margin-bottom: 8px; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.04); transition: transform .1s; }
.patient-item:active { transform: scale(.98); }
.patient-avatar { width: 42px; height: 42px; border-radius: 12px; color: #fff; font-weight: 700; font-size: 15px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.patient-info { flex: 1; min-width: 0; }
.patient-info .name { font-size: 15px; font-weight: 700; color: #1e1e2d; }
.patient-info .meta { font-size: 12px; color: #8e92a4; margin-top: 1px; }
.patient-info .tags { margin-top: 4px; }
.session-count { text-align: center; font-size: 11px; color: #8e92a4; flex-shrink: 0; }
.session-count strong { display: block; font-size: 18px; color: #2d5a7b; }

/* Timeline */
.timeline-item { display: flex; gap: 0; padding: 0 16px; cursor: pointer; }
.timeline-line { display: flex; flex-direction: column; align-items: center; width: 24px; flex-shrink: 0; padding-top: 4px; }
.timeline-dot { width: 10px; height: 10px; border-radius: 50%; background: #2d5a7b; flex-shrink: 0; }
.timeline-stem { width: 2px; flex: 1; background: #dde3ea; margin-top: 4px; }
.timeline-content { flex: 1; padding-bottom: 20px; }
.timeline-content .date { font-size: 11px; color: #8e92a4; }
.timeline-content .title { font-size: 14px; font-weight: 700; color: #1e1e2d; margin: 2px 0; }
.timeline-content .excerpt { font-size: 12px; color: #6b7a8d; }
.timeline-badges { margin-top: 6px; }
.titulo-display { font-size: 16px; font-weight: 700; color: #2d5a7b; font-style: italic; padding: 8px 16px 4px; }

/* Ficha tabs */
.ficha-tabs { display: flex; gap: 0; overflow-x: auto; padding: 0 16px 8px; -webkit-overflow-scrolling: touch; }
.ficha-tabs::-webkit-scrollbar { display: none; }
.ficha-tab { padding: 8px 12px; font-size: 12px; font-weight: 600; color: #8e92a4; white-space: nowrap; cursor: pointer; border-bottom: 2px solid transparent; transition: all .2s; flex-shrink: 0; }
.ficha-tab.active { color: #2d5a7b; border-bottom-color: #2d5a7b; }

/* Sectors */
.sector-card { background: #fff; border-radius: 12px; padding: 14px; margin: 0 16px 10px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.sector-name { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.conflict-type { display: flex; gap: 8px; margin-bottom: 8px; }
.conflict-btn { padding: 6px 14px; border-radius: 8px; font-size: 12px; font-weight: 600; border: 1px solid #dde3ea; background: #fff; color: #4a5568; cursor: pointer; transition: all .2s; user-select: none; }
.conflict-btn.sel { background: #2d5a7b; color: #fff; border-color: #2d5a7b; }
.intensity-bar { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: #8e92a4; }
.intensity-dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #dde3ea; cursor: pointer; transition: all .2s; }
.intensity-dot.fill1 { background: #a8d5ba; border-color: #a8d5ba; }
.intensity-dot.fill2 { background: #f0d68a; border-color: #f0d68a; }
.intensity-dot.fill3 { background: #e8a87c; border-color: #e8a87c; }
.intensity-dot.fill4 { background: #e07b7b; border-color: #e07b7b; }
.intensity-dot.fill5 { background: #c0392b; border-color: #c0392b; }

/* Toggle */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; }
.toggle-row .label { font-size: 14px; font-weight: 600; }
.toggle-row .sublabel { font-size: 12px; color: #8e92a4; }
.toggle { width: 46px; height: 26px; border-radius: 13px; background: #dde3ea; cursor: pointer; position: relative; transition: background .2s; flex-shrink: 0; }
.toggle::after { content: ''; width: 22px; height: 22px; border-radius: 50%; background: #fff; position: absolute; top: 2px; left: 2px; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle.on { background: #2d5a7b; }
.toggle.on::after { transform: translateX(20px); }

/* Search */
.search-bar { display: flex; align-items: center; gap: 8px; margin: 8px 16px 12px; background: #fff; padding: 8px 12px; border-radius: 10px; border: 1px solid #dde3ea; }
.search-icon { color: #8e92a4; display: flex; }
.search-bar input { flex: 1; border: none; outline: none; font-size: 14px; font-family: inherit; background: transparent; }

/* Dashboard */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 16px; }
.stat-box { background: #fff; border-radius: 12px; padding: 14px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.stat-box .num { font-size: 28px; font-weight: 700; color: #2d5a7b; }
.stat-box .lbl { font-size: 12px; color: #8e92a4; margin-top: 2px; }
.chart-placeholder { margin: 8px 16px; background: #fff; border-radius: 12px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.chart-bar-group { display: flex; align-items: flex-end; gap: 4px; height: 100px; padding-bottom: 4px; }
.chart-col { display: flex; flex-direction: column; align-items: center; flex: 1; }
.chart-col .bar { width: 100%; border-radius: 3px; min-height: 2px; }
.chart-col .lbl { font-size: 9px; color: #8e92a4; margin-top: 4px; }
.chart-legend { display: flex; gap: 12px; margin-top: 8px; font-size: 11px; color: #6b7a8d; }
.chart-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }
.progress-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.progress-label { font-size: 12px; font-weight: 600; width: 100px; color: #4a5568; }
.progress-bar { flex: 1; height: 8px; background: #eef3f8; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width .3s; }
.progress-value { font-size: 12px; font-weight: 600; color: #2d5a7b; width: 30px; text-align: right; }
.sig-cloud { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.sig-bubble { color: #2d5a7b; font-weight: 600; }
.sig-bubble small { color: #8e92a4; font-weight: 400; }

/* Detail */
.detail-item { margin-bottom: 8px; font-size: 14px; }
.detail-text { font-size: 13px; color: #4a5568; line-height: 1.6; white-space: pre-wrap; }

/* FAB */
.fab { position: fixed; bottom: 80px; right: calc(50% - 220px); width: 52px; height: 52px; border-radius: 16px; background: linear-gradient(135deg, #2d5a7b 0%, #1a3a52 100%); color: #fff; font-size: 24px; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 4px 12px rgba(45,90,123,.3); z-index: 10; }
@media (max-width: 480px) { .fab { right: 20px; } }

/* Bottom nav */
.bottom-nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; background: #fff; display: flex; justify-content: space-around; padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid #eef3f8; z-index: 20; }
.nav-item { display: flex; flex-direction: column; align-items: center; font-size: 10px; color: #8e92a4; cursor: pointer; gap: 2px; padding: 4px 0; }
.nav-item .ico { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; }
.nav-item.act { color: #2d5a7b; font-weight: 600; }

/* States */
.loading-area { padding: 40px; text-align: center; color: #8e92a4; }
.empty-state { padding: 40px 24px; text-align: center; color: #8e92a4; font-size: 14px; }
.error-state { padding: 40px 24px; text-align: center; color: #c0392b; font-size: 14px; }
.error-msg { color: #c0392b; font-size: 13px; text-align: center; margin-top: 8px; min-height: 18px; }
