:root {
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-2: #eef1ee;
  --text: #1d2624;
  --muted: #5e6b68;
  --border: #d9dfdc;
  --accent: #1f6f78;
  --accent-ink: #ffffff;
  --accent-soft: #dcefee;
  --star: #b7791f;
  --danger: #b4423a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 28, .06), 0 4px 16px rgba(20, 30, 28, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131817;
    --surface: #1b2120;
    --surface-2: #232b2a;
    --text: #e7ecea;
    --muted: #9aa8a5;
    --border: #2f3a38;
    --accent: #5fb7bf;
    --accent-ink: #0d1514;
    --accent-soft: #1f3b3d;
    --star: #e0b45a;
    --danger: #e0786f;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131817; --surface: #1b2120; --surface-2: #232b2a; --text: #e7ecea; --muted: #9aa8a5;
  --border: #2f3a38; --accent: #5fb7bf; --accent-ink: #0d1514; --accent-soft: #1f3b3d; --star: #e0b45a; --danger: #e0786f;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
h2 { font-size: 1.15rem; margin: 0; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ---------- Πάνω μπάρα ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 64px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand img { width: 34px; height: 34px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-weight: 600; font-size: 1rem; }
.brand-by { font-size: .85rem; color: var(--accent); font-weight: 500; }
.tabs { display: flex; gap: 4px; }
.tab {
  border: 0; background: none; padding: 8px 12px; border-radius: 8px; cursor: pointer; color: var(--muted);
}
.tab.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.view { display: none; }
.view.active { display: block; }

/* ---------- Εργαλειοθήκη ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px 4px;
}
.gender { display: flex; align-items: center; gap: 6px; }
.gender-label { color: var(--muted); }
.gender.missing .pill { border-color: var(--danger); }
.toolbar-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.sections-nav {
  position: sticky; top: 64px; z-index: 10;
  display: flex; gap: 6px; overflow-x: auto; padding: 8px 16px;
  background: var(--bg); scrollbar-width: none;
}
.sections-nav::-webkit-scrollbar { display: none; }
.chip-nav {
  flex: none; border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 6px 12px; cursor: pointer; font-size: .9rem; color: var(--muted);
}
.chip-nav .count { font-size: .78rem; margin-left: 4px; color: var(--accent); }
.chip-nav.off { opacity: .55; }

/* ---------- Διάταξη ---------- */
.layout { display: grid; grid-template-columns: 1fr; gap: 16px; padding: 8px 16px 16px; }
@media (min-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr) minmax(380px, 40%); align-items: start; }
  .preview { position: sticky; top: 120px; max-height: calc(100vh - 136px); display: flex; flex-direction: column; }
  .fab, .close-preview { display: none !important; }
}
@media (max-width: 1099px) {
  .preview { display: none; }
  .preview.open {
    display: flex; flex-direction: column; position: fixed; inset: 0; z-index: 30; border-radius: 0;
    padding-top: max(16px, env(safe-area-inset-top));
  }
}

/* ---------- Ενότητες φόρμας ---------- */
.section {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 16px; scroll-margin-top: 124px;
}
.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.section.off .section-head { border-bottom: 0; }
.section.off .section-body { display: none; }
.section-body { padding: 4px 16px 12px; }
.group { padding: 10px 0; border-bottom: 1px dashed var(--border); }
.group:last-child { border-bottom: 0; }
.group-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 4px 0 8px; font-weight: 600; }

.field { display: grid; grid-template-columns: 170px 1fr; gap: 6px 12px; align-items: start; padding: 6px 0; }
.field.nolabel { grid-template-columns: 1fr; }
.field.nolabel .field-name { display: none; }
@media (max-width: 640px) { .field { grid-template-columns: 1fr; } }
.field-name { color: var(--muted); padding-top: 7px; font-size: .92rem; }
.options { display: flex; flex-wrap: wrap; gap: 6px; }

.pill {
  min-height: 36px; padding: 6px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-size: .92rem; line-height: 1.2; touch-action: manipulation;
}
.pill:hover { border-color: var(--accent); }
.pill.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pill.multi.on::before { content: "✓ "; }

/* πλέγμα επιπέδων */
.grid { width: 100%; border-collapse: collapse; }
.grid td { padding: 5px 0; vertical-align: middle; }
.grid td:first-child { color: var(--text); padding-right: 12px; width: 38%; }
@media (max-width: 640px) {
  .grid tr { display: block; padding: 6px 0; }
  .grid td { display: block; width: auto !important; }
}

textarea, input, select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
}
textarea { min-height: 64px; resize: vertical; }
textarea:focus, input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* διακόπτης */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--muted); font-size: .9rem; }
.switch input { display: none; }
.switch .track { width: 40px; height: 24px; border-radius: 999px; background: var(--border); position: relative; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }

/* παρεμβάσεις */
.int-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--surface-2); cursor: pointer; }
.int-item input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.int-item .star { color: var(--star); font-size: .8rem; white-space: nowrap; }

/* ---------- Προεπισκόπηση ---------- */
.preview {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; gap: 10px;
}
.preview-head { display: flex; justify-content: space-between; align-items: center; }
.preview-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.preview-body {
  flex: 1; overflow-y: auto; font-family: Calibri, "Segoe UI", system-ui, sans-serif; font-size: .95rem; line-height: 1.6;
  text-align: justify; padding-right: 4px; min-height: 120px;
}
.preview-body p { margin: 0 0 .8em; }
.preview-body ul { margin: 0 0 .8em; padding-left: 1.2em; }
.preview-body .diag { text-align: center; font-weight: 600; }
.preview-body .empty { color: var(--muted); text-align: left; }
.ph { background: var(--accent-soft); color: var(--accent); border-radius: 4px; padding: 0 4px; font-weight: 600; white-space: nowrap; }
.preview-edit { flex: 1; min-height: 50vh; font-family: Calibri, "Segoe UI", sans-serif; line-height: 1.55; }
.edited-banner { background: var(--accent-soft); border-radius: 8px; padding: 8px 10px; font-size: .88rem; }

/* ---------- Κουμπιά ---------- */
.btn {
  min-height: 38px; padding: 8px 14px; border-radius: 9px; cursor: pointer; border: 1px solid var(--border);
  background: var(--surface); font-weight: 500; touch-action: manipulation;
}
.btn.small { min-height: 32px; padding: 5px 10px; font-size: .88rem; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.block { width: 100%; }
.btn.icon { border: 0; background: none; font-size: 1.1rem; }
.link { border: 0; background: none; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 0; }

.fab {
  position: fixed; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 25;
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px;
  padding: 12px 20px; font-weight: 600; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); cursor: pointer;
}

/* ---------- Σελίδες ---------- */
.page { max-width: 860px; margin: 0 auto; padding: 20px 16px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.page-head > div { display: flex; gap: 6px; }
.field-label { display: block; margin: 14px 0 6px; color: var(--muted); font-size: .9rem; }
.field-label input, .field-label textarea { margin-top: 6px; color: var(--text); }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; }
.hint { color: var(--muted); font-size: .85rem; margin: 6px 0; }
.search { margin: 10px 0 14px; }

.hist-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px;
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
}
.hist-main { font-weight: 600; }
.hist-meta { color: var(--muted); font-size: .88rem; }
.hist-actions { grid-row: span 2; display: flex; gap: 6px; }
.hist-diag { grid-column: 1; font-size: .9rem; }

/* ---------- Διάλογοι ---------- */
dialog {
  border: 1px solid var(--border); border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
dialog::backdrop { background: rgba(10, 16, 15, .45); }
.dlg { padding: 20px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.tpl-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--surface-2); }
.tpl-item div { display: flex; gap: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; transition: all .2s; z-index: 50; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.credits {
  text-align: center; color: var(--muted); font-size: 1.05rem; line-height: 1.6;
  margin: 24px 16px 0; padding: 24px 16px 104px; border-top: 1px solid var(--border);
}
.credits strong { display: block; color: var(--text); font-weight: 700; font-size: 1.35rem; }
.credits a { color: var(--accent); text-decoration: none; font-weight: 500; }
.credits-label { display: block; font-size: .95rem; letter-spacing: .02em; }
.credits a:hover { text-decoration: underline; }

@media (max-width: 520px) {
  .brand-text { display: none; }
  .brand img { width: 30px; height: 30px; }
  .topbar { gap: 8px; }
  .tabs { min-width: 0; }
  .tab { padding: 8px 8px; font-size: .9rem; }
  .tab { padding: 8px 9px; }
}
