:root {
  --ochre: #C8913A; --ochre-dark: #A0662A; --ochre-ink: #6E4A16; --ochre-soft: #F3E6CC; --ochre-faint: #FAF4E7;
  --slate: #2F3E4C; --slate-2: #3E5163; --slate-mid: #6B8296; --slate-soft: #DCE4EA; --mist: #EEF1F4;
  --line: #D9E0E6; --white: #fff; --red: #B4483A; --red-soft: #F6E1DD; --green: #3F7A5A; --green-soft: #DFEDE4;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--slate); background: var(--mist); }
a { color: var(--ochre-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 650; }
[hidden] { display: none !important; }

#shell { display: flex; min-height: 100%; }
.side { width: 232px; flex-shrink: 0; background: var(--slate); color: #C9D3DC; display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ochre-soft); font-weight: 650; font-size: 16px; padding: 4px 8px 20px; }
.brand:hover { text-decoration: none; }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a { display: flex; align-items: center; gap: 10px; color: #C9D3DC; padding: 9px 10px; border-radius: 8px; font-size: 14px; }
#nav a:hover { background: var(--slate-2); text-decoration: none; }
#nav a.on { background: var(--slate-2); color: var(--ochre-soft); box-shadow: inset 3px 0 0 var(--ochre); }
#nav i { font-size: 19px; }
.side-foot { margin-top: auto; font-size: 13px; padding: 8px; display: flex; flex-direction: column; gap: 6px; color: #9FB0BE; }
.side-foot .link { color: #C9D3DC; }

main { flex: 1; min-width: 0; padding: 28px 32px 60px; max-width: 1280px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.head .sub { color: var(--slate-mid); font-size: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 14px; font-weight: 550; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--white); color: var(--slate); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--slate-mid); text-decoration: none; }
.btn.primary { background: var(--ochre); border-color: var(--ochre); color: #2A2110; }
.btn.primary:hover { background: #D39D48; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 5px 9px; font-size: 13px; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--ochre-dark); cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.icon-btn { background: none; border: 0; color: var(--slate-mid); cursor: pointer; padding: 4px; border-radius: 6px; font-size: 17px; }
.icon-btn:hover { background: var(--mist); color: var(--slate); }

.card { background: var(--white); border-radius: var(--radius); border: 1px solid var(--line); padding: 18px 20px; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 16px; }
.kpi .label { font-size: 13px; color: var(--slate-mid); }
.kpi .value { font-size: 25px; font-weight: 650; letter-spacing: -.01em; }
.kpi .hint { font-size: 12.5px; color: var(--slate-mid); }
.kpi.warn .value { color: var(--red); }
.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.two .card { min-width: 0; overflow-x: auto; }
.detail { grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); align-items: start; }

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--white); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ochre); outline-offset: -1px; border-color: var(--ochre); }
textarea { min-height: 72px; resize: vertical; }
.toolbar input, .toolbar select { width: auto; }
.toolbar .search { flex: 1; min-width: 200px; max-width: 380px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 550; color: var(--slate-mid); font-size: 12.5px; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--mist); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--ochre-faint); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--slate-mid); }
.small { font-size: 13px; }
.table-card { padding: 4px 8px; overflow-x: auto; }
.empty { padding: 28px 12px; text-align: center; color: var(--slate-mid); }

.tag { display: inline-block; font-size: 12px; font-weight: 550; padding: 2px 9px; border-radius: 99px; background: var(--slate-soft); color: var(--slate); white-space: nowrap; }
.tag.ochre { background: var(--ochre-soft); color: var(--ochre-ink); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.ghost { background: transparent; border: 1px dashed var(--slate-mid); color: var(--slate-mid); }

dl.info { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; margin: 0; font-size: 14px; }
dl.info dt { color: var(--slate-mid); }
dl.info dd { margin: 0; overflow-wrap: anywhere; }
.contact { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--mist); }
.contact:last-child { border-bottom: 0; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--ochre-soft); color: var(--ochre-ink); font-weight: 650; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.contact .body { flex: 1; min-width: 0; font-size: 14px; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.section-head h2 { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.board { display: grid; grid-template-columns: repeat(6, minmax(190px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.col { background: var(--slate-soft); border-radius: var(--radius); padding: 10px; min-height: 180px; }
.col.over { outline: 2px dashed var(--ochre); outline-offset: -2px; }
.col-head { display: flex; justify-content: space-between; font-size: 13px; font-weight: 650; margin-bottom: 2px; }
.col-sum { font-size: 12.5px; color: var(--slate-mid); margin-bottom: 8px; }
.deal { background: var(--white); border-radius: 8px; padding: 10px 11px; margin-bottom: 8px; cursor: grab; border: 1px solid var(--line); border-left: 3px solid var(--ochre); font-size: 13.5px; }
.deal:hover { border-color: var(--ochre); }
.deal .t { font-weight: 600; }
.deal .v { font-weight: 650; margin-top: 4px; }
.col[data-stage=vyhrano] .deal { border-left-color: var(--green); }
.col[data-stage=prohrano] .deal { border-left-color: var(--slate-mid); opacity: .75; }

dialog { border: 0; border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 32px)); color: inherit; box-shadow: 0 20px 60px rgba(47, 62, 76, .35); }
dialog::backdrop { background: rgba(47, 62, 76, .5); }
dialog form { padding: 22px 24px; }
dialog h2 { font-size: 18px; margin-bottom: 16px; }
.fields { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.f { grid-column: span 6; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--slate-mid); }
.f.s2 { grid-column: span 2; } .f.s3 { grid-column: span 3; } .f.s4 { grid-column: span 4; }
.f input, .f select, .f textarea { color: var(--slate); font-size: 14.5px; }
.inline { display: flex; gap: 8px; }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--slate); font-size: 14px; }
.check input { width: auto; }
.form-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 20px; }
.err { color: var(--red); font-size: 13.5px; margin-top: 10px; min-height: 1em; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--slate); color: var(--ochre-soft); padding: 10px 18px; border-radius: 99px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; }
#toast.show { opacity: 1; }

#auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--slate); padding: 20px; }
.auth-card { background: var(--white); border-radius: 18px; padding: 34px 32px; width: min(400px, 100%); text-align: center; }
.auth-card img { margin-bottom: 10px; }
.auth-card h1 { margin-bottom: 4px; }
.auth-card p { color: var(--slate-mid); margin: 0 0 20px; font-size: 14px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.auth-card .btn { justify-content: center; padding: 10px; }

.act { display: flex; gap: 12px; align-items: flex-start; padding: 9px 4px; border-bottom: 1px solid var(--mist); cursor: pointer; font-size: 14px; }
.act:last-child { border-bottom: 0; }
.act:hover { background: var(--ochre-faint); }
.act > i { font-size: 18px; color: var(--slate-mid); margin-top: 2px; width: 18px; }
.act input[type=checkbox] { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--ochre); flex-shrink: 0; cursor: pointer; }
.act .body { flex: 1; min-width: 0; }
.act.done b { text-decoration: line-through; color: var(--slate-mid); font-weight: 500; }
.late { color: var(--red); font-weight: 600; white-space: nowrap; }
code { background: var(--mist); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; overflow-wrap: anywhere; }

/* editor faktury */
.items td { padding: 5px 4px; border: 0; }
.items th { padding: 4px; border: 0; }
.items input, .items select { padding: 7px 8px; }
.totals { margin-left: auto; width: 280px; font-size: 14px; }
.totals div { display: flex; justify-content: space-between; padding: 3px 0; }
.totals .sum { font-size: 18px; font-weight: 650; border-top: 2px solid var(--slate); margin-top: 6px; padding-top: 8px; }

/* tisková podoba faktury */
.paper { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 44px 48px; max-width: 860px; font-size: 13.5px; }
.paper-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid var(--ochre); padding-bottom: 18px; margin-bottom: 22px; }
.paper-head .doc { text-align: right; }
.paper-head .doc b { font-size: 22px; display: block; }
.paper-brand { display: flex; align-items: center; gap: 12px; font-size: 18px; font-weight: 650; }
.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-bottom: 22px; }
.parties h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--slate-mid); margin: 0 0 6px; font-weight: 600; }
.parties .name { font-weight: 650; font-size: 15px; }
.meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; background: var(--mist); border-radius: 8px; padding: 12px 16px; margin-bottom: 22px; }
.meta span { display: block; font-size: 11.5px; color: var(--slate-mid); }
.paper table th { border-bottom: 1.5px solid var(--slate); }
.paper-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-top: 22px; }
.qr { text-align: center; font-size: 11.5px; color: var(--slate-mid); }
.qr img, .qr svg { display: block; width: 130px; height: 130px; }
.stamp { margin-top: 26px; color: var(--slate-mid); font-size: 12px; }
.watermark { color: var(--red); font-weight: 650; border: 2px solid var(--red); display: inline-block; padding: 2px 12px; border-radius: 6px; transform: rotate(-4deg); margin-bottom: 10px; }

@media (max-width: 860px) {
  #shell { flex-direction: column; }
  .side { width: auto; height: auto; position: static; flex-direction: row; align-items: center; padding: 8px 10px; overflow-x: auto; }
  .brand { padding: 0 8px 0 0; } .brand span, .side-foot span { display: none; }
  #nav { flex-direction: row; } #nav a { white-space: nowrap; }
  .side-foot { margin: 0 0 0 auto; padding: 0 0 0 8px; }
  main { padding: 18px 14px 50px; }
  .detail, .parties { grid-template-columns: 1fr; }
  .meta { grid-template-columns: 1fr 1fr; }
  .paper { padding: 22px 18px; }
  .f.s2, .f.s3, .f.s4 { grid-column: span 6; }
}
@media print {
  body { background: #fff; }
  .side, .head, #toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .paper { border: 0; padding: 0; max-width: none; }
  @page { margin: 16mm; }
}
.card.notice { border-left: 4px solid var(--red); padding: 12px 16px; margin-bottom: 14px; }
.items .icon-btn + .icon-btn { margin-left: 2px; }
@media print { .card.notice { display: none; } }

.ares-box { background: var(--mist); border-radius: 10px; padding: 10px 12px; }
.ares-results { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; max-height: 240px; overflow-y: auto; }
.ares-results button { text-align: left; background: #fff; border: 1px solid transparent; border-radius: 8px; padding: 7px 10px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; color: var(--slate); font: inherit; }
.ares-results button:hover { border-color: var(--ochre); }
.ares-results button span { font-size: 12.5px; color: var(--slate-mid); }

.paper-brand .own-logo { max-height: 56px; max-width: 200px; object-fit: contain; }
.logo-card { display: flex; gap: 18px; align-items: center; }
.logo-prev { width: 160px; height: 80px; border: 1px dashed var(--line); border-radius: 10px; display: grid; place-items: center; flex: none; background: #fff; }
.logo-prev img { max-width: 140px; max-height: 64px; object-fit: contain; }
@media print {
  .parties { grid-template-columns: 1fr 1fr !important; }
  .meta { grid-template-columns: repeat(4, 1fr) !important; }
  .paper-foot, .parties, .meta, .paper table tr { break-inside: avoid; }
  main { padding: 0 !important; }
}

.toolbar .fl { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--slate-mid); }
.toolbar .fl input { width: auto; }
.toolbar .fl input[type=number] { width: 110px; }
.saved-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: -4px 0 14px; }
.saved-filters:empty { display: none; }
.chip { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: #fff; overflow: hidden; }
.chip button { border: 0; background: none; font: inherit; font-size: 13px; color: var(--slate); padding: 4px 6px 4px 12px; cursor: pointer; }
.chip button + button { padding: 4px 9px 4px 4px; color: var(--slate-mid); }
.chip.on { border-color: var(--ochre); background: var(--ochre-soft); }
tfoot td { border-top: 1.5px solid var(--line); padding-top: 10px; }
.red-t { color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--slate-mid); }
.btn.ghost:hover { color: var(--slate); background: var(--mist); }

.tag-select { appearance: none; -webkit-appearance: none; width: auto; border: 1px solid transparent; cursor: pointer; font: inherit; font-size: 12px; font-weight: 550;
  padding: 2px 22px 2px 9px; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 11px) 55%, calc(100% - 7px) 55%; background-size: 4px 4px; background-repeat: no-repeat; }
.tag-select:hover, .tag-select:focus { border-color: var(--ochre); outline: none; }
.tag-btn { border: 1px solid transparent; cursor: pointer; font: inherit; font-size: 12px; font-weight: 550; }
.tag-btn:hover { border-color: var(--ochre); }
.tag-select { width: auto !important; field-sizing: content; max-width: 240px; vertical-align: middle; }
.ask { width: min(420px, calc(100vw - 32px)); }
.toolbar input:disabled { opacity: .65; }

.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tabs a { display: inline-flex; gap: 6px; align-items: center; padding: 8px 14px; color: var(--slate-mid); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--slate); border-bottom-color: var(--ochre); font-weight: 600; }
.perm-table { width: 100%; font-size: 13.5px; }
.perm-table td, .perm-table th { padding: 6px 8px; text-align: left; }
.perm-table td:nth-child(n+3), .perm-table th:nth-child(n+3) { text-align: center; }
.perm-table td:last-child, .perm-table th:last-child { text-align: left; }
.perm-table select { width: auto; padding: 4px 8px; }
.perm-table input[type=checkbox] { width: auto; }
.perm-table tr.off td:first-child { color: var(--slate-mid); }
.perm-table .check { display: inline-flex; gap: 6px; align-items: center; }
.perm-sum .tag, .card .tag { margin: 2px 2px 2px 0; }
dialog#modal:has(.perm-table) { width: min(860px, calc(100vw - 32px)); }
.card.click { cursor: pointer; } .card.click:hover { border-color: var(--ochre); }

.or { display: flex; align-items: center; gap: 10px; color: var(--slate-mid); font-size: 13px; margin: 14px 0 10px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.ms-btn { width: 100%; justify-content: center; }
.empty-state { max-width: 620px; margin: 40px auto; text-align: center; padding: 36px 28px; }
.empty-state > i { font-size: 40px; color: var(--ochre); }
.empty-state h1 { margin: 10px 0; }
.notice-ochre { background: var(--ochre-faint); border: 1px solid var(--ochre-soft); padding: 12px 16px; margin-bottom: 14px; }
