/* Vispal Customer Platform — mobile-first, touch-friendly, dependency-free.
   Designed phone-up; tablet/desktop enhancements via min-width media queries. */
:root {
  --bg: #0f172a; --surface: #1e293b; --surface2: #334155;
  --text: #f1f5f9; --muted: #94a3b8; --border: #334155;
  --primary: #3b82f6; --primary-ink: #fff;
  --green: #22c55e; --amber: #f59e0b; --radius: 14px;
  --tap: 48px; /* minimum touch target */
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f8fafc; --surface: #fff; --surface2: #f1f5f9;
    --text: #0f172a; --muted: #64748b; --border: #e2e8f0;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* The `hidden` attribute must always win over element display rules (e.g.
   .login-view uses display:grid, which would otherwise keep it visible). */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px; line-height: 1.5;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
h2 { font-size: 1.05rem; }

/* Buttons — large touch targets */
.btn {
  min-height: var(--tap); padding: 12px 18px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface2); color: var(--text);
  font-size: 1rem; font-weight: 600; cursor: pointer; transition: transform .05s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 38px; padding: 8px 12px; font-size: .9rem; }
.btn-block { width: 100%; }

/* Login */
.login-view { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 28px 22px;
}
.brand { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; }
.brand-sub { color: var(--muted); margin-bottom: 22px; }
#login-form label { display: block; font-size: .85rem; color: var(--muted); margin: 14px 0 6px; }
#login-form input {
  width: 100%; min-height: var(--tap); padding: 12px 14px; font-size: 1rem;
  background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 12px;
}
#login-form button { margin-top: 22px; }
.error { color: #ef4444; font-size: .9rem; margin-top: 12px; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; padding: 12px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-brand { font-weight: 800; font-size: 1.2rem; cursor: pointer; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.company-name { color: var(--muted); font-size: .9rem; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { max-width: 900px; margin: 0 auto; padding: 16px; }
.section-h { color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-size: .78rem; margin: 22px 0 10px; }
.back-btn { margin-bottom: 14px; }

/* Cards — 1 col phone, 2 col tablet+ */
.card-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 680px) { .card-grid { grid-template-columns: 1fr 1fr; } }
.pcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; cursor: pointer; transition: transform .05s ease, border-color .15s;
}
.pcard:active { transform: scale(.99); }
.pcard:hover { border-color: var(--primary); }
.pcard h3 { margin: 0 0 6px; font-size: 1.1rem; }
.pcard .meta { color: var(--muted); font-size: .85rem; }
.empty { color: var(--muted); padding: 14px 2px; }

/* Status pill */
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.pill.waiting { background: color-mix(in srgb, var(--muted) 25%, transparent); color: var(--muted); }
.pill.processing { background: color-mix(in srgb, var(--amber) 22%, transparent); color: var(--amber); }
.pill.completed { background: color-mix(in srgb, var(--green) 22%, transparent); color: var(--green); }

/* Detail */
.detail-head { margin-bottom: 16px; }
.detail-head h1 { font-size: 1.5rem; margin: 4px 0; }
.detail-head .dates { color: var(--muted); }

/* Pipeline stepper — vertical on phone, horizontal on tablet+ */
.stepper { display: flex; flex-direction: column; gap: 0; margin: 18px 0; }
.step { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.step .dot {
  width: 26px; height: 26px; border-radius: 50%; flex: 0 0 26px; display: grid; place-items: center;
  background: var(--surface2); color: var(--muted); font-size: .75rem; font-weight: 700; border: 2px solid var(--border);
}
.step.done .dot { background: var(--green); color: #fff; border-color: var(--green); }
.step.current .dot { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 25%, transparent); }
.step .label { font-size: .95rem; }
.step.upcoming .label { color: var(--muted); }
@media (min-width: 680px) {
  .stepper { flex-direction: row; justify-content: space-between; }
  .step { flex-direction: column; text-align: center; gap: 8px; flex: 1; }
  .step .label { font-size: .8rem; }
}

/* Metric tiles */
.tiles { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 18px 0; }
@media (min-width: 520px) { .tiles { grid-template-columns: 1fr 1fr; } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.tile .k { color: var(--muted); font-size: .85rem; }
.tile .v { font-size: 2rem; font-weight: 800; margin-top: 4px; }
.bars { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr auto; gap: 10px; align-items: center; }
.bar-name { font-size: .85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--surface2); border-radius: 999px; height: 12px; overflow: hidden; }
.bar-fill { background: var(--primary); height: 100%; border-radius: 999px; }
.bar-val { font-weight: 700; font-size: .9rem; }

.toasts { position: fixed; left: 0; right: 0; bottom: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 16px; font-size: .9rem; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.error { border-color: #ef4444; color: #ef4444; }
