:root {
    --bg-canvas: #090e1a;
    --bg-shell: #0f172a;
    --bg-card: #151e2e;
    --bg-input: #0b1220;
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-sky: #0ea5e9;
    --accent-sky-dark: #0284c7;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #ef4444;
    --accent-violet: #a78bfa;
    --accent-pink: #ec4899;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.mono {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

body.portal-body {
    background-color: var(--bg-canvas);
    color: var(--text-main);
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    position: relative;
    overflow-x: hidden;
}

.ambient-grid {
    display: none;
}

@media (min-width: 640px) {
    body.portal-body {
        padding: 20px;
    }
    .ambient-grid {
        display: block;
        position: fixed;
        inset: 0;
        pointer-events: none;
        opacity: 0.25;
        background-image: radial-gradient(rgba(56, 189, 248, 0.2) 1px, transparent 1px);
        background-size: 28px 28px;
    }
}

.app-container {
    width: 100%;
    max-width: 430px;
    min-height: 100dvh;
    background: var(--bg-shell);
    padding: 16px 20px 28px;
    text-align: center;
    position: relative;
    z-index: 1;
    box-shadow: 0 20px 50px -15px rgba(0, 0, 0, 0.75);
}

@media (min-width: 640px) {
    .app-container {
        min-height: 780px;
        border-radius: 34px;
        border: 5px solid #1e293b;
        padding: 18px 22px 30px;
    }
}

.app-container.has-nav {
    padding-bottom: 94px;
}

/* Top Sync Bar */
.status-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-muted);
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border-subtle);
}

.sync-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sync-label {
    color: #34d399;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.sep {
    color: #475569;
}

.pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.65);
    animation: pulseDot 2.2s infinite;
}

@keyframes pulseDot {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.65); }
    70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.brand-badge {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    padding: 2px 8px;
    border-radius: 999px;
}

/* Header */
.app-header {
    margin-bottom: 18px;
    text-align: left;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.company-logo {
    width: 46px;
    height: 46px;
    object-fit: contain;
    background: #ffffff;
    padding: 4px;
    border-radius: 14px;
    flex-shrink: 0;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.brand-meta {
    min-width: 0;
    flex: 1;
}

.brand-title-line {
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.verified-pill {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #7dd3fc;
    background: rgba(14, 165, 233, 0.14);
    border: 1px solid rgba(56, 189, 248, 0.25);
    padding: 2px 7px;
    border-radius: 6px;
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-header p {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.screen-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.hidden {
    display: none !important;
}

.section-kicker {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    padding: 0 2px;
}

/* PIN Pad */
.pin-display {
    background: var(--bg-input);
    padding: 16px;
    border-radius: 16px;
    border: 1px solid var(--border-subtle);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.45);
}

.dots {
    font-size: 1.85rem;
    letter-spacing: 12px;
    color: #38bdf8;
    line-height: 1;
}

.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.key {
    background: var(--bg-card);
    color: #fff;
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    font-size: 1.25rem;
    padding: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease;
}

.key:hover {
    border-color: var(--border-strong);
    background: #1c283d;
}

.key:active {
    transform: scale(0.96);
}

.action-key {
    background: rgba(2, 132, 199, 0.22);
    border-color: rgba(56, 189, 248, 0.35);
    color: #7dd3fc;
}

.key.go {
    background: linear-gradient(135deg, #10b981, #059669);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px -6px rgba(16, 185, 129, 0.55);
}

/* Menu Cards */
.menu-card {
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: left;
    width: 100%;
    background: linear-gradient(145deg, rgba(28, 39, 60, 0.9), rgba(15, 23, 42, 0.96));
    border: 1px solid var(--border-subtle);
    border-left-width: 4px;
    border-radius: 18px;
    padding: 15px 16px;
    cursor: pointer;
    color: #fff;
    transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.menu-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
    box-shadow: 0 12px 24px -12px rgba(0, 0, 0, 0.65);
}

.menu-card:active {
    transform: scale(0.985);
}

.menu-card.attend { border-left-color: var(--accent-sky); }
.menu-card.qa { border-left-color: var(--accent-emerald); }
.menu-card.prog { border-left-color: var(--accent-amber); }
.menu-card.diary { border-left-color: var(--accent-pink); }
.menu-card.hrs { border-left-color: var(--accent-violet); }

.menu-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.menu-text {
    flex: 1;
    min-width: 0;
}

.menu-text strong {
    display: block;
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.menu-card.attend strong { color: #38bdf8; }
.menu-card.qa strong { color: #34d399; }
.menu-card.prog strong { color: #fbbf24; }
.menu-card.diary strong { color: #f472b6; }
.menu-card.hrs strong { color: #c4b5fd; }

.menu-text small {
    display: block;
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 2px;
}

.menu-chev {
    color: #64748b;
    font-size: 1.3rem;
    font-weight: 600;
}

/* Scanner & Toggle */
.user-badge {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #e2e8f0;
}

.action-toggle {
    display: flex;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 4px;
    gap: 4px;
}

.toggle-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.85rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.toggle-btn.active {
    background: var(--accent-sky-dark);
    color: #fff;
    box-shadow: 0 4px 12px -3px rgba(2, 132, 199, 0.55);
}

.scan-instructions {
    font-size: 0.8rem;
    color: var(--text-muted);
}

#qr-reader {
    background: var(--bg-input);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}

.status-card {
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.4;
}

.status-card.info { background: rgba(2, 132, 199, 0.2); border: 1px solid rgba(56, 189, 248, 0.35); color: #bae6fd; }
.status-card.success { background: rgba(16, 185, 129, 0.2); border: 1px solid rgba(52, 211, 153, 0.35); color: #a7f3d0; }
.status-card.error { background: rgba(239, 68, 68, 0.2); border: 1px solid rgba(248, 113, 113, 0.35); color: #fecaca; }

.error-msg {
    color: #f87171;
    font-size: 0.82rem;
    min-height: 1em;
}

.retry-btn {
    background: var(--accent-sky-dark);
    color: #fff;
    border: none;
    border-radius: 14px;
    padding: 13px;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
}

.logout-btn {
    background: rgba(255, 255, 255, 0.02);
    color: #cbd5e1;
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 11px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border-strong);
}

.confirm-box {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.confirm-box button {
    flex: 1;
    border: none;
    border-radius: 12px;
    padding: 12px;
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
}

.confirm-yes { background: #10b981; }
.confirm-no { background: #334155; }
.confirm-box .forgot-btn {
    flex: 1 1 100%;
    background: transparent;
    border: 1px solid var(--border-strong);
    color: #cbd5e1;
    font-size: 0.82rem;
}

.manual-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 14px;
}

.manual-title { font-weight: 700; font-size: 0.95rem; text-align: center; }
.manual-form label { font-size: 0.8rem; color: var(--text-muted); }
.manual-form textarea {
    background: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 10px;
    font-size: 0.92rem;
    width: 100%;
    resize: vertical;
}
.manual-note { font-size: 0.75rem; color: var(--text-muted); }

/* QA, Progress & Diary */
.qa-section { text-align: left; }
.qa-section h3 { font-size: 0.9rem; font-weight: 700; margin-bottom: 8px; color: #f1f5f9; }
.qa-section h3 small { color: var(--text-muted); font-weight: 500; }

.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.field input,
.field select,
.field textarea,
.qa-check textarea {
    width: 100%;
    background: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 0.92rem;
}

.field input[readonly],
.field select:disabled {
    opacity: 0.75;
    background: rgba(15, 23, 42, 0.55);
}

.qa-check {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-left: 3px solid var(--accent-sky);
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 10px;
}

.qa-check-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.qa-check-head strong { display: block; font-size: 0.88rem; }
.qa-check-head small { color: var(--text-muted); font-size: 0.74rem; }

.seg { display: flex; gap: 5px; }
.seg button {
    border: none;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    opacity: 0.45;
}
.seg button.on { opacity: 1; box-shadow: 0 0 0 2px #fff; }
.seg button[data-r="PASS"] { background: #10b981; }
.seg button[data-r="FAIL"] { background: #ef4444; }
.seg button[data-r="NA"] { background: #64748b; }
.seg button[data-r="ACCEPT"] { background: #10b981; }
.seg button[data-r="DECLINE"] { background: #ef4444; }

.qa-photo { margin-top: 8px; text-align: left; }
.photo-drop {
    display: block;
    border: 1.5px dashed rgba(52, 211, 153, 0.45);
    background: rgba(16, 185, 129, 0.05);
    border-radius: 14px;
    padding: 16px;
    cursor: pointer;
    color: #34d399;
    font-weight: 700;
    font-size: 0.85rem;
}
.photo-drop.small { padding: 10px; font-size: 0.82rem; }
.photo-drop.small small { color: #fbbf24; font-weight: 500; }

.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.thumb { position: relative; width: 72px; height: 72px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.thumb button {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: #ef4444;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}
.thumbs.big .thumb { width: 100%; height: auto; }
.thumbs.big .thumb img { height: auto; }

#qa-body { display: flex; flex-direction: column; gap: 14px; }

.qa-submit {
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    color: #fff;
    border: none;
    border-radius: 16px;
    padding: 14px;
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
    box-shadow: 0 10px 22px -8px rgba(14, 165, 233, 0.65);
}

.qa-draft {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(52, 211, 153, 0.4);
    color: #34d399;
    border-radius: 16px;
    padding: 12px;
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
}

.stage-box {
    background: var(--bg-card);
    border: 1px solid rgba(245, 158, 11, 0.45);
    border-radius: 14px;
    padding: 12px;
    margin: 4px 0 12px;
    text-align: left;
}
.stage-box h3 { font-size: 0.9rem; margin-bottom: 4px; }
.stage-bar { height: 8px; background: var(--bg-input); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.stage-bar div { height: 100%; background: #10b981; transition: width 0.25s ease; }
.stage-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.9rem;
    cursor: pointer;
}
.stage-row:last-of-type { border-bottom: none; }
.stage-row input { width: 22px; height: 22px; accent-color: #10b981; flex: none; }
.stage-ok { color: #34d399; font-weight: 700; font-size: 0.82rem; margin-top: 8px; }

#dy-list, #dy-edit { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.dy-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 12px 14px;
    cursor: pointer;
    text-align: left;
    width: 100%;
    color: #fff;
    margin-bottom: 8px;
}
.dy-card b { display: block; font-size: 0.9rem; }
.dy-card small { color: var(--text-muted); font-size: 0.74rem; }
.dy-sub { font-size: 0.82rem; color: #fbbf24; margin: 6px 0; }
.dy-pill { border-radius: 999px; padding: 3px 10px; font-size: 0.7rem; font-weight: 700; background: #334155; color: #fff; white-space: nowrap; }
.dy-pill.draft { background: #d97706; }
.dy-pill.done { background: #10b981; }
.dy-photo-btns { display: flex; gap: 8px; }
.dy-photo-btns label {
    flex: 1;
    text-align: center;
    border: 1.5px dashed rgba(52, 211, 153, 0.45);
    background: rgba(16, 185, 129, 0.05);
    border-radius: 12px;
    padding: 12px 6px;
    color: #34d399;
    font-weight: 700;
    font-size: 0.82rem;
    cursor: pointer;
}

/* Hours, Invoices & FAQ */
.mini { width: 100%; border-collapse: collapse; font-size: 0.78rem; background: var(--bg-card); border-radius: 12px; overflow: hidden; }
.mini th, .mini td { border: 1px solid var(--border-subtle); padding: 7px 6px; }
.mini th { background: var(--bg-input); color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase; }
.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--bg-card); padding: 8px 10px; border-radius: 14px; border: 1px solid var(--border-subtle); }
.week-nav button { background: #1e293b; color: #fff; border: 1px solid var(--border-subtle); border-radius: 10px; padding: 7px 13px; cursor: pointer; font-weight: 700; }
.total-bar { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 14px; padding: 12px; font-size: 0.9rem; }
.rate { width: 74px; background: var(--bg-input); color: var(--text-main); border: 1px solid var(--border-strong); border-radius: 8px; padding: 6px; text-align: right; }
.rate:disabled { opacity: 0.35; }
.note-small { font-size: 0.75rem; color: var(--text-muted); line-height: 1.45; }

.queue-banner { background: rgba(217, 119, 6, 0.22); border: 1px solid rgba(251, 191, 36, 0.4); color: #fde68a; border-radius: 12px; padding: 9px 12px; font-size: 0.78rem; margin-bottom: 10px; }
.queue-note { background: rgba(14, 165, 233, 0.18); border: 1px solid rgba(56, 189, 248, 0.35); color: #bae6fd; border-radius: 12px; padding: 9px 12px; font-size: 0.78rem; margin-bottom: 10px; }
.queue-note.ok { background: rgba(16, 185, 129, 0.2); border-color: rgba(52, 211, 153, 0.4); color: #a7f3d0; }

.faq details { text-align: left; background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 14px; padding: 11px 14px; }
.faq summary { cursor: pointer; font-weight: 700; font-size: 0.85rem; }
.faq details p { margin-top: 8px; font-size: 0.8rem; color: #cbd5e1; line-height: 1.5; }

.inv-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    text-align: left;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 8px;
    font-size: 0.84rem;
}
.inv-card small { color: var(--text-muted); }
.inv-card button { background: var(--accent-sky-dark); color: #fff; border: none; border-radius: 10px; padding: 8px 14px; font-weight: 700; cursor: pointer; }

.mismatch { color: #fbbf24 !important; }

/* Bottom Navigation Bar */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 430px;
    display: flex;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border-subtle);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    z-index: 50;
}

.bottom-nav button {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.62rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 2px;
    border-radius: 12px;
    transition: color 0.15s ease, background 0.15s ease;
}

.bottom-nav button span { font-size: 1.15rem; }
.bottom-nav button.on { color: #38bdf8; background: rgba(14, 165, 233, 0.12); }

/* Footer */
.app-footer {
    margin-top: 22px;
    padding-top: 14px;
    border-top: 1px solid var(--border-subtle);
}

.app-footer p {
    font-size: 0.72rem;
    color: #64748b;
}

.app-footer .credit {
    margin-top: 4px;
}
