:root {
  --ice-50: #f0f9ff;
  --ice-100: #dff1fb;
  --ice-500: #2ba9e0;
  --navy-900: #0b2b45;
  --navy-700: #123a5c;
  --gray-500: #5b6b78;
  --gray-200: #dde5eb;
  --red-500: #d64545;
  --green-600: #1f9d55;
  --radius: 12px;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(180deg, var(--ice-50) 0%, #ffffff 260px);
  color: var(--navy-900);
}

.topbar {
  background: var(--navy-900);
  color: #fff;
}
.topbar-inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 20px;
}
.brand { display: flex; align-items: center; }
.brand-logo-box {
  display: inline-flex;
  align-items: center;
  background: #fff;
  border-radius: 10px;
  padding: 6px 16px;
}
.brand-logo-img {
  height: 52px;
  width: auto;
  display: block;
}

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.hero { text-align: center; margin: 12px 0 22px; }
.hero h1 { font-size: 1.4rem; margin: 0 0 8px; color: var(--navy-900); }
.hero p { margin: 0; color: var(--gray-500); font-size: 0.92rem; line-height: 1.5; }

.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 22px 18px;
  box-shadow: 0 4px 20px rgba(11, 43, 69, 0.08);
  border: 1px solid var(--gray-200);
}

.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--navy-700);
  margin-bottom: 6px;
}
.req { color: var(--red-500); }

input[type="text"],
input[type="tel"],
textarea,
select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  color: var(--navy-900);
  transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--ice-500);
  box-shadow: 0 0 0 3px rgba(43, 169, 224, 0.15);
}
textarea { resize: vertical; }

.field.invalid input,
.field.invalid select,
.field.invalid textarea {
  border-color: var(--red-500);
}

.imei-row { display: flex; gap: 8px; }
.imei-row input { flex: 1; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--ice-100);
  color: var(--navy-700);
  border: 1px solid var(--ice-500);
  border-radius: 8px;
  padding: 0 14px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn-secondary svg { width: 16px; height: 16px; }
.btn-secondary:hover { background: var(--ice-500); color: #fff; }

.hint { margin: 6px 0 0; font-size: 0.8rem; color: var(--gray-500); }
.hint.ok { color: var(--green-600); }
.hint.bad { color: var(--red-500); }

.error-msg {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: var(--red-500);
  min-height: 0;
}
.error-msg:empty { display: none; }

.upload-box {
  position: relative;
  border: 1.5px dashed var(--gray-200);
  border-radius: 10px;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--ice-50);
}
.upload-box input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--gray-500);
  font-size: 0.85rem;
  padding: 20px;
  text-align: center;
}
.upload-placeholder svg { width: 28px; height: 28px; color: var(--ice-500); }
#upload-preview {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  background: #000;
}

.form-level-error {
  background: #fdecec;
  border: 1px solid var(--red-500);
  color: var(--red-500);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin: 0 0 16px;
}

.btn-primary {
  width: 100%;
  background: var(--navy-900);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 14px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: opacity 0.15s;
}
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary:not(:disabled):hover { background: var(--navy-700); }

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#success-section { text-align: center; }
.success-icon { color: var(--green-600); margin-bottom: 6px; }
.success-icon svg { width: 52px; height: 52px; }
#success-section h2 { margin: 0 0 6px; font-size: 1.25rem; }
.success-sub { color: var(--gray-500); font-size: 0.9rem; margin: 0 0 18px; }

.summary {
  text-align: left;
  background: var(--ice-50);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 0.88rem;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--gray-200);
}
.summary-row:last-child { border-bottom: none; }
.summary-row .k { color: var(--gray-500); }
.summary-row .v { font-weight: 600; text-align: right; color: var(--navy-900); }

.mode-switch {
  max-width: 560px;
  margin: 0 auto 16px;
  display: flex;
  gap: 8px;
  background: var(--ice-100);
  border-radius: 12px;
  padding: 5px;
}
.mode-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 11px 8px;
  border-radius: 9px;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--navy-700);
  cursor: pointer;
}
.mode-btn.active {
  background: var(--navy-900);
  color: #fff;
}

.lookup-result {
  margin-top: 20px;
  border-top: 1px solid var(--gray-200);
  padding-top: 20px;
}
.lookup-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 14px;
}
.lookup-badge.active {
  background: #eafaf0;
  color: var(--green-600);
  border: 1px solid var(--green-600);
}
.lookup-badge.expired {
  background: #fdecec;
  color: var(--red-500);
  border: 1px solid var(--red-500);
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--ice-50);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 20px;
}
.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--gray-500);
  cursor: pointer;
}
.tab-btn.active {
  background: #fff;
  color: var(--navy-900);
  box-shadow: 0 1px 4px rgba(11, 43, 69, 0.12);
}

.form-level-success {
  background: #eafaf0;
  border: 1px solid var(--green-600);
  color: var(--green-600);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin: 0 0 16px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--ice-500);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}
.btn-link:hover { text-decoration: underline; }

.dealer-bar {
  max-width: 560px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--navy-900);
  color: #fff;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.85rem;
}
.dealer-label { color: var(--ice-100); margin-right: 6px; }
.dealer-code { color: var(--ice-100); margin-left: 6px; font-size: 0.8rem; }

.scan-tools {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.scan-tools .btn-secondary { flex: 1; justify-content: center; }
.file-fallback-btn { cursor: pointer; text-align: center; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(11, 43, 69, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
.modal[hidden] { display: none; }
.modal-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  width: 100%;
  max-width: 420px;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--navy-900);
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--gray-500);
}
#qr-reader { width: 100%; border-radius: 8px; overflow: hidden; }

@media (max-width: 420px) {
  .imei-row { flex-direction: column; }
  .btn-secondary { justify-content: center; padding: 10px; }
}
