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

:root {
  --blue: #0066CC;
  --blue-light: #E8F0FB;
  --red: #CC0000;
  --red-light: #FFE5E5;
  --green: #00875A;
  --bg: #F5F7FA;
  --white: #fff;
  --border: #E0E0E0;
  --text: #111;
  --muted: #888;
  --radius: 12px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ── Header ── */
header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  padding-top: max(12px, env(safe-area-inset-top));
}
.header-title { font-size: 22px; font-weight: 800; color: var(--blue); }
.header-sub   { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Tab Bar ── */
.tab-bar {
  display: flex;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--white);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 0 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  border-top: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.tab span { font-size: 22px; }
.tab.active { color: var(--blue); border-top-color: var(--blue); font-weight: 700; }

/* ── Tab Content ── */
.tab-content {
  display: none;
  position: fixed;
  top: 68px; left: 0; right: 0;
  bottom: 56px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.tab-content.active { display: flex; flex-direction: column; }

/* ── Camera ── */
.camera-container {
  position: relative;
  flex: 1;
  background: #000;
  overflow: hidden;
}
#video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.target-frame {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.target-inner {
  width: 300px;
  height: 76px;
  border: 3px solid #00FF88;
  border-radius: 8px;
  box-shadow: 0 0 0 2000px rgba(0,0,0,.45);
}
.target-hint {
  color: #fff;
  font-size: 13px;
  margin-top: 12px;
  background: rgba(0,0,0,.5);
  padding: 4px 12px;
  border-radius: 6px;
}

.scan-controls {
  background: #111;
  padding: 20px 0 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.capture-btn {
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .1s;
}
.capture-btn:active { transform: scale(.93); }
.capture-inner {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: #fff;
}
.scan-hint { color: #888; font-size: 12px; }

/* ── List ── */
.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: #444;
}
.btn-export {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-export:active { opacity: .8; }

.entry-list { padding: 12px; display: flex; flex-direction: column; gap: 10px; }

.entry-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.07);
}
.entry-info { flex: 1; }
.entry-plate { font-size: 20px; font-weight: 700; letter-spacing: 2px; color: #111; }
.entry-code  { font-size: 16px; font-weight: 600; color: var(--blue); margin-top: 4px; }
.entry-date  { font-size: 12px; color: var(--muted); margin-top: 4px; }

.btn-delete {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--red-light);
  border: none;
  font-size: 16px;
  color: var(--red);
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 12px;
}
.btn-delete:active { opacity: .7; }

.empty-state {
  text-align: center;
  padding: 60px 32px;
  color: #555;
}
.empty-state p { font-size: 16px; font-weight: 600; }
.empty-sub { font-size: 13px; color: var(--muted); margin-top: 8px; }

/* ── Manuell-Tab ── */
.manual-container {
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.manual-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
}
.manual-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 24px;
  line-height: 1.5;
}
.manual-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
  display: block;
}
.manual-plate-input {
  width: 100%;
  margin-bottom: 16px;
}
.btn-manual-save {
  width: 100%;
  padding: 16px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity .15s;
}
.btn-manual-save:disabled {
  opacity: .35;
  cursor: default;
}
.btn-manual-save:not(:disabled):active { opacity: .8; }

/* ── Modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  padding-bottom: env(safe-area-inset-bottom);
}
.modal-box {
  background: var(--white);
  border-radius: 20px 20px 0 0;
  padding: 28px 24px 32px;
  width: 100%;
}
.modal-title { font-size: 20px; font-weight: 700; margin-bottom: 20px; }
.modal-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; display: block; }

.plate-input {
  width: 100%;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #000;
  outline: none;
  transition: border-color .15s;
}
.plate-input:focus { border-color: var(--blue); }

.code-preview {
  background: var(--blue-light);
  border-radius: 10px;
  padding: 14px;
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.code-label { font-size: 13px; color: var(--blue); font-weight: 600; }
.code-value  { font-size: 24px; font-weight: 800; color: var(--blue); letter-spacing: 2px; }

.modal-buttons {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}
.btn-cancel, .btn-confirm {
  flex: 1;
  padding: 14px;
  border-radius: 10px;
  border: none;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.btn-cancel  { background: #eee; color: #555; }
.btn-confirm { background: var(--blue); color: #fff; }
.btn-cancel:active, .btn-confirm:active { opacity: .85; }

/* ── OCR Status ── */
.ocr-status {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f0f0f0;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 14px;
  color: #444;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid #ccc;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #222;
  color: #fff;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  z-index: 300;
  white-space: nowrap;
  animation: fadeInOut 2.5s ease forwards;
}
@keyframes fadeInOut {
  0%   { opacity: 0; transform: translateX(-50%) translateY(10px); }
  15%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}
