:root {
    --navy: #0f172a;
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --green: #15803d;
    --amber: #b45309;
    --red: #b91c1c;
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-500: #64748b;
    --slate-700: #334155;
    --white: #fff;
    --radius: 18px;
    --shadow: 0 14px 34px rgba(15, 23, 42, .10);
}
* { box-sizing: border-box; }
html { background: var(--slate-100); }
body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--navy);
    background: linear-gradient(180deg, #eaf1ff 0, var(--slate-100) 240px);
    -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; }
button { touch-action: manipulation; }
.app-header {
    min-height: 86px;
    padding: calc(18px + env(safe-area-inset-top)) 18px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--white);
    background: var(--navy);
}
.app-header h1 { margin: 2px 0 0; font-size: 22px; }
.eyebrow { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: .13em; opacity: .7; }
.icon-link {
    width: 42px; height: 42px; display: grid; place-items: center;
    color: white; text-decoration: none; font-size: 24px;
    border: 1px solid rgba(255,255,255,.25); border-radius: 14px;
}
.app-shell { width: min(820px, 100%); margin: 0 auto; padding: 16px 14px calc(28px + env(safe-area-inset-bottom)); }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: -4px; }
.stats-grid article { padding: 13px 10px; background: white; border-radius: 16px; box-shadow: var(--shadow); text-align: center; }
.stats-grid strong { display: block; font-size: 21px; }
.stats-grid span { display: block; margin-top: 2px; color: var(--slate-500); font-size: 11px; }
.export-actions { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 10px; }
.export-actions .btn { display: grid; place-items: center; text-decoration: none; }
.btn.export.excel { color: white; background: #15803d; }
.btn.export.pdf { color: white; background: #b91c1c; }
.btn.export.csv { color: var(--navy); background: white; border: 1px solid var(--slate-200); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin: 16px 0; padding: 5px; background: #dce5f3; border-radius: 16px; }
.tab { border: 0; border-radius: 12px; padding: 12px 8px; font-weight: 700; color: var(--slate-700); background: transparent; }
.tab.active { color: var(--navy); background: white; box-shadow: 0 4px 14px rgba(15,23,42,.08); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.scanner-card, .manual-search, .result-card, .list-filter { background: white; border-radius: var(--radius); box-shadow: var(--shadow); }
.scanner-card { overflow: hidden; }
.video-wrap { position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: #020617; }
video { width: 100%; height: 100%; object-fit: cover; }
.scan-mask { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; background: linear-gradient(rgba(0,0,0,.38), rgba(0,0,0,.38)); }
.scan-window {
    position: relative; width: 90%; height: 32%; min-height: 105px;
    border: 3px solid rgba(255,255,255,.95); border-radius: 14px;
    box-shadow: 0 0 0 999px rgba(0,0,0,.16) inset;
}
.scan-window::before, .scan-window::after { content: ''; position: absolute; width: 34px; height: 34px; border-color: #60a5fa; }
.scan-window::before { left: -3px; top: -3px; border-left: 5px solid #60a5fa; border-top: 5px solid #60a5fa; border-radius: 12px 0 0; }
.scan-window::after { right: -3px; bottom: -3px; border-right: 5px solid #60a5fa; border-bottom: 5px solid #60a5fa; border-radius: 0 0 12px; }
.scan-line { position: absolute; left: 4%; right: 4%; top: 50%; height: 2px; background: #ef4444; box-shadow: 0 0 12px #ef4444; animation: scan 1.35s ease-in-out infinite alternate; }
@keyframes scan { from { transform: translateY(-35px); } to { transform: translateY(35px); } }
.camera-message { position: absolute; left: 12px; right: 12px; bottom: 12px; padding: 9px 11px; color: white; font-size: 12px; line-height: 1.35; background: rgba(15,23,42,.75); border-radius: 10px; text-align: center; }
.scanner-actions { display: grid; grid-template-columns: 1.3fr .8fr .7fr; gap: 8px; padding: 12px 12px 4px; }
.iphone-scan-row { padding: 8px 12px 2px; }
.iphone-scan-row .btn { width: 100%; }
.scanner-status { min-height: 18px; margin: 7px 14px 13px; color: var(--slate-500); font-size: 12px; line-height: 1.4; }
.btn { min-height: 44px; border: 0; border-radius: 12px; padding: 10px 13px; font-weight: 700; cursor: pointer; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { color: white; background: var(--blue); }
.btn.primary:active { background: var(--blue-dark); }
.btn.secondary { color: var(--navy); background: var(--slate-100); border: 1px solid var(--slate-200); }
.btn.ghost { color: var(--slate-700); background: transparent; border: 1px solid var(--slate-200); }
.btn.success { color: white; background: var(--green); }
.btn.full { width: 100%; }
.manual-search { margin-top: 14px; padding: 14px; }
.manual-search label, .operator-grid label { display: block; color: var(--slate-700); font-size: 12px; font-weight: 700; }
.input-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 7px; }
input, select { width: 100%; min-height: 44px; border: 1px solid #cbd5e1; border-radius: 12px; padding: 10px 12px; color: var(--navy); background: white; outline: none; }
input:focus, select:focus { border-color: #60a5fa; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.result-card { margin-top: 14px; padding: 16px; }
.result-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.result-top h2 { margin: 7px 0 3px; font-size: 20px; }
.result-top p { margin: 0; color: var(--slate-500); }
.badge { display: inline-flex; padding: 5px 8px; border-radius: 999px; color: #1d4ed8; background: #dbeafe; font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.status-badge { flex: 0 0 auto; padding: 7px 9px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.status-badge.pending { color: var(--red); background: #fee2e2; }
.status-badge.complete { color: var(--green); background: #dcfce7; }
.asset-details { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 15px 0; overflow: hidden; border: 1px solid var(--slate-200); border-radius: 14px; background: var(--slate-200); }
.asset-details div { min-width: 0; padding: 11px; background: white; }
.asset-details div:last-child { grid-column: 1 / -1; }
.asset-details dt { color: var(--slate-500); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.asset-details dd { margin: 4px 0 0; font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }
.operator-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.operator-grid input { margin-top: 6px; }
.photo-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.photo-grid.single-photo { max-width: 560px; margin: 0 auto; }
.photo-box { padding: 12px; border: 1px solid var(--slate-200); border-radius: 15px; background: var(--slate-50); }
.photo-box.done { border-color: #86efac; background: #f0fdf4; }
.photo-box-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.photo-box-head strong { display: block; font-size: 14px; }
.photo-box-head small { display: block; margin-top: 2px; color: var(--slate-500); }
.photo-box-head span { font-size: 23px; color: var(--slate-500); }
.photo-box.done .photo-box-head span { color: var(--green); }
.photo-box img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; margin-top: 10px; border-radius: 10px; background: var(--slate-200); }
.photo-actions { display: grid; gap: 7px; margin-top: 10px; }
.file-button { display: grid; place-items: center; }
.result-footer { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 14px; }
.choice-list { display: grid; gap: 8px; margin-top: 10px; }
.choice-item { width: 100%; padding: 12px; text-align: left; border: 1px solid var(--slate-200); border-radius: 13px; background: var(--slate-50); }
.choice-item strong, .choice-item span { display: block; }
.choice-item span { margin-top: 3px; color: var(--slate-500); font-size: 12px; }
.list-filter { display: grid; grid-template-columns: 1fr 150px; gap: 8px; padding: 12px; margin-bottom: 12px; }
.asset-list { display: grid; gap: 9px; }
.asset-list-item { padding: 13px; border: 1px solid var(--slate-200); border-radius: 15px; background: white; box-shadow: 0 6px 18px rgba(15,23,42,.05); }
.asset-list-item button { width: 100%; padding: 0; border: 0; background: transparent; text-align: left; }
.asset-list-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.asset-list-item h3 { margin: 0; font-size: 15px; }
.asset-list-item p { margin: 4px 0 0; color: var(--slate-500); font-size: 12px; }
.code-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.code-row span { padding: 8px; border-radius: 10px; background: var(--slate-50); font-size: 11px; overflow-wrap: anywhere; }
.muted { color: var(--slate-500); text-align: center; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); max-width: calc(100% - 28px); transform: translate(-50%, 120px); padding: 11px 15px; color: white; background: var(--navy); border-radius: 12px; box-shadow: var(--shadow); opacity: 0; transition: .25s; text-align: center; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }
.busy-overlay { position: fixed; z-index: 60; inset: 0; display: grid; place-content: center; justify-items: center; color: white; background: rgba(15,23,42,.78); }
.spinner { width: 42px; height: 42px; border: 4px solid rgba(255,255,255,.25); border-top-color: white; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
@media (max-width: 560px) {
    .photo-grid, .operator-grid, .export-actions { grid-template-columns: 1fr; }
    .list-filter { grid-template-columns: 1fr; }
    .asset-details { grid-template-columns: 1fr; }
    .asset-details div:last-child { grid-column: auto; }
}
@media (min-width: 760px) {
    .video-wrap { aspect-ratio: 16 / 9; }
    .scan-window { width: 78%; height: 34%; }
}
