/* ClassPhoto IDs — interface styles. Family resemblance to ClassPhoto / ServiceStix:
   DM Sans + Outfit, blue primaries, soft cards on a pale blue field. */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:       #2563eb;
  --blue-dark:  #1d4ed8;
  --blue-mid:   #3b82f6;
  --blue-light: #dbeafe;
  --blue-bg:    #eff6ff;
  --navy:       #0f172a;
  --navy-mid:   #1e293b;
  --coral:      #f97362;
  --amber:      #f59e0b;
  --green:      #10b981;
  --green-dark: #047857;
  --red:        #dc2626;
  --red-bg:     #fef2f2;
  --bg:         #f0f6ff;
  --card:       #ffffff;
  --text:       #0f172a;
  --muted:      #64748b;
  --muted-2:    #94a3b8;
  --border:     #e2e8f0;
  --border-2:   #cbd5e1;
  --radius:     12px;
  --shadow-sm:  0 1px 3px rgba(15,23,42,.07);
  --shadow:     0 4px 16px rgba(15,23,42,.09);
  --shadow-lg:  0 18px 48px rgba(15,23,42,.18);
}

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.55; min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -0.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
:focus-visible { outline: 2.5px solid var(--blue-mid); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ── Header ─────────────────────────────────────────────────── */
.site-header { background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 55%, #1d4ed8 100%); color: #fff; }
.header-inner { max-width: 1320px; margin: 0 auto; padding: 0.85rem 1.25rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.header-brand { display: flex; align-items: center; gap: 12px; }
.cp-logo svg { display: block; }
.brand-text { line-height: 1.15; }
.brand-name { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.4px; display: flex; align-items: center; gap: 8px; }
.brand-version { font-size: 0.62rem; font-weight: 700; padding: 2px 7px; background: rgba(255,255,255,.18); border-radius: 99px; letter-spacing: .5px; }
.brand-by { font-family: 'Outfit', sans-serif; font-size: 0.76rem; opacity: .8; }
.brand-by a { color: #bfdbfe; text-decoration: none; }
.brand-by a:hover { text-decoration: underline; }
.header-right { display: flex; align-items: center; gap: 14px; }
.header-link { color: rgba(255,255,255,.72); text-decoration: none; font-size: 0.82rem; font-family: 'Outfit', sans-serif; }
.header-link:hover { color: #fff; }
.project-chip { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.12); border-radius: 99px; padding: 4px 6px 4px 4px; }
.project-name { background: rgba(255,255,255,.14); border: none; color: #fff; padding: 5px 12px; border-radius: 99px; cursor: pointer; font-size: 0.85rem; font-weight: 600; display: flex; align-items: center; gap: 7px; max-width: 260px; }
.project-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-name:hover { background: rgba(255,255,255,.24); }
.save-state { font-size: 0.7rem; color: rgba(255,255,255,.7); font-family: 'Outfit', sans-serif; padding-right: 8px; }
.save-state.saving { color: #fde68a; }

.steps-nav { max-width: 1320px; margin: 0 auto; padding: 0 1.25rem; display: flex; gap: 4px; }
.step-tab {
  background: transparent; border: none; border-bottom: 3px solid transparent; color: rgba(255,255,255,.66);
  padding: 0.6rem 1rem 0.7rem; cursor: pointer; font-size: 0.87rem; font-weight: 600; display: flex; align-items: center; gap: 8px;
  transition: color .15s, border-color .15s;
}
.step-tab:hover:not(:disabled) { color: #fff; }
.step-tab.active { color: #fff; border-bottom-color: var(--blue-mid); }
.step-tab:disabled { opacity: .4; cursor: not-allowed; }
.step-dot { width: 20px; height: 20px; border-radius: 50%; background: rgba(255,255,255,.18); display: grid; place-items: center; font-size: 0.72rem; font-weight: 700; }
.step-tab.active .step-dot { background: var(--blue-mid); }
.step-tab.done .step-dot { background: var(--green); font-size: 0; }
.step-tab.done .step-dot::after { content: '✓'; font-size: 0.72rem; color: #fff; }

/* ── Layout ─────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.wrap { max-width: 940px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.wrap-wide { max-width: 1320px; display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 1.5rem; align-items: start; }
.col-side .side-sticky { position: sticky; top: 1rem; display: flex; flex-direction: column; gap: 0.9rem; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem 1.5rem; margin-bottom: 1.1rem; box-shadow: var(--shadow-sm); }
.card.compact { padding: 1rem 1.05rem; margin-bottom: 0.85rem; }
.card > h2 { font-size: 1rem; font-weight: 700; color: var(--navy); margin-bottom: 0.9rem; padding-bottom: 0.55rem; border-bottom: 2px solid var(--bg); }
.card.compact > h2 { font-size: 0.86rem; margin-bottom: 0.7rem; padding-bottom: 0.45rem; }
.card h3 { font-size: 0.88rem; font-weight: 600; margin: 0.9rem 0 0.35rem; color: var(--navy-mid); }
.card h4 { font-size: 0.8rem; font-weight: 700; color: var(--navy-mid); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 0.5rem; }
.card p { font-size: 0.88rem; color: var(--muted); }
.hint { font-size: 0.82rem; color: var(--muted); margin-top: 0.35rem; }
.hint.small { font-size: 0.76rem; line-height: 1.5; }
.card-foot { margin-top: 1rem; padding-top: 0.9rem; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: center; }
.card-foot.spread { justify-content: space-between; }
.step-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 1.2rem; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1.5px solid transparent; border-radius: 9px; padding: 0.6rem 1.15rem; font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: background .15s, border-color .15s, transform .1s, box-shadow .15s; text-decoration: none; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); box-shadow: 0 4px 12px rgba(37,99,235,.28); }
.btn-secondary { background: var(--blue-bg); color: var(--blue-dark); border-color: var(--blue-light); }
.btn-secondary:hover:not(:disabled) { background: var(--blue-light); }
.btn-ghost { background: #fff; color: var(--navy); border-color: var(--border-2); }
.btn-ghost:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.btn-ghost.danger { color: var(--red); border-color: #fecaca; }
.btn-ghost.danger:hover { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.btn-lg { padding: 0.8rem 1.6rem; font-size: 1rem; }
.btn-sm { padding: 0.42rem 0.85rem; font-size: 0.82rem; border-radius: 8px; }
.btn-block { width: 100%; margin-top: 0.6rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { background: #fff; border: 1.5px solid var(--border-2); border-radius: 8px; width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer; font-size: 1.15rem; line-height: 1; color: var(--navy); }
.icon-btn:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.link-btn { background: none; border: none; color: var(--blue); cursor: pointer; font-size: inherit; padding: 0; text-decoration: underline; text-underline-offset: 2px; }
.link-btn.tiny { font-size: 0.7rem; font-weight: 500; color: var(--muted-2); margin-left: 6px; }
.link-btn.tiny:hover { color: var(--blue); }

/* ── Forms ──────────────────────────────────────────────────── */
.field { display: block; margin-bottom: 0.85rem; }
.field > span { display: flex; align-items: center; font-size: 0.8rem; font-weight: 600; color: var(--navy-mid); margin-bottom: 5px; }
.field > span em { font-style: normal; font-weight: 400; color: var(--muted-2); margin-left: 5px; }
.field input[type=text], .field input[type=search], select, input[type=number] {
  width: 100%; padding: 0.6rem 0.75rem; border: 1.5px solid var(--border); border-radius: 8px; background: #fff; font-size: 0.9rem; transition: border-color .15s, box-shadow .15s;
}
select { cursor: pointer; }
.field input:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; }
.check { display: flex; align-items: center; gap: 9px; font-size: 0.87rem; padding: 0.32rem 0; cursor: pointer; }
.check input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--blue); cursor: pointer; flex-shrink: 0; }
.check em { font-style: normal; color: var(--muted-2); font-size: 0.8rem; }
.check.sub, .opt-row.sub { padding-left: 25px; }
.opt-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0.45rem 0; }
.opt-label { font-size: 0.82rem; font-weight: 500; color: var(--muted); flex-shrink: 0; }
.opt-row select { width: auto; min-width: 130px; max-width: 190px; padding: 0.35rem 0.5rem; font-size: 0.82rem; }
.opt-row input[type=range] { flex: 1; max-width: 150px; accent-color: var(--blue); }
.range-val { font-size: 0.78rem; color: var(--muted); min-width: 52px; text-align: right; }
.seg { display: inline-flex; background: var(--bg); border: 1.5px solid var(--border); border-radius: 8px; padding: 2px; gap: 2px; }
.seg button { background: none; border: none; padding: 0.3rem 0.7rem; border-radius: 6px; cursor: pointer; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.seg button.on { background: #fff; color: var(--blue-dark); box-shadow: var(--shadow-sm); }
.seg button:hover:not(.on) { color: var(--navy); }
code { background: #f1f5f9; border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-size: 0.85em; font-family: 'SF Mono', Menlo, monospace; }

/* ── Welcome ────────────────────────────────────────────────── */
.welcome { max-width: 1000px; margin: 0 auto; padding: 3rem 1.25rem 4rem; }
.welcome-hero { text-align: center; max-width: 690px; margin: 0 auto 2.5rem; }
.welcome-hero h1 { font-size: 2.25rem; font-weight: 700; letter-spacing: -0.03em; margin-bottom: 0.8rem; }
.welcome-hero > p { font-family: 'Outfit', sans-serif; font-size: 1.05rem; color: var(--muted); line-height: 1.65; }
.welcome-actions { display: flex; gap: 12px; justify-content: center; margin: 1.6rem 0 0.9rem; flex-wrap: wrap; }
.welcome-note { font-size: 0.85rem; color: var(--muted-2); }
.welcome-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.9rem; margin-bottom: 2.5rem; }
.wc { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow-sm); }
.wc-num { width: 26px; height: 26px; border-radius: 50%; background: var(--blue-bg); color: var(--blue-dark); font-weight: 700; font-size: 0.8rem; display: grid; place-items: center; margin-bottom: 0.6rem; }
.wc h3 { font-size: 0.92rem; margin-bottom: 0.3rem; }
.wc p { font-size: 0.82rem; color: var(--muted); line-height: 1.5; }
.recent h2 { font-size: 1.05rem; margin-bottom: 0.8rem; }
.recent-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0.8rem; }
.recent-item { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 0.9rem 1rem; display: flex; gap: 12px; align-items: center; cursor: pointer; transition: border-color .15s, box-shadow .15s; text-align: left; width: 100%; }
.recent-item:hover { border-color: var(--blue); box-shadow: var(--shadow); }
.recent-thumb { width: 46px; height: 46px; border-radius: 8px; background: var(--blue-bg); display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; padding: 4px; }
.recent-thumb img { max-width: 100%; max-height: 38px; width: auto; height: auto; object-fit: contain; }
.recent-info { flex: 1; min-width: 0; }
.recent-info strong { display: block; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-info span { font-size: 0.78rem; color: var(--muted); }
.recent-foot { margin-top: 0.9rem; }

/* ── Logo + colors ──────────────────────────────────────────── */
.logo-row { display: flex; gap: 1rem; align-items: flex-start; }
.logo-drop { flex: 1; border: 2.5px dashed var(--border-2); border-radius: 10px; padding: 1.2rem; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; min-height: 132px; display: grid; place-items: center; }
.logo-drop:hover, .logo-drop.dragover { border-color: var(--blue); background: var(--blue-bg); }
.logo-drop-empty { color: var(--muted); display: grid; gap: 4px; justify-items: center; }
.logo-drop-empty strong { font-size: 0.92rem; color: var(--navy); }
.logo-drop-empty span { font-size: 0.78rem; }
.logo-preview { display: flex; gap: 10px; width: 100%; }
.logo-swatch { flex: 1; height: 104px; border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 10px; overflow: hidden; }
.logo-swatch.light { background: #fff; border: 1px solid var(--border); }
.logo-swatch.dark { background: var(--navy); }
.logo-swatch img { max-width: 100%; max-height: 84px; width: auto; height: auto; object-fit: contain; }
.logo-meta { width: 168px; font-size: 0.78rem; color: var(--muted); }
.meta-line { margin-bottom: 4px; }
.meta-actions { display: flex; gap: 6px; margin-top: 0.7rem; flex-wrap: wrap; }

.palette-suggest { background: var(--blue-bg); border: 1px solid var(--blue-light); border-radius: 10px; padding: 0.85rem 1rem; margin-bottom: 1rem; }
.ps-head { display: flex; flex-direction: column; margin-bottom: 0.6rem; }
.ps-head strong { font-size: 0.86rem; }
.ps-head span { font-size: 0.78rem; color: var(--muted); }
.ps-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.ps-chip { display: flex; align-items: center; gap: 7px; background: #fff; border: 1.5px solid var(--border); border-radius: 99px; padding: 3px 10px 3px 4px; cursor: pointer; font-size: 0.76rem; font-family: 'SF Mono', Menlo, monospace; }
.ps-chip:hover { border-color: var(--blue); }
.ps-chip .sw { width: 20px; height: 20px; border-radius: 50%; border: 1px solid rgba(15,23,42,.12); }
.color-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); gap: 0.8rem; }
.color-item { border: 1.5px solid var(--border); border-radius: 10px; padding: 0.7rem 0.8rem; }
.color-item.target { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.color-item-head { display: flex; flex-direction: column; gap: 1px; margin-bottom: 0.5rem; min-width: 0; }
.color-item-head span { font-size: 0.8rem; font-weight: 600; line-height: 1.3; }
.color-item-head em { font-style: normal; font-size: 0.72rem; color: var(--muted-2); line-height: 1.3; }
.color-input-row { display: flex; gap: 7px; align-items: center; min-width: 0; }
/* the hex field is an <input>, whose intrinsic width refuses to shrink — without an explicit
   flex basis here the color well gets squeezed to a sliver in narrow columns */
.color-swatch-input { flex: 0 0 38px; width: 38px; height: 34px; border: 1.5px solid var(--border); border-radius: 7px; padding: 2px; background: #fff; cursor: pointer; }
.color-swatch-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-swatch-input::-webkit-color-swatch { border: none; border-radius: 4px; }
.color-hex { flex: 1 1 0; min-width: 0; width: 100%; padding: 0.42rem 0.55rem; border: 1.5px solid var(--border); border-radius: 7px; font-family: 'SF Mono', Menlo, monospace; font-size: 0.82rem; text-transform: lowercase; }
.contrast-notes { margin-top: 0.85rem; display: grid; gap: 6px; }
.note { font-size: 0.8rem; padding: 0.5rem 0.7rem; border-radius: 7px; display: flex; gap: 8px; align-items: flex-start; }
.note.warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.note.err { background: var(--red-bg); border: 1px solid #fecaca; color: #991b1b; }
.note.ok { background: #ecfdf5; border: 1px solid #a7f3d0; color: var(--green-dark); }
.note.info { background: var(--blue-bg); border: 1px solid var(--blue-light); color: #1e40af; }

/* ── Fonts ──────────────────────────────────────────────────── */
.font-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 0.9rem; }
.font-tab { background: #fff; border: 1.5px solid var(--border); border-radius: 99px; padding: 0.3rem 0.8rem; font-size: 0.8rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.font-tab.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.font-tab:hover:not(.on) { border-color: var(--blue); color: var(--blue); }
.font-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.font-col-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.78rem; font-weight: 600; color: var(--navy-mid); margin-bottom: 6px; }
.font-col-head em { font-style: normal; color: var(--blue); font-weight: 500; }
.font-list { border: 1.5px solid var(--border); border-radius: 10px; max-height: 230px; overflow-y: auto; }
.font-opt { display: block; width: 100%; text-align: left; background: none; border: none; border-bottom: 1px solid var(--bg); padding: 0.5rem 0.7rem; cursor: pointer; }
.font-opt:last-child { border-bottom: none; }
.font-opt:hover { background: var(--blue-bg); }
.font-opt.on { background: var(--blue-bg); box-shadow: inset 3px 0 0 var(--blue); }
.font-opt .fo-name { font-size: 0.7rem; color: var(--muted); display: block; }
.font-opt .fo-sample { font-size: 1.02rem; line-height: 1.3; color: var(--navy); }
.font-status { margin-top: 0.7rem; font-size: 0.78rem; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.spinner { width: 13px; height: 13px; border: 2px solid var(--border-2); border-top-color: var(--blue); border-radius: 50%; animation: spin .6s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.profile-list { display: grid; gap: 8px; }
.profile-item { display: flex; align-items: center; gap: 10px; border: 1.5px solid var(--border); border-radius: 9px; padding: 0.55rem 0.75rem; }
.profile-item strong { font-size: 0.88rem; flex: 1; }
.profile-item span { font-size: 0.76rem; color: var(--muted); }

/* ── Card preview stage ─────────────────────────────────────── */
.preview-shell { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow-sm); }
.preview-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-2); margin-bottom: 0.6rem; }
.card-stage { background: repeating-conic-gradient(#f1f5f9 0% 25%, #ffffff 0% 50%) 50% / 16px 16px; border-radius: 8px; padding: 12px; display: flex; align-items: center; justify-content: center; }
.card-stage canvas { max-width: 100%; height: auto; border-radius: 5px; box-shadow: 0 3px 14px rgba(15,23,42,.22); display: block; }
.card-stage.big { padding: 20px; }
.preview-caption { font-size: 0.76rem; color: var(--muted); text-align: center; margin-top: 0.6rem; }

/* ── Import ─────────────────────────────────────────────────── */
.drop-zone { border: 2.5px dashed var(--border-2); border-radius: var(--radius); padding: 2.6rem 1.5rem; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; color: var(--muted); }
.drop-zone:hover, .drop-zone.dragover { border-color: var(--blue); background: var(--blue-bg); }
.drop-zone h3 { font-size: 1.05rem; color: var(--navy); margin: 0.6rem 0 0.3rem; }
.drop-zone p { font-size: 0.86rem; }
.drop-actions { display: flex; gap: 10px; justify-content: center; margin-top: 1rem; }
.accordion { border: 1px solid var(--border); border-radius: 10px; margin-top: 1rem; overflow: hidden; }
.accordion summary { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1rem; cursor: pointer; list-style: none; font-size: 0.87rem; font-weight: 600; color: var(--navy); }
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary:hover { background: var(--blue-bg); }
.accordion-chevron { color: var(--muted-2); transition: transform .2s; }
.accordion[open] .accordion-chevron { transform: rotate(90deg); }
.accordion-body { padding: 0 1rem 1rem; border-top: 1px solid var(--border); }
.accordion-body p { font-size: 0.85rem; margin-bottom: 0.4rem; }

.mapping-table-wrap { overflow-x: auto; }
.mapping-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.mapping-table th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 0.4rem 0.6rem; border-bottom: 1.5px solid var(--border); }
.mapping-table td { padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--bg); vertical-align: middle; }
.mapping-table .col-name { font-weight: 600; }
.mapping-table .col-sample { color: var(--muted); font-size: 0.8rem; font-family: 'SF Mono', Menlo, monospace; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mapping-table select { min-width: 160px; padding: 0.35rem 0.5rem; font-size: 0.82rem; }
.mapping-table tr.mapped td { background: rgba(37,99,235,.04); }

.report-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.7rem; margin-bottom: 1rem; }
.stat { border: 1.5px solid var(--border); border-radius: 10px; padding: 0.75rem 0.9rem; }
.stat.good { border-color: #a7f3d0; background: #ecfdf5; }
.stat.warn { border-color: #fde68a; background: #fffbeb; }
.stat.bad  { border-color: #fecaca; background: var(--red-bg); }
.stat .num { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat .lbl { font-size: 0.78rem; color: var(--muted); }
.report-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 0.8rem; }
.exceptions { display: grid; gap: 8px; max-height: 420px; overflow-y: auto; }
.exception { display: flex; align-items: center; gap: 11px; border: 1.5px solid var(--border); border-radius: 9px; padding: 0.55rem 0.75rem; }
.exception.err { border-color: #fecaca; background: var(--red-bg); }
.exception.warn { border-color: #fde68a; background: #fffbeb; }
.exception .ex-photo { width: 34px; height: 42px; border-radius: 5px; background: var(--bg); object-fit: cover; flex-shrink: 0; }
.exception .ex-main { flex: 1; min-width: 0; }
.exception .ex-name { font-size: 0.88rem; font-weight: 600; }
.exception .ex-why { font-size: 0.78rem; color: var(--muted); }
.unmatched-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 0.7rem; max-height: 400px; overflow-y: auto; }
.unmatched-item { border: 1.5px solid var(--border); border-radius: 9px; overflow: hidden; cursor: pointer; background: #fff; }
.unmatched-item:hover { border-color: var(--blue); }
.unmatched-item img { width: 100%; aspect-ratio: 4/5; object-fit: cover; display: block; background: var(--bg); }
.unmatched-item span { display: block; font-size: 0.68rem; color: var(--muted); padding: 4px 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Design view ────────────────────────────────────────────── */
.design-layout { max-width: 1440px; margin: 0 auto; padding: 1.2rem 1.25rem 3rem; display: grid; grid-template-columns: 306px minmax(0, 1fr); gap: 1.3rem; align-items: start; }
.design-side .side-scroll { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; padding-right: 4px; }
.template-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tpl-btn { border: 2px solid var(--border); border-radius: 9px; background: #fff; padding: 6px; cursor: pointer; text-align: left; transition: border-color .15s, box-shadow .15s; }
.tpl-btn:hover { border-color: var(--blue-mid); }
.tpl-btn.on { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.14); }
.tpl-btn canvas { width: 100%; height: auto; border-radius: 4px; display: block; background: var(--bg); }
.tpl-btn .tpl-name { font-size: 0.76rem; font-weight: 600; margin-top: 5px; color: var(--navy); }
.barcode-health { font-size: 0.78rem; margin: 0.5rem 0; padding: 0.45rem 0.6rem; border-radius: 7px; background: var(--bg); color: var(--muted); }
.barcode-health.ok { background: #ecfdf5; color: var(--green-dark); }
.barcode-health.bad { background: var(--red-bg); color: #991b1b; }

.preview-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 0.9rem; flex-wrap: wrap; }
.preview-nav { display: flex; gap: 6px; }
.preview-search { position: relative; flex: 1; min-width: 180px; }
.preview-search input { width: 100%; padding: 0.5rem 0.75rem; border: 1.5px solid var(--border); border-radius: 8px; font-size: 0.87rem; }
.search-results { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-radius: 9px; box-shadow: var(--shadow-lg); z-index: 30; max-height: 300px; overflow-y: auto; margin-top: 4px; }
.search-results button { display: block; width: 100%; text-align: left; background: none; border: none; padding: 0.5rem 0.75rem; cursor: pointer; font-size: 0.85rem; border-bottom: 1px solid var(--bg); }
.search-results button:hover, .search-results button.hi { background: var(--blue-bg); }
.stress-select { max-width: 210px; padding: 0.5rem 0.6rem; border: 1.5px solid var(--border); border-radius: 8px; font-size: 0.85rem; }
.health-chip { margin-left: auto; font-size: 0.82rem; font-weight: 600; padding: 0.4rem 0.8rem; border-radius: 99px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.health-chip.ok { background: #ecfdf5; color: var(--green-dark); }
.health-chip.warn { background: #fffbeb; color: #92400e; }
.health-chip.bad { background: var(--red-bg); color: #991b1b; }
.preview-main { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow-sm); margin-bottom: 1.1rem; }
.preview-meta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; font-size: 0.78rem; color: var(--muted); margin-top: 0.8rem; }
.preview-meta .pm { display: flex; align-items: center; gap: 5px; }
.preview-meta .pm.warn { color: #92400e; }
.preview-meta .pm.bad { color: #991b1b; }
.preview-student-bar { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 0.7rem; padding-top: 0.7rem; border-top: 1px solid var(--bg); font-size: 0.85rem; }
.preview-student-bar strong { font-weight: 600; }

.roster-card { padding: 0; overflow: hidden; }
.roster-head { display: flex; align-items: center; gap: 12px; padding: 0.9rem 1.1rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.roster-head h2 { font-size: 0.95rem; border: none; padding: 0; margin: 0; }
.roster-filters { display: flex; gap: 5px; flex-wrap: wrap; flex: 1; }
.filter-chip { background: var(--bg); border: 1.5px solid transparent; border-radius: 99px; padding: 0.24rem 0.7rem; font-size: 0.78rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.filter-chip:hover { color: var(--navy); }
.filter-chip.on { background: var(--navy); color: #fff; }
.filter-chip .cnt { opacity: .7; margin-left: 4px; }
.roster-tools { position: relative; }
.menu { position: absolute; right: 0; top: 100%; margin-top: 5px; background: #fff; border: 1px solid var(--border); border-radius: 9px; box-shadow: var(--shadow-lg); z-index: 40; min-width: 200px; overflow: hidden; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: none; padding: 0.55rem 0.85rem; font-size: 0.85rem; cursor: pointer; }
.menu button:hover { background: var(--blue-bg); }
.menu button.danger { color: var(--red); }
.menu hr { border: none; border-top: 1px solid var(--border); }
.roster-table-wrap { max-height: 460px; overflow-y: auto; position: relative; }
.roster-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.roster-table thead th { position: sticky; top: 0; background: #fff; z-index: 2; text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 0.5rem 0.7rem; border-bottom: 1.5px solid var(--border); }
.roster-table td { padding: 0.4rem 0.7rem; border-bottom: 1px solid var(--bg); }
.roster-table tbody tr { cursor: pointer; }
.roster-table tbody tr:hover { background: var(--blue-bg); }
.roster-table tbody tr.sel { background: rgba(37,99,235,.07); }
.roster-table tbody tr.disabled { opacity: .5; }
.c-sel { width: 34px; } .c-photo { width: 52px; } .c-status { width: 168px; } .c-grade { width: 92px; } .c-bar { width: 108px; }
.r-photo { width: 34px; height: 42px; border-radius: 4px; object-fit: cover; background: var(--bg); display: block; }
.r-photo.none { display: grid; place-items: center; font-size: 0.62rem; color: var(--muted-2); }
.r-name { font-weight: 600; }
.r-sub { font-size: 0.74rem; color: var(--muted); }
.r-id { font-family: 'SF Mono', Menlo, monospace; font-size: 0.8rem; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 0.72rem; font-weight: 600; padding: 0.15rem 0.5rem; border-radius: 99px; white-space: nowrap; }
.pill.ready { background: #ecfdf5; color: var(--green-dark); }
.pill.warn { background: #fffbeb; color: #92400e; }
.pill.err { background: var(--red-bg); color: #991b1b; }
.pill.info { background: var(--blue-bg); color: #1e40af; }
.pill.muted { background: var(--bg); color: var(--muted); }
.pill + .pill { margin-left: 4px; }
.roster-empty { padding: 2rem; text-align: center; color: var(--muted); font-size: 0.88rem; }

/* ── Export ─────────────────────────────────────────────────── */
.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
.preflight-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.9rem; padding-bottom: 0.55rem; border-bottom: 2px solid var(--bg); }
.preflight-head h2 { font-size: 1rem; border: none; padding: 0; margin: 0; }
.pf-list { display: grid; gap: 6px; }
.pf-row { display: flex; align-items: center; gap: 10px; font-size: 0.89rem; padding: 0.4rem 0.6rem; border-radius: 7px; }
.pf-row .pf-icon { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 0.72rem; font-weight: 700; color: #fff; flex-shrink: 0; }
.pf-row.ok .pf-icon { background: var(--green); }
.pf-row.warn { background: #fffbeb; } .pf-row.warn .pf-icon { background: var(--amber); }
.pf-row.bad { background: var(--red-bg); } .pf-row.bad .pf-icon { background: var(--red); }
.pf-row .pf-text { flex: 1; }
.pf-banner { margin-top: 1rem; padding: 1rem 1.2rem; border-radius: 10px; text-align: center; font-weight: 700; font-size: 1.05rem; }
.pf-banner.ready { background: #ecfdf5; color: var(--green-dark); border: 1.5px solid #a7f3d0; }
.pf-banner.hold { background: #fffbeb; color: #92400e; border: 1.5px solid #fde68a; }
.checking { color: var(--muted); font-size: 0.88rem; display: flex; gap: 8px; align-items: center; }
.filename-example { font-family: 'SF Mono', Menlo, monospace; font-size: 0.78rem; background: var(--navy); color: #86efac; padding: 0.5rem 0.7rem; border-radius: 7px; margin: 0.5rem 0 0.7rem; overflow-x: auto; white-space: nowrap; }

/* ── Drawer ─────────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 90; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 460px; max-width: 100vw; background: #fff; z-index: 100; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: slideIn .2s ease-out; }
@keyframes slideIn { from { transform: translateX(20px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); }
.drawer-head h3 { font-size: 1.05rem; }
.drawer-sub { font-size: 0.78rem; color: var(--muted); }
.drawer-body { flex: 1; overflow-y: auto; padding: 1.1rem 1.2rem; }
.drawer-card { background: repeating-conic-gradient(#f1f5f9 0% 25%, #ffffff 0% 50%) 50% / 14px 14px; border-radius: 8px; padding: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 1rem; }
.drawer-card canvas { max-width: 100%; height: auto; border-radius: 4px; box-shadow: 0 2px 10px rgba(15,23,42,.2); }
.drawer-section { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.drawer-notes { display: grid; gap: 6px; }
.drawer-foot { border-top: 1px solid var(--border); padding: 0.8rem 1.2rem; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.drawer-nav { display: flex; gap: 6px; }
.orig-note { font-size: 0.76rem; color: var(--muted-2); }
.crop-editor { display: grid; gap: 0.8rem; }
.crop-stage { position: relative; background: #0f172a; border-radius: 8px; overflow: hidden; display: grid; place-items: center; cursor: grab; touch-action: none; }
.crop-stage.dragging { cursor: grabbing; }
.crop-stage canvas { display: block; max-width: 100%; }
.crop-frame { position: absolute; border: 2px solid rgba(255,255,255,.9); box-shadow: 0 0 0 9999px rgba(15,23,42,.55); pointer-events: none; border-radius: 2px; }
.crop-zoom { display: flex; align-items: center; gap: 10px; font-size: 0.82rem; color: var(--muted); }
.crop-zoom input { flex: 1; accent-color: var(--blue); }
.crop-btns { display: flex; gap: 7px; flex-wrap: wrap; }
.bc-test { text-align: center; }
.bc-test canvas { max-width: 100%; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 6px; }
.bc-test .bc-status { font-size: 0.82rem; margin-top: 0.5rem; font-weight: 600; }
.bc-test .bc-status.ok { color: var(--green-dark); }
.bc-test .bc-status.bad { color: var(--red); }
.bc-test .bc-detail { font-size: 0.76rem; color: var(--muted); font-family: 'SF Mono', Menlo, monospace; }

/* ── Modal / progress / toast ───────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; padding: 1rem; }
.modal-box { background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); max-width: 520px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 1.5rem 1.6rem; }
.modal-box h3 { font-size: 1.15rem; margin-bottom: 0.5rem; }
.modal-box p { font-size: 0.9rem; color: var(--muted); margin-bottom: 1rem; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 1.2rem; flex-wrap: wrap; }
.progress-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 120; display: grid; place-items: center; }
.progress-box { background: #fff; border-radius: 14px; padding: 1.6rem 1.8rem; box-shadow: var(--shadow-lg); min-width: 340px; text-align: center; }
.progress-box h3 { font-size: 1rem; margin-bottom: 0.9rem; }
.progress-bar { height: 9px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--blue); border-radius: 99px; width: 0%; transition: width .18s; }
.progress-text { font-size: 0.84rem; color: var(--muted); margin: 0.6rem 0 0.9rem; }
.toast-stack { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 130; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { background: var(--navy); color: #fff; padding: 0.65rem 1.1rem; border-radius: 9px; font-size: 0.87rem; box-shadow: var(--shadow-lg); animation: toastIn .2s ease-out; pointer-events: auto; max-width: 92vw; display: flex; gap: 10px; align-items: center; }
.toast.ok { background: var(--green-dark); } .toast.bad { background: #991b1b; } .toast.warn { background: #92400e; }
.toast button { background: rgba(255,255,255,.2); border: none; color: #fff; border-radius: 6px; padding: 3px 9px; font-size: 0.78rem; cursor: pointer; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.site-footer { text-align: center; padding: 2rem 1rem 2.5rem; font-size: 0.78rem; color: var(--muted); border-top: 1px solid var(--border); background: #fff; }
.site-footer p { margin-bottom: 3px; }
.site-footer a { color: var(--blue); text-decoration: none; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .design-layout { grid-template-columns: 262px minmax(0, 1fr); }
  .wrap-wide { grid-template-columns: minmax(0, 1fr) 320px; }
}
@media (max-width: 980px) {
  .wrap-wide, .design-layout { grid-template-columns: minmax(0, 1fr); }
  .col-side .side-sticky, .design-side .side-scroll { position: static; max-height: none; }
  .design-side .side-scroll { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; align-items: start; }
  .welcome-cards { grid-template-columns: 1fr 1fr; }
  .export-grid { grid-template-columns: 1fr; }
  .template-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 720px) {
  .header-inner { padding: 0.7rem 1rem; }
  .header-right .header-link { display: none; }
  .steps-nav { overflow-x: auto; }
  .step-tab { padding: 0.55rem 0.7rem; font-size: 0.8rem; }
  .welcome-hero h1 { font-size: 1.7rem; }
  .welcome-cards { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .font-picker { grid-template-columns: 1fr; }
  .design-side .side-scroll { grid-template-columns: 1fr; }
  .logo-row { flex-direction: column; }
  .logo-meta { width: 100%; }
  .drawer { width: 100vw; }
  .c-bar, .c-grade { display: none; }
  .wrap, .design-layout { padding-left: 0.85rem; padding-right: 0.85rem; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
