* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: #000;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
    overflow: hidden;
    height: 100dvh;
    width: 100vw;
}

/* ── Scanner view ── */

#scanner-container {
    position: relative;
    width: 100vw;
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
}

#camera {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

/* ── Mode tabs (iOS segmented control style) ── */

#mode-tabs {
    position: absolute;
    top: max(16px, env(safe-area-inset-top, 16px));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    z-index: 10;
    border-radius: 9px;
    overflow: hidden;
    background: rgba(120, 120, 128, 0.24);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 2px;
    gap: 2px;
}

.mode-tab {
    padding: 7px 24px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: rgba(255, 255, 255, 0.7);
    background: transparent;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-tab.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.18);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* ── Side indicator ── */

#side-indicator {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 14px;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 700;
    z-index: 10;
    background: rgba(48, 209, 88, 0.25);
    color: #30d158;
    text-align: center;
    /* positioned dynamically via JS */
}

/* ── Status pill ── */

#status {
    position: absolute;
    top: calc(max(16px, env(safe-area-inset-top, 16px)) + 48px);
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 16px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
    z-index: 10;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    text-align: center;
    white-space: nowrap;
    max-width: 90vw;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Capture button (iOS camera style) ── */

#capture-btn {
    position: absolute;
    bottom: max(32px, env(safe-area-inset-bottom, 32px));
    left: 50%;
    transform: translateX(-50%);
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.2);
    color: transparent;
    font-size: 0;
    cursor: pointer;
    z-index: 10;
    transition: all 0.15s ease;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

#capture-btn::after {
    content: "";
    display: block;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    margin: 4px auto;
    transition: all 0.15s ease;
}

#capture-btn:not(:disabled):active::after {
    background: rgba(255, 255, 255, 0.8);
    transform: scale(0.9);
}

#capture-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

#capture-btn:disabled::after {
    background: rgba(255, 255, 255, 0.15);
}

/* ── Preview view ── */

#preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100dvh;
    padding: 24px;
    padding-top: max(24px, env(safe-area-inset-top, 24px));
    padding-bottom: max(24px, env(safe-area-inset-bottom, 24px));
    background: #000;
    position: relative;
    z-index: 20;
}

#preview-container h2 {
    margin-bottom: 20px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: rgba(255, 255, 255, 0.9);
}

#preview {
    max-width: 90vw;
    max-height: 55dvh;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

#preview-buttons {
    display: flex;
    gap: 12px;
    margin-top: 28px;
    width: 100%;
    max-width: 320px;
}

#retake-btn,
#confirm-btn,
#go-btn {
    flex: 1;
    padding: 14px 24px;
    border-radius: 14px;
    border: none;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.02em;
    cursor: pointer;
    transition: all 0.15s ease;
}

#retake-btn {
    background: rgba(120, 120, 128, 0.24);
    color: #fff;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

#retake-btn:active {
    background: rgba(120, 120, 128, 0.4);
    transform: scale(0.97);
}

#confirm-btn {
    background: #0a84ff;
    color: #fff;
}

#confirm-btn:active {
    background: #0070e0;
    transform: scale(0.97);
}

/* ── Submit container (both sides captured) ── */

#submit-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100dvh;
    padding: 24px;
    padding-top: max(24px, env(safe-area-inset-top, 24px));
    padding-bottom: max(24px, env(safe-area-inset-bottom, 24px));
    background: #000;
    overflow-y: auto;
    position: relative;
    z-index: 20;
}

#submit-container h2 {
    margin-bottom: 16px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: rgba(255, 255, 255, 0.9);
}

#both-previews {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    width: 100%;
    max-width: 320px;
}

.thumb-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.thumb-label {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.thumb-wrapper canvas {
    width: 100%;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.retake-side-btn {
    padding: 5px 12px;
    border-radius: 8px;
    border: none;
    font-size: 12px;
    font-weight: 600;
    background: rgba(120, 120, 128, 0.24);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
}

.retake-side-btn:active {
    background: rgba(120, 120, 128, 0.4);
}

#submit-container #go-btn {
    width: auto;
    flex: none;
    padding: 14px 48px;
    margin-bottom: 16px;
}

#go-btn {
    background: #30d158;
    color: #fff;
}

#go-btn:active {
    background: #28b74b;
    transform: scale(0.97);
}

#go-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ── Extracted Fields ── */

#extracted-fields {
    width: 100%;
    max-width: 320px;
    margin-top: 20px;
}

#extracted-fields h3 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 8px;
}

#fields-card {
    background: rgba(120, 120, 128, 0.16);
    border-radius: 12px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.field-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.field-label {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
}

.field-value {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    text-align: right;
}

.field-value.missing {
    color: rgba(255, 255, 255, 0.3);
    font-style: italic;
    font-weight: 400;
}

.doc-type-badge {
    align-self: flex-start;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(48, 209, 88, 0.2);
    color: #30d158;
    margin-bottom: 4px;
}

