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

:root {
  --primary: #1a73e8;
  --primary-dark: #1558b0;
  --surface: #ffffff;
  --bg: #f1f3f4;
  --text: #202124;
  --text-secondary: #5f6368;
  --border: #dadce0;
  --error: #d93025;
  --success: #188038;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.15);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.5;
}

/* ── Top app bar ── */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-bar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.app-bar .brand img {
  width: 32px;
  height: 32px;
  border-radius: 6px;
}

.app-bar .user-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-bar .user-email {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background .15s, box-shadow .15s, opacity .15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow); }
.btn-primary:disabled { opacity: .55; cursor: default; }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:hover { background: #e8f0fe; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 12px;
}
.btn-ghost:hover { background: #f1f3f4; }

.btn-full { width: 100%; }

/* ── Card ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* ── Login / landing page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  gap: 24px;
}

.login-hero {
  text-align: center;
}

.login-hero .app-icon {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
}

.login-hero h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 6px;
}

.login-hero p {
  color: var(--text-secondary);
  font-size: 15px;
}

.login-card {
  width: 100%;
  max-width: 400px;
}

.login-card h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 20px;
}

/* ── Form elements ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input {
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  width: 100%;
}
.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,.15);
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.form-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0;
  color: var(--text-secondary);
  font-size: 13px;
}
.form-divider::before,
.form-divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--border);
}

.form-group--inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.form-group--inline input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.form-group--inline label { font-size: 14px; color: var(--text); cursor: pointer; margin: 0; }

.form-footer {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-secondary);
}

.form-footer a,
.link-btn {
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
  font-weight: 500;
  background: none;
  border: none;
  font-size: inherit;
  padding: 0;
}
.form-footer a:hover,
.link-btn:hover { text-decoration: underline; }

/* ── Error / status messages ── */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-error { background: #fce8e6; color: var(--error); border: 1px solid #f5c6c4; }
.alert-success { background: #e6f4ea; color: var(--success); border: 1px solid #b7dfbf; }
.hidden { display: none !important; }

/* ── Scan history page ── */
.page-content {
  max-width: 600px;
  margin: 24px auto;
  padding: 0 16px;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 16px;
}

.scan-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scan-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  border-left: 3px solid var(--primary);
}

.scan-card .scan-value {
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  word-break: break-all;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.4;
}

.scan-card .scan-meta {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.scan-card .tracking-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #e8f0fe;
  color: var(--primary);
  border-radius: 100px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 500;
}

.scan-card .tracking-info {
  margin-top: 8px;
  padding: 8px 10px;
  background: #f8f9fa;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
}

.scan-card .tracking-info strong {
  color: var(--primary);
  margin-right: 4px;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: .6;
}

.empty-state h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--text);
}

/* ── Load more ── */
.load-more-wrap {
  text-align: center;
  margin-top: 20px;
  padding-bottom: 32px;
}

/* ── Spinner ── */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 32px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 480px) {
  .app-bar .user-email { display: none; }
  .login-hero h1 { font-size: 24px; }
  .login-hero .app-icon { width: 64px; height: 64px; }
}
