/* Vystaviť e-faktúru — form left, live document right. Uses only tokens from base.css. */

.issue.page { max-width: 1400px; }
.issue [hidden] { display: none !important; }
.issue-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 600px); gap: var(--s-7); align-items: start; }

/* ── form ────────────────────────────────────────────────────────────── */
.issue-form { min-width: 0; }
.issue-form .panel { padding: var(--s-5) 0; }
.issue-form .panel:first-child { padding-top: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-2); }
.panel-head h2 { margin: 0; }
.issue-form h2 { margin-bottom: var(--s-3); }

.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4) var(--s-4); margin-bottom: var(--s-4); }
.fields:last-child { margin-bottom: 0; }
.fields .wide { grid-column: 1 / -1; }
.fields > .field.due { display: grid; gap: var(--s-2); }
label.field .hint { display: block; }

.btn-sm { min-height: 32px; padding: 0 var(--s-3); font-size: var(--f-13); }

.chips { display: flex; gap: var(--s-1); flex-wrap: wrap; }
.chips button { min-height: 32px; padding: 0 var(--s-3); border-radius: 999px; border: 1px solid var(--control); background: transparent;
  color: var(--ink-2); font: 500 var(--f-13)/1 "Onest", system-ui, sans-serif; cursor: pointer; }
.chips button:hover { color: var(--ink); }
.chips button[aria-pressed="true"] { color: var(--stamp); border-color: color-mix(in srgb, var(--stamp) 45%, var(--rule)); background: var(--stamp-wash); }

.me-summary { display: grid; gap: 2px; padding: var(--s-3) var(--s-4); border-left: 3px solid var(--stamp); background: var(--sheet); border-radius: 0 var(--r-ctl) var(--r-ctl) 0; }
.me-summary strong { font-weight: 600; }
.me-summary span { color: var(--ink-2); font-size: var(--f-13); line-height: 20px; }

.lookup { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-3); align-items: start; }
.lookup .btn { margin-top: 22px; }
.lookup-status { min-height: 0; margin: var(--s-2) 0 var(--s-4); font-size: var(--f-13); color: var(--ink-2); display: flex; align-items: center; gap: var(--s-2); }
.lookup-status:empty { margin: 0 0 var(--s-4); }
.lookup-status.ok { color: var(--ok); } .lookup-status.bad { color: var(--bad); }
.lookup-status svg { width: 16px; height: 16px; flex: none; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--rule); border-top-color: var(--stamp); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.filled { animation: filled 1.2s ease-out; }
@keyframes filled { from { background: var(--stamp-wash); } to { background: var(--sheet); } }

label.check { display: grid; grid-template-columns: 20px 1fr; gap: var(--s-3); align-items: start; margin-top: var(--s-4); cursor: pointer; }
label.check input { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--stamp); }
label.check .hint { display: block; max-width: 60ch; }
label.check.reverse { padding: var(--s-3) var(--s-4); border: 1px solid var(--rule); border-radius: var(--r-ctl); }
label.check.reverse:has(input:checked) { border-color: color-mix(in srgb, var(--stamp) 45%, var(--rule)); background: var(--stamp-wash); }

/* items: a grid that becomes stacked rows on narrow screens */
.items { display: grid; gap: 0; }
.items { border-top: 1px solid var(--rule); }
.item { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .8fr) minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1.2fr) 36px;
  grid-template-areas: "p p p p p x" "q u c v t t"; gap: var(--s-2) var(--s-3); align-items: end; padding: var(--s-3) 0; border-bottom: 1px solid var(--rule); }
.item .c-popis { grid-area: p; } .item .c-qty { grid-area: q; } .item .c-mj { grid-area: u; } .item .c-price { grid-area: c; }
.item .c-vat { grid-area: v; } .item .line-sum { grid-area: t; padding-bottom: 8px; text-align: right; } .item .remove { grid-area: x; align-self: end; }
.item .cell-label { display: block; font-size: 12px; line-height: 16px; color: var(--ink-2); margin-bottom: 2px; }
.item .c-popis .cell-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.item .c-popis input { font-weight: 550; }
.item input, .item select { height: 40px; min-height: 40px; padding: 6px var(--s-2); }
.item input.num { text-align: right; font-variant-numeric: tabular-nums; }
.item .line-total { text-align: right; font-variant-numeric: tabular-nums; font-weight: 550; white-space: nowrap; }
.item .remove { width: 36px; height: 36px; display: grid; place-items: center; border: 0; background: transparent; color: var(--ink-2); border-radius: var(--r-ctl); cursor: pointer; }
.item .remove:hover { color: var(--bad); background: var(--bad-wash); }
.item .remove svg { width: 18px; height: 18px; }
.items-actions { display: flex; align-items: center; gap: var(--s-3); margin-top: var(--s-3); flex-wrap: wrap; }

/* submit */
.submit-row { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; }
.submit-row .hint { max-width: 46ch; margin: 0; }
.problems, .result { margin-bottom: var(--s-4); padding: var(--s-4); border-radius: var(--r-ctl); }
.problems { border: 1px solid color-mix(in srgb, var(--bad) 35%, var(--rule)); background: var(--bad-wash); }
.problems h3, .result h3 { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-2); }
.problems h3 { color: var(--bad); } .result h3 { color: var(--ok); }
.problems h3 svg, .result h3 svg { width: 20px; height: 20px; }
.problems ul { margin: 0; padding-left: var(--s-5); }
.problems li { margin: var(--s-1) 0; }
.problems li strong { font-weight: 600; }
.problems a { color: var(--ink); }
.result { border: 1px solid color-mix(in srgb, var(--ok) 35%, var(--rule)); background: var(--ok-wash); }
.result p { margin-bottom: var(--s-3); }
.result .actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.problems:focus, .result:focus { outline: none; }

/* ── preview: the document sheet ─────────────────────────────────────── */
.issue-preview { position: sticky; top: var(--s-5); min-width: 0; }
.issue-preview summary { display: none; }
.doc { padding: var(--s-6) var(--s-6) var(--s-5); font-size: var(--f-13); line-height: 20px; }
.doc .empty-val { color: var(--ink-2); opacity: .7; }
.doc-head { display: flex; justify-content: space-between; gap: var(--s-4); padding-bottom: var(--s-4); border-bottom: 2px solid var(--ink); }
.doc-kind { margin: 0; font-size: var(--f-13); color: var(--ink-2); }
.doc-no { margin: 0; font-size: var(--f-26); line-height: 32px; font-weight: 650; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.doc-dates { display: grid; grid-template-columns: auto auto; gap: 2px var(--s-3); margin: 0; align-content: start; }
.doc-dates div, .doc-pay div { display: contents; }
.doc dt { color: var(--ink-2); }
.doc dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-5); padding: var(--s-4) 0; }
.doc-parties h3 { font-size: var(--f-13); font-weight: 500; color: var(--ink-2); line-height: 20px; margin-bottom: var(--s-1); }
.doc-parties .name { font-weight: 650; font-size: var(--f-15); line-height: 22px; }
.doc-parties .ids { margin-top: var(--s-1); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.doc-items { width: 100%; border-collapse: collapse; margin-top: var(--s-2); }
.doc-items th { font-weight: 500; color: var(--ink-2); text-align: left; padding: var(--s-2) var(--s-2) var(--s-2) 0; border-bottom: 1px solid var(--rule); }
.doc-items td { padding: var(--s-2) var(--s-2) var(--s-2) 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.doc-items th:last-child, .doc-items td:last-child { padding-right: 0; }
.doc-items .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc-items td.empty-row { color: var(--ink-2); padding: var(--s-4) 0; }
.doc-foot { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 260px); gap: var(--s-5); padding-top: var(--s-4); align-items: end; }
.doc-pay { display: grid; grid-template-columns: auto 1fr; gap: 2px var(--s-3); margin: 0; align-content: end; }
.doc-pay dd { text-align: left; overflow-wrap: anywhere; }
.doc-pay dd.iban { word-spacing: 0.1em; }
.doc-note { grid-column: 1 / -1; margin: var(--s-2) 0 0; color: var(--stamp); font-weight: 550; }
.doc-totals table { width: 100%; border-collapse: collapse; }
.doc-totals td { padding: 2px 0; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.doc-totals td.num { text-align: right; color: var(--ink); }
.doc-due { display: grid; gap: 0; margin-top: var(--s-3); padding-top: var(--s-3); border-top: 2px solid var(--ink); text-align: right; }
.doc-due span { color: var(--ink-2); }
.doc-due strong { font-size: var(--f-41); line-height: 48px; font-weight: 650; letter-spacing: -0.02em; }

/* ── responsive ──────────────────────────────────────────────────────── */
@media (max-width: 1279px) {
  .issue-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 480px); gap: var(--s-6); }
  .doc { padding: var(--s-5); }
  .doc-due strong { font-size: var(--f-33); line-height: 40px; }
}
@media (max-width: 1099px) {
  .issue-grid { grid-template-columns: 1fr; }
  .issue-preview { position: static; }
  .issue-preview summary { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); min-height: 48px;
    padding: 0 var(--s-4); border: 1px solid var(--rule); border-radius: var(--r-ctl); background: var(--sheet); cursor: pointer;
    font-weight: 600; list-style: none; }
  .issue-preview summary::-webkit-details-marker { display: none; }
  .issue-preview summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(45deg); margin-left: var(--s-2); }
  .issue-preview details[open] summary::after { transform: rotate(-135deg); }
  .issue-preview summary .num { margin-left: auto; font-weight: 650; }
  .issue-preview details[open] .doc { margin-top: var(--s-3); }
}
@media (max-width: 767px) {
  .fields { grid-template-columns: 1fr; }
  .lookup { grid-template-columns: 1fr; }
  .lookup .btn { margin-top: 0; justify-self: start; }
  .item { grid-template-columns: repeat(6, minmax(0, 1fr)); grid-template-areas: "p p p p p x" "q q u u c c" "v v v t t t"; }
  .submit-row .btn { width: 100%; }
  .doc { padding: var(--s-4); }
  .doc-head { flex-direction: column; }
  .doc-dates { grid-template-columns: auto 1fr; }
  .doc-dates dd { text-align: left; }
  .doc-parties { grid-template-columns: 1fr; gap: var(--s-3); }
  .doc-items th:nth-child(2), .doc-items td:nth-child(2), .doc-items th:nth-child(3), .doc-items td:nth-child(3) { display: none; }
  .doc-foot { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; border-top-color: var(--ink-2); } .filled { animation: none; } }

/* floating total on narrow screens; hides while the preview itself is on screen */
.pv-mini { display: none; }
@media (max-width: 1099px) {
  .pv-mini { position: fixed; right: var(--s-4); bottom: var(--s-4); z-index: 15; display: inline-flex; align-items: center; gap: var(--s-3);
    min-height: 44px; padding: 0 var(--s-4); border: 1px solid var(--rule); border-radius: 999px; background: var(--sheet); color: var(--ink);
    box-shadow: var(--sheet-shadow); font: 600 var(--f-15)/1 "Onest", system-ui, sans-serif; cursor: pointer; transition: opacity .15s, transform .15s; }
  .pv-mini span:first-child { color: var(--ink-2); font-weight: 500; }
  .pv-mini.away { opacity: 0; transform: translateY(8px); pointer-events: none; }
}
@media (max-width: 767px) { .pv-mini { bottom: 76px; } }

/* ── Slovak date field + calendar ─────────────────────────────────────── */
.date-field { position: relative; display: block; }
.date-field input { padding-right: 44px; font-variant-numeric: tabular-nums; }
.date-btn { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; display: grid; place-items: center;
  border: 0; border-radius: 6px; background: transparent; color: var(--ink-2); cursor: pointer; }
.date-btn:hover, .date-btn[aria-expanded="true"] { color: var(--stamp); background: var(--stamp-wash); }
.date-btn svg { width: 18px; height: 18px; }

.cal { position: absolute; z-index: 40; padding: var(--s-3); background: var(--sheet); border-radius: var(--r-ctl);
  box-shadow: var(--sheet-shadow), 0 0 0 1px var(--rule); }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-2); }
.cal-title { margin: 0; font-weight: 600; text-transform: none; }
.cal-title::first-letter { text-transform: uppercase; }
.cal-nav { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent;
  color: var(--ink-2); cursor: pointer; }
.cal-nav:hover { color: var(--ink); background: var(--paper); }
.cal-nav svg { width: 18px; height: 18px; }
.cal table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal th { font-size: 12px; font-weight: 500; color: var(--ink-2); padding: 2px 0 6px; }
.cal td { padding: 1px; text-align: center; }
.cal td button { width: 100%; aspect-ratio: 1; max-height: 38px; border: 0; border-radius: 6px; background: transparent; color: var(--ink);
  font: 500 var(--f-13)/1 "Onest", system-ui, sans-serif; font-variant-numeric: tabular-nums; cursor: pointer; }
.cal td button.weekend { color: var(--ink-2); }
.cal td button:hover { background: var(--paper); }
.cal td button.today { box-shadow: inset 0 0 0 1px var(--stamp); }
.cal td button[aria-selected="true"] { background: var(--stamp); color: var(--on-stamp); }
.cal-foot { display: flex; justify-content: flex-end; margin-top: var(--s-2); }

/* ── recent customers ────────────────────────────────────────────────── */
.recent { margin: 0 0 var(--s-4); }
.recent-label { display: block; font-size: var(--f-13); font-weight: 500; color: var(--ink-2); margin-bottom: var(--s-2); }
.recent-list { display: flex; gap: var(--s-2); overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.recent-item { display: grid; gap: 0; text-align: left; flex: none; max-width: 240px; padding: 6px var(--s-3); border: 1px solid var(--rule);
  border-radius: var(--r-ctl); background: var(--sheet); color: var(--ink); cursor: pointer; font: inherit; }
.recent-item:hover { border-color: color-mix(in srgb, var(--stamp) 45%, var(--rule)); }
.r-name { font-weight: 600; font-size: var(--f-13); line-height: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-meta { font-size: 12px; line-height: 16px; color: var(--ink-2); white-space: nowrap; }
.hint.note { color: var(--stamp); }
