/* Design tokens live in ../../css/tokens.css, shared with the public cert page */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  /* Subtle dot-grid texture — matches the real internal app's working
     screens (admin.html), not used on the public cert page. */
  background-image: radial-gradient(circle at 1px 1px, rgba(20,22,28,0.05) 1px, transparent 0);
  background-size: 24px 24px;
}

h1, h2 { font-family: 'Fraunces', serif; font-weight: 500; margin: 0; color: var(--ink); }
h1 { font-size: 26px; letter-spacing: -0.005em; }
h2 { font-size: 18px; }

button, input, select { font-family: inherit; font-size: inherit; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ===================== Buttons ===================== */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  padding: 13px 22px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
  transition: opacity .15s ease, background-color .15s ease, border-color .15s ease;
}
/* Dashboard content buttons: neutral graphite, matching admin.html's
   button.primary exactly — the internal app uses near-black for primary
   actions and reserves the product accent for lighter-touch identity. */
.btn-primary {
  background: var(--ink);
  color: #fff;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { background: var(--muted); opacity: 1; cursor: wait; }
.btn-block { width: 100%; margin-top: 20px; }
.btn-center { display: block; margin: 10px auto 0; }

/* Auth screen carve-out: the real sign-in screen uses the product accent
   color for its primary CTA (confirmed from the actual certs.we-verifi.co.uk
   screenshot), unlike the rest of the authenticated app. */
.auth-form .btn-primary { background: var(--brand); }
.auth-form .btn-primary:hover { opacity: 0.9; }

.btn-secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-secondary:hover { border-color: var(--muted); }

.btn-text {
  background: none;
  color: var(--brand);
  border: none;
  padding: 8px 4px;
  font-weight: 600;
}
.btn-text:hover { color: var(--brand-dark); }
.btn-small { font-size: 13px; padding: 4px 2px; }

.link-arrow {
  background: none; border: none; padding: 0;
  color: var(--brand); font-weight: 600; cursor: pointer;
}
.link-arrow:hover { color: var(--brand-dark); }

/* ===================== Auth screen ===================== */
.auth-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 40px 36px;
  text-align: center;
}
.auth-icon {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 2px solid var(--brand);
  color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
}
.auth-card h1 { font-size: 24px; }
.auth-sub { color: var(--muted); margin: 6px 0 28px; font-size: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 4px; text-align: left; }
.auth-form label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 14px;
}
.auth-form input {
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  background: var(--brand-tint);
  color: var(--ink);
}
.auth-form input:focus { border-color: var(--brand); outline: none; }

.auth-divider { border: none; border-top: 1px solid var(--line); margin: 22px 0 14px; }
.auth-toggle-line { font-size: 13px; color: var(--muted); margin: 0; text-align: center; }

.back-link { color: var(--brand); font-size: 14px; font-weight: 600; text-decoration: none; }
.back-link:hover { color: var(--brand-dark); }

/* ===================== Dashboard shell ===================== */
.dashboard {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--card);
  border-right: 1px solid var(--line);
  color: var(--ink);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 32px; }
.brand-seal {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--brand); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 16px; }

.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--ink-soft);
  padding: 10px 14px;
  border-radius: var(--radius-btn);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
}
.nav-item:hover { color: var(--ink); background: var(--brand-tint); }
.nav-item.is-active { color: var(--brand); background: var(--brand-tint); font-weight: 700; }

.sidebar-foot { margin-top: auto; padding-top: 20px; border-top: 1px solid var(--line); }
.user-email { font-size: 12px; color: var(--muted); word-break: break-all; margin-bottom: 6px; }

.content { padding: 40px 48px; max-width: 980px; }

.view { display: none; }
.view.is-active { display: block; }

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}
.view-sub { color: var(--muted); margin: 6px 0 0; font-size: 14px; }

.empty-state {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
}

/* ===================== Cards ===================== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.piece-card, .pack-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.piece-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.piece-title { font-weight: 700; font-size: 16px; margin: 0 0 2px; }
.piece-artist { color: var(--ink-soft); font-size: 13px; margin: 0; }
.piece-meta { color: var(--muted); font-size: 12px; margin-top: 10px; }
.piece-cert { font-family: var(--font-mono); font-size: 12px; color: var(--brand); margin-top: 8px; }
.piece-actions { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }

/* Status pill — matches the brand's pill language rather than a stamp motif */
.seal-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.seal-badge.draft    { color: var(--muted);   background: #F1F1F6; }
.seal-badge.pending  { color: var(--warn-fg); background: var(--warn-bg); }
.seal-badge.active   { color: var(--verified);background: var(--verified-bg); }
.seal-badge.notfound { color: var(--muted);   background: #F1F1F6; }

.pack-piece-count { font-family: var(--font-mono); font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
.pack-status-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--verified-bg);
  color: var(--verified);
}
.pack-status-tag.dissolved { background: #F1F1F6; color: var(--muted); }

/* ===================== Account view ===================== */
.account-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  max-width: 420px;
}
.balance-block { margin-bottom: 20px; }
.balance-label { display: block; font-size: 13px; color: var(--muted); }
.balance-number { display: block; font-size: 40px; font-weight: 700; margin: 4px 0; }
.internal-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  background: var(--warn-bg);
  color: var(--warn-fg);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}
.field-note { color: var(--muted); font-size: 13px; margin-top: 14px; }

/* ===================== Modal ===================== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20,21,26,0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal {
  background: var(--card);
  border-radius: 16px;
  width: 100%; max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(20,21,26,0.2);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}
.modal-close {
  background: none; border: none; font-size: 22px; line-height: 1;
  color: var(--muted); cursor: pointer; padding: 4px;
}
.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; }

.field-row { display: flex; flex-direction: column; gap: 6px; }
.field-row label, .field-row legend {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 0;
}
.field-row input, .field-row select {
  padding: 11px 13px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-btn);
  background: #fff;
}
.field-row input:focus, .field-row select:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(20,22,28,0.1); outline: none; }
.field-row.two-up { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-row.two-up > div { display: flex; flex-direction: column; gap: 6px; }
fieldset.field-row { border: none; padding: 0; margin: 0; }
.radio-line { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-top: 8px; text-transform: none; font-weight: 400; letter-spacing: normal; color: var(--ink); }

.field-error {
  color: var(--danger);
  background: var(--danger-bg);
  padding: 8px 12px;
  border-radius: var(--radius-btn);
  font-size: 13px;
  margin: 0;
}
.field-success {
  color: var(--verified);
  background: var(--verified-bg);
  padding: 8px 12px;
  border-radius: var(--radius-btn);
  font-size: 13px;
  margin: 0;
}

/* Shot upload */
.shot-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.shot-slot {
  border: 1px dashed var(--line);
  border-radius: var(--radius-btn);
  padding: 12px 10px;
  text-align: center;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.shot-label { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.shot-preview {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius-btn);
  background: var(--brand-tint);
}
.shot-slot input[type=file] { font-size: 11px; width: 100%; }
.shot-status { font-size: 11px; color: var(--muted); font-family: var(--font-mono); }
.shot-status.done { color: var(--verified); }
.shot-status.error { color: var(--danger); }
.shot-status.existing { color: var(--brand); }

.piece-picker { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-btn); padding: 10px; background: #fff; }
.piece-picker label { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 400; padding: 4px 0; text-transform: none; letter-spacing: normal; color: var(--ink); }
.piece-picker-empty { color: var(--muted); font-size: 13px; }

/* ===================== Toast ===================== */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  z-index: 200;
}
.toast.is-error { background: var(--danger); }

/* ===================== Responsive ===================== */
@media (max-width: 760px) {
  .dashboard { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row;
    align-items: center;
    padding: 12px 16px;
    gap: 4px;
    overflow-x: auto;
  }
  .brand { margin-bottom: 0; margin-right: 12px; }
  .sidebar-foot { margin-top: 0; margin-left: auto; padding-top: 0; border-top: none; display: flex; align-items: center; gap: 10px; }
  .user-email { display: none; }
  .content { padding: 24px 18px; }
  .field-row.two-up { grid-template-columns: 1fr; }
  .shot-grid { grid-template-columns: 1fr; }
}