/* xRef Vault — Web UI Stylesheet */
:root {
  --bg: #f5f5f0;
  --card-bg: #fff;
  --text: #0f1923;
  --text-dim: #5c6670;
  --primary: #1e3a5f;
  --primary-hover: #152d4a;
  --accent: #c9a227;
  --accent-hover: #b08e1f;
  --green: #1a7a3a;
  --red: #c02020;
  --yellow: #b07d0a;
  --blue: #1e3a5f;
  --border: #ddd9d0;
  --radius: 8px;
}

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

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

/* ── Topbar ─────────────────────────────────────────── */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 24px; height: 52px;
  background: var(--text); color: #fff;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }
.logo { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; letter-spacing: -0.01em; }
.nav-sep { color: #3a4a5a; }
.nav-label { color: #9aa5b0; font-size: 0.85rem; }
.nav-link { color: #b0b8c0; text-decoration: none; font-size: 0.85rem; }
.nav-link:hover { color: #fff; }
.locale-flag { font-weight: 700; font-size: 0.75rem; padding: 2px 6px; border: 1px solid #3a4a5a; border-radius: 3px; }
.locale-flag:hover { border-color: #fff; }
.secure-badge { display: flex; align-items: center; gap: 4px; color: #8abf7a; font-size: 0.75rem; font-weight: 600; }
.secure-badge svg { width: 12px; height: 12px; fill: currentColor; }
.login-locale { position: absolute; top: 16px; right: 20px; }
.login-locale a { color: #8090a0; text-decoration: none; font-weight: 700; font-size: 0.8rem; padding: 3px 8px; border: 1px solid #4a5a6a; border-radius: 3px; }
.login-locale a:hover { border-color: #fff; color: #fff; }

/* ── Container ──────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }
h1 { margin-bottom: 24px; font-size: 1.5rem; }
h2 { margin: 32px 0 16px; font-size: 1.2rem; }
h3 { margin: 16px 0 8px; font-size: 1rem; }

/* ── Login ──────────────────────────────────────────── */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: linear-gradient(135deg, #0a1628 0%, #132744 50%, #1a3355 100%);
}
.login-card {
  background: var(--card-bg); border-radius: 12px;
  padding: 48px 40px; width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.login-shield { text-align: center; margin-bottom: 8px; }
.login-shield svg { width: 48px; height: 48px; fill: var(--primary); }
.login-title { text-align: center; font-size: 1.6rem; margin-bottom: 2px; color: var(--primary); letter-spacing: -0.02em; }
.login-product { text-align: center; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.15em; color: var(--accent); margin-bottom: 4px; }
.login-subtitle { text-align: center; color: var(--text-dim); margin-bottom: 28px; font-size: 0.85rem; }
.login-footer {
  text-align: center; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border);
  font-size: 0.72rem; color: #9aa0a8; letter-spacing: 0.02em;
}
.login-footer svg { width: 10px; height: 10px; fill: currentColor; vertical-align: -1px; margin-right: 2px; }
.login-legal { text-align: center; margin-top: 16px; font-size: 0.72rem; }
.login-legal a { color: #9aa0a8; text-decoration: none; }
.login-legal a:hover { color: var(--primary); text-decoration: underline; }

/* ── Legal pages ───────────────────────────────────── */
.legal-card {
  background: var(--card-bg); border-radius: 12px;
  padding: 48px 48px 40px; max-width: 720px; width: 100%; margin: 0 auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  font-size: 0.88rem; line-height: 1.7; color: var(--text);
}
.legal-card h1 { font-size: 1.4rem; margin-bottom: 4px; color: var(--primary); }
.legal-card .updated { color: var(--text-dim); font-size: 0.78rem; margin-bottom: 28px; }
.legal-card h2 { font-size: 1rem; margin-top: 24px; margin-bottom: 6px; color: var(--primary); }
.legal-card p, .legal-card li { margin-bottom: 6px; }
.legal-card ul { padding-left: 20px; }
.legal-card a { color: var(--primary); }
.legal-card a:hover { color: var(--primary-hover); }
.legal-card strong { color: var(--text); }
.legal-back {
  display: inline-block; margin-bottom: 20px; font-size: 0.82rem;
  color: var(--text-dim); text-decoration: none;
}
.legal-back:hover { color: var(--primary); }
@media (max-width: 700px) {
  .legal-card { padding: 28px 20px 24px; border-radius: 8px; }
}

/* ── Site footer ────────────────────────────────────── */
.site-footer {
  text-align: center; padding: 24px 0 16px; margin-top: 32px;
  font-size: 0.72rem; color: #9aa0a8; letter-spacing: 0.02em;
}
.site-footer a { color: #9aa0a8; text-decoration: none; }
.site-footer a:hover { color: var(--primary); text-decoration: underline; }

/* ── Forms ──────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; color: var(--text-dim); }
input[type="text"], input[type="password"], input[type="email"] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 0.95rem; outline: none;
  transition: border-color 0.15s;
}
input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,58,95,0.1); }

.form-inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.form-inline input { width: auto; flex: 1; min-width: 120px; }

/* ── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 20px; border: none; border-radius: var(--radius);
  font-size: 0.9rem; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: all 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-block { width: 100%; }
.btn-sm { padding: 4px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 32px; font-size: 1rem; }

/* ── Alerts ─────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 0.9rem; }
.alert-error { background: #fef2f2; color: var(--red); border: 1px solid #f0c0c0; }

/* ── Upload zone ────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: 12px;
  padding: 48px; text-align: center; cursor: pointer;
  transition: all 0.2s; background: var(--card-bg);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent); background: #fdfbf4;
}
.upload-icon { font-size: 2.2rem; margin-bottom: 12px; color: var(--primary); }
.upload-icon svg { width: 40px; height: 40px; fill: var(--primary); }
.upload-text { font-size: 1.05rem; font-weight: 600; margin-bottom: 4px; }
.upload-hint { font-size: 0.82rem; color: var(--text-dim); }
.upload-secure { font-size: 0.75rem; color: #8a9a7a; margin-top: 8px; display: flex; align-items: center; justify-content: center; gap: 4px; }
.upload-secure svg { width: 11px; height: 11px; fill: currentColor; }
.upload-progress { display: flex; flex-direction: column; align-items: center; gap: 12px; }

/* ── Tables ─────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.table th { text-align: left; padding: 8px 12px; border-bottom: 2px solid var(--border); font-weight: 600; color: var(--text-dim); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.table-sm td, .table-sm th { padding: 6px 8px; }
.td-filename { max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-date { white-space: nowrap; color: var(--text-dim); font-size: 0.8rem; }

/* ── Cards ──────────────────────────────────────────── */
.card { background: var(--card-bg); border-radius: var(--radius); padding: 20px; border: 1px solid var(--border); }

/* ── Badges ─────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 0.75rem; font-weight: 600; }
.badge-green { background: #e0f0e4; color: var(--green); }
.badge-red { background: #fdeeed; color: var(--red); }
.badge-blue { background: #e0e8f0; color: var(--blue); }
.badge-yellow { background: #f8f0d8; color: var(--yellow); }
.badge-grey { background: #eeede8; color: var(--text-dim); }

.text-red { color: var(--red); font-weight: 600; }
code { background: #eeedea; padding: 2px 6px; border-radius: 4px; font-size: 0.8rem; }

/* ── KPI Grid ───────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
.kpi-card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 20px; text-align: center; border: 1px solid var(--border);
}
.kpi-val { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-label { font-size: 0.8rem; color: var(--text-dim); margin-top: 4px; }

/* ── Job status page ────────────────────────────────── */
.job-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.job-header h1 { margin-bottom: 0; }

.status-card {
  background: var(--card-bg); border-radius: 12px;
  padding: 48px; border: 1px solid var(--border);
}

.status-done { text-align: center; }
.status-icon { font-size: 3rem; margin-bottom: 12px; }
.status-icon-green { color: var(--green); }
.status-icon-red { color: var(--red); }
.error-message { color: var(--red); margin: 12px 0; font-size: 0.9rem; }

.status-metrics { display: flex; justify-content: center; gap: 32px; margin: 24px 0; flex-wrap: wrap; }
.metric { text-align: center; }
.metric-val { display: block; font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.metric-label { font-size: 0.8rem; color: var(--text-dim); }

/* ── Progress ring ──────────────────────────────────── */
.status-running { display: flex; gap: 40px; align-items: center; }
.progress-ring { position: relative; width: 140px; height: 140px; flex-shrink: 0; }
.progress-ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.progress-bg { fill: none; stroke: var(--border); stroke-width: 8; }
.progress-bar { fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 0.5s ease; }
.progress-text {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; font-size: 1.5rem; font-weight: 700;
}
.progress-info { flex: 1; }
.progress-info h2 { margin-bottom: 4px; }
.stage-message { color: var(--text-dim); font-size: 0.9rem; margin-bottom: 12px; }
.stage-detail { color: var(--text-dim); font-size: 0.8rem; margin-top: 8px; }

.progress-bar-linear {
  height: 6px; background: var(--border); border-radius: 3px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--accent); border-radius: 3px;
  transition: width 0.5s ease;
}

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

/* ── Last login ─────────────────────────────────────── */
.last-login { font-size: 0.78rem; color: var(--text-dim); margin-bottom: 20px; }
.last-login svg { width: 11px; height: 11px; fill: currentColor; vertical-align: -1px; margin-right: 3px; }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 600px) {
  .container { padding: 12px; }

  /* Topbar: compact */
  .topbar { padding: 0 12px; height: 44px; }
  .topbar-left, .topbar-right { gap: 8px; }
  .secure-badge { display: none; }
  .nav-sep { display: none; }
  .nav-label { display: none; }

  /* Login: fit phone width */
  .login-card { width: 100%; max-width: 400px; padding: 32px 24px; }
  .login-title { font-size: 1.3rem; }
  .login-subtitle { font-size: 0.8rem; margin-bottom: 20px; }

  /* Upload zone: less padding */
  .upload-zone { padding: 28px 16px; }
  .upload-text { font-size: 0.95rem; }

  /* Tables: horizontal scroll wrapper */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -12px; padding: 0 12px; }
  .td-filename { max-width: 160px; }

  /* Job status */
  .status-card { padding: 24px 16px; }
  .status-running { flex-direction: column; align-items: center; text-align: center; gap: 20px; }
  .progress-ring { width: 110px; height: 110px; }
  .progress-text { font-size: 1.2rem; }
  .status-metrics { gap: 12px; }
  .metric-val { font-size: 1.2rem; }

  /* KPI grid */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi-card { padding: 12px; }
  .kpi-val { font-size: 1.4rem; }

  /* Forms */
  .form-inline { flex-direction: column; }
  .form-inline input { width: 100%; }

  /* Buttons */
  .btn-lg { padding: 10px 24px; font-size: 0.95rem; }

  /* Legal pages */
  .legal-card { padding: 24px 16px 20px; }

  /* Headings */
  h1 { font-size: 1.2rem; }
  h2 { font-size: 1.05rem; }
}
