:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #d1d5db;
  --primary: #0f766e;
  --primary-hover: #115e59;
  --danger: #b91c1c;
  --ok-bg: #dcfce7;
  --ok-text: #166534;
  --err-bg: #fee2e2;
  --err-text: #991b1b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(circle at top left, #d8f0ec, var(--bg) 40%);
  color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

body.public-guest.bg-gradient {
  background: linear-gradient(180deg, var(--public-bg-start, #d8f0ec) 0%, var(--public-bg-end, #f4f7fb) 100%);
}

body.public-guest.bg-solid {
  background: var(--public-bg-start, #d8f0ec);
}

body.public-guest.bg-dark {
  background: linear-gradient(180deg, var(--public-bg-dark, #0f172a) 0%, #020617 100%);
}

.is-hidden { display: none !important; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.main-content { padding: 24px 0 48px; }
.main-content.guest { max-width: 700px; }
html.is-embedded .main-content.guest { padding: 12px 0 12px; }
html.is-embedded .main-content.guest .card:last-child { margin-bottom: 0; }

.topbar { background: #0b3b36; color: #fff; }
.topbar-inner { display: flex; justify-content: space-between; align-items: center; min-height: 64px; }
.brand { color: #fff; text-decoration: none; font-weight: 700; letter-spacing: .02em; }
.topnav { display: flex; gap: 16px; align-items: center; }
.topnav a, .topbar .link-button { color: #d1fae5; text-decoration: none; background: none; border: 0; cursor: pointer; font: inherit; }
.link-button {
  color: var(--primary);
  text-decoration: none;
  background: none;
  border: 0;
  cursor: pointer;
  font: inherit;
}
.link-button:hover { text-decoration: underline; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
  margin-bottom: 16px;
}
.card.medium { max-width: 720px; }
.auth-card { max-width: 500px; margin: 32px auto; }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.page-head h1 { margin: 0; font-size: 1.3rem; }

.form-stack { display: grid; gap: 10px; }
.compact-form { max-width: 320px; }
label { font-weight: 600; font-size: 0.95rem; }
input, textarea, select {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 9px 10px;
  font: inherit;
  background: #fff;
}
textarea { min-height: 110px; resize: vertical; }
textarea[readonly] { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #0f172a;
  padding: 8px 12px;
  text-decoration: none;
  cursor: pointer;
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.alert { border-radius: 8px; padding: 12px; margin-bottom: 12px; font-weight: 600; }
.alert-success { background: var(--ok-bg); color: var(--ok-text); }
.alert-error { background: var(--err-bg); color: var(--err-text); }

.field-error { margin: 2px 0 0; color: var(--danger); font-size: .86rem; }
.hint { margin: 0; color: var(--muted); font-size: .9rem; }
.js-zip-status { min-height: 1.2em; }
.required { color: #dc2626; }

.filters { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 8px; }
.submission-filters { grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto; }
.bulk-actions { margin-bottom: 10px; }
.analytics-summary {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 12px;
}
.analytics-stat { margin-bottom: 0; }
.analytics-value {
  margin: 6px 0 0;
  font-size: 1.5rem;
  font-weight: 700;
}
.analytics-bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-height: 180px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.analytics-bar-item {
  min-width: 50px;
  text-align: center;
}
.analytics-bar {
  width: 100%;
  background: linear-gradient(180deg, #0f766e 0%, #14b8a6 100%);
  border-radius: 6px 6px 0 0;
}
.analytics-field { margin-top: 16px; }
.analytics-field h3 { margin: 0 0 8px; }
.analytics-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 3fr 50px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.analytics-row-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.analytics-row-track {
  background: #e2e8f0;
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
}
.analytics-row-fill {
  height: 100%;
  background: linear-gradient(90deg, #14b8a6, #0f766e);
}
.analytics-row-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { border-bottom: 1px solid #e5e7eb; padding: 10px; vertical-align: top; text-align: left; }
.memo-cell { max-width: 280px; white-space: pre-wrap; word-break: break-word; }
.badge { padding: 2px 8px; border-radius: 999px; font-size: .75rem; }
.badge-draft { background: #fef3c7; color: #92400e; }
.badge-published { background: #dcfce7; color: #166534; }
.badge-closed { background: #fee2e2; color: #991b1b; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline; margin: 0; }
.link-button.danger { color: #b91c1c; }
.actions a,
.actions .link-button {
  color: #0b3b36;
  font-weight: 700;
  text-decoration: none;
}
.actions a:hover,
.actions .link-button:hover {
  color: #062a27;
  text-decoration: underline;
}

.builder-toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
.field-list { display: grid; gap: 10px; }
.field-item { border: 1px solid #cbd5e1; border-radius: 10px; padding: 10px; background: #f8fafc; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.field-actions { display: flex; gap: 8px; margin-top: 8px; }
.check-inline { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check-inline input { width: auto; }
.choice-group { display: grid; gap: 6px; }
.tel-split-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tel-split-row input {
  width: min(32%, 180px);
}
.tel-split-row .sep {
  color: #64748b;
  font-weight: 700;
}
.postal-split-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.postal-split-row input:first-child { width: min(28%, 140px); }
.postal-split-row input:last-child { width: min(36%, 180px); }
.postal-split-row .sep {
  color: #64748b;
  font-weight: 700;
}
.product-option { align-items: center; }
.product-option-image {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
}
.select-product-preview {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
}
.select-product-preview-image {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
}
.branding-preview {
  display: block;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
}
.branding-preview.logo {
  max-height: 60px;
  width: auto;
  max-width: 260px;
  padding: 8px;
}
.branding-preview.header {
  width: min(100%, 560px);
  max-height: 180px;
  object-fit: cover;
}
.public-field {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px;
  transition: border-color .2s, background-color .2s;
}
.public-field.is-hidden { display: none; }
.public-field.is-required {
  background: #fffbeb;
  border-color: #fef3c7;
}
.public-field.is-invalid {
  border-color: #fca5a5;
  background: #fff1f2;
}
.public-field.is-valid {
  border-color: #86efac;
  background: #f0fdf4;
}
.valid-mark {
  display: none;
  margin-left: 8px;
  color: #16a34a;
  font-weight: 700;
}
.public-field.is-valid .valid-mark { display: inline; }
.confirm-table th { width: 34%; background: #f8fafc; }
.confirm-table td, .confirm-table th { padding: 12px; }
.confirm-actions {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #e5e7eb;
}
.step-head {
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #3730a3;
  border-radius: 8px;
  padding: 10px 12px;
}
.terms-box {
  max-height: 220px;
  overflow: auto;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
  line-height: 1.7;
}
.public-field[data-type="terms"] .actions {
  margin-top: 12px;
}

.public-theme.template-classic .public-form {
  border-color: #d1d5db;
  background: #ffffff;
}

.public-header-image-wrap { margin: -18px -18px 16px; }
.public-header-image {
  display: block;
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: 12px 12px 0 0;
}

.public-logo-wrap { margin-bottom: 12px; }
.public-logo {
  display: block;
  max-width: 240px;
  max-height: 70px;
  width: auto;
  height: auto;
}

.public-theme.template-soft .public-form {
  border-color: #cbd5e1;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 12px 28px rgba(30, 41, 59, 0.08);
}

.public-theme.template-soft .public-field.is-required {
  background: #f0f9ff;
  border-color: #bae6fd;
}

.public-theme.template-contrast .public-form {
  border-color: #0f172a;
  background: #0f172a;
  color: #f8fafc;
}

.public-theme.template-contrast label,
.public-theme.template-contrast .hint,
.public-theme.template-contrast p,
.public-theme.template-contrast h1,
.public-theme.template-contrast h2 {
  color: #e2e8f0;
}

.public-theme.template-contrast input,
.public-theme.template-contrast textarea,
.public-theme.template-contrast select {
  background: #1e293b;
  color: #f8fafc;
  border-color: #334155;
}

.public-theme.template-contrast .public-field.is-required {
  background: #111827;
  border-color: #374151;
}

@media (max-width: 768px) {
  .filters { grid-template-columns: 1fr; }
  .submission-filters { grid-template-columns: 1fr; }
  .analytics-row { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: flex-start; }
}
