:root {
  --bg: #f4f6f9; --panel: #fff; --ink: #14263a; --muted: #5a6b7e; --line: #d9e0e8; --line-strong: #b8c4d1;
  --brand: #0f3d66; --brand-ink: #fff; --brand-soft: #e6eef6; --ok: #17704a; --ok-soft: #e3f4ec; --warn: #8a5a00; --warn-soft: #fdf3dc;
  --err: #b3261e; --err-soft: #fbe9e7; --radius: 10px; --shadow: 0 1px 2px rgba(20,38,58,.06), 0 4px 16px rgba(20,38,58,.05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
h1 { font-size: 22px; line-height: 1.25; margin: 0; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
a { color: var(--brand); }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); } }

/* Ovládacie prvky */
label.field { display: block; }
.field > .lbl { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.req { color: var(--err); margin-left: 2px; }
.help { color: var(--muted); font-size: 13px; margin-top: 4px; }
.error { color: var(--err); font-size: 13px; margin-top: 4px; font-weight: 500; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=password], input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; min-height: 42px; padding: 9px 11px; font: inherit; font-size: 16px; color: inherit; background: #fff; border: 1px solid var(--line-strong); border-radius: 8px; }
@media (min-width: 900px) { input[type=text], input[type=email], input[type=tel], input[type=number], input[type=password], input[type=date], input[type=datetime-local], input[type=search], select, textarea { font-size: 15px; } }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
textarea { min-height: 110px; resize: vertical; }
.invalid { border-color: var(--err) !important; }
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 16px; font: inherit; font-weight: 600; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 8px; cursor: pointer; text-decoration: none; }
button:hover, .btn:hover { background: #f1f4f7; }
button.primary, .btn.primary { color: var(--brand-ink); background: var(--brand); border-color: var(--brand); }
button.primary:hover, .btn.primary:hover { background: #0b3054; }
button.danger { color: var(--err); border-color: #e6b8b4; }
button.link { min-height: 0; padding: 0; background: none; border: 0; color: var(--brand); font-weight: 500; text-decoration: underline; }
button.sm, .btn.sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: .55; cursor: default; }
.check { display: flex; gap: 9px; align-items: flex-start; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--brand); }
.notice { padding: 10px 13px; border-radius: 8px; background: var(--brand-soft); font-size: 14px; }
.notice.warn { background: var(--warn-soft); color: #5e3f00; }
.notice.err { background: var(--err-soft); color: #7f1a14; }
.notice.ok { background: var(--ok-soft); color: #0e4f33; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #e8ecf1; color: #33465a; }
.st-nova { background: #dceafb; color: #0d4a8c; }
.st-zaevidovana { background: #e6e4fb; color: #3d2f9e; }
.st-rozpracovana { background: var(--warn-soft); color: var(--warn); }
.st-v_rieseni { background: #dff3f5; color: #0c5f69; }
.st-ukoncena { background: var(--ok-soft); color: var(--ok); }

/* Verejný formulár */
body.public { background: var(--bg); }
.pub-head { background: var(--brand); color: #fff; padding: 14px 16px; }
.pub-head .in { max-width: 680px; margin: 0 auto; display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.pub-head img { max-height: 30px; }
.pub-wrap { max-width: 680px; margin: 0 auto; padding: 16px 16px calc(40px + env(safe-area-inset-bottom)); }
.steps { display: flex; gap: 4px; margin: 4px 0 6px; }
.steps i { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.steps i.on { background: var(--brand); }
.step-title { margin: 10px 0 14px; }
.fields > * + * { margin-top: 16px; }
.nav { display: flex; gap: 10px; margin-top: 22px; }
.nav .primary { flex: 1; }
.suggest { position: relative; }
.suggest ul { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin: 3px 0 0; padding: 4px; list-style: none; background: #fff; border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow); max-height: 240px; overflow: auto; }
.suggest li button { width: 100%; justify-content: flex-start; text-align: left; border: 0; font-weight: 400; background: none; }
.suggest li button:hover { background: var(--brand-soft); }
.house { border: 2px solid var(--line-strong); border-radius: var(--radius); padding: 12px 14px; background: #fff; }
.house.sel { border-color: var(--ok); background: var(--ok-soft); }
.house b { display: block; font-size: 16px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-top: 10px; }
.thumb { position: relative; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #eef1f5; display: flex; align-items: center; justify-content: center; font-size: 12px; text-align: center; padding: 3px; word-break: break-all; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb .x { position: absolute; top: 3px; right: 3px; width: 26px; height: 26px; min-height: 0; padding: 0; border-radius: 50%; background: rgba(0,0,0,.65); color: #fff; border: 0; font-size: 15px; line-height: 1; }
.thumb .busy { position: absolute; inset: 0; background: rgba(255,255,255,.75); display: flex; align-items: center; justify-content: center; font-weight: 600; color: var(--ink); }
.sigbox { position: relative; border: 1px dashed var(--line-strong); border-radius: 8px; background: #fff; height: 170px; touch-action: none; }
.sigbox canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; border-radius: 8px; }
.sigbox .ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #9aa7b5; pointer-events: none; }
.done { text-align: center; padding: 32px 12px; }
.done .mark { width: 58px; height: 58px; line-height: 58px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 30px; margin: 0 auto 14px; }

/* Aplikácia */
.shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--brand); color: #fff; padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.side .logo { font-weight: 800; font-size: 18px; padding: 4px 10px 14px; }
.side a { color: #dbe7f2; text-decoration: none; padding: 9px 10px; border-radius: 7px; font-weight: 500; display: flex; justify-content: space-between; align-items: center; }
.side a:hover { background: rgba(255,255,255,.1); }
.side a.on { background: rgba(255,255,255,.18); color: #fff; }
.side .sp { flex: 1; }
.side .who { font-size: 12.5px; color: #b9cde0; padding: 6px 10px; word-break: break-all; }
.side .count { background: #fff; color: var(--brand); border-radius: 99px; padding: 0 7px; font-size: 12px; font-weight: 700; }
.main { padding: 20px 24px 60px; min-width: 0; }
.main-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.topbar { display: none; }
@media (max-width: 860px) {
  .shell { display: block; }
  .side { display: none; }
  .side.open { display: flex; position: fixed; inset: 0 25% 0 0; z-index: 40; height: 100%; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--brand); color: #fff; font-weight: 700; position: sticky; top: 0; z-index: 30; }
  .topbar button { min-height: 36px; background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
  .main { padding: 14px 14px 60px; }
}
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr; gap: 8px; margin-bottom: 12px; align-items: end; }
.filters .field > .lbl { font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 2px; }
@media (max-width: 1100px) { .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); } .filters > :first-child { grid-column: 1 / -1; } }
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th { text-align: left; padding: 9px 12px; font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafbfc; }
.t td { padding: 9px 12px; border-bottom: 1px solid #edf0f4; vertical-align: top; }
.t tr:last-child td { border-bottom: 0; }
.t tr.click { cursor: pointer; }
.t tr.click:hover td { background: #f7f9fb; }
.t tr.group td { background: var(--brand-soft); font-weight: 700; padding: 7px 12px; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.pager { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 10px; }
.detail { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1050px) { .detail { grid-template-columns: minmax(0, 1fr); } }
.kv { display: grid; grid-template-columns: minmax(110px, 38%) minmax(0, 1fr); gap: 4px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
dl { margin: 0; }
.sec-title { font-weight: 700; font-size: 13px; color: var(--muted); margin: 14px 0 6px; padding-bottom: 3px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; border-radius: 0; font-weight: 500; white-space: nowrap; color: var(--muted); }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 700; }
.list-row { display: flex; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px solid #edf0f4; font-size: 14px; flex-wrap: wrap; }
.list-row:last-child { border-bottom: 0; }
dialog { border: 0; border-radius: 12px; padding: 0; width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.3); color: inherit; }
dialog::backdrop { background: rgba(10,25,40,.5); }
.dlg-h { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 2; }
.dlg-h h2 { margin: 0; }
.dlg-b { padding: 16px 18px; }
.dlg-f { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: #fff; z-index: 2; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); padding: 10px 16px; background: #14263a; color: #fff; border-radius: 8px; z-index: 100; max-width: calc(100vw - 32px); font-size: 14px; }
.toast.err { background: var(--err); }
.login { max-width: 400px; margin: 8vh auto; padding: 0 16px; }
.fe-field { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; }
.fe-sec { background: #f8fafb; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.iconbtn { min-height: 32px; width: 32px; padding: 0; }
