:root {
  --bg0: #f3f6f9;
  --bg1: #ffffff;
  --ink: #152033;
  --muted: #5b6b7c;
  --line: #d7e0ea;
  --accent: #1f4e78;
  --accent-soft: #e8f0f7;
  --ok: #1b7a4a;
  --ok-soft: #e6f6ee;
  --err: #b42318;
  --err-soft: #fdecec;
  --shadow: 0 18px 40px rgba(21, 32, 51, 0.08);
  --radius: 14px;
  --font-display: "Outfit", sans-serif;
  --font-body: "Source Sans 3", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 500px at 10% -10%, #dceaf7 0%, transparent 55%),
    radial-gradient(900px 420px at 100% 0%, #e7f3ee 0%, transparent 50%),
    var(--bg0);
}

.page { min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1rem 1.75rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar--public { justify-content: flex-start; }

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-mark {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 10px;
  background:
    linear-gradient(145deg, #1f4e78 0%, #2f6fa8 55%, #3d9b78 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.brand-name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.brand-sub {
  margin: 0.1rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
}

.nav-link:hover,
.nav-link.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.badge {
  display: inline-block;
  margin-left: 0.2rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  vertical-align: middle;
}

.user-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
  margin-left: 0.35rem;
}

.user-name { font-weight: 600; font-size: 0.88rem; }
.user-email { color: var(--muted); font-size: 0.75rem; }

.content {
  width: min(960px, calc(100% - 2rem));
  margin: 2rem auto 3rem;
}

.intro h1,
.auth-panel h1 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 2.4vw, 2rem);
  letter-spacing: -0.02em;
}

.lede {
  margin: 0;
  color: var(--muted);
  max-width: 42rem;
  line-height: 1.5;
}

.auth-main {
  display: grid;
  place-items: center;
  padding: 4rem 1rem;
}

.auth-panel {
  width: min(420px, 100%);
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 1.75rem;
}

.fineprint {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.upload-form {
  margin-top: 1.5rem;
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.35rem;
}

.file-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
}

.file-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem;
  border: 1px dashed #b7c7d6;
  border-radius: 12px;
  background: #f8fafc;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.file-field:hover,
.file-field:focus-within {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.98rem;
}

.file-hint {
  color: var(--muted);
  font-size: 0.8rem;
}

.file-field input[type="file"] {
  width: 100%;
  font-size: 0.82rem;
}

.file-picked {
  color: var(--ink);
  font-size: 0.82rem;
  word-break: break-all;
  min-height: 1.2em;
}

.actions {
  margin-top: 1.15rem;
  display: flex;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.7rem 1.1rem;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover:not(:disabled) { background: #183d5e; }

.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.btn--ghost:hover { background: #eef3f8; }

.btn--google {
  width: 100%;
  margin-top: 1.25rem;
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.btn--google:hover { background: #f7fafc; }

.progress-panel {
  margin-top: 1.25rem;
  padding: 1rem;
  border-radius: 12px;
  background: var(--accent-soft);
  border: 1px solid #c9dae9;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  margin-bottom: 0.55rem;
  font-size: 0.92rem;
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: #fff;
  overflow: hidden;
  border: 1px solid #c9dae9;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #1f4e78, #3d9b78);
  transition: width 0.15s ease;
}

.progress-bar.is-indeterminate {
  width: 40% !important;
  animation: indeterminate 1.1s ease-in-out infinite;
}

@keyframes indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(280%); }
}

.progress-detail {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.alert {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  line-height: 1.4;
}

.alert--error {
  background: var(--err-soft);
  color: var(--err);
  border: 1px solid #f3c1bd;
}

.result-panel {
  margin-top: 1.15rem;
  padding: 1.1rem 1.2rem;
  border-radius: 12px;
  background: var(--ok-soft);
  border: 1px solid #b7e0c8;
}

.result-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 650;
  color: var(--ok);
}

.result-sub {
  margin: 0.25rem 0 0.9rem;
  color: var(--muted);
  word-break: break-all;
}

.table-wrap {
  margin-top: 1.25rem;
  overflow: auto;
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

.history-table th,
.history-table td {
  text-align: left;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.history-table th {
  font-family: var(--font-display);
  font-weight: 600;
  background: #f7fafc;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.history-table tr:last-child td { border-bottom: 0; }

.mono { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.cell-stack { display: flex; flex-direction: column; gap: 0.15rem; }

.status {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.status--ok { background: var(--ok-soft); color: var(--ok); }
.status--err { background: var(--err-soft); color: var(--err); }

.empty {
  margin-top: 1.5rem;
  color: var(--muted);
}

@media (max-width: 860px) {
  .file-grid { grid-template-columns: 1fr; }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .nav { width: 100%; justify-content: flex-start; }
  .user-chip { align-items: flex-start; }
}
