:root {
    --bg-main: #0B0F19;
    --bg-card: #151D2F;
    --bg-card-hover: #1E293B;
    --primary: #3B82F6;
    --primary-hover: #2563EB;
    --success: #10B981;
    --success-bg: rgba(16, 185, 129, 0.15);
    --danger: #EF4444;
    --danger-bg: rgba(239, 68, 68, 0.2);
    --warning: #F59E0B;
    --text-main: #F9FAFB;
    --text-muted: #9CA3AF;
    --border: #2D3748;
    --radius: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Header & Navigation */
header {
    background: #111827;
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    background: linear-gradient(135deg, #3B82F6, #8B5CF6);
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
}

.brand-title {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.operator-badge {
    font-size: 0.8rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 20px;
    color: var(--text-muted);
}

/* Tab Navigation */
.tabs-nav {
    display: flex;
    background: #111827;
    border-bottom: 1px solid var(--border);
    padding: 0 8px;
    overflow-x: auto;
}

.tab-btn {
    flex: 1;
    min-width: 100px;
    background: none;
    border: none;
    outline: none;
    color: var(--text-muted);
    padding: 14px 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Main Container */
main {
    flex: 1;
    padding: 12px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Scanner View */
.scanner-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.camera-card {
    position: relative;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid var(--border);
    width: 100%;
    aspect-ratio: 9 / 16;
    max-height: 72vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

#camera-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Visual Target Box overlay - grande zone de scan */
.scan-target-box {
    position: absolute;
    width: 90%;
    height: 75%;
    border: 2px dashed rgba(255, 255, 255, 0.4);
    border-radius: 16px;
    pointer-events: none;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
}

.laser-line {
    position: absolute;
    left: 3%;
    right: 3%;
    height: 2px;
    background: #EF4444;
    box-shadow: 0 0 10px #EF4444;
    animation: laserScan 2s infinite alternate ease-in-out;
}

@keyframes laserScan {
    0% { top: 10%; }
    100% { top: 90%; }
}

/* Flash Screen Alerts */
.camera-card.alert-hit {
    border-color: #EF4444 !important;
    animation: blinkRed 0.3s infinite alternate;
}

.camera-card.alert-normal {
    border-color: #10B981 !important;
    box-shadow: 0 0 25px rgba(16, 185, 129, 0.6);
}

@keyframes blinkRed {
    from { box-shadow: 0 0 30px rgba(239, 68, 68, 0.9); }
    to { box-shadow: 0 0 5px rgba(239, 68, 68, 0.2); }
}

/* Controls Bar */
.camera-controls {
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.15s ease;
}

.btn:hover {
    background: var(--bg-card-hover);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
}

/* Result Banner */
.result-banner {
    padding: 16px;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
}

.result-banner.hit {
    background: var(--danger-bg);
    border: 2px solid var(--danger);
}

.result-banner.normal {
    background: var(--success-bg);
    border: 1px solid var(--success);
}

.result-title {
    font-size: 1.25rem;
    font-weight: 800;
}

.result-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* KPI Summary Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    text-align: center;
}

.kpi-num {
    font-size: 1.8rem;
    font-weight: 800;
    margin-top: 4px;
}

.kpi-card.hit .kpi-num { color: var(--danger); }
.kpi-card.normal .kpi-num { color: var(--success); }
.kpi-card.targets .kpi-num { color: var(--primary); }

/* Table styling */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-top: 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

th, td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

th {
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-muted);
    font-weight: 600;
}

tr:hover {
    background: var(--bg-card-hover);
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-hit {
    background: rgba(239, 68, 68, 0.2);
    color: #F87171;
    border: 1px solid #EF4444;
}

.badge-normal {
    background: rgba(16, 185, 129, 0.2);
    color: #34D399;
}

/* Forms and Inputs */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

input[type="text"], input[type="password"], input[type="file"], input[type="datetime-local"], select {
    background: #0D1322;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus, input[type="password"]:focus, input[type="datetime-local"]:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

/* Ack Modal for HIT */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
}

.modal-content {
    background: #1F1717;
    border: 2px solid var(--danger);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 480px;
    width: 100%;
    text-align: center;
    box-shadow: 0 0 50px rgba(239, 68, 68, 0.4);
}
