* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, Segoe UI, Roboto, sans-serif;
    background: #0f1115;
    color: #e6e8eb;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: #161922;
    border-bottom: 1px solid #262a35;
}
.topbar h1 { font-size: 18px; margin: 0; }

.ws-status {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 12px;
}
.ws-status.connected { background: #16351f; color: #4ade80; }
.ws-status.disconnected { background: #3a1f1f; color: #f87171; }

.layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    padding: 20px 24px;
}

.camera-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.camera-card {
    background: #161922;
    border: 1px solid #262a35;
    border-radius: 10px;
    overflow: hidden;
}
.camera-title {
    padding: 10px 12px;
    font-weight: 600;
    border-bottom: 1px solid #262a35;
}
.camera-feed {
    width: 100%;
    display: block;
    background: #000;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}
.camera-meta {
    padding: 8px 12px;
    font-size: 12px;
    color: #9aa2af;
}

.alerts-panel h2, .cameras-panel h2 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9aa2af;
    margin-bottom: 12px;
}

.violation-log {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 80vh;
    overflow-y: auto;
}
.violation-item {
    background: #201417;
    border: 1px solid #4a1f24;
    border-left: 4px solid #f87171;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13px;
}
.violation-item .vi-title { font-weight: 600; color: #f87171; }
.violation-item .vi-meta { color: #9aa2af; margin-top: 4px; }
.violation-item .vi-thumb {
    display: block;
    margin-top: 8px;
    max-width: 100%;
    border-radius: 6px;
    border: 1px solid #4a1f24;
}

.active-count {
    display: inline-block;
    background: #3a1f1f;
    color: #f87171;
    font-size: 12px;
    padding: 2px 9px;
    border-radius: 10px;
    margin-left: 6px;
    vertical-align: middle;
}
.active-count.zero { background: #16351f; color: #4ade80; }

.active-violations {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}
.no-active-msg {
    font-size: 13px;
    color: #9aa2af;
    margin: 0;
}

/* Active violation cards stay visible for the FULL duration of the
   violation - no auto-dismiss timer - so this is deliberately styled to
   stand out and stay put, not read as a transient toast/popup. */
.active-violation-card {
    background: #201417;
    border: 1px solid #6b2530;
    border-left: 5px solid #f87171;
    border-radius: 8px;
    padding: 12px 14px;
    animation: pulse-border 2s ease-in-out infinite;
}
@keyframes pulse-border {
    0%, 100% { border-left-color: #f87171; }
    50% { border-left-color: #dc2626; }
}
.active-violation-card .av-title {
    font-weight: 700;
    color: #fca5a5;
    font-size: 14px;
}
.active-violation-card .av-meta {
    color: #9aa2af;
    font-size: 12px;
    margin-top: 4px;
}
.active-violation-card .av-duration {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: #f87171;
}
.active-violation-card .av-thumb {
    display: block;
    margin-top: 8px;
    max-width: 100%;
    border-radius: 6px;
}

/* Resolved state - the visible real-time flip when the person becomes
   compliant again. Stays green/visible briefly before being removed, so
   the transition itself is noticeable, not instant/invisible. */
.active-violation-card.resolved {
    border-color: #1f6b3a;
    border-left-color: #4ade80;
    animation: none;
    background: #14201a;
}
.active-violation-card.resolved .av-title {
    color: #86efac;
}
.active-violation-card.resolved .av-title::after {
    content: " - RESOLVED, now compliant";
    color: #4ade80;
    font-weight: 700;
}

.history-heading {
    margin-top: 8px;
}

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-card {
    background: #161922;
    border: 1px solid #262a35;
    border-radius: 10px;
    padding: 28px 32px;
    width: 280px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.login-card h1 { font-size: 16px; margin: 0 0 12px; }
.login-card label { font-size: 12px; color: #9aa2af; margin-top: 8px; }
.login-card input {
    background: #0f1115;
    border: 1px solid #262a35;
    border-radius: 6px;
    padding: 8px 10px;
    color: #e6e8eb;
}
.login-card button {
    margin-top: 16px;
    background: #4ade80;
    color: #0f1115;
    border: none;
    border-radius: 6px;
    padding: 10px;
    font-weight: 600;
    cursor: pointer;
}
.login-error { color: #f87171; font-size: 13px; }
.login-info { color: #4ade80; font-size: 13px; }

.logout-link {
    color: #9aa2af;
    font-size: 12px;
    text-decoration: none;
    margin-left: 12px;
}
.logout-link:hover { color: #e6e8eb; }

.browser-cam-section {
    background: #161922;
    border: 1px solid #262a35;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 20px;
}
.browser-cam-wrap {
    position: relative;
    width: 100%;
    max-width: 640px;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}
.browser-cam-wrap video, .browser-cam-wrap canvas {
    width: 100%;
    display: block;
}
.browser-cam-wrap canvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}
.browser-cam-controls {
    margin-top: 10px;
    display: flex;
    gap: 10px;
    align-items: center;
}
.browser-cam-controls button {
    background: #262a35;
    color: #e6e8eb;
    border: 1px solid #333846;
    border-radius: 6px;
    padding: 8px 14px;
    cursor: pointer;
}
.browser-cam-status { font-size: 12px; color: #9aa2af; }

.identity-picker {
    margin-bottom: 14px;
    padding: 12px;
    background: #0f1115;
    border: 1px solid #262a35;
    border-radius: 8px;
}
.identity-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}
.identity-tab {
    background: #1a1d26;
    color: #9aa2af;
    border: 1px solid #262a35;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
}
.identity-tab.active {
    background: #262a35;
    color: #e6e8eb;
    border-color: #4ade80;
}
.identity-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.identity-panel select, .identity-panel input {
    background: #1a1d26;
    border: 1px solid #262a35;
    border-radius: 6px;
    padding: 7px 10px;
    color: #e6e8eb;
    font-size: 13px;
}
.identity-panel button {
    background: #4ade80;
    color: #0f1115;
    border: none;
    border-radius: 6px;
    padding: 7px 14px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}
.identity-confirmed {
    margin-top: 8px;
    font-size: 12px;
    color: #4ade80;
}

.admin-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 20px 24px;
}
.admin-panel {
    background: #161922;
    border: 1px solid #262a35;
    border-radius: 10px;
    padding: 16px;
}
.admin-panel h2 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9aa2af;
    margin: 0 0 12px;
}
.admin-panel h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9aa2af;
    margin: 20px 0 8px;
}
.admin-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #262a35;
}
.admin-form input {
    background: #0f1115;
    border: 1px solid #262a35;
    border-radius: 6px;
    padding: 8px 10px;
    color: #e6e8eb;
    font-size: 13px;
    flex: 1 1 140px;
}
.admin-form button {
    background: #4ade80;
    color: #0f1115;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.admin-table th {
    text-align: left;
    color: #9aa2af;
    font-weight: 500;
    padding: 6px 8px;
    border-bottom: 1px solid #262a35;
}
.admin-table td {
    padding: 8px;
    border-bottom: 1px solid #1b1e27;
}
.admin-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.photo-upload-form {
    display: flex;
    gap: 6px;
    align-items: center;
}
.photo-upload-form input[type="file"] {
    font-size: 11px;
    max-width: 120px;
}
.photo-upload-form button, .delete-btn, .checkout-btn {
    background: #262a35;
    color: #e6e8eb;
    border: 1px solid #333846;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12px;
    cursor: pointer;
}
.delete-btn { border-color: #4a1f24; color: #f87171; }
.photo-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
}
.photo-badge.enrolled { background: #16351f; color: #4ade80; }
.photo-badge.missing { background: #3a1f1f; color: #f87171; }
