:root {
    --primary: #1a365d;
    --primary-light: #2a4a7f;
    --primary-dark: #0f2340;
    --accent: #e67e22;
    --accent-light: #f39c12;
    --accent-dark: #d35400;
    --success: #27ae60;
    --danger: #e74c3c;
    --warning: #f39c12;
    --info: #3498db;
    --bg: #f0f2f5;
    --card-bg: #ffffff;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --border: #ddd;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 16px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-text-size-adjust: 100%;
}

.navbar {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.navbar-brand {
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-brand .icon {
    font-size: 1.5rem;
}

.navbar-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    transition: all 0.2s;
    white-space: nowrap;
}

.nav-link:hover, .nav-link.active {
    background: rgba(255,255,255,0.15);
    color: white;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid var(--accent);
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.card-header {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    text-align: center;
    border-top: 4px solid var(--primary);
}

.stat-card.success { border-top-color: var(--success); }
.stat-card.danger { border-top-color: var(--danger); }
.stat-card.warning { border-top-color: var(--warning); }
.stat-card.info { border-top-color: var(--info); }

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

.stat-label {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    min-height: 48px;
}

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

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

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover { background: #219a52; }

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover { background: #c0392b; }

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: white; }

.btn-sm { padding: 0.5rem 1rem; font-size: 0.875rem; min-height: 36px; }
.btn-lg { padding: 1rem 2rem; font-size: 1.125rem; min-height: 56px; }
.btn-block { width: 100%; }

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.375rem;
    color: var(--text);
    font-size: 0.95rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s;
    min-height: 48px;
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,54,93,0.15);
}

select.form-control {
    appearance: auto;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th, table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

table th {
    background: var(--primary);
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
}

table tr:hover { background: #f8f9fa; }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-done { background: #d4edda; color: #155724; }
.badge-late { background: #fff3cd; color: #856404; }
.badge-not-done { background: #f8d7da; color: #721c24; }
.badge-exception { background: #f8d7da; color: #721c24; }
.badge-in-progress { background: #cce5ff; color: #004085; }

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.alert-success { background: #d4edda; color: #155724; border-left: 4px solid var(--success); }
.alert-error { background: #f8d7da; color: #721c24; border-left: 4px solid var(--danger); }
.alert-warning { background: #fff3cd; color: #856404; border-left: 4px solid var(--warning); }
.alert-info { background: #cce5ff; color: #004085; border-left: 4px solid var(--info); }

.rig-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.rig-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    border-left: 5px solid var(--primary);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.rig-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.rig-card h3 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.rig-card .rig-code {
    color: var(--text-light);
    font-size: 0.875rem;
}

.status-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.wizard-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
}

.progress-bar-wrapper {
    background: #e0e0e0;
    border-radius: 20px;
    height: 12px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    border-radius: 20px;
    transition: width 0.3s;
}

.progress-text {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}

.wizard-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    padding: 1.5rem;
    text-align: center;
}

.wizard-section {
    background: var(--primary);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 1rem;
}

.wizard-question {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1.5rem;
    line-height: 1.4;
}

.answer-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.answer-btn {
    flex: 1;
    min-width: 80px;
    max-width: 120px;
    padding: 1rem;
    border: 3px solid var(--border);
    border-radius: var(--radius);
    background: white;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.answer-btn:hover { border-color: var(--primary); }
.answer-btn.selected { border-color: var(--primary); background: var(--primary); color: white; }
.answer-btn.yes:hover, .answer-btn.yes.selected { border-color: var(--success); background: var(--success); color: white; }
.answer-btn.no:hover, .answer-btn.no.selected { border-color: var(--danger); background: var(--danger); color: white; }
.answer-btn.na:hover, .answer-btn.na.selected { border-color: var(--text-light); background: var(--text-light); color: white; }

.camera-area {
    margin: 1rem 0;
    display: none;
}

.camera-overlay-text {
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 0.75rem;
    border-radius: var(--radius) var(--radius) 0 0;
    font-size: 0.85rem;
    text-align: left;
}

#cameraPreview {
    width: 100%;
    aspect-ratio: 9/16;
    max-height: 70vh;
    border-radius: 0 0 var(--radius) var(--radius);
    background: #000;
    object-fit: cover;
}

#photoCanvas {
    display: none;
}

.photo-preview {
    display: none;
    margin: 1rem 0;
}

.photo-preview img {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: var(--radius);
    border: 2px solid var(--success);
}

.comment-area {
    display: none;
    margin: 1rem 0;
}

.comment-area textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    min-height: 80px;
    resize: vertical;
}

.comment-area .required-note {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    padding: 1rem;
}

.login-card {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.login-logo {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-logo h1 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-top: 0.5rem;
}

.login-logo .icon {
    font-size: 3rem;
}

.review-item {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.review-item:last-child { border-bottom: none; }

.review-item .question { font-weight: 600; margin-bottom: 0.375rem; }
.review-item .answer { font-size: 0.95rem; }
.review-item .answer.yes { color: var(--success); }
.review-item .answer.no { color: var(--danger); }
.review-item .answer.na { color: var(--text-light); }
.review-item .comment { color: var(--text-light); font-size: 0.875rem; margin-top: 0.25rem; font-style: italic; }
.review-item .exception-badge { display: inline-block; background: var(--danger); color: white; padding: 0.125rem 0.5rem; border-radius: 4px; font-size: 0.75rem; }

.review-photo {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
}

.section-header {
    background: var(--primary);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-weight: 600;
    margin: 0.75rem 0 0.5rem;
    font-size: 0.95rem;
}

.shift-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.shift-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem 1.5rem;
    text-align: center;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: var(--text);
}

.shift-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.shift-card.completed { opacity: 0.6; pointer-events: none; border-color: var(--success); }
.shift-card .shift-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.shift-card h3 { font-size: 1.25rem; color: var(--primary); }
.shift-card p { font-size: 0.875rem; color: var(--text-light); margin-top: 0.25rem; }

.pagination {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.pagination a, .pagination span {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    font-size: 0.875rem;
}

.pagination .current {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.actions-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state p { font-size: 1.1rem; }

.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--primary-dark);
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
}

.mobile-nav-items {
    display: flex;
    justify-content: space-around;
    padding: 0.5rem 0;
}

.mobile-nav-item {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    text-align: center;
    padding: 0.375rem;
    font-size: 0.7rem;
    flex: 1;
}

.mobile-nav-item .icon { font-size: 1.25rem; display: block; }
.mobile-nav-item.active { color: var(--accent); }

.camera-capture-btn {
    margin-top: 0.5rem;
    padding: 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    min-height: 56px;
}

.camera-full-width {
    width: 100%;
}

.compact-row {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: nowrap;
}

.wizard-sticky-bar {
    margin-top: 1rem;
}

body.camera-active {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

body.camera-active .navbar,
body.camera-active .mobile-nav,
body.camera-active .progress-bar-wrapper,
body.camera-active .progress-text,
body.camera-active .answer-buttons,
body.camera-active .comment-area,
body.camera-active .photo-preview,
body.camera-active .wizard-sticky-bar,
body.camera-active .wizard-section,
body.camera-active .wizard-question {
    display: none !important;
}

body.camera-active .wizard-container {
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.camera-active .wizard-card {
    padding: 0;
    margin: 0;
    background: #000;
    border-radius: 0;
    box-shadow: none;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

body.camera-active .camera-area {
    flex: 1;
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 0;
    background: #000;
    position: relative;
}

body.camera-active .camera-area video {
    width: 100%;
    max-height: calc(100vh - 90px);
    object-fit: cover;
}

body.camera-active .camera-overlay-text {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 0.75rem;
    background: rgba(0,0,0,0.6);
    color: white;
    font-size: 0.85rem;
    z-index: 10;
    text-align: center;
}

body.camera-active .camera-capture-btn {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    padding: 1.25rem;
    font-size: 1.3rem;
    border-radius: 0;
    min-height: 70px;
    z-index: 10;
}

.incomplete-banner {
    background: linear-gradient(135deg, #e67e22, #d35400);
    color: white;
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    box-shadow: 0 2px 8px rgba(230,126,34,0.3);
    flex-wrap: wrap;
}

.incomplete-banner-text {
    font-weight: 600;
    font-size: 0.95rem;
}

.incomplete-banner-detail {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-top: 0.25rem;
}

.incomplete-banner .btn {
    background: white;
    color: var(--accent-dark);
    font-weight: 700;
    white-space: nowrap;
    padding: 0.6rem 1.5rem;
}

@media (max-width: 768px) {
    .hamburger { display: block; }

    .navbar-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--primary-dark);
        flex-direction: column;
        padding: 0.5rem;
    }

    .navbar-menu.open { display: flex; }

    .nav-link { padding: 0.75rem 1rem; width: 100%; }

    .mobile-nav { display: block; }

    body { padding-bottom: 60px; }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .rig-grid {
        grid-template-columns: 1fr;
    }

    .shift-cards { grid-template-columns: 1fr; }

    .wizard-container {
        padding: 0.5rem;
    }

    .wizard-card {
        padding: 0.75rem;
    }

    .wizard-question {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }

    .wizard-section {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
        margin-bottom: 0.5rem;
    }

    .answer-btn {
        padding: 0.6rem 0.5rem;
        font-size: 0.95rem;
        min-width: 60px;
        max-width: none;
        flex: 1;
    }

    .answer-buttons {
        gap: 0.5rem;
        margin-bottom: 0.5rem;
    }

    .progress-bar-wrapper {
        margin-bottom: 0.5rem;
        height: 8px;
    }

    .progress-text {
        font-size: 0.8rem;
        margin-bottom: 0.5rem;
    }

    .comment-area {
        margin: 0.5rem 0;
    }

    .comment-area textarea {
        min-height: 60px;
        font-size: 0.9rem;
    }

    .camera-area {
        margin: 0.5rem 0;
    }

    .camera-capture-btn {
        padding: 0.875rem;
        font-size: 1rem;
    }

    .photo-preview {
        margin: 0.5rem 0;
    }

    .wizard-sticky-bar {
        position: sticky;
        bottom: 0;
        background: var(--bg);
        padding: 0.5rem 0;
        margin-top: 0.5rem;
        z-index: 100;
    }

    .container {
        padding: 0.5rem;
    }

    .page-title {
        font-size: 1.25rem;
        margin-bottom: 0.75rem;
    }

    .card {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .stat-card {
        padding: 0.75rem;
    }

    .stat-number {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }
}

.loading-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.checkbox-group {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem;
    font-weight: normal;
    cursor: pointer;
}

.checkbox-group label:hover { background: #f8f9fa; border-radius: 4px; }

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.wizard-body {
    padding-bottom: 0;
    background: var(--bg);
    min-height: 100vh;
}

.wizard-topbar {
    display: flex;
    align-items: center;
    background: var(--primary);
    color: white;
    padding: 0.75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 200;
}

.wizard-topbar-title {
    flex: 1;
    text-align: center;
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 0.5rem;
}

.wizard-topbar-spacer {
    width: 60px;
    flex-shrink: 0;
}

.wizard-exit-btn {
    background: rgba(255,255,255,0.15);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: var(--radius);
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

.wizard-exit-btn:active {
    background: rgba(255,255,255,0.3);
}

.exit-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.exit-modal {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 360px;
    width: 100%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.exit-modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.75rem;
}

.exit-modal-text {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 1.25rem;
    line-height: 1.4;
}

.exit-modal-buttons {
    display: flex;
    gap: 0.75rem;
}

.exit-modal-buttons .btn {
    flex: 1;
}

.btn-danger {
    background: #e74c3c;
    color: white;
    border: none;
}

.btn-danger:hover {
    background: #c0392b;
}

body.camera-active .wizard-topbar {
    display: none !important;
}

body.camera-active .exit-modal-overlay {
    display: none !important;
}
