/* ==========================================================================
   PrintHub design system
   One stylesheet for every surface: customer scan/pay flow, vendor portal,
   super admin. Dark-mode aware, mobile-first, no external dependencies.
   ========================================================================== */

/* ---------- tokens ---------- */
:root {
  --brand-50:  #eef2ff;
  --brand-100: #e0e7ff;
  --brand-300: #a5b4fc;
  --brand-500: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;

  --ink:       #0f172a;
  --ink-2:     #334155;
  --muted:     #64748b;
  --line:      #e2e8f0;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --bg:        #f1f5f9;

  --ok:      #059669;
  --ok-bg:   #ecfdf5;
  --warn:    #b45309;
  --warn-bg: #fffbeb;
  --bad:     #dc2626;
  --bad-bg:  #fef2f2;
  --info:    #0369a1;
  --info-bg: #f0f9ff;

  --r-sm: 8px;
  --r:    14px;
  --r-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow:    0 4px 16px rgba(15, 23, 42, .07), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow-lg: 0 20px 45px rgba(15, 23, 42, .16);
  --focus: 0 0 0 3px var(--brand-100);
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
          'Helvetica Neue', Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink:       #f1f5f9;
    --ink-2:     #cbd5e1;
    --muted:     #94a3b8;
    --line:      #1e293b;
    --surface:   #0f172a;
    --surface-2: #16213c;
    --bg:        #080f1f;

    --brand-50:  #1e1b4b;
    --brand-100: #312e81;
    --ok-bg:   #052e23;
    --warn-bg: #3b2705;
    --bad-bg:  #3f1113;
    --info-bg: #082f49;
    --ok:   #34d399;
    --warn: #fbbf24;
    --bad:  #f87171;
    --info: #38bdf8;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow:    0 4px 16px rgba(0, 0, 0, .45);
    --shadow-lg: 0 20px 45px rgba(0, 0, 0, .6);
    --focus: 0 0 0 3px rgba(99, 102, 241, .45);
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; letter-spacing: -.02em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 600; }
p  { margin: 0 0 .75rem; }
a  { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: .875em; background: var(--surface-2); color: var(--ink);
  padding: .15em .4em; border-radius: 6px; border: 1px solid var(--line);
}

.muted { color: var(--muted); font-size: .875rem; }
.tiny  { font-size: .78rem; }
.center { text-align: center; }
.stack > * + * { margin-top: 1rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

/* ---------- app chrome ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: 1120px; margin: 0 auto; padding: .7rem 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700;
         color: var(--ink); letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff; font-size: .95rem; flex: none;
}
.brand-sub { font-weight: 500; color: var(--muted); font-size: .82rem; }
.topnav { display: flex; align-items: center; gap: 1rem; font-size: .9rem; }
.topnav a { color: var(--muted); }
.topnav a:hover { color: var(--brand-600); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.wrap-narrow { max-width: 760px; }
.wrap-tight  { max-width: 460px; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 1.25rem; box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 1rem; }
.card-head { display: flex; align-items: baseline; justify-content: space-between;
             gap: .75rem; margin-bottom: .9rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }

/* numbered step header for the customer flow */
.step { display: flex; align-items: center; gap: .6rem; margin-bottom: .9rem; }
.step-n {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: .8rem; font-weight: 700;
  background: var(--brand-600); color: #fff;
}
.step h2 { margin: 0; }

/* ---------- forms ---------- */
label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-2);
        margin-bottom: .3rem; }
input[type=text], input[type=password], input[type=email], input[type=tel],
input[type=number], select, textarea {
  width: 100%; padding: .6rem .75rem;
  font: inherit; font-size: 16px;      /* 16px stops iOS zoom-on-focus */
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-500); box-shadow: var(--focus);
}
select {
  appearance: none; padding-right: 2rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center;
}
.field + .field { margin-top: .85rem; }
.field-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 160px; margin-top: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .62rem 1.1rem; font: inherit; font-size: .92rem; font-weight: 600;
  border: 1px solid transparent; border-radius: var(--r-sm);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .12s, box-shadow .15s, background .15s, opacity .15s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn-primary { background: var(--brand-600); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-700); }
.btn-success { background: var(--ok); color: #fff; box-shadow: var(--shadow-sm); }
.btn-success:hover { filter: brightness(1.06); }
.btn-ghost { background: var(--surface); color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { filter: brightness(1.06); }
.btn-sm { padding: .4rem .7rem; font-size: .82rem; }
.btn-lg { padding: .85rem 1.5rem; font-size: 1rem; border-radius: var(--r); }
.btn-block { display: flex; width: 100%; }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; }

/* ---------- pills, badges, notes ---------- */
.pill {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .18rem .6rem; border-radius: 999px;
  font-size: .74rem; font-weight: 650; letter-spacing: .01em;
  border: 1px solid transparent; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%;
                background: currentColor; }
.pill-ok      { background: var(--ok-bg);   color: var(--ok); }
.pill-warn    { background: var(--warn-bg); color: var(--warn); }
.pill-bad     { background: var(--bad-bg);  color: var(--bad); }
.pill-info    { background: var(--info-bg); color: var(--info); }
.pill-neutral { background: var(--surface-2); color: var(--muted); }

.note {
  padding: .8rem 1rem; border-radius: var(--r-sm); font-size: .875rem;
  border: 1px solid transparent;
}
.note-ok   { background: var(--ok-bg);   color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.note-warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.note-bad  { background: var(--bad-bg);  color: var(--bad);  border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.note-info { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.note + .note { margin-top: .6rem; }

/* one-time credential reveal */
.creds {
  background: var(--warn-bg); border: 1.5px dashed color-mix(in srgb, var(--warn) 45%, transparent);
  border-radius: var(--r); padding: 1.1rem;
}
.creds .kv { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap;
             margin-top: .5rem; }
.creds code { font-size: 1.05rem; font-weight: 700; background: var(--surface);
              padding: .3rem .6rem; }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; margin: 0 -.25rem; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { padding: .6rem .7rem; text-align: left; vertical-align: top;
         border-bottom: 1px solid var(--line); }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
     color: var(--muted); font-weight: 650; background: var(--surface-2);
     white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }
.empty { padding: 1.5rem; text-align: center; color: var(--muted); font-size: .875rem; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
         gap: .75rem; }
.stat { background: var(--surface); border: 1px solid var(--line);
        border-radius: var(--r); padding: .9rem 1rem; }
.stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
              color: var(--muted); font-weight: 650; }
.stat-value { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em;
              margin-top: .15rem; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 60; display: none;
  align-items: center; justify-content: center; padding: 1rem;
  background: rgba(8, 15, 31, .65); backdrop-filter: blur(3px);
}
.modal.open { display: flex; }
.modal-box {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  width: min(680px, 100%); max-height: 92vh; overflow: auto; padding: 1.25rem;
}

/* ---------- spinner ---------- */
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--brand-600);
  animation: spin .8s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- footer ---------- */
.foot { text-align: center; color: var(--muted); font-size: .8rem;
        padding: 2rem 1rem; }

@media (max-width: 560px) {
  .wrap { padding: 1rem .75rem 3rem; }
  .card { padding: 1rem; border-radius: 12px; }
  h1 { font-size: 1.35rem; }
}
