/* ============================================================
   RepairGenie Bulk Work Order Uploader — Cell Tech
   Same design system as the celltech.app portal / Claims Uploader:
   pure black & white, iOS-inspired minimal design,
   white pill cards on light gray, black circular badges.
   ============================================================ */

:root {
  --bg: #f2f2f2;
  --card: #ffffff;
  --ink: #0a0a0a;
  --ink-dim: #6e6e73;
  --ink-faint: #a3a3a8;
  --line: rgba(0, 0, 0, 0.07);
  --line-strong: rgba(0, 0, 0, 0.12);
  --black: #111111;
  --ok: #0f7a3f;
  --err: #b42318;
  --warn: #8a5a00;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.05), 0 10px 28px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 6px 16px rgba(0, 0, 0, 0.07), 0 24px 60px rgba(0, 0, 0, 0.1);
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-brand: "Barlow Condensed", "Inter", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.3, 0.44, 1);
  --r-card: 26px;
  --r-pill: 999px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { color-scheme: light; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

button, a, label, [role="button"] { touch-action: manipulation; }

::selection { background: rgba(0, 0, 0, 0.85); color: #fff; }

.hidden { display: none !important; }

.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--ink-dim);
  font-size: 0.9rem;
}

/* ------------------------------------------------------------
   Login (identical structure/classes to the portal login)
   ------------------------------------------------------------ */

.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.login-card {
  width: min(410px, 100%);
  margin: 0 auto;
  padding: 52px 44px 38px;
  text-align: center;
  border-radius: 34px;
  background: var(--card);
  box-shadow: var(--shadow-lg);
  animation: card-in 0.8s var(--ease-out) both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(22px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.login-logo {
  width: 84px;
  height: 84px;
  border-radius: 22px;
  object-fit: cover;
  margin-bottom: 22px;
  box-shadow: var(--shadow-md);
}

.login-title {
  font-family: var(--font-brand);
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  line-height: 1;
}

.login-title-dim { font-weight: 500; color: var(--ink-dim); }

.login-sub {
  margin: 14px 0 30px;
  color: var(--ink-dim);
  font-size: 0.92rem;
  line-height: 1.65;
}

.google-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 15px 20px;
  border-radius: var(--r-pill);
  background: var(--black);
  color: #fff;
  font-weight: 600;
  font-size: 0.94rem;
  text-decoration: none;
  transition: transform 0.25s var(--ease-spring), box-shadow 0.25s ease, background 0.2s ease;
  box-shadow: var(--shadow-md);
}

.google-btn:hover {
  transform: translateY(-2px);
  background: #000;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.google-btn:active { transform: translateY(0) scale(0.99); }

.login-error {
  margin-top: 18px;
  padding: 11px 14px;
  border-radius: 14px;
  background: #f5f5f5;
  border: 1px solid var(--line-strong);
  color: #3a3a3c;
  font-size: 0.84rem;
  line-height: 1.5;
  text-align: left;
}

.login-foot {
  margin-top: 26px;
  font-size: 0.76rem;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}

.login-foot strong { color: var(--ink-dim); font-weight: 600; }

/* ------------------------------------------------------------
   App chrome (same topbar pattern as the portal)
   ------------------------------------------------------------ */

.shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px clamp(16px, 4.5vw, 56px);
  padding-top: max(20px, env(safe-area-inset-top));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  animation: fade-down 0.6s var(--ease-out) both;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(242, 242, 242, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

@keyframes fade-down {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: none; }
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
  background: none;
  border: none;
  font: inherit;
  flex-shrink: 0;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: var(--shadow-sm);
}

.brand-name {
  font-family: var(--font-brand);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1;
}

.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; margin-left: auto; }

/* Expandable user chip — identical interaction to the portal */

.user-chip {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: 40px;
  width: 40px;
  gap: 0;
  padding: 4px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
  transition:
    width 0.4s var(--ease-out),
    border-radius 0.35s var(--ease-out),
    gap 0.3s ease,
    padding 0.35s var(--ease-out),
    box-shadow 0.2s ease;
}

.user-chip:hover,
.user-chip:focus-within {
  width: 248px;
  border-radius: var(--r-pill);
  gap: 10px;
  padding: 4px 6px 4px 4px;
  box-shadow: var(--shadow-md);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
}

.avatar-fallback {
  display: grid;
  place-items: center;
  background: var(--black);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: max-width 0.35s var(--ease-out), opacity 0.22s ease;
}

.user-chip:hover .user-meta,
.user-chip:focus-within .user-meta {
  max-width: 160px;
  opacity: 1;
}

.user-name {
  font-size: 0.82rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.68rem;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-btn {
  display: grid;
  place-items: center;
  width: 0;
  height: 32px;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  border-radius: 50%;
  border: none;
  background: #eeeeee;
  color: var(--ink-dim);
  cursor: pointer;
  flex: none;
  padding: 0;
  transition:
    max-width 0.35s var(--ease-out),
    width 0.35s var(--ease-out),
    opacity 0.22s ease,
    color 0.2s ease,
    background 0.2s ease,
    transform 0.2s var(--ease-spring);
}

.user-chip:hover .logout-btn,
.user-chip:focus-within .logout-btn { width: 32px; max-width: 32px; opacity: 1; }

.logout-btn:hover { color: #fff; background: var(--black); transform: scale(1.06); }
.logout-btn:active { transform: scale(0.96); }

.main {
  flex: 1;
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: clamp(14px, 3vh, 36px) clamp(16px, 4.5vw, 56px) 60px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(60px, calc(24px + env(safe-area-inset-bottom)));
}

/* ------------------------------------------------------------
   Hero page header (matches portal's home hero)
   ------------------------------------------------------------ */

.view { animation: view-in 0.5s var(--ease-out) both; }

@keyframes view-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

.hero { margin: clamp(10px, 3vh, 30px) 0 clamp(24px, 4vh, 40px); }

.hero-kicker {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 14px;
}

.hero-title {
  font-size: clamp(1.8rem, 4.4vw, 2.7rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.08;
}

.hero-sub {
  margin-top: 14px;
  color: var(--ink-dim);
  font-size: 0.96rem;
  max-width: 56ch;
  line-height: 1.6;
}

/* ------------------------------------------------------------
   Icon badge — black circle, white glyph (portal signature)
   ------------------------------------------------------------ */

.badge {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--black);
  color: #fff;
  flex: none;
  transition: transform 0.35s var(--ease-spring);
}

.badge svg { width: 20px; height: 20px; }
.badge.sm { width: 40px; height: 40px; }
.badge.sm svg { width: 17px; height: 17px; }

/* ------------------------------------------------------------
   Section labels
   ------------------------------------------------------------ */

.section-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 16px;
  padding: 0 6px;
}

.section-label h2 {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.section-label span { font-size: 0.78rem; color: var(--ink-faint); }

/* ------------------------------------------------------------
   Step cards
   ------------------------------------------------------------ */

.step-card {
  position: relative;
  padding: 26px 26px 24px;
  border-radius: var(--r-card);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
  transition: transform 0.35s var(--ease-spring), box-shadow 0.3s ease;
  animation: rise-in 0.6s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 80ms);
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(20px) scale(0.99); }
  to   { opacity: 1; transform: none; }
}

.step-card:hover { box-shadow: var(--shadow-md); }
.step-card:hover .badge { transform: scale(1.06); }

.step-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.step-head-body { flex: 1; min-width: 0; }

.step-card h3 {
  font-size: 1.16rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.step-card .step-hint {
  margin-top: 5px;
  color: var(--ink-dim);
  font-size: 0.83rem;
  line-height: 1.55;
}

.step-num {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 4px;
}

/* ------------------------------------------------------------
   Form fields
   ------------------------------------------------------------ */

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }

.field-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-left: 4px;
}

.input,
.select {
  width: 100%;
  min-height: 46px;
  padding: 12px 18px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-weight: 500;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input::placeholder { color: var(--ink-faint); font-weight: 400; }
.input:hover, .select:hover { border-color: var(--ink-faint); }

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--black);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

.select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  padding-right: 46px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%230a0a0a' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 18px center;
}

/* File picker */

.file-drop {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-radius: 22px;
  border: 1.5px dashed var(--line-strong);
  background: #fafafa;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.file-drop:hover,
.file-drop.dragover { border-color: var(--black); background: #f4f4f4; }

.file-drop input[type="file"] { display: none; }

.file-drop-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }

.file-drop-name {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-drop-hint { font-size: 0.76rem; color: var(--ink-faint); }

.file-clear {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: #eeeeee;
  color: var(--ink-dim);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s var(--ease-spring);
}

.file-clear:hover { background: var(--black); color: #fff; transform: scale(1.06); }

/* ------------------------------------------------------------
   Buttons
   ------------------------------------------------------------ */

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; align-items: center; }

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  background: var(--black);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 0.86rem;
  padding: 13px 22px;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: transform 0.25s var(--ease-spring), box-shadow 0.3s ease, background 0.2s ease;
}

.primary-btn:hover:not(:disabled) {
  background: #000;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.primary-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: var(--card);
  color: var(--ink-dim);
  font: inherit;
  font-weight: 600;
  font-size: 0.84rem;
  padding: 12px 20px;
  border-radius: var(--r-pill);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: color 0.2s ease, box-shadow 0.2s ease, transform 0.2s var(--ease-spring);
}

.ghost-btn:hover:not(:disabled) { color: var(--ink); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.ghost-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.danger-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: #fdf2f1;
  color: var(--err);
  font: inherit;
  font-weight: 600;
  font-size: 0.84rem;
  padding: 12px 20px;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s var(--ease-spring);
}

.danger-btn:hover:not(:disabled) { background: #f8e4e2; transform: translateY(-1px); }
.danger-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.button-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 13px 22px;
  border-radius: var(--r-pill);
  background: var(--black);
  color: #fff;
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.25s var(--ease-spring), box-shadow 0.3s ease, background 0.2s ease;
}

.button-link:hover { background: #000; transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18); }

/* ------------------------------------------------------------
   Inline messages
   ------------------------------------------------------------ */

.msg-ok,
.msg-err,
.msg-note {
  margin-top: 16px;
  font-size: 0.84rem;
  border-radius: 14px;
  padding: 11px 14px;
  line-height: 1.55;
}

.msg-ok { color: var(--ok); background: #eef8f1; }
.msg-err { color: var(--err); background: #fdf2f1; }
.msg-note { color: var(--ink-dim); background: #f5f5f5; }

/* ------------------------------------------------------------
   Stats
   ------------------------------------------------------------ */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.stat {
  display: flex;
  flex-direction: column;
  padding: 20px 20px 18px;
  border-radius: 22px;
  background: #fafafa;
  transition: transform 0.35s var(--ease-spring);
  animation: rise-in 0.55s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}

.stat:hover { transform: translateY(-3px); }

.stat-value {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  margin-top: 8px;
  color: var(--ink-faint);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.stat.ok .stat-value { color: var(--ok); }
.stat.err .stat-value { color: var(--err); }
.stat.warn .stat-value { color: var(--warn); }

/* Progress */

.progress-wrap { margin-bottom: 8px; }

.progress-track {
  height: 8px;
  border-radius: 4px;
  background: #ebebeb;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--black);
  width: 0;
  min-width: 0;
  transition: width 0.5s var(--ease-out);
}

.progress-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.progress-status {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.progress-msg {
  font-size: 0.82rem;
  color: var(--ink-dim);
  text-align: right;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------
   Tables
   ------------------------------------------------------------ */

.table-wrap {
  border-radius: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  overflow: hidden;
}

.table-scroll { overflow: auto; max-height: 56vh; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.table th,
.table td {
  text-align: left;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}

.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--ink-faint);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  border-top: 0;
  background: #fafafa;
}

.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .mono { font-family: var(--font-mono); font-size: 0.78rem; }
.table tbody tr:hover td { background: #fafafa; }

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: #f0f0f0;
  color: var(--ink-dim);
  white-space: nowrap;
}

.status-pill.success { background: #eef8f1; color: var(--ok); }
.status-pill.duplicate { background: #f0f0f0; color: var(--ink-dim); }
.status-pill.failed { background: #fdf2f1; color: var(--err); }
.status-pill.skipped { background: #fbf3e4; color: var(--warn); }

.empty {
  padding: 30px 18px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.86rem;
  line-height: 1.6;
}

/* ------------------------------------------------------------
   Responsive
   ------------------------------------------------------------ */

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; row-gap: 10px; }
  .topbar-right { margin-left: auto; }
}

@media (max-width: 640px) {
  .brand-name { display: none; }
  .login-card { width: 100%; max-width: 360px; padding: 36px 22px 28px; border-radius: 28px; }
  .login-logo { width: 72px; height: 72px; border-radius: 18px; margin-bottom: 18px; }
  .login-title { font-size: 2.05rem; }
  .login-sub { margin: 12px 0 24px; font-size: 0.88rem; }
  .google-btn { padding: 14px 18px; font-size: 0.92rem; }
  .login-foot { margin-top: 22px; }
  .field-grid, .stat-row { grid-template-columns: 1fr; }
  .hero-title { font-size: clamp(1.6rem, 8vw, 2.1rem); }
  .user-chip:hover, .user-chip:focus-within { width: 210px; }
  .step-card { padding: 22px 18px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
}
