:root {
  --bg: #f4f2ee; --card: #fff; --ink: #1f2420; --muted: #6b716c; --line: #e3e0d9;
  --accent: #2f6b3f; --accent-ink: #fff; --warn: #b3412e; --ovr: #fff4d6;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
header { position: sticky; top: 0; z-index: 5; background: var(--accent); color: var(--accent-ink); display: flex; align-items: center; gap: 16px; padding: 8px 16px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav button { background: transparent; color: var(--accent-ink); border: 0; padding: 8px 12px; border-radius: 6px; opacity: .8; }
nav button.active, nav button:hover { background: rgba(255,255,255,.18); opacity: 1; }
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
h2 { margin: 0 0 10px; font-size: 20px; }
h3 { margin: 14px 0 8px; font-size: 15px; }
.card > h3:first-child { margin-top: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-bottom: 10px; }
label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); gap: 3px; }
label.chk { flex-direction: row; align-items: center; gap: 6px; color: var(--ink); font-size: 14px; margin: 4px 10px 4px 0; display: inline-flex; }
input, select, textarea { font: inherit; color: var(--ink); padding: 7px 9px; border: 1px solid #cfcbc2; border-radius: 6px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc4a6; border-color: var(--accent); }
textarea { resize: vertical; }
button, .btn { font: inherit; cursor: pointer; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); white-space: nowrap; }
button.ghost, .btn.ghost { background: #fff; color: var(--accent); }
button.x { background: #fff; color: var(--warn); border-color: #e7c3bb; padding: 4px 9px; }
button:hover { filter: brightness(1.07); }
.btn { display: inline-flex; align-items: center; flex-direction: row; }
details { margin: 8px 0; }
summary { cursor: pointer; color: var(--accent); font-weight: 600; margin-bottom: 8px; }
.tag { font-size: 12px; background: #e3f0e6; color: var(--accent); padding: 2px 8px; border-radius: 99px; vertical-align: middle; font-weight: 500; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: 6px; }
td { border-bottom: 1px solid var(--line); padding: 5px 6px; vertical-align: middle; }
.r { text-align: right; }
input.wide { width: 100%; min-width: 340px; }
input.n { width: 90px; text-align: right; }
input.u { width: 60px; }
input.ovr { background: var(--ovr); }
tr.auto td { color: var(--muted); font-style: italic; }
tr.overdue td { background: #fdf0ed; }
.tier { display: inline-flex; align-items: center; gap: 2px; margin-left: 6px; font-size: 12px; color: var(--muted); }
.tier input.n { width: 72px; }
.totals { text-align: right; margin: 14px 0; }
.totals > div { margin: 2px 0; }
.totals .big { font-size: 22px; }
.add select { max-width: 100%; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(80px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; transition: transform .25s, opacity .25s; opacity: 0; pointer-events: none; }
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
#print { display: none; }

/* dokument (faktura / nabídka) */
.preview { border: 1px solid var(--line); padding: 24px; background: #fff; overflow-x: auto; }
.doc { color: #111; font-size: 13px; max-width: 800px; margin: 0 auto; }
.doc-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid #111; padding-bottom: 6px; margin-bottom: 16px; }
.doc-head h1 { margin: 0; font-size: 24px; }
.docno { font-size: 16px; font-weight: 600; }
.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 14px; }
.party .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #666; margin-bottom: 4px; }
.meta { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 24px; background: #f5f5f3; padding: 10px; margin-bottom: 14px; }
.doc-lines th { color: #333; border-bottom: 1px solid #111; }
.doc-lines td { border-bottom: 1px solid #ddd; }
.doc-totals { text-align: right; margin-top: 12px; }
.doc-totals .big { font-size: 18px; margin-top: 4px; }
.doc-note { margin-top: 18px; }
.doc-foot { margin-top: 24px; color: #555; font-size: 12px; }

@media (max-width: 640px) {
  main { padding: 8px; }
  .parties, .meta { grid-template-columns: 1fr; }
  input.wide { min-width: 160px; }
}
@media print {
  body { background: #fff; }
  header, main, #toast { display: none !important; }
  #print { display: block; }
  @page { margin: 14mm; }
}
.betonsum { align-self: flex-end; padding: 6px 4px; }
.warn { color: var(--warn); font-weight: 600; margin: 6px 0 0; }
