:root {
  --bg: #f5f7f7;
  --surface: #ffffff;
  --ink: #111827;
  --muted: #667085;
  --line: #d9e1e2;
  --primary: #06414a;
  --primary-2: #0c6a70;
  --success: #16803c;
  --danger: #b42318;
  --warning: #b54708;
  --radius: 8px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}
a { color: inherit; }
.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 48px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 800;
  letter-spacing: .01em;
}
.brand::before {
  content: "";
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}
.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.admin-nav a {
  min-height: 36px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  text-decoration: none;
  color: var(--muted);
  font-size: 14px;
}
.hero {
  min-height: calc(100vh - 120px);
  display: grid;
  grid-template-columns: minmax(0, .86fr) minmax(520px, 1.14fr);
  gap: 36px;
  align-items: center;
}
.hero-copy h1,
.page-head h1 {
  margin: 8px 0 10px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.04;
  letter-spacing: 0;
}
.hero-copy p,
.page-head p {
  max-width: 630px;
  color: var(--muted);
  font-size: 18px;
  margin: 0 0 28px;
}
.system-mark,
.page-head span {
  color: var(--primary-2);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 13px;
}
.hero-preview {
  overflow: auto;
  padding: 18px;
}
.signature-card,
.signature-output {
  background: #fff;
  width: max-content;
  max-width: 100%;
}
.sample { transform-origin: left center; transform: scale(.78); }
.workspace { padding-top: 24px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 18px;
}
.panel h1,
.panel h2 {
  margin: 0 0 18px;
  line-height: 1.2;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}
.select-card {
  display: block;
  min-height: 88px;
  cursor: pointer;
}
.select-card input { position: absolute; opacity: 0; pointer-events: none; }
.select-card span {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-height: 88px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.select-card input:checked + span {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(6, 65, 74, .12);
}
.select-card small { color: var(--muted); }
.logo-strip {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.logo-strip img {
  max-height: 42px;
  max-width: 110px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--primary);
  padding: 8px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}
.field input,
.field select,
.field textarea,
.toolbar input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}
.field textarea { min-height: 96px; resize: vertical; }
.code-editor {
  min-height: 280px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
}
.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-weight: 700;
}
.switch input { width: 18px; height: 18px; }
.actions,
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 10px 15px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}
.button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.button.ghost {
  background: transparent;
}
.button.large {
  min-width: 146px;
  min-height: 50px;
}
.button.full { width: 100%; margin-top: 12px; }
.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 18px;
  align-items: start;
}
.preview-panel { overflow: auto; }
.action-panel {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 10px;
}
.admin-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
}
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.stat strong { display: block; font-size: 34px; line-height: 1; }
.stat span { color: var(--muted); text-transform: capitalize; }
.table-wrap { overflow: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: middle;
}
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.thumb {
  max-width: 74px;
  max-height: 38px;
  object-fit: contain;
  background: var(--primary);
  border-radius: 6px;
  padding: 5px;
}
.brand-card-logo {
  display: block;
  max-width: 100px;
  max-height: 36px;
  object-fit: contain;
  background: var(--primary);
  border-radius: 6px;
  padding: 6px;
  margin-bottom: 6px;
}
.row-action {
  color: var(--primary);
  font-weight: 800;
  text-decoration: none;
}
.row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.row-actions form {
  margin: 0;
}
.row-action.danger-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--danger);
  font: inherit;
  cursor: pointer;
}
.template-preview {
  margin-top: 22px;
  overflow: auto;
}
.template-preview .signature-output {
  transform: scale(.45);
  transform-origin: left top;
  min-height: 270px;
}
.alert {
  border-radius: 7px;
  padding: 12px 14px;
  margin: 12px 0;
  border: 1px solid var(--line);
  background: #fff;
}
.alert.success { border-color: rgba(22,128,60,.35); color: var(--success); }
.alert.danger { border-color: rgba(180,35,24,.35); color: var(--danger); }
.alert.warning { border-color: rgba(181,71,8,.35); color: var(--warning); }
.empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 7px;
  padding: 18px;
}
.empty.small { padding: 12px; }
.hint {
  color: var(--muted);
  font-size: 13px;
  margin: 8px 0 14px;
}
.login-box {
  min-height: calc(100vh - 120px);
  display: grid;
  place-items: center;
}
.login-box .panel { width: min(420px, 100%); }

@media (max-width: 900px) {
  .hero,
  .result-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }
  .hero { align-items: start; padding-top: 30px; }
  .hero-preview { padding: 0; }
  .sample { transform: scale(.62); }
  .form-grid { grid-template-columns: 1fr; }
  .action-panel { position: static; }
}

@media (max-width: 560px) {
  .shell { width: min(100% - 20px, 1180px); }
  .panel { padding: 16px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .sample { transform: scale(.45); }
  .hero-preview { min-height: 270px; }
}
