:root {
  --bg: #f4f6fb;
  --bg-elevated: #fff;
  --card: #fff;
  --ink: #0b1328;
  --ink-soft: #334155;
  --muted: #64748b;
  --primary: #1e40af;
  --primary-dark: #152b7a;
  --primary-light: #3b82f6;
  --primary-50: #eef2ff;
  --primary-100: #e0e7ff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --ok: #047857;
  --ok-bg: #d1fae5;
  --err: #b91c1c;
  --err-bg: #fee2e2;
  --wait: #b45309;
  --wait-bg: #fef3c7;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 4px 12px rgba(15, 23, 42, .08);
  --shadow-lg: 0 8px 32px rgba(15, 23, 42, .12);
  --radius: 10px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ============ HEADER ============ */
header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
  color: #fff;
  padding: 14px 0;
  margin-bottom: 28px;
  box-shadow: 0 2px 12px rgba(30, 64, 175, .18);
}
header .wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.brand {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -.01em;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.brand-logo {
  width: 32px; height: 32px;
  background: rgba(255,255,255,.14);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}
nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
nav a {
  color: rgba(255,255,255,.86);
  text-decoration: none;
  font-weight: 500;
  font-size: .92rem;
  padding: 7px 14px;
  border-radius: 7px;
  transition: all .15s;
}
nav a:hover { color: #fff; background: rgba(255,255,255,.1); }
.navuser {
  color: rgba(255,255,255,.88);
  margin-left: 10px;
  font-size: .9rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.navtag {
  display: inline-block;
  background: rgba(255,255,255,.18);
  color: #fff;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: .68rem;
  font-weight: 700;
  margin-left: 4px;
  letter-spacing: .02em;
}

/* ============ LAYOUT ============ */
main { padding-bottom: 80px; }
footer {
  color: var(--muted);
  padding: 28px 0;
  font-size: .85rem;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* ============ CARDS ============ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.card.narrow { max-width: 480px; margin-left: auto; margin-right: auto; }

h1 { margin-top: 0; color: var(--ink); font-weight: 700; font-size: 1.6rem; letter-spacing: -.02em; }
h2 { margin-top: 0; color: var(--ink); font-size: 1.1rem; font-weight: 700; letter-spacing: -.01em; }
h3 { color: var(--ink-soft); font-size: .96rem; margin-top: 20px; margin-bottom: 8px; font-weight: 600; }

.muted { color: var(--muted); }
.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ============ FORMS ============ */
.form label {
  display: block;
  margin-bottom: 16px;
  font-weight: 600;
  color: var(--ink);
  font-size: .9rem;
}
.form label input,
.form label textarea,
.form label select {
  font-weight: 400;
  margin-top: 6px;
}

input[type=text], input[type=email], input[type=password],
input[type=date], input[type=datetime-local], input[type=number],
textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: #fff;
  font: inherit;
  color: var(--ink);
  transition: all .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .14);
}
input:disabled, textarea:disabled, select:disabled {
  background: #f8fafc; color: var(--muted); cursor: not-allowed;
}

small.muted { display: block; font-weight: 400; color: var(--muted); margin-top: 4px; font-size: .82em; }

/* ============ BUTTONS ============ */
button, .btn, .primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 600;
  font-size: .92rem;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
button:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
button:active { transform: translateY(0); }
button.secondary, .btn-secondary {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--primary);
}
button.secondary:hover, .btn-secondary:hover { background: var(--primary-50); color: var(--primary-dark); }
button.ghost { background: transparent; color: var(--ink-soft); }
button.ghost:hover { background: var(--primary-50); color: var(--primary); }
.btn-link {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 7px;
  font-weight: 600;
  font-size: .9rem;
  transition: all .15s;
}
.btn-link:hover { background: var(--primary-dark); transform: translateY(-1px); }
.link-danger {
  background: transparent;
  color: var(--err);
  border: none;
  cursor: pointer;
  font-weight: 500;
  padding: 0;
  margin-left: 10px;
  font-size: .9rem;
  text-decoration: underline;
}
.link-danger:hover { color: #7f1d1d; background: transparent; }

/* ============ TABLE ============ */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th {
  color: var(--muted);
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 700;
  background: #f8fafc;
}
tbody tr:hover { background: #fafbfe; }

code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .82em;
  background: var(--primary-50);
  color: var(--primary-dark);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ============ BADGES ============ */
.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .02em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge.ok   { background: var(--ok-bg);   color: var(--ok); }
.badge.err  { background: var(--err-bg);  color: var(--err); }
.badge.wait { background: var(--wait-bg); color: var(--wait); }
.badge.primary { background: var(--primary-50); color: var(--primary); }

/* ============ GRIDS ============ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }

.sign-grid {
  display: grid;
  grid-template-columns: minmax(320px, 380px) 1fr;
  gap: 24px;
}
@media (max-width: 1000px) { .sign-grid { grid-template-columns: 1fr; } }
.sign-grid .form-side { font-size: .9rem; }
.sign-grid .pdf-side .card { padding: 16px; }

/* ============ DASHBOARD ============ */
.dashboard-hero {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  padding: 30px 32px;
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.dashboard-hero h1 { color: #fff; margin: 0 0 6px; font-size: 1.5rem; }
.dashboard-hero p { color: rgba(255,255,255,.9); margin: 0; }

.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.action-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-decoration: none;
  color: inherit;
  transition: all .18s;
  display: block;
  position: relative;
  overflow: hidden;
}
.action-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.action-card .icon {
  width: 44px; height: 44px;
  background: var(--primary-50);
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 14px;
  color: var(--primary);
}
.action-card h3 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
}
.action-card p { margin: 0; color: var(--muted); font-size: .88rem; }
.action-card .arrow {
  position: absolute;
  top: 24px; right: 24px;
  color: var(--border-strong);
  transition: all .18s;
}
.action-card:hover .arrow { color: var(--primary); transform: translateX(3px); }

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-tile {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-tile .label {
  color: var(--muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  margin-bottom: 4px;
}
.stat-tile .value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
}
.stat-tile .sub { color: var(--muted); font-size: .82rem; margin-top: 2px; }

/* ============ KV / INFO BOX ============ */
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 10px 20px; }
.kv dt { color: var(--muted); font-weight: 500; font-size: .88rem; }
.kv dd { margin: 0; word-break: break-all; font-size: .9rem; }

.checks { list-style: none; padding-left: 0; }
.checks li {
  padding: 11px 14px;
  border-radius: 7px;
  margin-bottom: 8px;
  background: var(--primary-50);
  font-size: .9rem;
}
.checks li.ok  { background: var(--ok-bg); color: var(--ok); }
.checks li.err { background: var(--err-bg); color: var(--err); }

.flashes { margin-bottom: 20px; }
.flash {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 10px;
  font-size: .92rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.flash.error { background: var(--err-bg); color: var(--err); border-left: 3px solid var(--err); }
.flash.message { background: var(--primary-50); color: var(--primary-dark); border-left: 3px solid var(--primary); }

.info-box {
  background: var(--primary-50);
  border-left: 4px solid var(--primary);
  padding: 14px 18px;
  border-radius: 6px;
  margin-top: 12px;
  font-size: .92rem;
}

/* ============ SIGNERS ============ */
.signer-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  line-height: 1.35;
  font-size: .88em;
  white-space: nowrap;
}
.signer-line .dot { color: var(--primary); flex: 0 0 auto; }
.signer-line .signer-name { font-weight: 500; }
.signer-line .signer-date { font-size: .85em; }

/* ============ DOCS TABLE ============ */
.docs-table { table-layout: fixed; }
.docs-table th:nth-child(1) { width: 42%; }
.docs-table th:nth-child(2) { width: 24%; }
.docs-table th:nth-child(3) { width: 12%; }
.docs-table th:nth-child(4) { width: 10%; }
.docs-table th:nth-child(5) { width: 12%; }
.docs-table td { vertical-align: top; overflow: hidden; }
.docs-table td.nowrap { white-space: nowrap; }

.doc-cell { min-width: 0; }
.doc-title {
  font-weight: 600;
  color: var(--text, #111);
  font-size: 1.0rem;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-fname {
  font-size: .72rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 2px;
  color: var(--muted, #777);
}

.signers-cell { min-width: 0; }

@media (max-width: 900px) {
  .docs-table { table-layout: auto; }
  .doc-title, .doc-fname { white-space: normal; }
}

/* ============ DOC ROW HOVER + PREVIEW BUTTON ============ */
.doc-row { cursor: pointer; transition: background 120ms ease; }
.doc-row:hover { background: #f8fafc; }
.doc-row td { position: relative; }
.btn-preview {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  font-size: .82rem;
  background: var(--primary, #2563eb);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: background 120ms ease;
}
.btn-preview:hover { background: #1d4ed8; }

/* ============ DOC MODAL (DocuSign-style preview) ============ */
.doc-modal {
  position: fixed; inset: 0;
  z-index: 100;
  display: flex; align-items: stretch; justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 160ms ease;
}
.doc-modal[aria-hidden="false"] {
  pointer-events: auto;
  opacity: 1;
}
.doc-modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
}
.doc-modal__panel {
  position: relative;
  margin: 24px auto;
  width: min(1200px, 95vw);
  height: calc(100vh - 48px);
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(10px);
  transition: transform 160ms ease;
}
.doc-modal[aria-hidden="false"] .doc-modal__panel {
  transform: translateY(0);
}
.doc-modal__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  background: #fafbfc;
}
.doc-modal__titles { min-width: 0; flex: 1; }
.doc-modal__title {
  font-weight: 600;
  font-size: 1.05rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.doc-modal__fname {
  font-size: .72rem;
  color: var(--muted, #777);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.doc-modal__actions { display: flex; align-items: center; gap: 8px; }
.doc-modal__actions .small { padding: 6px 10px; font-size: .82rem; }
.btn-close {
  background: transparent; border: none;
  width: 32px; height: 32px;
  border-radius: 6px;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--muted, #777);
}
.btn-close:hover { background: #e5e7eb; color: #111; }
.doc-modal__body { flex: 1; background: #f3f4f6; }
.doc-modal__body iframe { width: 100%; height: 100%; border: 0; background: #fff; }

body.modal-open { overflow: hidden; }

/* ============ SEARCH BAR ============ */
.search-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 12px 0 4px;
  background: #f8fafc;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  padding: 2px 4px;
}
.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 12px;
  font-size: .95rem;
  outline: none;
}
.search-bar input::placeholder { color: var(--muted, #94a3b8); }
#docs-search-clear {
  background: transparent;
  border: none;
  width: 32px; height: 32px;
  border-radius: 6px;
  color: var(--muted, #777);
  cursor: pointer;
  font-size: 1.0rem;
}
#docs-search-clear:hover { background: #e5e7eb; color: #111; }
.signers { list-style: none; padding: 0; }
.signers li { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.signers li:last-child { border-bottom: none; }
.files { list-style: none; padding-left: 0; }
.files li { padding: 6px 0; font-size: .9rem; }

/* ============ POSITION PICKER ============ */
.pos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 8px 0 4px;
  max-width: 280px;
}
.pos-grid label {
  margin: 0;
  font-weight: 500;
  background: #fff;
  border: 1.5px solid var(--border-strong);
  border-radius: 7px;
  padding: 10px 0;
  text-align: center;
  cursor: pointer;
  user-select: none;
  font-size: .82em;
  transition: all .12s;
}
.pos-grid input[type=checkbox] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.pos-grid label:has(input:checked) {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.pos-grid label:hover { border-color: var(--primary-light); }

/* ============ CHAIN ============ */
.chain-explainer {
  background: var(--primary-50);
  border-left: 4px solid var(--primary);
  padding: 14px 18px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: .92rem;
}
.chain-explainer code { background: rgba(255,255,255,.75); }
.chain-flow { font-family: ui-monospace, Menlo, monospace; font-size: .82em; color: var(--muted); }
.chain-arrow { color: var(--primary); font-weight: 700; }

/* ============ FIELDSETS ============ */
fieldset.perms {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 18px;
}
fieldset.perms legend { color: var(--primary); font-weight: 600; padding: 0 8px; font-size: .9rem; }
label.cb { display: block; margin-bottom: 11px; font-weight: 400; font-size: .9rem; }
label.cb input[type=checkbox] { margin-right: 7px; }

/* ============ DRAG-DROP ============ */
.position-mode-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.position-mode-tabs button {
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 9px 16px;
  font-weight: 600;
  font-size: .88rem;
  cursor: pointer;
  border-radius: 0;
  transition: all .15s;
}
.position-mode-tabs button:hover { background: transparent; color: var(--primary); transform: none; box-shadow: none; }
.position-mode-tabs button.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.pos-section { margin-bottom: 12px; }
.pos-section.hidden { display: none; }

#pdf-canvas-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #f5f5f5;
}
#pdf-canvas { display: block; max-width: 100%; height: auto; }
.draggable-stamp {
  position: absolute;
  background: rgba(238, 242, 255, .75);
  border: 1.5px dashed var(--primary);
  border-radius: 5px;
  padding: 6px 8px;
  cursor: grab;
  user-select: none;
  font-size: .68rem;
  color: var(--primary-dark);
  font-family: ui-monospace, Menlo, monospace;
  text-align: center;
  min-width: 110px;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(30, 64, 175, .2);
}
.draggable-stamp:active { cursor: grabbing; }
.draggable-stamp .sig-name {
  font-family: "Brush Script MT", "Caveat", "Snell Roundhand", cursive;
  font-size: 1.1rem;
  font-style: italic;
  color: var(--primary-dark);
  display: block;
  margin-bottom: 2px;
}
.draggable-stamp .sig-divider {
  border-top: 1px solid var(--primary-dark);
  margin: 1px 4px 2px;
}
.draggable-stamp .sig-verified {
  font-weight: 700;
  font-size: .64rem;
  letter-spacing: .03em;
}
.drag-hint {
  background: var(--primary-50);
  color: var(--primary-dark);
  padding: 9px 13px;
  border-radius: 6px;
  font-size: .85rem;
  margin-bottom: 10px;
}
.pdf-nav {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  font-size: .9rem;
}
.pdf-nav button {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--border-strong);
  padding: 5px 11px;
  font-size: .85rem;
}
.pdf-nav button:hover { background: var(--primary-50); transform: none; box-shadow: none; }

/* ============ RESPONSIVE ============ */
@media (max-width: 640px) {
  .wrap { padding: 0 14px; }
  header { padding: 12px 0; margin-bottom: 20px; }
  .brand { font-size: 1rem; }
  nav a { padding: 5px 10px; font-size: .85rem; margin-left: 6px; }
  .navuser { display: none; }
  .card { padding: 18px 20px; }
  h1 { font-size: 1.3rem; }
  .dashboard-hero { padding: 22px 20px; }
}

/* =====================================================================
   v2 design layer (2026-10-31) — modern, nyugodt felület
   Elrendezés-minták: felső navigáció, gyorsnézetes dokumentumlista,
   aláírónkénti állapot + előzmények. A régi osztálynevek megmaradnak,
   csak a megjelenésük frissül.
   ===================================================================== */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --ink: #111827;
  --ink-soft: #374151;
  --muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --primary: #1d4ed8;
  --primary-dark: #1e3a8a;
  --primary-light: #3b82f6;
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --ok: #047857;  --ok-bg: #ecfdf5;
  --err: #b91c1c; --err-bg: #fef2f2;
  --wait: #b45309; --wait-bg: #fffbeb;
  --info: #1d4ed8; --info-bg: #eff6ff;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(17,24,39,.05);
  --shadow: 0 1px 3px rgba(17,24,39,.08), 0 1px 2px rgba(17,24,39,.04);
}
body { background: var(--bg); font-size: 15px; }
.wrap { max-width: 1240px; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3 { font-size: 1rem; }

/* ---- felső sáv ---- */
header.topbar {
  background: var(--surface); color: var(--ink);
  border-bottom: 1px solid var(--border);
  box-shadow: none; padding: 0; margin-bottom: 24px;
  position: sticky; top: 0; z-index: 50;
}
header.topbar .wrap { height: 60px; flex-wrap: nowrap; gap: 24px; }
header.topbar .brand { color: var(--ink); font-weight: 700; font-size: 1.02rem; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
header.topbar .brand-logo {
  width: 30px; height: 30px; border-radius: 8px; background: var(--primary);
  color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: .9rem;
}
.mainnav { display: flex; align-items: stretch; gap: 2px; flex: 1; height: 60px; overflow-x: auto; scrollbar-width: none; }
.mainnav::-webkit-scrollbar { display: none; }
.mainnav > a, .mainnav > details > summary {
  color: var(--ink-soft); text-decoration: none; padding: 0 12px; display: flex; align-items: center;
  font-weight: 500; font-size: .93rem; border-bottom: 2px solid transparent; white-space: nowrap;
  cursor: pointer; list-style: none; background: none; border-radius: 0;
}
.mainnav > details > summary::-webkit-details-marker { display: none; }
.mainnav > a:hover, .mainnav > details > summary:hover { color: var(--primary); background: none; }
.mainnav > a.active, .mainnav > details.active > summary { color: var(--primary); border-bottom-color: var(--primary); }
.mainnav details { position: relative; display: flex; }
.mainnav .menu {
  position: fixed; margin-top: 58px; min-width: 220px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(17,24,39,.12);
  padding: 6px; z-index: 60;
}
.mainnav .menu a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; font-size: .92rem; }
.mainnav .menu a:hover { background: var(--surface-2); }
.mainnav .menu .menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.navtag { background: var(--err); color: #fff; border-radius: 999px; font-size: .7rem; padding: 1px 6px; margin-left: 6px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.btn-start {
  background: var(--primary); color: #fff !important; text-decoration: none; font-weight: 600;
  padding: 8px 14px; border-radius: var(--radius); font-size: .9rem; display: inline-flex; gap: 6px; align-items: center;
}
.btn-start:hover { background: var(--primary-dark); }
.avatar {
  width: 34px; height: 34px; border-radius: 999px; background: var(--primary-100); color: var(--primary-dark);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem;
  text-decoration: none; position: relative;
}
.avatar .admin-dot { position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 999px; background: var(--wait); border: 2px solid #fff; }
.logout-link { color: var(--muted); font-size: .85rem; text-decoration: none; }
.logout-link:hover { color: var(--ink); }

/* ---- kártyák, gombok ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 20px 22px; margin-bottom: 18px; }
button, .btn, .primary { border-radius: var(--radius); }
.btn-secondary, a.btn-secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--border-strong); padding: 7px 12px; border-radius: var(--radius); text-decoration: none; font-weight: 500; font-size: .9rem; display: inline-flex; gap: 6px; align-items: center; }
.btn-secondary:hover { background: var(--surface-2); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 2px 0 0; color: var(--muted); }
.dashboard-hero { background: none; border: 0; padding: 0; margin-bottom: 18px; box-shadow: none; color: var(--ink); }
.dashboard-hero h1 { color: var(--ink); }
.dashboard-hero p { color: var(--muted); }

/* ---- státusz chip ---- */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 999px; background: currentColor; }
.chip.wait { background: var(--wait-bg); color: var(--wait); }
.chip.info { background: var(--info-bg); color: var(--info); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.err { background: var(--err-bg); color: var(--err); }
.chip.muted { background: #f3f4f6; color: var(--muted); }
.badge { border-radius: 999px; font-weight: 600; font-size: .78rem; }

/* ---- kezdőlap ---- */
.home-grid { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; text-decoration: none; color: var(--ink); display: block; transition: border-color .15s, box-shadow .15s; }
.tile:hover { border-color: var(--primary-light); box-shadow: var(--shadow); }
.tile .n { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.tile .l { color: var(--muted); font-size: .88rem; margin-top: 2px; }
.tile.action .n { color: var(--wait); }
.tile.waiting .n { color: var(--info); }
.tile.complete .n { color: var(--ok); }
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); padding: 26px; text-align: center; transition: border-color .15s, background .15s; }
.dropzone.drag { border-color: var(--primary); background: var(--primary-50); }
.dropzone h2 { margin-bottom: 4px; }
.dropzone p { color: var(--muted); margin: 0 0 14px; }
.dropzone .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.dropzone input[type=text] { max-width: 260px; }
.side-panel h3 { margin: 0 0 10px; font-size: .95rem; }
.sys-list { list-style: none; margin: 0; padding: 0; }
.sys-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.sys-list li:last-child { border-bottom: 0; }
.alert { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; display: flex; gap: 12px; align-items: flex-start; border: 1px solid; }
.alert.warn { background: var(--wait-bg); border-color: #fcd34d; color: #78350f; }
.alert.err { background: var(--err-bg); border-color: #fca5a5; color: #7f1d1d; }
.alert.ok { background: var(--ok-bg); border-color: #6ee7b7; color: #064e3b; }
.alert .grow { flex: 1; }

/* ---- lista (Dokumentumok) ---- */
.agreements { display: grid; grid-template-columns: 220px 1fr; gap: 18px; align-items: start; }
.folders { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 8px; position: sticky; top: 76px; }
.folders a { display: flex; justify-content: space-between; align-items: center; padding: 9px 10px; border-radius: 6px; text-decoration: none; color: var(--ink-soft); font-size: .93rem; font-weight: 500; }
.folders a:hover { background: var(--surface-2); }
.folders a.active { background: var(--primary-50); color: var(--primary); }
.folders .cnt { font-size: .78rem; color: var(--muted); font-weight: 600; }
.folders a.active .cnt { color: var(--primary); }
.folders .sep { height: 1px; background: var(--border); margin: 6px 4px; }
.folders .scope { padding: 6px 10px 4px; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.list-card { padding: 0; overflow: hidden; }
.list-toolbar { display: flex; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); align-items: center; flex-wrap: wrap; }
.list-toolbar form { flex: 1; display: flex; gap: 8px; min-width: 220px; }
.list-toolbar input[type=search] { flex: 1; margin: 0; }
.agr-table { width: 100%; border-collapse: collapse; }
.agr-table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.agr-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top; font-size: .93rem; }
.agr-table tr:last-child td { border-bottom: 0; }
.agr-table tbody tr { cursor: pointer; }
.agr-table tbody tr:hover td { background: #fafbff; }
.agr-title { font-weight: 600; color: var(--ink); text-decoration: none; display: block; overflow-wrap: anywhere; }
.agr-sub { color: var(--muted); font-size: .82rem; margin-top: 2px; overflow-wrap: anywhere; }
.people { display: flex; flex-direction: column; gap: 3px; }
.person { display: flex; align-items: center; gap: 6px; font-size: .86rem; }
.person .tick { width: 16px; height: 16px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; font-size: .65rem; flex: none; }
.person .tick.done { background: var(--ok); color: #fff; }
.person .tick.todo { border: 2px solid var(--border-strong); }
.progress { height: 4px; background: #eef0f3; border-radius: 999px; overflow: hidden; margin-top: 6px; max-width: 120px; }
.progress > span { display: block; height: 100%; background: var(--ok); }
.kind { font-size: .72rem; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; margin-left: 6px; vertical-align: 1px; font-weight: 500; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: .88rem; }
.pager a { text-decoration: none; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ---- részletek oldal ---- */
.detail-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.detail-head .meta { color: var(--muted); font-size: .9rem; margin-top: 4px; }
.detail-grid { display: grid; grid-template-columns: 1fr 360px; gap: 18px; align-items: start; }
.recipients { list-style: none; margin: 0; padding: 0; }
.recipients li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.recipients li:last-child { border-bottom: 0; }
.recipients .num { width: 28px; height: 28px; border-radius: 999px; background: #f3f4f6; color: var(--ink-soft); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; flex: none; }
.recipients .num.done { background: var(--ok); color: #fff; }
.recipients .who { flex: 1; min-width: 0; }
.recipients .who strong { display: block; }
.recipients .who small { color: var(--muted); overflow-wrap: anywhere; }
.recipients .when { text-align: right; font-size: .85rem; color: var(--muted); white-space: nowrap; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 14px 14px; font-size: .9rem; }
.timeline li::before { content: ""; position: absolute; left: -21px; top: 5px; width: 10px; height: 10px; border-radius: 999px; background: var(--primary); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--primary-100); }
.timeline .t { color: var(--muted); font-size: .82rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; }
.tech { margin-top: 10px; }
.tech summary { cursor: pointer; color: var(--muted); font-size: .88rem; }
.tech table { margin-top: 8px; }

/* ---- napló ---- */
.chain-table td { font-size: .88rem; }
.chain-table .date { font-weight: 600; white-space: nowrap; }

/* ---- reszponzív ---- */
@media (max-width: 980px) {
  .home-grid, .detail-grid, .agreements { grid-template-columns: 1fr; }
  .folders { position: static; display: flex; overflow-x: auto; gap: 4px; }
  .folders a { white-space: nowrap; }
  .folders .sep, .folders .scope { display: none; }
}
@media (max-width: 720px) {
  header.topbar .wrap { gap: 10px; padding: 0 12px; }
  header.topbar .brand span.txt { display: none; }
  .btn-start span.txt { display: none; }
  .tiles { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .tile { padding: 12px; }
  .tile .n { font-size: 1.4rem; }
  .agr-table .hide-sm { display: none; }
  .agr-table td, .agr-table th { padding: 10px 12px; }
  .card { padding: 16px; }
  .wrap { padding: 0 16px; }
}
.brand::before { content: none !important; }

/* ---- v2 javítások ---- */
nav.mainnav { flex-wrap: nowrap; }
nav.mainnav > a { margin-left: 0; }
header.topbar { padding: 0 !important; }
.back-link { display: inline-block; color: var(--muted); text-decoration: none; font-size: .9rem; margin-bottom: 8px; }
.back-link:hover { color: var(--primary); }
input[type=file] { font-size: .9rem; color: var(--ink-soft); max-width: 100%; }
input[type=file]::file-selector-button {
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  padding: 7px 12px; border-radius: var(--radius); margin-right: 10px; cursor: pointer; font-weight: 500;
}
input[type=file]::file-selector-button:hover { background: var(--surface-2); }
.list-toolbar input[type=search], .list-toolbar select {
  padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  font-size: .93rem; background: var(--surface); width: auto;
}
.list-toolbar input[type=search]:focus { outline: 2px solid var(--primary-100); border-color: var(--primary-light); }
.agr-table th, .agr-table td { width: auto; }
@media (max-width: 720px) {
  header.topbar .wrap { height: auto; min-height: 56px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 0; }
  header.topbar .brand { order: 1; }
  header.topbar .topbar-right { order: 2; margin-left: auto; }
  nav.mainnav { order: 3; flex-basis: 100%; height: 44px; }
  nav.mainnav > a, nav.mainnav > details > summary { padding: 0 10px; font-size: .9rem; }
  .mainnav .menu { margin-top: 42px; left: 12px; right: 12px; }
  .alert { flex-direction: column; }
  .dropzone { padding: 18px; }
}
.card.list-card { padding: 0 !important; }
@media (max-width: 980px) { .folders a { gap: 8px; } }

/* Aláírási munkafolyamat: közös navigáció, fókuszált előkészítés. */
:root { --primary:#4735a0; --primary-dark:#352477; --primary-light:#7864ce; --primary-50:#f5f3fc; --primary-100:#e9e3fc; --bg:#f6f6f8; }
body { color:var(--ink); line-height:1.5; }
button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible { outline:3px solid #9684df; outline-offset:3px; }
a { color:var(--primary); }
.eyebrow { font-size:.7rem; font-weight:700; letter-spacing:.14em; color:var(--primary) !important; margin-bottom:8px !important; }
.send-banner { display:flex; align-items:center; justify-content:space-between; gap:32px; padding:30px 32px; margin:24px 0; background:var(--primary-50); border:1px solid var(--primary-100); border-radius:12px; }
.send-banner h2 { font-size:1.35rem; margin:0 0 8px; }
.send-banner p { margin:0; color:var(--ink-soft); max-width:640px; }
.send-banner .btn-start { flex-shrink:0; padding:12px 20px; }
.tiles { margin-bottom:28px; }
.tile { padding:22px 24px; }
.tile .l { font-weight:500; }
.admin-entry { display:flex; gap:16px; justify-content:space-between; padding:20px 0; color:var(--muted); font-size:.85rem; }
.send-steps { display:flex; gap:24px; padding:16px 0 24px; margin-bottom:12px; border-bottom:1px solid var(--border); }
.send-step { display:flex; gap:9px; align-items:center; font-size:.9rem; color:var(--muted); }
.step-number { width:28px; height:28px; display:inline-flex; align-items:center; justify-content:center; border-radius:50%; border:1px solid var(--border-strong); font-size:.8rem; flex-shrink:0; }
.send-step.current { color:var(--primary); font-weight:700; }
.send-step.current .step-number { background:var(--primary); color:white; border-color:var(--primary); }
.send-step.done .step-number { background:var(--primary-100); color:var(--primary); border-color:var(--primary-100); }
.send-form { max-width:860px; margin:24px auto; padding:30px; }
.upload-area { display:flex; flex-direction:column; align-items:center; gap:12px; padding:38px 24px; border:1px dashed #a99ccf; background:var(--surface-2); border-radius:8px; margin:24px 0; cursor:pointer; text-align:center; }
.upload-symbol { font-size:28px; color:var(--primary); }
.upload-area input { width:auto; max-width:100%; }
.form-actions { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:28px; padding-top:22px; border-top:1px solid var(--border); }
.archive-links { display:grid; gap:16px; padding:8px 0; }
.review-recipients { list-style:none; margin:0; padding:0; }
.review-recipients li { display:flex; flex-wrap:wrap; align-items:center; gap:12px; padding:16px 0; border-bottom:1px solid var(--border); }
.review-recipients li:last-child { border:0; }
.review-recipients li>div { flex:1; min-width:160px; }
.review-recipients small,.document-file small,.share-recipient small { display:block; color:var(--muted); overflow-wrap:anywhere; }
.message-preview { white-space:pre-wrap; overflow-wrap:anywhere; }
.delivery-note { padding:12px; background:var(--primary-50); border-radius:6px; font-size:.88rem; }
.document-file { display:flex; flex-wrap:wrap; gap:14px; align-items:center; }
.document-file strong { overflow-wrap:anywhere; }
.pdf-icon { display:inline-flex; align-items:center; justify-content:center; width:44px; height:54px; background:#fff1ee; color:#a23d25; font-size:.7rem; border:1px solid #f4d5ce; border-radius:6px; flex-shrink:0; }
.share-recipient { border-top:1px solid var(--border); padding:16px 0; }
.share-recipient input { margin:10px 0; font-size:.8rem; }
.copy-feedback { font-size:.8rem; margin-left:8px; color:var(--ok); }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.fields-layout>section,.detail-grid>section,.agreements>section { min-width:0; }
.placed-field { touch-action:none; }
.fields-palette .field-btn.active { background:var(--primary); border-color:var(--primary); }
.fields-palette .helper { background:var(--primary-50); font-size:.82rem; }
.signing-page .topbar .wrap { justify-content:space-between; }
.signing-page .pdf-pages { overflow-x:auto; }
.signing-page .sign-sidebar { top:80px; }
.signing-page .sign-field { min-height:20px; }
@media (max-width:980px) {
  main .fields-layout { grid-template-columns:1fr; }
  main .fields-palette { position:static; display:flex; flex-wrap:wrap; align-items:center; gap:8px; }
  .fields-palette h3 { width:100%; margin:4px 0 !important; }
  .fields-palette .field-btn { width:auto; margin:0; min-height:40px; }
  .fields-palette .rec-chip { margin:0; }
  .fields-palette .helper { display:none; }
  .signing-page .sign-sidebar { position:sticky; bottom:0; top:auto; z-index:10; box-shadow:0 -4px 20px #00000012; }
}
@media (max-width:720px) {
  h1 { font-size:1.4rem; }
  .send-banner { padding:22px; align-items:flex-start; flex-direction:column; gap:20px; }
  .send-banner h2 { font-size:1.15rem; }
  .send-form { padding:20px; }
  .upload-area { padding:24px 12px; }
  .send-steps { gap:8px; justify-content:space-between; }
  .send-step { flex-direction:column; gap:5px; font-size:.72rem; text-align:center; }
  .tile { padding:16px 10px; }
  .tile .l { font-size:.75rem; }
  .admin-entry { flex-direction:column; gap:8px; }
  .agr-table { table-layout:fixed; }
  .agr-table th:first-child { width:45%; }
  .agr-table th:last-child { width:auto; }
  .agr-table td,.agr-table th { padding:12px 8px; }
  .agr-title,.agr-sub { overflow-wrap:anywhere; }
  .agr-table .chip { font-size:.67rem; white-space:normal; }
  .agr-table .btn-secondary,.agr-table .btn-start { padding:7px 8px; font-size:.72rem; }
  .list-toolbar form { width:100%; flex-wrap:wrap; }
  .list-toolbar input[type=search] { flex:1; width:100%; min-width:120px; }
  .recipients-table thead { display:none; }
  .recipients-table,.recipients-table tbody { display:block; }
  .recipients-table .rec-row { display:grid; grid-template-columns:1fr 1fr; gap:10px; border:1px solid var(--border); border-radius:8px; padding:14px; margin-bottom:12px; }
  .recipients-table td { display:block; border:0; padding:0; min-width:0; }
  .recipients-table td:nth-child(2),.recipients-table td:nth-child(3) { grid-column:1 / -1; }
  .recipients-table td::before { display:block; font-size:.75rem; color:var(--muted); margin-bottom:4px; }
  .recipients-table td:nth-child(1)::before { content:'Sorrend'; }
  .recipients-table td:nth-child(2)::before { content:'Név'; }
  .recipients-table td:nth-child(3)::before { content:'Email'; }
  .recipients-table td:nth-child(4)::before { content:'Szerep'; }
  .recipients-table td:nth-child(5):has(input[type=date])::before { content:'Archív aláírási dátum'; }
  .recipients-table input,.recipients-table select { width:100%; }
  .form-actions { flex-wrap:wrap; }
  .form-actions button { flex:1; }
}
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { animation:none !important; transition:none !important; scroll-behavior:auto !important; } }
.send-steps .send-step a { color:var(--primary); background:none; padding:0; margin:0; text-decoration:none; }
.send-steps .send-step a:hover { text-decoration:underline; }
.fields-palette .field-btn { color:var(--ink); }
.fields-palette .field-btn.active { color:#fff; }

.fields-palette .rec-chip { color:var(--ink); background:var(--surface-2); text-align:left; }

/* DocuFlowr brand */
.docuflowr-mark { width:32px; height:32px; flex-shrink:0; }
.brand-accent { color:var(--primary); }
.reminder-action { margin-top:12px; }
.reminder-note { color:var(--muted); font-size:.82rem; margin-top:8px; }

/* DocuFlowr petrol / neon identity. */
:root { --primary:#006b63; --primary-dark:#00564f; --primary-light:#318c7e; --primary-50:#f0f6f0; --primary-100:#dcefe7; --bg:#faf9f5; }
.brand-accent { color:#233330; }

/* Unified Flowr icon accents. */
:root{--df-accent:#c7f75b;--df-accent-soft:#eff8d8}.contacts-page .icon-heading{color:#23382f}.tile.action .n{color:#006b63}.chip.ok{background:#edf7da;color:#315a35}

/* Brand accents remain readable on light surfaces. */
.avatar .admin-dot{background:#c7f75b;border-color:#006b63}button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible{outline-color:#006b63}.upload-area{border-color:#86b6a3}.pdf-icon{background:#eff8d8;color:#315a35;border-color:#c7e4b0}

.legal-nav{display:flex;flex-wrap:wrap;gap:12px 24px}.legal-copy{max-width:900px}.legal-copy p{line-height:1.8}dl dt{font-weight:700;margin-top:12px}dl dd{margin-left:0;color:var(--muted)}
