:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --bg: #f4f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e6e8ef;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.04);
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
body.auth-wait .container,
body.auth-wait .header { visibility: hidden; }

.header {
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: inherit;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  overflow: hidden;
  background: #4f46e5;
  flex-shrink: 0;
}
.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand-name { font-weight: 700; font-size: 0.92rem; letter-spacing: -0.02em; }
.brand-tag { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.nav { display: flex; gap: 0.25rem; align-items: center; flex-wrap: wrap; }
.nav a {
  color: #475569;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
}
.nav a:hover { background: #f1f5f9; color: var(--text); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); }

.container { max-width: 1120px; margin: 0 auto; padding: 1.75rem; }
.container.compact { max-width: 100%; padding: 1.1rem; }
body.embed { background: #fff; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.35rem;
}
.page-head h1 { font-size: 1.5rem; letter-spacing: -0.03em; margin: 0; }
.page-sub { color: var(--muted); font-size: 0.9rem; margin-top: 0.2rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 1.1rem 1.25rem 0.5rem; margin-bottom: 0; }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.card h2 { font-size: 0.98rem; color: var(--text); margin: 0; letter-spacing: -0.02em; }
.muted { color: var(--muted); font-size: 0.84rem; margin-top: 0.2rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  box-shadow: var(--shadow);
}

.stat-value { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.04em; color: var(--text); }
.stat-label { color: var(--muted); font-size: 0.78rem; font-weight: 500; margin-top: 0.15rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.8rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #fafbff;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbff; }
td a { font-weight: 600; color: var(--text); }
td a:hover { color: var(--primary); text-decoration: none; }

.person {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
  text-transform: uppercase;
}
.badge-pdf { background: #fee2e2; color: #991b1b; }
.badge-doc { background: #dbeafe; color: #1e40af; }
.badge-txt { background: #f1f5f9; color: #475569; }

.btn, .btn-resume, .btn-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.8rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-ghost { background: #fff; color: #334155; border: 1px solid var(--border); }
.btn-ghost:hover { background: #f8fafc; text-decoration: none; }

.btn-resume {
  background: var(--primary);
  color: #fff !important;
}
.btn-resume:hover { background: var(--primary-dark); text-decoration: none; }

.btn-delete {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}
.btn-delete:hover { background: #fee2e2; }
.btn-delete:disabled { opacity: 0.6; cursor: wait; }

.actions {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1rem;
}
.search-box, .search-inline {
  width: 100%;
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  background: #fff;
  outline: none;
}
.search-inline { width: 220px; margin: 0; }
.search-box:focus, .search-inline:focus {
  border-color: #a5b4fc;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
.search-count { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.boolean-help {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin: -0.35rem 0 1rem;
}
.boolean-chip {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.78rem;
  cursor: pointer;
}
.boolean-chip:hover { border-color: #a5b4fc; color: #3730a3; }
.search-parsed { color: var(--muted); font-size: 0.78rem; }
.search-snippet {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.2rem;
  line-height: 1.4;
}
.search-snippet mark {
  background: #fef3c7;
  color: inherit;
  padding: 0 0.1em;
  border-radius: 2px;
}

.profile-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1rem;
}
.profile-field { margin-bottom: 0.85rem; }
.profile-label { color: var(--muted); font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.profile-value { font-weight: 500; margin-top: 0.15rem; word-break: break-word; }

.note {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem;
  margin-bottom: 0.6rem;
  background: #fafbff;
}

.empty {
  text-align: center;
  padding: 2.75rem 1.5rem;
  color: var(--muted);
}
.empty strong { display: block; color: var(--text); margin-bottom: 0.3rem; }
.empty code { background: #f1f5f9; padding: 0.1rem 0.35rem; border-radius: 4px; }

.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: #0f172a;
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.875rem;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
  z-index: 1100;
  max-width: 360px;
}

.split-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.tool-summary {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.tool-preview {
  max-height: 220px;
  overflow: auto;
  margin-bottom: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafbff;
}

.tool-preview:empty { display: none; }

.dup-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}
.dup-row:last-child { border-bottom: none; }
.dup-row strong { display: block; }

.email-box {
  width: 100%;
  min-height: 110px;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.875rem;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 0.75rem;
  outline: none;
}
.email-box:focus {
  border-color: #a5b4fc;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.card-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem;
}
.login-brand {
  background:
    radial-gradient(1200px 600px at -10% 110%, rgba(79, 70, 229, 0.35), transparent 50%),
    linear-gradient(160deg, #0f172a 0%, #1e1b4b 55%, #312e81 100%);
  color: #fff;
}
.login-brand-inner { max-width: 420px; }
.login-screen .brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(79, 70, 229, 0.35);
}
.login-brand h2 { font-size: 2rem; margin: 1rem 0 0.75rem; letter-spacing: -0.03em; }
.login-brand p { color: #c7d2fe; font-size: 1rem; }
.login-points {
  margin-top: 2rem;
  list-style: none;
  color: #e0e7ff;
}
.login-points li {
  padding: 0.55rem 0;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 0.95rem;
}
.login-points li:before { content: "✓  "; color: #a5b4fc; }
.login-form-wrap { background: #f8fafc; }
.login-card {
  background: var(--card);
  padding: 2.25rem;
  border-radius: 16px;
  width: 100%;
  max-width: 400px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.login-kicker {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 0.35rem;
}
.login-logo { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.03em; }
.login-sub { color: var(--muted); margin: 0.25rem 0 1.4rem; font-size: 0.9rem; }
.login-card label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: #475569;
  margin: 0.85rem 0 0.3rem;
}
.login-card input {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.925rem;
  background: #fff;
  color: var(--text);
  outline: none;
}
.login-card input:focus {
  border-color: #a5b4fc;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
.btn-block { width: 100%; margin-top: 1.1rem; }
.error { color: var(--danger); font-size: 0.875rem; margin-top: 0.75rem; }
.legal-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}
.legal-wrap .brand { margin-bottom: 1.25rem; }
.legal-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem 2.1rem;
  box-shadow: var(--shadow);
}
.legal-card h1 { font-size: 1.75rem; letter-spacing: -0.03em; margin: 0.2rem 0 0.35rem; }
.legal-card h2 { font-size: 1.05rem; margin: 1.4rem 0 0.45rem; }
.legal-card p, .legal-card li { color: #334155; font-size: 0.95rem; }
.legal-card ul { padding-left: 1.2rem; margin: 0.4rem 0 0.8rem; }
.legal-card li { margin-bottom: 0.35rem; }
.legal-foot { margin-top: 1.75rem; font-size: 0.875rem; }

@media (max-width: 900px) {
  .split-tools { grid-template-columns: 1fr; }
  .login-screen { grid-template-columns: 1fr; }
  .login-brand { display: none; }
}

.container-wide { max-width: 1440px; }

.profile-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.viewer-card { padding: 0; overflow: hidden; min-height: calc(100vh - 160px); display: flex; flex-direction: column; }
.viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}
.viewer-title { font-weight: 700; font-size: 0.95rem; letter-spacing: -0.02em; }
.viewer-meta { color: var(--muted); font-size: 0.78rem; margin-top: 0.1rem; }
.viewer-stage {
  flex: 1;
  min-height: 520px;
  background: #d7dbe2;
  overflow: auto;
  position: relative;
}
.viewer-stage iframe {
  width: 100%;
  height: 100%;
  min-height: 70vh;
  border: 0;
  background: #525659;
}
.viewer-status, .viewer-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 2rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.viewer-fallback { position: relative; min-height: 280px; }
.resume-paper {
  max-width: 816px;
  margin: 1.25rem auto;
  background: #fff;
  padding: 2.25rem 2.5rem;
  min-height: 100%;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.12);
  color: #111827;
  font-size: 0.95rem;
  line-height: 1.55;
}
.resume-paper p { margin: 0 0 0.7rem; }
.resume-paper h1, .resume-paper h2, .resume-paper h3 { margin: 0 0 0.65rem; }
.resume-paper table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.resume-paper td, .resume-paper th { border: 1px solid #e5e7eb; padding: 0.35rem 0.5rem; }
.resume-text {
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
}

.viewer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 1000;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 1.25rem;
}
.viewer-panel {
  width: min(1180px, 100%);
  height: 100%;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.viewer-overlay .viewer-stage { min-height: 0; flex: 1; }

@media (max-width: 900px) {
  .profile-layout { grid-template-columns: 1fr; }
  .viewer-overlay { padding: 0.5rem; }
  .viewer-panel { border-radius: 10px; }
}

@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; }
  .search-inline { width: 100%; }
  .search-bar { flex-direction: column; align-items: stretch; }
  .search-bar .btn { width: 100%; }
}
