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

:root {
  --purple: #534AB7;
  --purple-light: #EEEDFE;
  --purple-dark: #26215C;
  --border: #e2e2e2;
  --bg: #F5F5F7;
  --surface: #FFFFFF;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --radius: 10px;
  --sidebar-w: 220px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 1.25rem 1.5rem;
  font-size: 17px;
  font-weight: 600;
  color: var(--purple);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

nav { padding: 0 0.75rem; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  font-size: 14px;
  transition: background 0.12s, color 0.12s;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--purple-light); color: var(--purple); font-weight: 500; }
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 1rem 1.25rem 0;
  border-top: 1px solid var(--border);
  margin-top: auto;
  padding-top: 1rem;
}

.pill {
  background: var(--purple-light);
  color: var(--purple);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 99px;
  font-weight: 500;
}

/* ── Main ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 1080px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-header { margin-bottom: 1.5rem; }
.panel-header h1 { font-size: 24px; font-weight: 600; margin-bottom: 4px; }
.panel-header p { color: var(--muted); font-size: 14px; }

/* ── Drop zone ── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--surface);
  margin-bottom: 1rem;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--purple);
  background: var(--purple-light);
}
.drop-icon { color: var(--muted); margin-bottom: 12px; }
.drop-text { font-size: 15px; margin-bottom: 4px; }
.drop-hint { color: var(--muted); font-size: 13px; }

.sample-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 1.5rem;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 1rem;
}

/* ── Fields ── */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
}
.field span { font-size: 13px; color: var(--muted); }
.req { color: #e55; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

input[type=text], input[type=number], input[type=color], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.12s;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--purple); }
textarea { resize: vertical; }
input[type=color] {
  min-height: 38px;
  padding: 4px;
  cursor: pointer;
}

/* ── Stats ── */
.stats-row { display: flex; gap: 12px; margin-bottom: 1rem; }
.stat-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.stat-val { font-size: 26px; font-weight: 600; color: var(--text); }
.stat-lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--bg);
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  font-weight: 500;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--purple); color: #fff; border-color: var(--purple); }
.btn-primary:hover { background: var(--purple-dark); border-color: var(--purple-dark); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg); border-color: var(--border); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }
.btn-row { display: flex; gap: 10px; margin-top: 1.5rem; }

/* ── Design layout ── */
.design-layout {
  display: grid;
  grid-template-columns: minmax(600px, 1fr) minmax(700px, 1.9fr);
  gap: 1.5rem;
  margin-bottom: 1rem;
}
.design-controls { display: flex; flex-direction: column; }
.design-preview .card { padding: 1rem; }

.template-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.tmpl {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 8px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.12s;
  font-size: 12px;
  color: var(--muted);
}
.tmpl:hover { border-color: var(--purple); }
.tmpl.active { border-color: var(--purple); color: var(--purple); font-weight: 500; }
.tmpl-swatch { width: 48px; height: 32px; border-radius: 4px; border: 3px solid; }

/* ── Preview ── */
.cert-preview-wrap {
  background: var(--bg);
  border-radius: 8px;
  padding: 12px;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cert-preview-wrap--design {
  min-height: 620px;
  padding: 8px;
}
.cert-preview-wrap--design #previewImg {
  width: 100%;
  max-height: 76vh;
  object-fit: contain;
}
.preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  padding: 2rem;
}
.preview-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

/* ── Progress ── */
.progress-track {
  height: 8px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
  margin: 8px 0;
}
.progress-bar {
  height: 100%;
  background: var(--purple);
  border-radius: 99px;
  width: 0%;
  transition: width 0.3s;
}

/* ── Success ── */
.success-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #EAF3DE;
  color: #3B6D11;
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 500;
  margin-top: 1rem;
}

@media (max-width: 800px) {
  .design-layout { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; }
  .main { padding: 1.25rem; }
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .cert-preview-wrap--design { min-height: 340px; }
}
