:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --border: #e2e6e9;
  --text: #1b2530;
  --text-muted: #6b7680;
  --accent: #1f6f66;
  --accent-dark: #14453f;
  --accent-soft: #eaf3f1;
  --danger: #b3403a;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--accent-dark);
  color: #fff;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.topbar .brand { font-weight: 700; font-size: 17px; color: #fff; letter-spacing: 0.2px; text-decoration: none; }
.topbar .brand:hover { color: #fff; text-decoration: none; opacity: 0.85; }
.topbar nav { display: flex; align-items: center; gap: 20px; }
.topbar nav a { color: #d7e6e3; font-size: 14px; white-space: nowrap; }
.topbar nav a.active, .topbar nav a:hover { color: #fff; }
.topbar nav a.btn { text-decoration: none; }
.topbar nav a.btn-primary, .topbar nav a.btn-primary:hover { color: #fff; }
.lang-switch { display: flex; align-items: center; gap: 4px; border-left: 1px solid #3a4c5e; padding-left: 16px; }
.lang-switch a { font-size: 12px; font-weight: 600; color: #7f97a8; padding: 2px 5px; border-radius: 4px; text-decoration: none; }
.lang-switch a.active { color: #fff; background: #3a4c5e; }
.lang-switch a:hover { color: #fff; }

.hero {
  background: linear-gradient(180deg, var(--accent-dark) 0%, #1c342f 100%);
  color: #fff;
  padding: 64px 24px 72px;
}
.hero-inner { max-width: 720px; margin: 0 auto; text-align: center; }
.hero h1 { font-size: 34px; line-height: 1.25; margin: 0 0 16px; }
.hero-sub { font-size: 16px; line-height: 1.55; color: #d7e6e3; margin: 0 0 28px; }
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero-cta .btn { padding: 10px 20px; font-size: 14.5px; }
.hero-cta .btn:not(.btn-primary) { background: transparent; border-color: #3a5a53; color: #fff; }
.hero-cta .btn:not(.btn-primary):hover { border-color: #fff; color: #fff; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-top: -36px;
  margin-bottom: 20px;
}
.feature-card h3 { font-size: 15.5px; margin: 0 0 8px; color: var(--accent-dark); }
.feature-card p { margin: 0; color: var(--text-muted); font-size: 13.6px; line-height: 1.5; }

.landing-footer { text-align: center; padding: 30px 20px 50px; color: var(--text-muted); font-size: 13px; }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.subtitle { color: var(--text-muted); margin: 0 0 22px; font-size: 14px; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13.5px;
  cursor: pointer;
  line-height: 1.3;
}
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 13.8px; vertical-align: middle; }
th { color: var(--text-muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.4px; }
tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11.5px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 600;
}
.badge.muted { background: #eef0f2; color: var(--text-muted); }

.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}

/* forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.8px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.3px; }
.field input[type=text], .field input[type=email], .field input[type=tel], .field textarea, .field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
}
.field textarea { resize: vertical; min-height: 70px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 14px; }

.section-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  background: #fbfcfc;
}
.section-block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.section-block-head strong { font-size: 14px; }

.repeat-item {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #fff;
  position: relative;
}
.repeat-item .remove-btn {
  position: absolute;
  top: 8px;
  right: 8px;
}

.bullets-list .bullet-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}
.bullets-list .bullet-row input { flex: 1; }

.tags-input .tag-row { display: flex; gap: 6px; margin-bottom: 6px; }
.tags-input .tag-row input { flex: 1; }

.toolbar { display: flex; gap: 10px; align-items: center; margin: 18px 0; flex-wrap: wrap; }

.save-bar {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 20px;
  margin: 24px -24px -60px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
}

.toast {
  position: fixed;
  top: 18px;
  right: 18px;
  background: var(--accent-dark);
  color: #fff;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13.5px;
  opacity: 0;
  transform: translateY(-8px);
  transition: all 0.2s ease;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 25, 30, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal {
  background: #fff;
  border-radius: 10px;
  padding: 22px 24px;
  width: 420px;
  max-width: 92vw;
}
.modal h2 { margin-bottom: 16px; }
.modal .actions-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.hidden { display: none !important; }

.section-heading {
  margin: 32px 0 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border, #e2e2e2);
}
.section-heading:first-of-type {
  margin-top: 8px;
  padding-top: 0;
  border-top: none;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 300px);
  justify-content: center;
  gap: 22px;
}
.template-card { width: 300px; }

/* Thumbnails render the real A4 page at full size in the iframe, then
   scale the whole thing down with a CSS transform so the entire page is
   visible at a glance instead of a tiny scrollable slice of it. */
.thumb-wrap {
  width: 260px;
  height: 368px;
  margin: 0 auto 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  position: relative;
  box-shadow: 0 1px 4px rgba(20, 30, 40, 0.1);
}
.thumb-wrap iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 794px;
  height: 1123px;
  border: 0;
  transform: scale(0.3275);
  transform-origin: top left;
  pointer-events: none;
}
.thumb-fullview {
  display: block;
  text-align: center;
  font-size: 12.5px;
  margin-bottom: 10px;
}
.template-card h3 { margin: 12px 0 4px; }
.template-card p { color: var(--text-muted); font-size: 13.2px; margin: 0 0 6px; }

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.preview-pane {
  position: sticky;
  top: 16px;
}
.preview-pane iframe {
  width: 100%;
  height: 80vh;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}
@media (max-width: 980px) {
  .editor-layout { grid-template-columns: 1fr; }
  .preview-pane { position: static; }
}
