:root {
  --bg: #0b1220;
  --panel: #111827;
  --panel-soft: #1f2937;
  --text: #f8fafc;
  --muted: #cbd5e1;
  --line: rgba(255,255,255,.12);
  --accent: #21c6b7;
  --accent-2: #6ee7b7;
  --danger: #ef4444;
  --shadow: 0 18px 45px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }

.app-header { position: sticky; top: 0; z-index: 10; display: flex; gap: 14px; align-items: center; padding: 16px; background: linear-gradient(180deg, rgba(11,18,32,.98), rgba(11,18,32,.86)); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.brand-mark { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #06201d; font-weight: 900; font-size: 20px; box-shadow: var(--shadow); }
h1 { margin: 0; font-size: 20px; }
.app-header p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }

.app-shell { padding: 16px; max-width: 980px; margin: 0 auto; }
.view { display: none; animation: fade .18s ease-out; }
.view.active { display: block; }
@keyframes fade { from { opacity: .4; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.status-card, .panel, .action-card { background: linear-gradient(180deg, rgba(31,41,55,.96), rgba(17,24,39,.96)); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.status-card { display: flex; justify-content: space-between; gap: 12px; padding: 14px; margin-bottom: 16px; color: var(--muted); }
.status-card strong { color: var(--text); }

.actions-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.action-card { min-height: 156px; color: var(--text); text-align: left; padding: 18px; border: 1px solid var(--line); cursor: pointer; }
.action-card:active { transform: scale(.99); }
.action-card strong { display: block; margin-top: 12px; font-size: 17px; }
.action-card small { display: block; margin-top: 7px; color: var(--muted); line-height: 1.35; }
.action-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: rgba(33,198,183,.14); color: var(--accent-2); font-size: 24px; }

.panel { padding: 16px; margin: 16px 0; }
.panel h2, .panel h3 { margin: 0 0 10px; }
.panel p { color: var(--muted); line-height: 1.55; }
.view-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.view-nav h2 { margin: 0; font-size: 21px; }
.back-btn { width: 44px; height: 44px; padding: 0; border-radius: 50%; }

button { border: 0; border-radius: 14px; padding: 13px 16px; background: var(--accent); color: #06201d; font-weight: 800; cursor: pointer; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.secondary { background: rgba(255,255,255,.08); color: var(--text); border: 1px solid var(--line); }
button.danger { background: rgba(239,68,68,.16); color: #fecaca; border: 1px solid rgba(239,68,68,.34); }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }

.camera-box { position: relative; background: #020617; border-radius: 22px; min-height: 360px; overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); }
video { width: 100%; height: 360px; object-fit: cover; background: #020617; display: block; }
.scan-frame { position: absolute; inset: 22%; border: 3px solid var(--accent); border-radius: 20px; box-shadow: 0 0 0 999px rgba(0,0,0,.25); }
.result-box { white-space: pre-wrap; min-height: 64px; padding: 12px; background: rgba(2,6,23,.55); color: #d1fae5; border-radius: 14px; border: 1px solid var(--line); overflow: auto; }
.asset-preview { padding: 14px; background: rgba(33,198,183,.09); border: 1px solid rgba(33,198,183,.28); border-radius: 14px; margin-top: 10px; }
.asset-preview strong { display: block; margin-bottom: 6px; }

input, textarea, select { width: 100%; padding: 12px; border-radius: 13px; border: 1px solid var(--line); background: rgba(2,6,23,.42); color: var(--text); font: inherit; }
textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.check-line { display: flex !important; align-items: center; gap: 10px !important; }
.check-line input { width: auto; }
.preview-image { max-width: 100%; border-radius: 16px; border: 1px solid var(--line); margin: 12px 0; }

.queue-list { display: grid; gap: 12px; margin-top: 14px; }
.queue-item { padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: rgba(2,6,23,.35); }
.queue-item header { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.queue-item pre { white-space: pre-wrap; overflow: auto; color: #e2e8f0; }
.badge { display: inline-flex; align-items: center; border-radius: 99px; padding: 3px 8px; background: rgba(33,198,183,.16); color: var(--accent-2); font-weight: 700; font-size: 12px; }
.toast { position: fixed; left: 16px; right: 16px; bottom: 16px; padding: 14px 16px; background: #f8fafc; color: #020617; border-radius: 16px; box-shadow: var(--shadow); z-index: 20; font-weight: 700; }
.hidden { display: none !important; }

@media (max-width: 720px) {
  .actions-grid, .form-grid { grid-template-columns: 1fr; }
  .camera-box, video { min-height: 320px; height: 320px; }
  .status-card { display: grid; }
}

.ocr-tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 12px 0; }
.ocr-tools label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.tip { font-size: 13px; border-left: 3px solid var(--accent); padding-left: 10px; }

@media (max-width: 720px) {
  .ocr-tools { grid-template-columns: 1fr; }
}
