/* Microsenses MINI 2 — Behavioral Vibration Analysis */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: #1a1a2e; color: #fff; min-height: 100vh; }

/* App wrapper — hidden until authenticated */
.app-wrapper { display: none; }
.app-wrapper.authenticated { display: block; }

/* Password Gate */
.password-gate {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #1a1a2e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.password-gate.hidden { display: none; }
.password-card {
  background: #16213e;
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  text-align: center;
}
.password-card h2 {
  font-size: 24px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #4a9eff, #00d4aa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.password-card p {
  font-size: 13px;
  color: #888;
  margin-bottom: 24px;
}
.password-card input {
  width: 100%;
  padding: 14px 16px;
  background: #1a1a2e;
  border: 2px solid #2d3a4f;
  border-radius: 10px;
  color: white;
  font-size: 15px;
  text-align: center;
  margin-bottom: 16px;
}
.password-card input:focus {
  outline: none;
  border-color: #4a9eff;
}
.password-card .error {
  color: #f44336;
  font-size: 13px;
  margin-bottom: 12px;
  display: none;
}
.password-card .error.show { display: block; }
.auth-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #4a9eff, #2d5a87);
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.auth-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(74, 158, 255, 0.3);
}

/* Header */
.header { background: linear-gradient(135deg, #1e3a5f 0%, #2d5a87 100%); padding: 16px 24px; display: flex; align-items: center; justify-content: space-between; }
.header h1 { font-size: 22px; font-weight: 600; }
.header .subtitle { font-size: 11px; opacity: 0.8; }
.flip-btn { padding: 8px 16px; background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.25); border-radius: 8px; color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.flip-btn:hover { background: rgba(255,255,255,0.25); }

/* Main Layout */
.main-container { display: grid; grid-template-columns: 380px 1fr; gap: 16px; padding: 16px; max-width: 1600px; margin: 0 auto; }
@media (max-width: 900px) { .main-container { grid-template-columns: 1fr; } }

/* Left Panel - Video */
.video-panel { background: #16213e; border-radius: 12px; padding: 16px; }
.video-container { position: relative; background: #000; border-radius: 8px; overflow: hidden; aspect-ratio: 4/3; }
.video-container video { width: 100%; height: 100%; object-fit: cover; }
#overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
.drop-zone { border: 3px dashed #4a9eff !important; background: rgba(74,158,255,0.1) !important; }
.drop-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: #4a9eff; font-weight: 600; display: none; }

/* Controls */
.controls { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.btn { padding: 12px 20px; border: none; border-radius: 8px; font-weight: 600; cursor: pointer; font-size: 13px; transition: all 0.2s; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #4a9eff, #2d5a87); color: white; }
.btn-secondary { background: #2d3a4f; color: white; }
.btn-danger { background: #dc3545; color: white; }
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }

/* Status */
.status-bar { margin-top: 12px; padding: 10px 14px; border-radius: 8px; font-size: 13px; }
.status-bar.loading { background: #3d3d00; color: #ffc107; }
.status-bar.ready { background: #1e4620; color: #4caf50; }
.status-bar.scanning { background: #1e3a5f; color: #4a9eff; }
.status-bar.error { background: #4a1e1e; color: #f44336; }

/* Timer */
.timer-display { text-align: center; margin-top: 16px; }
.timer-value { font-size: 48px; font-weight: 700; color: #4a9eff; font-family: monospace; }
.progress-bar { height: 6px; background: #2d3a4f; border-radius: 3px; margin-top: 8px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #4a9eff, #00d4aa); transition: width 0.1s; }

/* Real-time Metrics */
.realtime-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.metric-card { background: linear-gradient(135deg, #2d3a4f, #1e2a3f); border-radius: 8px; padding: 12px; text-align: center; }
.metric-card .label { font-size: 10px; text-transform: uppercase; opacity: 0.7; letter-spacing: 1px; }
.metric-card .value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.metric-card.energy .value { color: #ff6b6b; }
.metric-card.vibration .value { color: #4ecdc4; }
.metric-card.frequency .value { color: #ffe66d; }

.formula-box { margin-top: 16px; padding: 12px; background: #1e2a3f; border-radius: 8px; font-size: 11px; color: #888; }

/* Persons Detected */
.persons-detected { margin-top: 16px; padding: 12px; background: #1e2a3f; border-radius: 8px; }
.person-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.p-chip { padding: 6px 12px; border-radius: 6px; font-size: 11px; font-weight: 700; letter-spacing: 1px; }
.p-chip.safe { background: rgba(76,175,80,0.2); color: #4caf50; border: 1px solid rgba(76,175,80,0.3); }
.p-chip.caution { background: rgba(255,193,7,0.2); color: #ffc107; border: 1px solid rgba(255,193,7,0.3); }
.p-chip.elevated { background: rgba(255,152,0,0.2); color: #ff9800; border: 1px solid rgba(255,152,0,0.3); }
.p-chip.critical { background: rgba(244,67,54,0.2); color: #f44336; border: 1px solid rgba(244,67,54,0.3); }

/* Right Panel - Results */
.results-panel { background: #16213e; border-radius: 12px; padding: 20px; display: none; }
.results-panel.active { display: block; }

/* Report Header */
.report-header { background: linear-gradient(135deg, #1e3a5f, #2d5a87); margin: -20px -20px 20px -20px; padding: 20px; border-radius: 12px 12px 0 0; }
.report-title { font-size: 18px; font-weight: 600; }
.report-subtitle { font-size: 11px; opacity: 0.8; margin-top: 4px; }

/* Threat Person Card */
.threat-card { background: #1e2a3f; border-radius: 12px; padding: 16px; margin-bottom: 16px; border-left: 4px solid #4caf50; }
.threat-card.safe { border-left-color: #4caf50; }
.threat-card.caution { border-left-color: #ffc107; }
.threat-card.elevated { border-left-color: #ff9800; }
.threat-card.critical { border-left-color: #f44336; }
.threat-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.threat-card-header .person-label { font-size: 14px; font-weight: 700; letter-spacing: 2px; }
.threat-card-header .threat-badge { padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.threat-badge.safe { background: rgba(76,175,80,0.2); color: #4caf50; }
.threat-badge.caution { background: rgba(255,193,7,0.2); color: #ffc107; }
.threat-badge.elevated { background: rgba(255,152,0,0.2); color: #ff9800; }
.threat-badge.critical { background: rgba(244,67,54,0.2); color: #f44336; }

/* Metrics Grid inside threat card */
.metrics-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
@media (max-width: 600px) { .metrics-grid { grid-template-columns: repeat(2, 1fr); } }
.m-item { background: #16213e; border-radius: 8px; padding: 10px; }
.m-label { font-size: 9px; text-transform: uppercase; letter-spacing: 1.5px; color: #888; margin-bottom: 4px; }
.m-bar { height: 4px; background: #2d3a4f; border-radius: 2px; overflow: hidden; margin-bottom: 4px; }
.m-bar-fill { height: 100%; border-radius: 2px; transition: width 0.5s ease; }
.m-bar-fill.aggression { background: #f44336; }
.m-bar-fill.stress { background: #ff9800; }
.m-bar-fill.deception { background: #e040fb; }
.m-bar-fill.tension { background: #ffc107; }
.m-bar-fill.intent { background: #f44336; }
.m-bar-fill.stability { background: #4caf50; }
.m-value { font-size: 18px; font-weight: 700; }

/* Indicator Tags */
.indicators-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ind-tag { font-size: 10px; letter-spacing: 1px; padding: 3px 8px; border-radius: 4px; font-weight: 600; text-transform: uppercase; }
.ind-tag.red { background: rgba(244,67,54,0.15); color: #f44336; }
.ind-tag.orange { background: rgba(255,152,0,0.15); color: #ff9800; }
.ind-tag.yellow { background: rgba(255,193,7,0.15); color: #ffc107; }
.ind-tag.purple { background: rgba(224,64,251,0.15); color: #e040fb; }
.ind-tag.green { background: rgba(76,175,80,0.15); color: #4caf50; }

/* Scan Info */
.scan-info { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 20px 0; }
.scan-info-item { background: #1e2a3f; border-radius: 8px; padding: 12px; text-align: center; }
.scan-info-label { font-size: 10px; opacity: 0.7; text-transform: uppercase; }
.scan-info-value { font-size: 18px; font-weight: 700; margin-top: 4px; }

/* Neuro Section */
.neuro-section-title { font-size: 16px; font-weight: 700; color: #4a9eff; margin: 24px 0 12px; letter-spacing: 2px; text-transform: uppercase; border-bottom: 1px solid #2d3a4f; padding-bottom: 8px; }
.bio-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.bio-item { background: #1e2a3f; border-radius: 8px; padding: 10px; text-align: center; }
.bio-item .bio-label { font-size: 9px; text-transform: uppercase; letter-spacing: 1px; color: #888; }
.bio-item .bio-val { font-size: 18px; font-weight: 700; margin-top: 4px; }
.bio-item .bio-val.ok { color: #4caf50; }
.bio-item .bio-val.warn { color: #ff9800; }
.bio-item .bio-val.alert { color: #f44336; }
.bio-item .bio-unit { font-size: 9px; color: #666; }

/* Condition Card */
.cond-card { background: #1e2a3f; border-radius: 10px; padding: 14px; margin-bottom: 10px; border-left: 4px solid #555; }
.cond-card.minimal { border-left-color: #555; }
.cond-card.low { border-left-color: #4caf50; }
.cond-card.moderate { border-left-color: #ffc107; }
.cond-card.high { border-left-color: #f44336; }
.cond-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.cond-name { font-size: 13px; font-weight: 700; letter-spacing: 1px; }
.cond-badge { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 20px; }
.cond-badge.minimal { background: rgba(85,85,85,0.2); color: #888; }
.cond-badge.low { background: rgba(76,175,80,0.15); color: #4caf50; }
.cond-badge.moderate { background: rgba(255,193,7,0.15); color: #ffc107; }
.cond-badge.high { background: rgba(244,67,54,0.15); color: #f44336; }
.cond-bar { height: 4px; background: #2d3a4f; border-radius: 2px; overflow: hidden; margin-bottom: 8px; }
.cond-bar-fill { height: 100%; border-radius: 2px; transition: width 0.8s ease; }
.cond-bar-fill.minimal { background: #555; }
.cond-bar-fill.low { background: #4caf50; }
.cond-bar-fill.moderate { background: #ffc107; }
.cond-bar-fill.high { background: #f44336; }
.cond-indicators { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.cond-ind { display: flex; justify-content: space-between; font-size: 11px; padding: 4px 8px; background: #16213e; border-radius: 4px; }
.cond-ind .ci-marker { color: #aaa; }
.cond-ind .ci-val { font-weight: 600; }
.cond-ind .ci-val.high { color: #f44336; }
.cond-ind .ci-val.moderate { color: #ffc107; }
.cond-ind .ci-val.low { color: #4caf50; }
.cond-note { font-size: 10px; color: #666; font-style: italic; line-height: 1.4; }
.cond-cat { font-size: 9px; letter-spacing: 1.5px; color: #666; text-transform: uppercase; margin-bottom: 2px; }

/* Disclaimer */
.disclaimer { margin: 20px 0; padding: 12px; background: rgba(255,152,0,0.08); border: 1px solid rgba(255,152,0,0.2); border-radius: 8px; font-size: 11px; color: #ff9800; text-align: center; line-height: 1.5; }

/* Actions */
.report-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.report-actions .btn { min-width: 120px; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); display: none; align-items: center; justify-content: center; z-index: 1000; }
.modal-overlay.show { display: flex; }
.modal { background: #1e2a3f; border-radius: 16px; padding: 32px; max-width: 420px; width: 90%; text-align: center; }
.modal h2 { font-size: 20px; margin-bottom: 8px; }
.modal p { font-size: 13px; color: #888; margin-bottom: 20px; }
.duration-options { display: flex; gap: 10px; justify-content: center; margin-bottom: 24px; flex-wrap: wrap; }
.duration-btn { padding: 12px 20px; border: 2px solid #2d3a4f; border-radius: 10px; background: transparent; color: white; cursor: pointer; font-weight: 600; transition: all 0.2s; font-size: 14px; }
.duration-btn:hover { border-color: #4a9eff; }
.duration-btn.selected { border-color: #4a9eff; background: #4a9eff; }

/* ── Mode Selection Modal ── */
.mode-modal { max-width: 520px; }
.mode-options { display: flex; gap: 16px; margin-bottom: 8px; }
@media (max-width: 600px) { .mode-options { flex-direction: column; } }
.mode-btn {
    flex: 1; padding: 24px 16px; border: 2px solid #2d3a4f; border-radius: 16px;
    background: #16213e; color: white; cursor: pointer; text-align: center; transition: all 0.3s;
}
.mode-btn:hover { border-color: #4a9eff; transform: translateY(-2px); box-shadow: 0 8px 24px rgba(74,158,255,0.2); }
.mode-icon { font-size: 36px; margin-bottom: 12px; }
.mode-title { font-size: 14px; font-weight: 700; letter-spacing: 2px; margin-bottom: 8px; }
.mode-desc { font-size: 11px; color: #888; line-height: 1.5; }

/* ── Mode Badge ── */
.mode-badge {
    padding: 4px 12px; border-radius: 20px; font-size: 10px;
    font-weight: 700; letter-spacing: 2px; text-transform: uppercase; white-space: nowrap;
}
.mode-badge.detection { background: rgba(244,67,54,0.2); color: #f44336; }
.mode-badge.deception { background: rgba(224,64,251,0.2); color: #e040fb; }

/* ── Deception Metrics ── */
.deception-metrics { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 768px) { .deception-metrics { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 480px) { .deception-metrics { grid-template-columns: repeat(2, 1fr); } }
.metric-card.deception-prob .value { color: #e040fb; }
.metric-card.concealment .value { color: #ff6b6b; }
.metric-card.voice-stress .value { color: #00bcd4; }
.metric-card.cognitive-load .value { color: #ffc107; }
.metric-card.truthfulness .value { color: #4caf50; }

/* ── Live Indicator Chips ── */
.deception-indicators { margin-top: 16px; padding: 12px; background: #1e2a3f; border-radius: 8px; }
.indicator-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ind-chip {
    padding: 4px 10px; border-radius: 4px; font-size: 10px;
    font-weight: 600; letter-spacing: 1px; text-transform: uppercase;
}
.ind-chip.flash { background: rgba(224,64,251,0.25); color: #e040fb; animation: pulse 0.5s 3; }
.ind-chip.warn { background: rgba(255,193,7,0.15); color: #ffc107; }
.ind-chip.alert { background: rgba(244,67,54,0.15); color: #f44336; }
.ind-chip.ok { background: rgba(76,175,80,0.15); color: #4caf50; }
.ind-chip.neutral { background: rgba(255,255,255,0.05); color: #666; }
.ind-chip.voice { background: rgba(0,188,212,0.15); color: #00bcd4; }
.ind-chip.voice-alert { background: rgba(244,67,54,0.15); color: #f44336; animation: pulse 0.5s 3; }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:0.4;} }

/* ── Deception Report Cards ── */
.deception-summary-card { background: #1e2a3f; border-radius: 12px; padding: 20px; margin-bottom: 16px; border-left: 4px solid #e040fb; }
.deception-summary-card.low { border-left-color: #4caf50; }
.deception-summary-card.moderate { border-left-color: #ffc107; }
.deception-summary-card.high { border-left-color: #f44336; }
.deception-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.deception-title { font-size: 14px; font-weight: 700; letter-spacing: 2px; }
.deception-badge { padding: 4px 12px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.deception-badge.low { background: rgba(76,175,80,0.15); color: #4caf50; }
.deception-badge.moderate { background: rgba(255,193,7,0.15); color: #ffc107; }
.deception-badge.high { background: rgba(244,67,54,0.15); color: #f44336; }
.deception-score-display { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 600px) { .deception-score-display { grid-template-columns: repeat(2, 1fr); } }
.score-ring { background: #16213e; border-radius: 12px; padding: 16px; text-align: center; }
.score-value { font-size: 28px; font-weight: 700; color: #e040fb; }
.score-label { font-size: 9px; color: #888; text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; }

.section-title { font-size: 12px; font-weight: 700; color: #4a9eff; letter-spacing: 2px; text-transform: uppercase; margin: 20px 0 12px; border-bottom: 1px solid #2d3a4f; padding-bottom: 6px; }

.dtype-card { background: #1e2a3f; border-radius: 10px; padding: 14px; margin-bottom: 10px; border-left: 4px solid #555; }
.dtype-card.active { border-left-color: #e040fb; }
.dtype-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.dtype-name { font-size: 13px; font-weight: 700; letter-spacing: 1px; }
.dtype-score { font-size: 18px; font-weight: 700; color: #e040fb; }
.dtype-desc { font-size: 10px; color: #666; margin-bottom: 8px; font-style: italic; }
.dtype-indicators { display: flex; flex-direction: column; gap: 3px; }
.dtype-ind { font-size: 11px; padding: 3px 8px; background: #16213e; border-radius: 4px; display: flex; justify-content: space-between; }
.dtype-ind .severity { font-weight: 600; }
.dtype-ind .severity.high { color: #f44336; }
.dtype-ind .severity.moderate { color: #ffc107; }
.dtype-ind .severity.low { color: #4caf50; }

.micro-log { margin-top: 12px; }
.micro-item { font-size: 11px; padding: 6px 10px; background: #16213e; border-radius: 4px; margin-bottom: 4px; display: flex; justify-content: space-between; align-items: center; }
.micro-type { color: #e040fb; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }
.micro-time { color: #666; font-size: 10px; }
.micro-intensity { font-weight: 700; }

.blink-card, .asymmetry-card { background: #1e2a3f; border-radius: 10px; padding: 14px; margin-bottom: 10px; }
.blink-grid, .asym-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
@media (max-width: 600px) { .blink-grid, .asym-grid { grid-template-columns: repeat(2, 1fr); } }
.blink-item, .asym-item { background: #16213e; border-radius: 6px; padding: 8px; text-align: center; }
.blink-item .b-label, .asym-item .a-label { font-size: 9px; color: #888; text-transform: uppercase; letter-spacing: 1px; }
.blink-item .b-val, .asym-item .a-val { font-size: 16px; font-weight: 700; margin-top: 2px; }

/* ── Mic Status ── */
.mic-status {
    margin-top: 12px; padding: 8px 12px; background: #1e2a3f; border-radius: 8px;
    font-size: 11px; display: flex; align-items: center; gap: 8px; letter-spacing: 1px;
}
.mic-status .mic-icon { font-size: 14px; }
.mic-status .mic-text { color: #888; }
.mic-status.active .mic-text { color: #4caf50; }
.mic-status.denied .mic-text { color: #f44336; }
.mic-status.no-speech .mic-text { color: #ffc107; }

/* ── VSA Report Card ── */
.vsa-card { background: #1e2a3f; border-radius: 10px; padding: 14px; margin-bottom: 10px; border-left: 4px solid #00bcd4; }
.vsa-card.elevated { border-left-color: #ff9800; }
.vsa-card.high { border-left-color: #f44336; }
.vsa-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.vsa-score { font-size: 28px; font-weight: 700; color: #00bcd4; }
.vsa-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
@media (max-width: 600px) { .vsa-grid { grid-template-columns: repeat(2, 1fr); } }
.vsa-item { background: #16213e; border-radius: 6px; padding: 8px; text-align: center; }
.vsa-item .vsa-label { font-size: 9px; color: #888; text-transform: uppercase; letter-spacing: 1px; }
.vsa-item .vsa-val { font-size: 16px; font-weight: 700; margin-top: 2px; color: #00bcd4; }

/* ── Safe area ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .main-container { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}
