:root {
  --bg: #f5f6f8; --card: #fff; --ink: #1d2433; --muted: #6b7385; --line: #e3e6ec;
  --brand: #2557d6; --brand-ink: #fff; --green: #15803d; --red: #c62828; --orange: #c2610c; --purple: #7c3aed;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: .2em 0 .6em; display: flex; gap: .5em; align-items: center; flex-wrap: wrap; }
h2 { font-size: 1.15rem; margin: 0 0 .7em; } h3 { font-size: 1rem; margin: 0 0 .6em; }
code { background: #eef1f6; padding: 1px 5px; border-radius: 4px; font-size: .88em; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .err { color: var(--red); } .right { text-align: right; } .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Fejléc */
.topbar { display: flex; align-items: center; gap: 1.5rem; background: #111827; color: #fff; padding: .6rem 1.4rem; position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 700; } .brand:hover { text-decoration: none; }
.topbar nav { display: flex; gap: .2rem; flex: 1; flex-wrap: wrap; }
.topbar nav a { color: #cbd2e1; padding: .35rem .7rem; border-radius: 6px; }
.topbar nav a:hover, .topbar nav a.active { background: #273248; color: #fff; text-decoration: none; }
.dot { background: #ef4444; color: #fff; border-radius: 99px; padding: 0 .45em; font-size: .75rem; font-weight: 700; }
.linklike { background: none; border: 0; color: #cbd2e1; cursor: pointer; font: inherit; }
main { max-width: 1280px; margin: 0 auto; padding: 1.4rem; }
main.narrow, .narrow { max-width: 560px; margin-left: auto; margin-right: auto; }

/* Kártyák, rácsok */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card-green { border-color: #86efac; background: #f0fdf4; } .card-red { border-color: #fca5a5; background: #fef2f2; } .card-orange { border-color: #fdba74; background: #fff7ed; }
.grid2, .grid3, .grid4 { display: grid; gap: .8rem 1rem; }
.grid2 { grid-template-columns: repeat(2, 1fr); } .grid3 { grid-template-columns: repeat(3, 1fr); } .grid4 { grid-template-columns: repeat(4, 1fr); }
.span2 { grid-column: span 2; } .span3 { grid-column: span 3; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 1.2rem; align-items: start; }
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start; }
.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.pagehead h1, .pagehead h2 { margin-bottom: .4em; }
@media (max-width: 900px) { .split, .editor-grid, .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } .span2, .span3 { grid-column: auto; } }

/* Űrlapok */
.form label, label { display: block; font-size: .87rem; font-weight: 600; color: #374151; margin-bottom: .7rem; }
input, select, textarea { display: block; width: 100%; margin-top: .25rem; padding: .5rem .6rem; border: 1px solid #cfd5df; border-radius: 7px; font: inherit; font-weight: 400; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfd0ff; border-color: var(--brand); }
textarea.mono { font: 13.5px/1.55 ui-monospace, "SFMono-Regular", Consolas, monospace; }
label.check { display: flex; gap: .5rem; align-items: flex-start; font-weight: 400; }
label.check input { width: auto; margin-top: .25rem; }
.inline { display: inline-flex; gap: .4rem; align-items: center; } .inline input { width: auto; margin: 0; }
.search { display: flex; gap: .5rem; margin-bottom: 1rem; } .search input, .search select { margin: 0; max-width: 360px; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0; }
.actions.sticky { position: sticky; bottom: 0; background: var(--bg); padding: .8rem 0; border-top: 1px solid var(--line); }
.row-gap { display: flex; gap: 1rem; flex-wrap: wrap; }
.side form { margin-bottom: .5rem; } .side select, .side input { margin-bottom: .5rem; }

/* Gombok */
.btn { display: inline-block; padding: .5rem .95rem; border-radius: 7px; border: 1px solid #cfd5df; background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.3; }
.btn:hover { background: #f2f4f8; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; } .btn-primary:hover { background: #1d47b5; }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; } .btn-success:hover { background: #116632; }
.btn-danger { color: var(--red); border-color: #f1b4b4; } .btn-danger:hover { background: #fef2f2; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-sm { padding: .25rem .6rem; font-size: .85rem; } .btn-lg { padding: .8rem 1.4rem; font-size: 1.05rem; }
.btn-block { display: block; width: 100%; text-align: center; }

/* Táblázatok */
table { border-collapse: collapse; width: 100%; }
.list { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.list th, .list td { padding: .6rem .8rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.list th { background: #f8f9fb; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.list.compact { box-shadow: none; border: 0; } .list.compact td { padding: .45rem .3rem; }
tr.clickable { cursor: pointer; } tr.clickable:hover td { background: #f8faff; }
.list .right { white-space: nowrap; }

.items-table th { text-align: left; font-size: .78rem; color: var(--muted); padding: .3rem; }
.items-table td { padding: .3rem; vertical-align: top; }
.items-table input, .items-table select { margin: 0; }
.items-table input.sub { margin-top: .25rem; font-size: .85rem; color: var(--muted); }
.w-num { width: 80px; } .w-unit { width: 70px; } .w-price { width: 120px; }
.line-net { padding-top: .8rem !important; font-weight: 600; }
.totals-live { display: flex; gap: 2rem; justify-content: flex-end; margin: .8rem 0 1rem; font-size: 1.05rem; }

/* Állapot jelvények */
.badge { display: inline-block; padding: .12rem .6rem; border-radius: 99px; font-size: .78rem; font-weight: 700; }
.badge-gray { background: #eceff3; color: #4b5563; } .badge-blue { background: #dbe7ff; color: #1d47b5; } .badge-purple { background: #ede4ff; color: var(--purple); }
.badge-green { background: #dcfce7; color: var(--green); } .badge-red { background: #fee2e2; color: var(--red); } .badge-orange { background: #ffedd5; color: var(--orange); }
.chip { margin-right: .2rem; }

/* Üzenetek */
.flash { padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1rem; background: #eef2ff; border: 1px solid #c7d2fe; }
.flash-ok { background: #f0fdf4; border-color: #86efac; } .flash-err { background: #fef2f2; border-color: #fca5a5; } .flash-warn { background: #fffbeb; border-color: #fcd34d; }
.copyline { display: flex; gap: .4rem; margin-top: .5rem; } .copyline input { margin: 0; font-size: .82rem; }

/* Statisztika */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; box-shadow: var(--shadow); display: flex; gap: 1rem; align-items: center; }
.stat-v { font-size: 2rem; font-weight: 800; } .stat-l { color: var(--muted); font-size: .9rem; line-height: 1.3; }
.stat-green .stat-v { color: var(--green); }
@media (max-width: 900px) { .stats { grid-template-columns: 1fr 1fr; } }
.events { list-style: none; padding: 0; margin: 0; }
.events li { display: flex; gap: .7rem; padding: .55rem .3rem; border-bottom: 1px solid var(--line); }
.events li.unread { background: #f5f8ff; } .events li.unread.ev-accepted { background: #ecfdf3; font-weight: 600; }
.ev-icon { width: 1.4rem; text-align: center; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: .88rem; } .timeline li { padding: .35rem 0; border-bottom: 1px dashed var(--line); }
dl.meta { display: grid; grid-template-columns: auto 1fr; gap: .2rem .7rem; font-size: .87rem; margin: .8rem 0; } dl.meta dt { color: var(--muted); } dl.meta dd { margin: 0; }
.hash { word-break: break-all; font-family: ui-monospace, monospace; font-size: .75rem; }
blockquote { margin: .5rem 0 0; padding: .4rem .7rem; border-left: 3px solid #ccc; background: rgba(0,0,0,.03); }

/* Változó-panel */
.var-panel { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow: auto; }
.var-panel details { border-top: 1px solid var(--line); padding: .45rem 0; }
.var-panel summary { cursor: pointer; font-weight: 700; font-size: .9rem; }
.var-btn { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left; background: none; border: 0; padding: .3rem .4rem; border-radius: 6px; cursor: pointer; font: inherit; }
.var-btn:hover { background: #eef3ff; } .var-btn span { font-size: .78rem; color: var(--muted); }
.ph-missing { background: #fee2e2; color: var(--red); border: 1px dashed #f87171; padding: 0 .3em; border-radius: 4px; font-family: ui-monospace, monospace; font-size: .85em; }
.ph-missing::before { content: "{{"; } .ph-missing::after { content: "}}"; }
.ph-value { background: #fff7c2; border-radius: 3px; }
.doc .ph-value { background: none; }
#preview .ph-value, .doc-contract .ph-value.hl { background: #fff7c2; }

/* Dokumentum (ajánlat / szerződés) */
.doc { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 2.4rem 2.6rem; box-shadow: var(--shadow); position: relative; }
.doc-head { display: flex; justify-content: space-between; gap: 2rem; border-bottom: 3px solid var(--ink); padding-bottom: 1rem; margin-bottom: 1.2rem; }
.doc-type { font-size: 1.7rem; font-weight: 800; letter-spacing: .06em; } .doc-no { color: var(--muted); font-weight: 600; } .doc-title { margin-top: .4rem; font-size: 1.1rem; }
.doc-parties { display: grid; grid-template-columns: 2fr 1fr; gap: 2rem; margin-bottom: 1.2rem; }
.label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: .4rem; font-weight: 700; }
.doc-table { width: 100%; margin: 1rem 0; font-size: .92rem; }
.doc-table th { background: #f3f4f7; text-align: left; padding: .5rem; font-size: .78rem; text-transform: uppercase; color: #4b5563; }
.doc-table td { padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.doc-table tfoot td, .doc-table tfoot th { border: 0; padding: .3rem .5rem; text-align: right; }
.doc-table small { color: var(--muted); }
.doc-totals { width: 360px; margin-left: auto; font-size: .93rem; }
.doc-totals td { padding: .3rem .5rem; } .doc-totals tr.grand td { font-size: 1.15rem; font-weight: 800; border-top: 2px solid var(--ink); padding-top: .5rem; }
.doc-text { margin: 1rem 0; } .doc-foot { margin-top: 2rem; padding-top: .8rem; border-top: 1px solid var(--line); font-size: .82rem; color: var(--muted); }
.doc-contract { line-height: 1.65; font-family: Georgia, "Times New Roman", serif; font-size: 15.5px; }
.doc-contract h2 { text-align: center; font-size: 1.35rem; letter-spacing: .05em; margin: .2em 0 1em; }
.doc-contract h3 { font-size: 1.05rem; margin: 1.4em 0 .4em; } .doc-contract h4 { font-size: 1rem; }
.doc-contract p { margin: 0 0 .8em; white-space: pre-wrap; }
.stamp { position: absolute; top: 2rem; right: 40%; transform: rotate(-12deg); border: 4px solid; border-radius: 10px; padding: .3rem 1rem; font-size: 1.6rem; font-weight: 900; letter-spacing: .1em; opacity: .85; text-align: center; }
.stamp small { display: block; font-size: .7rem; letter-spacing: 0; font-weight: 600; }
.stamp-green { color: var(--green); border-color: var(--green); } .stamp-red { color: var(--red); border-color: var(--red); }
.acceptance-box { margin-top: 2rem; padding: .8rem 1rem; border: 2px solid var(--green); border-radius: 8px; background: #f0fdf4; font-family: system-ui, sans-serif; font-size: .9rem; }

/* Nyilvános (ügyfél) oldal */
body.public { background: #eef0f4; }
.doc-wrap { max-width: 900px; }
.doc-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; color: var(--muted); }
.decision { margin-top: 1.2rem; border: 2px solid var(--brand); }
.decision-buttons { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.auth { margin-top: 8vh; }

@media print {
  .no-print, .topbar, .flash, .side, .actions { display: none !important; }
  body, body.public { background: #fff; }
  main { padding: 0; max-width: none; }
  .split { display: block; }
  .doc { border: 0; box-shadow: none; padding: 0; }
  .ph-value { background: none !important; }
  @page { margin: 16mm; }
}


/* Szerződés – kétoszlopos aláírás */
.doc-contract .contract-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 45px;
  margin-top: 75px;
  margin-bottom: 20px;
  break-inside: avoid;
  page-break-inside: avoid;
}

.doc-contract .signature-party {
  text-align: center;
  line-height: 1.5;
  min-width: 0;
  overflow-wrap: anywhere;
}

.doc-contract .signature-line {
  border-top: 1px solid #222;
  margin-bottom: 10px;
}

.doc-contract .signature-party strong {
  display: block;
}

.doc-contract .signature-party small {
  display: block;
  color: #555;
  margin-top: 5px;
}

@media print {
  .doc-contract .contract-signatures {
    display: grid;
    grid-template-columns: 1fr 1fr;
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
