:root {
    --brand-primary: #103b66;
    --brand-primary-dark: #091d5a;
    --brand-primary-light: #1c548a;
    --brand-accent: #009fe3;
    --brand-accent-hover: #0084c7;
    --brand-accent-light: #eaf4fb;
    --brand-dark: #0e1b2a;
    --brand-light: #f4f7fb;
    --brand-surface: #ffffff;
    --brand-text: #1e293b;
    --brand-text-muted: #64748b;
    --brand-border: #e2e8f0;
    --brand-success: #10b981;
    --brand-danger: #ef4444;
    --brand-warning: #f59e0b;
    --brand-radius: 8px;
    --brand-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--brand-light);
    color: var(--brand-text);
    line-height: 1.5;
}

/* Layout Structure (Sidebar + Main) */
.app-layout {
    display: flex;
    min-height: 100vh;
    background-color: var(--brand-light);
}

.sidebar {
    width: 260px;
    min-width: 260px;
    background: linear-gradient(180deg, var(--brand-primary-dark) 0%, var(--brand-primary) 100%);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-brand-container {
    padding: 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #ffffff;
}

.brand-logo-img {
    width: 100%;
    border-radius: 6px;
    background: #ffffff;
    padding: 2px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.brand-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #ffffff;
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 0.72rem;
    color: var(--brand-accent);
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 1.25rem 0.85rem;
    flex: 1;
}

.sidebar-nav-link {
    color: #cbd5e1;
    padding: 0.65rem 1rem;
    border-radius: var(--brand-radius);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-nav-link:hover {
    background-color: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    transform: translateX(3px);
}

.sidebar-nav-link.active {
    background-color: var(--brand-accent);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 4px 6px -1px rgba(0, 159, 227, 0.3);
}

.sidebar-nav-link.highlight {
    background-color: rgba(0, 159, 227, 0.15);
    color: #ffffff;
    border: 1px solid rgba(0, 159, 227, 0.35);
}

.sidebar-nav-link.highlight:hover {
    background-color: rgba(0, 159, 227, 0.3);
}

.sidebar-nav-link.highlight.active {
    background-color: var(--brand-accent);
    border-color: var(--brand-accent);
}

.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
}

/* Header */
.app-header {
    background-color: var(--brand-surface);
    border-bottom: 1px solid var(--brand-border);
    padding: 0.85rem 1.75rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 90;
}

.header-user-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: auto;
}

.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0.45rem 1rem;
    background-color: var(--brand-light);
    border: 1px solid var(--brand-border);
    border-radius: 20px;
    font-size: 0.9rem;
    color: var(--brand-primary);
    font-weight: 600;
}

.user-badge-icon {
    font-size: 1rem;
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.45rem 0.9rem;
    background-color: #ffffff;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    color: var(--brand-danger);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background-color: #fee2e2;
    border-color: var(--brand-danger);
    color: #991b1b;
}

/* Main Content & Footer */
.main-content {
    flex: 1;
    padding: 0;
}

.app-footer {
    text-align: center;
    padding: 1.5rem 1rem;
    color: var(--brand-text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--brand-border);
    background: var(--brand-surface);
    margin-top: auto;
}

/* Page Layout */
.main-container {
    max-width: 1300px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
}

@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        min-width: 100%;
        height: auto;
        position: static;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
        padding: 0.75rem;
    }

    .sidebar-nav-link:hover {
        transform: none;
    }

    .app-header {
        padding: 0.75rem 1rem;
    }
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--brand-primary);
    margin: 0;
}

/* Card */
.card {
    background: var(--brand-surface);
    border-radius: var(--brand-radius);
    border: 1px solid var(--brand-border);
    box-shadow: var(--brand-shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--brand-primary);
    margin-top: 0;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--brand-surface);
    border-radius: var(--brand-radius);
    padding: 1.25rem;
    border: 1px solid var(--brand-border);
    border-left: 4px solid var(--brand-accent);
    box-shadow: var(--brand-shadow);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--brand-text-muted);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--brand-primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0.55rem 1.1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--brand-primary);
    color: #ffffff;
}

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

.btn-accent {
    background-color: var(--brand-accent);
    color: #ffffff;
}

.btn-accent:hover {
    background-color: var(--brand-accent-hover);
}

.btn-secondary {
    background-color: #ffffff;
    color: var(--brand-text);
    border-color: var(--brand-border);
}

.btn-secondary:hover {
    background-color: #f8fafc;
}

.btn-danger {
    background-color: var(--brand-danger);
    color: #ffffff;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
}

/* Table */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table th {
    background-color: #f8fafc;
    color: var(--brand-primary);
    font-weight: 600;
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--brand-border);
}

.table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--brand-border);
    vertical-align: middle;
}

.table tr:hover {
    background-color: #f8fafc;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-info {
    background-color: var(--brand-accent-light);
    color: var(--brand-primary);
}

.badge-gray {
    background-color: #e2e8f0;
    color: #475569;
}

/* Forms */
.form-group {
    margin-bottom: 1.15rem;
}

.form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--brand-text);
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--brand-border);
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.15s ease-in-out;
}

.form-control:focus {
    outline: none;
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 3px rgba(0, 159, 227, 0.15);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(14, 27, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: #ffffff;
    border-radius: var(--brand-radius);
    max-width: 650px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.75rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--brand-border);
}

/* Payment Matrix Pill Button */
.payment-cell-btn {
    min-width: 55px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

.payment-cell-paid {
    background-color: #10b981;
    color: #ffffff;
}

.payment-cell-unpaid {
    background-color: #ef4444;
    color: #ffffff;
}

.payment-cell-na {
    background-color: #94a3b8;
    color: #ffffff;
}

/* Print Card Styles */
@media print {
    body * {
        visibility: hidden;
    }
    .printable-card, .printable-card * {
        visibility: visible;
    }
    .printable-card {
        position: absolute;
        left: 0;
        top: 0;
        width: 320px;
        padding: 16px;
        border: 2px solid #103b66;
        border-radius: 8px;
        font-family: sans-serif;
    }
}

/* Camera QR Scanner Styles */
.camera-scanner-wrapper {
    margin-bottom: 1.5rem;
}

.camera-video-wrapper {
    position: relative;
    width: 100%;
    max-width: 520px;
    margin: 1rem auto 0;
    aspect-ratio: 4 / 3;
    background: #0f172a;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25);
    border: 3px solid var(--brand-border);
    transition: all 0.2s ease-in-out;
}

.camera-video-wrapper.scan-flash {
    border-color: #10b981 !important;
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.7) !important;
}

.camera-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.scanner-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scanner-viewfinder {
    width: 220px;
    height: 220px;
    position: relative;
    border-radius: 12px;
    border: 2px dashed rgba(255, 255, 255, 0.45);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
}

.scanner-corner {
    position: absolute;
    width: 20px;
    height: 20px;
    border-color: var(--brand-accent);
    border-style: solid;
}

.scanner-corner-tl {
    top: -2px;
    left: -2px;
    border-width: 4px 0 0 4px;
    border-top-left-radius: 10px;
}

.scanner-corner-tr {
    top: -2px;
    right: -2px;
    border-width: 4px 4px 0 0;
    border-top-right-radius: 10px;
}

.scanner-corner-bl {
    bottom: -2px;
    left: -2px;
    border-width: 0 0 4px 4px;
    border-bottom-left-radius: 10px;
}

.scanner-corner-br {
    bottom: -2px;
    right: -2px;
    border-width: 0 4px 4px 0;
    border-bottom-right-radius: 10px;
}

.scanner-laser {
    position: absolute;
    left: 4%;
    right: 4%;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--brand-accent), #38bdf8, transparent);
    box-shadow: 0 0 10px var(--brand-accent);
    animation: scanLaser 2s infinite ease-in-out alternate;
}

@keyframes scanLaser {
    0% {
        top: 6%;
    }
    100% {
        top: 92%;
    }
}

.scanner-status-pill {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.85);
    color: #ffffff;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(4px);
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.scanner-pulse-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #10b981;
    display: inline-block;
    box-shadow: 0 0 8px #10b981;
    animation: pulseDot 1.5s infinite;
}

@keyframes pulseDot {
    0% {
        transform: scale(0.95);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.3);
        opacity: 1;
    }
    100% {
        transform: scale(0.95);
        opacity: 0.8;
    }
}
