:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #657386;
  --line: #d8dee7;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --blue: #2563eb;
  --amber: #b45309;
  --red: #b91c1c;
  --soft: #edf7f5;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  min-height: 38px;
  padding: 8px 12px;
}

button:hover {
  border-color: #aeb8c6;
}

button.primary,
a.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover,
a.primary:hover {
  background: var(--accent-dark);
}

button.danger {
  border-color: #fecaca;
  color: var(--red);
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 18px;
  min-height: 68px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 3;
}

.brand {
  align-items: center;
  display: flex;
  gap: 10px;
  min-width: 210px;
}

.brand-mark {
  align-items: center;
  background: var(--accent);
  border-radius: 6px;
  color: #fff;
  display: inline-flex;
  font-weight: 800;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.brand-mark.large {
  font-size: 24px;
  height: 62px;
  width: 62px;
}

.brand-logo {
  border: 1px solid var(--line);
  border-radius: 6px;
  height: 34px;
  object-fit: contain;
  width: 34px;
}

.brand-logo.large {
  height: 62px;
  width: 62px;
}

.brand strong {
  display: block;
  line-height: 1.1;
}

.brand span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 2px;
}

.tabs {
  display: flex;
  flex: 1;
  gap: 6px;
  overflow-x: auto;
}

.tab {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  white-space: nowrap;
}

.tab.active {
  background: var(--soft);
  border-color: #bddbd6;
  color: var(--accent-dark);
}

.workspace {
  margin: 0 auto;
  max-width: 1240px;
  padding: 26px 28px 48px;
}

.section-header {
  align-items: flex-end;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.section-header h1,
.section-header h2 {
  font-size: 24px;
  line-height: 1.2;
  margin: 0;
}

.section-header p {
  color: var(--muted);
  margin: 6px 0 0;
  max-width: 680px;
}

.stats-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 22px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.stat span {
  color: var(--muted);
  display: block;
  font-size: 13px;
}

.stat strong {
  display: block;
  font-size: 30px;
  line-height: 1.2;
  margin-top: 8px;
}

.layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) 360px;
}

.side-stack {
  display: grid;
  gap: 18px;
}

.main-stack {
  display: grid;
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.panel-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 14px 16px;
}

.panel-header h2,
.panel-header h3 {
  font-size: 16px;
  margin: 0;
}

.panel-body {
  padding: 16px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

td.actions {
  white-space: nowrap;
}

.badge-image {
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 54px;
  object-fit: cover;
  width: 54px;
}

.status {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
}

.status.issued {
  background: #dcfce7;
  color: #166534;
}

.status.issue_failed {
  background: #fee2e2;
  color: var(--red);
}

.status.pending,
.status.draft {
  background: #fef3c7;
  color: var(--amber);
}

.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid .full {
  grid-column: 1 / -1;
}

.user-form {
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
  padding-bottom: 16px;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  gap: 7px;
}

input,
textarea,
select {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 10px;
  width: 100%;
}

input[type="color"] {
  min-height: 40px;
  padding: 3px;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.color-row {
  display: grid;
  gap: 8px;
  grid-template-columns: 56px minmax(0, 1fr);
}

.inline-check {
  align-items: center;
  display: flex;
  flex-direction: row;
  gap: 10px;
}

.inline-check input {
  min-height: 18px;
  width: 18px;
}

.form-actions {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

.hint,
.empty,
.fine-print {
  color: var(--muted);
  font-size: 13px;
}

.empty {
  padding: 18px;
}

.callout {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  padding: 14px;
}

.branding-preview {
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 14px;
  margin-top: 16px;
  padding: 16px;
}

.branding-preview strong,
.branding-preview span {
  display: block;
}

.branding-preview strong {
  font-size: 18px;
}

.branding-preview span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.settings-list {
  display: grid;
  gap: 10px;
}

.settings-list div {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 8px 0;
}

.settings-list dt {
  color: var(--muted);
  font-size: 13px;
}

.settings-list dd {
  font-size: 13px;
  margin: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.toast {
  background: #17202a;
  border-radius: 8px;
  bottom: 24px;
  color: #fff;
  left: 50%;
  max-width: 520px;
  padding: 12px 16px;
  position: fixed;
  transform: translateX(-50%);
  z-index: 10;
}

.login-body {
  align-items: center;
  display: flex;
  min-height: 100vh;
  justify-content: center;
  padding: 24px;
}

.login-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 420px;
  padding: 28px;
  width: 100%;
}

.login-panel h1 {
  margin: 0 0 18px;
}

.eyebrow {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.form-error {
  color: var(--red);
  margin-bottom: 0;
}

.certificate-body {
  background: #eef1f5;
  min-height: 100vh;
}

.certificate-page {
  margin: 0 auto;
  max-width: 1080px;
  padding: 34px 24px;
}

.certificate-sheet {
  background: #fff;
  border: 1px solid #cfd6df;
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 0;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 560px;
  overflow: hidden;
}

.certificate-aside {
  background: #f8fafc;
  border-right: 1px solid var(--line);
  padding: 34px;
}

.certificate-main {
  padding: 44px;
}

.certificate-badge {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  height: 220px;
  object-fit: contain;
  padding: 18px;
  width: 220px;
}

.certificate-main h1 {
  font-size: 36px;
  line-height: 1.1;
  margin: 14px 0;
}

.certificate-main h2 {
  font-size: 22px;
  margin: 0 0 14px;
}

.certificate-main p {
  color: var(--muted);
  line-height: 1.55;
}

.recipient-name {
  color: var(--ink);
  font-size: 32px;
  font-weight: 800;
  margin: 16px 0 4px;
}

.certificate-meta {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 28px 0;
}

.certificate-meta div {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.certificate-meta span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  text-transform: uppercase;
}

.certificate-meta strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.share-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.share-row a,
.share-row button {
  align-items: center;
  border-radius: 6px;
  display: inline-flex;
  justify-content: center;
  min-height: 40px;
  padding: 8px 12px;
}

.share-row a {
  border: 1px solid var(--line);
}

@media (max-width: 900px) {
  .topbar,
  .section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    padding: 20px 14px 36px;
  }

  .stats-grid,
  .layout,
  .form-grid,
  .certificate-sheet {
    grid-template-columns: 1fr;
  }

  .certificate-aside {
    border-bottom: 1px solid var(--line);
    border-right: 0;
  }

  .certificate-main {
    padding: 28px;
  }

  .certificate-main h1 {
    font-size: 28px;
  }

  .certificate-meta {
    grid-template-columns: 1fr;
  }
}
