:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --border: #e7e9f0;
  --border-strong: #d5d9e4;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-50: #eef2ff;
  --green: #059669;
  --green-50: #ecfdf5;
  --amber: #b45309;
  --amber-50: #fffbeb;
  --red: #dc2626;
  --red-50: #fef2f2;
  --sidebar: #0b1020;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .04);
  --shadow-lg: 0 20px 60px rgba(15, 23, 42, .25);
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  display: grid; grid-template-columns: 248px 1fr; min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
.ico { flex-shrink: 0; }
.mono { font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: .95em; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.block { display: block; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- sidebar ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px;
  padding: 22px 16px; color: #cbd5e1;
  background: radial-gradient(120% 60% at 0% 0%, #1e1b4b 0%, var(--sidebar) 60%);
}
.logo { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 17px; padding: 0 6px; letter-spacing: -.01em; }
.logo-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6); box-shadow: 0 6px 16px rgba(99, 102, 241, .45);
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 14px 10px 6px; font-weight: 600; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm);
  color: #cbd5e1; font-weight: 500; transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar nav a.active { background: rgba(129, 140, 248, .16); color: #fff; }
.sidebar nav a.active .ico { color: #a5b4fc; }
.sidebar-foot {
  margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0;
  border-top: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-foot b { display: block; color: #fff; font-size: 13px; font-weight: 600; }
.sidebar-foot small { color: #64748b; font-size: 12px; }
.me-avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px;
  color: #fff; background: linear-gradient(135deg, #f472b6, #8b5cf6);
}

/* ---------- content ---------- */
.content { padding: 30px 40px 120px; max-width: 1360px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.02em; display: flex; align-items: center; gap: 12px; }
.page-head .sub { margin: 4px 0 0; color: var(--muted); }
.head-actions { display: flex; align-items: center; gap: 8px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; margin-bottom: 6px; font-size: 13px; }
.back:hover { color: var(--primary); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 15px;
  border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 13.5px;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(79, 70, 229, .3), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn-primary:hover { background: var(--primary-600); }
.btn-secondary { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); box-shadow: 0 1px 2px rgba(15, 23, 42, .05); }
.btn-secondary:hover { background: #f8fafc; border-color: #c4c9d6; }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: rgba(15, 23, 42, .05); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-danger-text { color: var(--red); }
.btn-danger-text:hover { background: var(--red-50); }
.btn-block { width: 100%; }
.btn-dashed {
  width: 100%; margin-top: 10px; background: transparent; color: var(--primary);
  border: 1.5px dashed #c7d2fe; height: 42px;
}
.btn-dashed:hover { background: var(--primary-50); border-color: var(--primary); }
.btn.loading { opacity: .7; pointer-events: none; }
.btn.loading .ico { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  position: relative; width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: 8px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: #f1f5f9; color: var(--text); }
.icon-btn-green:hover { background: var(--green-50); color: var(--green); }
.icon-btn-danger:hover { background: var(--red-50); color: var(--red); }
.icon-btn-primary:hover { background: var(--primary-50); color: var(--primary); }
[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff; font-size: 12px; font-weight: 500; padding: 4px 8px; border-radius: 6px;
  white-space: nowrap; pointer-events: none; z-index: 10;
}

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat {
  display: flex; gap: 14px; align-items: flex-start; padding: 18px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.stat span { display: block; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat b { display: block; font-size: 21px; font-weight: 700; letter-spacing: -.02em; margin: 2px 0; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); font-size: 12px; }
.stat-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; }
.stat-icon.indigo { background: var(--primary-50); color: var(--primary); }
.stat-icon.green { background: var(--green-50); color: var(--green); }
.stat-icon.amber { background: var(--amber-50); color: #d97706; }
.stat-icon.red { background: var(--red-50); color: var(--red); }
.stat-alert { border-color: #fecaca; background: linear-gradient(180deg, #fff, #fff7f7); }
.stat-alert b { color: var(--red); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 22px; }
.card-title { display: flex; align-items: center; gap: 9px; margin: 0 0 16px; font-size: 15px; font-weight: 650; }
.card-title .ico { color: var(--primary); }
.card-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.card-foot {
  display: flex; justify-content: space-between; padding: 14px 20px; color: var(--muted);
  border-top: 1px solid var(--border); background: #fafbfd; border-radius: 0 0 var(--radius) var(--radius);
}
.card-foot b { color: var(--text); }
.foot-total { font-size: 15px; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.layout-2 { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }

/* ---------- tabs & search ---------- */
.tabs { display: flex; gap: 4px; background: #f1f3f8; padding: 4px; border-radius: 10px; }
.tabs a { padding: 6px 14px; border-radius: 7px; color: var(--muted); font-weight: 600; font-size: 13px; }
.tabs a:hover { color: var(--text); }
.tabs a.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(15, 23, 42, .1); }
.search { position: relative; display: flex; align-items: center; }
.search .ico { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.search input { width: 300px; padding-left: 34px !important; }
.search-wide input { width: 420px; }
.select-pill { height: 38px; font-weight: 600; }

/* ---------- table ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); padding: 11px 16px; border-bottom: 1px solid var(--border); background: #fafbfd;
}
.table td { padding: 13px 16px; border-bottom: 1px solid #f0f2f6; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr[data-href] { cursor: pointer; transition: background .12s; }
.table tbody tr:hover { background: #f8f9fe; }
.table .amount { font-weight: 650; white-space: nowrap; }
.table .amount small { color: var(--muted); font-weight: 500; }
.actions-col { width: 1%; white-space: nowrap; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; opacity: .55; transition: opacity .15s; }
.row-actions form { display: contents; }
tr:hover .row-actions { opacity: 1; }
.doc-no { font-family: "SF Mono", ui-monospace, Menlo, monospace; font-weight: 600; font-size: 13px; color: var(--text); }
.party { display: flex; align-items: center; gap: 11px; }
.party b { display: block; font-weight: 600; }
.party small { display: block; color: var(--muted); font-size: 12px; }
.contact { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; }
.contact .ico { color: var(--muted); }
.count-pill { display: inline-block; min-width: 26px; padding: 2px 8px; border-radius: 20px; background: #f1f3f8; font-weight: 600; font-size: 12px; text-align: center; }

.avatar {
  width: 36px; height: 36px; border-radius: 10px; display: inline-grid; place-items: center; flex-shrink: 0;
  font-weight: 700; font-size: 12.5px; color: var(--primary); background: linear-gradient(135deg, #eef2ff, #e0e7ff);
}
.avatar.sm { width: 30px; height: 30px; border-radius: 8px; font-size: 11px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.5;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge:has(.ico)::before { display: none; }
.badge-green { background: var(--green-50); color: var(--green); }
.badge-amber { background: var(--amber-50); color: var(--amber); }
.badge-red { background: var(--red-50); color: var(--red); }
h1 .badge { font-size: 12.5px; letter-spacing: 0; }

.empty { text-align: center; padding: 60px 20px; }
.empty-icon { width: 60px; height: 60px; margin: 0 auto 14px; border-radius: 16px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); }
.empty h3 { margin: 0 0 4px; font-size: 16px; }
.empty p { margin: 0 0 18px; color: var(--muted); }

/* ---------- forms ---------- */
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: #fff; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 0 12px; height: 40px; transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; }
select {
  appearance: none; padding-right: 34px; cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 11px center;
}
input:hover, select:hover, textarea:hover { border-color: #b8bfcf; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field:last-child { margin-bottom: 0; }
.field.grow { flex: 1; margin-bottom: 0; }
.hint { display: flex; align-items: center; gap: 6px; font-style: normal; font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.field-row, .ares-box { display: flex; align-items: flex-end; gap: 10px; }
.ares-box { margin-bottom: 14px; }
.grid-2, .grid-3 { display: grid; gap: 0 12px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.span-2 { grid-column: span 2; }
.input-btn { display: flex; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.flash-fill { animation: fill 1.2s ease; }
@keyframes fill { 0% { background: #e0e7ff; } 100% { background: #fff; } }

.chips { display: flex; gap: 6px; margin: -4px 0 14px; }
.chip {
  flex: 1; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: #fafbfd;
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary-50); border-color: #c7d2fe; color: var(--primary); }

.customer-preview {
  display: flex; gap: 14px; align-items: center; margin-top: 14px; padding: 14px;
  border-radius: 12px; background: linear-gradient(135deg, #f8f9ff, #f3f4ff); border: 1px solid #e0e7ff;
}
.customer-preview .avatar { width: 44px; height: 44px; font-size: 14px; background: #fff; }
.customer-preview b { font-size: 15px; }
.customer-preview[hidden] { display: none; }

/* items */
.items-head, .item-row { display: grid; grid-template-columns: minmax(0, 1fr) 84px 64px 108px 116px 32px; gap: 8px; align-items: center; }
.items-head { margin: 4px 0 6px; padding: 0 2px; }
.items-head span { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.item-row { padding: 6px 0; border-bottom: 1px solid #f0f2f6; }
.item-row input { height: 38px; }
.item-row input.num { text-align: right; }
.rowtotal { font-weight: 650; white-space: nowrap; }
.totals { margin: 18px 0 0 auto; width: 320px; }
.totals > div { display: flex; justify-content: space-between; padding: 6px 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.totals .grand {
  margin-top: 6px; padding: 12px 14px; border-radius: 10px; background: var(--primary-50);
  color: var(--primary-600); font-weight: 700; font-size: 17px;
}
.totals p { text-align: right; margin: 8px 0 0; }

.next-number {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; margin: 0 0 14px; border-radius: 10px;
  background: var(--primary-50); color: var(--primary-600); font-size: 13px;
}

.signature { display: flex; gap: 18px; align-items: center; }
.signature img, .signature-empty {
  width: 180px; height: 90px; object-fit: contain; border-radius: 10px; border: 1.5px dashed var(--border-strong);
  background: #fafbfd; padding: 8px;
}
.signature-empty { display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.signature-actions { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.file-btn { cursor: pointer; }

/* ---------- savebar ---------- */
.savebar {
  position: fixed; left: 248px; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center;
  padding: 12px 40px; background: rgba(255, 255, 255, .85); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border); box-shadow: 0 -6px 24px rgba(15, 23, 42, .05);
}
.savebar-total span { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.savebar-total b { font-size: 20px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.savebar-actions { display: flex; gap: 8px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; top: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 280px; max-width: 420px; padding: 13px 16px;
  border-radius: 12px; background: #0f172a; color: #fff; font-weight: 500; box-shadow: var(--shadow-lg);
  animation: toast-in .25s ease; transition: opacity .3s, transform .3s;
}
.toast-ok .ico { color: #34d399; }
.toast-error { background: #7f1d1d; }
.toast-error .ico { color: #fca5a5; }
.toast.hide { opacity: 0; transform: translateX(20px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- modal ---------- */
.modal {
  border: 0; padding: 0; width: 420px; max-width: calc(100vw - 32px); border-radius: 18px; box-shadow: var(--shadow-lg);
  color: var(--text);
}
.modal[open] { animation: modal-in .2s ease; }
.modal::backdrop { background: rgba(15, 23, 42, .45); backdrop-filter: blur(3px); animation: fade .2s ease; }
.modal form { padding: 26px; }
.modal-icon { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; background: var(--red-50); color: var(--red); margin-bottom: 14px; }
.modal.modal-primary .modal-icon { background: var(--primary-50); color: var(--primary); }
.modal h3 { margin: 0 0 6px; font-size: 18px; letter-spacing: -.01em; }
.modal p { margin: 0; color: var(--muted); line-height: 1.55; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes fade { from { opacity: 0; } }

@media (max-width: 1150px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .layout-2, .settings-grid { grid-template-columns: 1fr; }
  .search input, .search-wide input { width: 220px; }
}

/* ---------- číselné řady ---------- */
a.link-row { text-decoration: none; }
a.link-row:hover { background: #e0e7ff; }
.year-group th.year-row {
  background: #fff; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--text);
  padding-top: 18px; border-bottom: 1px solid var(--border);
}
.year-row .badge { margin-left: 8px; font-size: 11.5px; }
.code-pill {
  display: inline-block; padding: 3px 9px; border-radius: 7px; background: var(--primary-50); color: var(--primary-600);
  font-weight: 700; font-size: 12px; letter-spacing: .03em;
}
.star { color: #f59e0b; }
.modal.modal-form { width: 520px; }
.modal.modal-form h3 { margin-bottom: 16px; }
.preview-number {
  display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-radius: 10px;
  background: #0f172a; color: #e2e8f0; margin-top: 4px;
}
.preview-number b { font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: 17px; color: #fff; letter-spacing: .02em; }
.preview-number span { font-size: 12px; color: #94a3b8; }
.callout {
  display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 16px 20px; margin-bottom: 18px;
  border-radius: var(--radius); background: linear-gradient(135deg, #eef2ff, #f5f3ff); border: 1px solid #e0e7ff;
}
.callout p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.badge-indigo { background: var(--primary-50); color: var(--primary-600); }
.badge-gray { background: #f1f5f9; color: #475569; }
.stat-info { border-color: #c7d2fe; background: linear-gradient(180deg, #fff, #f7f8ff); }
.stat-info b { color: var(--primary-600); }
.deduct-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px 32px; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid #f0f2f6; }
.deduct-row input.num { text-align: right; }
.adv-empty:empty { display: none; }
.adv-empty { padding: 10px 12px; border-radius: 10px; background: #f8fafc; }
#add-adv[hidden] { display: none; }
.callout a { font-weight: 600; }

/* Atribut hidden musí mít přednost před display z ostatních pravidel */
[hidden] { display: none !important; }

/* ---------- uživatel v menu ---------- */
.sidebar-foot { justify-content: space-between; }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; color: inherit; text-decoration: none; flex: 1; border-radius: 10px; padding: 4px; margin: -4px; }
.me:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.me-text { min-width: 0; }
.me-text b, .me-text small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { color: #64748b; font-size: 12px; }
.logout { color: #94a3b8; }
.logout:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sidebar-foot [data-tip]:hover::after { bottom: auto; top: -30px; }

.profile-banner {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; margin-bottom: 20px; border-radius: 12px;
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e; text-decoration: none; font-size: 13.5px;
}
.profile-banner span { flex: 1; }
.profile-banner:hover { background: #fef3c7; text-decoration: none; }

/* ---------- přihlášení a registrace ---------- */
.auth-body { display: block; background: radial-gradient(120% 80% at 50% 0%, #eef2ff 0%, var(--bg) 60%); }
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; margin-bottom: 22px; }
.auth-card { width: 400px; max-width: 100%; background: #fff; border: 1px solid var(--border); border-radius: 18px; padding: 32px; box-shadow: 0 10px 40px rgba(15, 23, 42, .08); }
.auth-card h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.auth-card .sub { margin: 4px 0 22px; color: var(--muted); }
.auth-card .btn-lg { height: 44px; font-size: 14.5px; margin-top: 6px; }
.auth-card .remember { margin: 2px 0 14px; color: var(--text-2); font-size: 13px; }
.auth-consent { align-items: flex-start; margin: 2px 0 14px; color: var(--text-2); font-size: 12.5px; line-height: 1.5; }
.auth-consent input { margin-top: 3px; flex: none; }
.auth-msg { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-radius: 10px; margin-bottom: 14px;
  background: var(--green-50); color: var(--green); font-size: 13px; }
.auth-msg-error { background: var(--red-50); color: var(--red); }
.auth-switch { text-align: center; margin: 18px 0 0; color: var(--muted); font-size: 13.5px; }
.auth-foot { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; margin-top: 18px; }
.auth-terms { font-size: 12.5px; color: var(--muted); text-align: center; margin: 12px 0 0; line-height: 1.5; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }   /* past na roboty */
.auth-links { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.auth-links a { color: var(--muted); }
.auth-links a:hover { color: var(--primary); }

/* =====================================================================
   Vzhled Dokládek – sjednocený s webem dokladek.cz
   ===================================================================== */
@font-face { font-family: "Nunito"; src: url("fonts/Nunito.woff2") format("woff2"); font-weight: 200 1000; font-display: swap; }
@font-face { font-family: "Baloo 2"; src: url("fonts/Baloo2.woff2") format("woff2"); font-weight: 400 800; font-display: swap; }

:root {
  --bg: #fffaf2;
  --surface: #ffffff;
  --border: #ece6db;
  --border-strong: #ddd4c4;
  --text: #1f1a3d;
  --text-2: #3d3858;
  --muted: #6e6987;
  --primary: #6c4cf5;
  --primary-600: #5535e0;
  --primary-50: #f1edff;
  --ink: #1f1a3d;
  --sun: #ffcf3f;
  --sun-d: #f0b400;
  --sun-50: #fff6d6;
  --mint: #2ed3a0;
  --mint-50: #dcfaf0;
  --coral: #ff7a6b;
  --coral-50: #ffe9e5;
  --green: #12a37a;
  --green-50: #dcfaf0;
  --amber: #8a6100;
  --amber-50: #fff6d6;
  --red: #e5483a;
  --red-50: #ffe9e5;
  --sidebar: #1f1a3d;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 2px 0 rgba(31, 26, 61, .05), 0 10px 28px rgba(31, 26, 61, .06);
  --display: "Baloo 2", "Nunito", system-ui, sans-serif;
}
body { font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 14.5px; color: var(--text); }
input, select, textarea, button { font-family: inherit; }

/* nadpisy hravým písmem */
.page-head h1, .card-title, .stat b, .logo, .empty h3, .modal h3, .auth-card h1, .auth-brand,
.savebar-total b, .totals .grand, .foot-total, .side-title { font-family: var(--display); letter-spacing: -.01em; }
.page-head h1 { font-size: 30px; font-weight: 800; }
.card-title { font-size: 18px; font-weight: 700; }
.card-title .ico { color: var(--primary); }

/* boční panel */
.sidebar { background: radial-gradient(120% 50% at 0% 0%, #2d2563 0%, var(--sidebar) 60%); }
.logo { font-size: 22px; font-weight: 800; gap: 10px; }
.logo-mark { width: auto; height: auto; background: none; box-shadow: none; border-radius: 0; }
.logo .mascot { transition: transform .3s; }
.logo:hover .mascot { transform: rotate(-8deg) scale(1.06); }
.sidebar nav a { font-weight: 700; border-radius: 999px; padding: 9px 14px; }
.sidebar nav a.active { background: rgba(255, 255, 255, .12); color: #fff; }
.sidebar nav a.active .ico { color: var(--sun); }
.nav-label { color: #8a84a8; }
.me-avatar { background: var(--sun); color: var(--ink); border: 2px solid #fff; }

/* tlačítka – stejné „3D“ jako na webu */
.btn { border-radius: 999px; font-weight: 800; height: 40px; padding: 0 18px; border-width: 2px;
  transition: transform .1s ease, box-shadow .1s ease, background .15s; }
.btn:active { transform: translateY(2px); }
.btn-primary { background: var(--primary); box-shadow: 0 3px 0 var(--primary-600); }
.btn-primary:hover { background: #7a5cff; }
.btn-primary:active { box-shadow: 0 1px 0 var(--primary-600); }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
.btn-secondary:hover { background: var(--sun-50); border-color: var(--ink); }
.btn-secondary:active { box-shadow: 0 1px 0 var(--ink); }
.btn-ghost:hover { background: rgba(31, 26, 61, .06); }
.btn-danger { background: var(--red); box-shadow: 0 3px 0 #b8342a; }
.btn-dashed { border: 2px dashed #cdbfff; border-radius: 14px; box-shadow: none; }
/* tlačítka se spodním „3D“ stínem: obsah o polovinu stínu níž, aby text opticky seděl na střed */
.btn-primary, .btn-secondary, .btn-danger { padding-top: 6px; }
.btn-dashed:hover { background: var(--primary-50); border-color: var(--primary); }
.sidebar .btn-primary { background: var(--sun); color: var(--ink); box-shadow: 0 3px 0 var(--sun-d); }
.sidebar .btn-primary:hover { background: #ffd95e; }
.icon-btn { border-radius: 10px; }

/* karty a statistiky */
.card, .stat { border: 2px solid var(--border); border-radius: var(--radius); box-shadow: none; }
.card:hover { box-shadow: none; }
.stat { transition: transform .2s, box-shadow .2s; }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat b { font-size: 24px; font-weight: 800; }
.stat-icon { border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); border-radius: 13px; color: var(--ink); }
.stat-icon.indigo { background: #e4dcff; color: var(--ink); }
.stat-icon.green { background: var(--mint-50); color: var(--ink); }
.stat-icon.amber { background: var(--sun); color: var(--ink); }
.stat-icon.red { background: var(--coral-50); color: var(--ink); }
.stat-alert { border-color: #ffc4bc; background: #fff7f5; }
.stat-info { border-color: #d7ccff; background: #faf8ff; }
.card-toolbar { border-bottom: 2px solid var(--border); }
.card-foot { background: #fffdf8; border-top: 2px solid var(--border); border-radius: 0 0 calc(var(--radius) - 2px) calc(var(--radius) - 2px); }

/* záložky, hledání, tabulky */
.tabs { background: #f6f1e7; border-radius: 999px; }
.tabs a { border-radius: 999px; font-weight: 800; }
.tabs a.active { background: #fff; color: var(--primary-600); box-shadow: 0 2px 0 rgba(31, 26, 61, .08); }
.table th { background: #fffdf8; color: var(--muted); font-weight: 800; letter-spacing: .04em; border-bottom: 2px solid var(--border); }
.table td { border-bottom: 1px solid #f3eee4; }
.table tbody tr:hover { background: #fffbf1; }
.doc-no { font-family: "Nunito", monospace; font-weight: 800; color: var(--primary-600); letter-spacing: .01em; }
.avatar { background: #e4dcff; color: var(--ink); border-radius: 12px; font-weight: 800; }
.count-pill { background: #f6f1e7; font-weight: 800; }
.code-pill { background: #e4dcff; color: var(--ink); border-radius: 8px; }

/* štítky */
.badge { font-weight: 800; }
.badge-green { background: var(--mint-50); color: #0e8a66; }
.badge-amber { background: var(--sun-50); color: #8a6100; }
.badge-red { background: var(--coral-50); color: #c23b2e; }
.badge-indigo { background: #ece6ff; color: var(--primary-600); }
.badge-gray { background: #f3efe6; color: var(--muted); }

/* formuláře */
input, select, textarea { border: 2px solid var(--border-strong); border-radius: var(--radius-sm); height: 42px; color: var(--ink); }
textarea { height: auto; }
input:hover, select:hover, textarea:hover { border-color: #cbbfa9; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(108, 76, 245, .15); }
input[type=checkbox] { height: 18px; width: 18px; }
.field > span { font-weight: 800; color: var(--text-2); }
.chip { border: 2px solid var(--border); border-radius: 999px; font-weight: 800; background: #fff; }
.chip.active { background: var(--sun); border-color: var(--ink); color: var(--ink); box-shadow: 0 2px 0 var(--ink); }
.customer-preview { background: #faf8ff; border: 2px dashed #d7ccff; border-radius: 16px; }
.customer-preview .avatar { background: var(--sun); border: 2px solid var(--ink); }
.item-row { border-bottom: 1px dashed var(--border); }
.totals .grand { background: var(--primary); color: #fff; border-radius: 14px; box-shadow: 0 3px 0 var(--primary-600); font-size: 20px; }
.next-number { background: var(--sun-50); color: #6b4c00; border: 2px dashed var(--sun-d); }
.callout { background: #faf8ff; border: 2px solid #e4dcff; border-radius: var(--radius); }
.preview-number { background: var(--ink); border-radius: 14px; }
.signature img, .signature-empty { border: 2px dashed var(--border-strong); border-radius: 14px; background: #fffdf8; }

/* spodní lišta s uložením */
.savebar { background: rgba(255, 250, 242, .9); border-top: 2px solid var(--border); }
.savebar-total b { font-size: 24px; font-weight: 800; color: var(--primary-600); }

/* upozornění, toasty, dialog */
.profile-banner { background: var(--sun-50); border: 2px dashed var(--sun-d); color: #6b4c00; border-radius: 16px; font-weight: 700; }
.toast { border-radius: 16px; background: var(--ink); border: 2px solid var(--ink); box-shadow: 4px 4px 0 rgba(31, 26, 61, .25); font-weight: 700; }
.toast-ok .ico { color: var(--mint); }
.toast-error { background: #7a1d16; }
.modal { border: 2px solid var(--ink); border-radius: 22px; box-shadow: 6px 6px 0 var(--ink); }
.modal-icon { border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); background: var(--coral-50); color: var(--ink); }
.modal.modal-primary .modal-icon { background: var(--sun); color: var(--ink); }
.empty-icon { background: var(--sun); color: var(--ink); border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); }
[data-tip]:hover::after { background: var(--ink); border-radius: 8px; font-weight: 700; }

/* přihlášení a registrace */
.auth-body { background: var(--bg); position: relative; overflow-x: hidden; }
.auth-body::before { content: ""; position: fixed; width: 520px; height: 520px; right: -140px; top: -140px; background: #e4dcff;
  border-radius: 42% 58% 62% 38% / 45% 40% 60% 55%; z-index: -1; }
.auth-body::after { content: ""; position: fixed; width: 300px; height: 300px; left: -100px; bottom: -120px; background: var(--sun-50);
  border-radius: 50%; z-index: -1; }
.auth-brand { flex-direction: column; gap: 6px; font-size: 30px; font-weight: 800; color: var(--ink); }
.auth-brand .mascot { animation: bob 4s ease-in-out infinite; }
.mascot-arm { transform-origin: 104px 78px; animation: wave 2.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-2deg); } }
@keyframes wave { 0%, 60%, 100% { transform: rotate(0); } 70% { transform: rotate(-18deg); } 80% { transform: rotate(10deg); } 90% { transform: rotate(-12deg); } }
.auth-card { border: 2px solid var(--ink); border-radius: 24px; box-shadow: 6px 6px 0 var(--ink); }
.auth-card h1 { font-size: 28px; font-weight: 800; }
.auth-card .btn-lg { height: 48px; font-size: 15.5px; }
.auth-msg { border-radius: 12px; font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .mascot, .mascot-arm { animation: none !important; } }

/* =====================================================================
   Položky faktury: popisky polí se zobrazují jen na mobilu
   ===================================================================== */
.il { display: contents; }
.il small { display: none; }
.sidebar .ns { display: none; }
.table td[data-label]::before { content: none; }

/* =====================================================================
   Tablet – užší boční panel
   ===================================================================== */
@media (max-width: 1150px) and (min-width: 861px) {
  body { grid-template-columns: 220px 1fr; }
  .savebar { left: 220px; padding: 12px 24px; }
  .content { padding: 26px 24px 120px; }
}

/* =====================================================================
   Tablet a mobil – tabulky jako karty
   ===================================================================== */
@media (max-width: 1250px) {
  /* tabulky dokladů a firem jako karty */
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody { display: block; }
  .table-cards tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center;
    padding: 14px 16px; border-bottom: 1px solid #f3eee4;
  }
  .table-cards tbody tr:last-child { border-bottom: 0; }
  .table-cards td { display: block; padding: 0; border: 0; }
  .table-cards .c-no { grid-column: 1; grid-row: 1; }
  .table-cards .c-amount { grid-column: 2; grid-row: 1; font-size: 16px; }
  .table-cards .c-party { grid-column: 1 / -1; }
  .table-cards .c-date { grid-column: 1; font-size: 13px; }
  .table-cards .c-due { grid-column: 2; font-size: 13px; text-align: right; }
  .table-cards td[data-label]::before { content: attr(data-label) " "; color: var(--muted); font-weight: 700; }
  .table-cards .c-status, .table-cards .c-settle, .table-cards .c-ids, .table-cards .c-contact { grid-column: 1 / -1; }
  .table-cards .c-count { grid-column: 1; text-align: left; font-size: 13px; }
  .table-cards .c-actions { grid-column: 1 / -1; width: auto; }
  .table-cards .row-actions { opacity: 1; justify-content: flex-start; gap: 6px; margin: 4px -6px 0; }
  .table-cards .icon-btn { width: 40px; height: 40px; background: #f6f1e7; }
  .table-cards .party .avatar { display: none; }
  .table-cards .c-ids small { display: inline; margin-left: 8px; }

  /* číselné řady – řádky jako seznam „popisek: hodnota“ */
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody { display: block; }
  .table-stack tr { display: block; padding: 12px 16px; border-bottom: 1px solid #f3eee4; }
  .table-stack td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border: 0; text-align: right; }
  .table-stack td[data-label]::before { content: attr(data-label); color: var(--muted); font-weight: 700; text-align: left; }
  .table-stack th.year-row { display: block; padding: 14px 16px 8px; }
  .table-stack .actions-col { width: auto; justify-content: flex-start; }
  .table-stack .row-actions { opacity: 1; }

}

/* =====================================================================
   Mobil – horní lišta, spodní navigace
   ===================================================================== */
@media (max-width: 860px) {
  body { display: block; font-size: 15px; }

  /* horní lišta: logo, nová faktura, účet */
  .sidebar {
    position: sticky; top: 0; z-index: 40; height: auto; flex-direction: row; align-items: center; gap: 10px;
    padding: 10px 14px; background: var(--sidebar); box-shadow: 0 2px 12px rgba(31, 26, 61, .25);
  }
  .sidebar .logo { font-size: 19px; padding: 0; margin-right: auto; }
  .sidebar > .btn-primary { width: auto; height: 36px; padding: 6px 14px 0; font-size: 13.5px; }
  .sidebar-foot { margin: 0; padding: 0; border: 0; gap: 4px; flex: none; }
  .sidebar-foot .me { flex: none; padding: 2px; margin: 0; }
  .me-text { display: none; }
  .sidebar-foot [data-tip]:hover::after { display: none; }

  /* spodní navigace */
  .sidebar nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; flex-direction: row; justify-content: space-around; gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--sidebar);
    border-top: 1px solid rgba(255, 255, 255, .08);
  }
  .sidebar nav .nav-label { display: none; }
  .sidebar nav a {
    flex: 1; flex-direction: column; gap: 3px; padding: 6px 2px; border-radius: 12px;
    font-size: 11px; font-weight: 800; color: #a9a3c7; text-align: center;
  }
  .sidebar nav a .ico { width: 22px; height: 22px; }
  .sidebar nav a.active { background: rgba(255, 255, 255, .1); color: #fff; }
  .sidebar .nl { display: none; }
  .sidebar .ns { display: inline; }

  /* obsah */
  .content { padding: 18px 14px calc(96px + env(safe-area-inset-bottom)); }
  .page-head { flex-direction: column; align-items: stretch; gap: 14px; margin-bottom: 18px; }
  .page-head h1 { font-size: 26px; flex-wrap: wrap; gap: 8px; }
  .head-actions { flex-wrap: wrap; }
  .head-actions > .btn, .head-actions > form .btn, .head-actions > a.btn { flex: 1 1 auto; }
  .year-switch { flex: 1 1 100%; }
  .profile-banner { flex-wrap: wrap; }

  .stats { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
  .stat { padding: 12px; gap: 0; }
  .stat-icon { display: none; }
  .stat b { font-size: 17px; }
  .stat:hover { transform: none; }

  .card-pad { padding: 16px; }
  .card-toolbar { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tabs a { white-space: nowrap; }
  .search input, .search-wide input { width: 100%; }
  .card-foot { flex-direction: column; gap: 4px; padding: 12px 16px; }
  .callout { flex-direction: column; align-items: stretch; }

  /* formuláře */
  .layout-2, .settings-grid { grid-template-columns: minmax(0, 1fr); }
  input, select, textarea { font-size: 16px; }           /* iOS jinak při psaní přibližuje stránku */
  .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .field-row { flex-wrap: wrap; }
  .field-row .field.grow { flex-basis: 100%; }

  .items-head { display: none; }
  .item-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.3fr) 36px; gap: 8px; padding: 12px 0;
  }
  .il { display: block; min-width: 0; }
  .il small { display: block; font-size: 11.5px; font-weight: 800; color: var(--muted); margin-bottom: 3px; }
  .il-text { grid-column: 1 / 4; }
  .item-row .del { grid-column: 4; grid-row: 1; align-self: end; height: 42px; width: 36px; }
  .il-qty { grid-column: 1; } .il-unit { grid-column: 2; } .il-price { grid-column: 3 / 5; }
  .rowtotal { grid-column: 1 / -1; text-align: right; color: var(--muted); }
  .totals { width: 100%; }
  .deduct-row { grid-template-columns: minmax(0, 1fr) 120px 36px; }
  .chips { flex-wrap: wrap; }

  .signature { flex-direction: column; align-items: flex-start; }

  /* spodní lišta s uložením nad navigací */
  .savebar {
    left: 0; bottom: calc(62px + env(safe-area-inset-bottom)); padding: 10px 14px; flex-wrap: wrap; gap: 8px;
  }
  .savebar > div:empty { display: none; }
  .savebar-total b { font-size: 19px; }
  .savebar-actions { flex: 1; justify-content: flex-end; }
  .savebar-actions .btn-ghost { display: none; }
  .savebar-actions .btn { padding-left: 14px; padding-right: 14px; }
  .content:has(.savebar) { padding-bottom: calc(170px + env(safe-area-inset-bottom)); }

  .toasts { top: auto; bottom: calc(80px + env(safe-area-inset-bottom)); left: 12px; right: 12px; }
  .toast { min-width: 0; max-width: none; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1; }
  .modal.modal-form .grid-3 { grid-template-columns: 1fr 1fr; }
  .modal.modal-form .grid-3 .field:first-child { grid-column: 1 / -1; }
  [data-tip]:hover::after { display: none; }
}

.hide-m { display: inline; }
@media (max-width: 860px) { .hide-m { display: none; } }

/* Menší notebooky – hustší tabulky */
@media (max-width: 1400px) and (min-width: 1251px) {
  .table th, .table td { padding-left: 10px; padding-right: 10px; }
  .table .party .avatar { display: none; }
  .content { padding-left: 28px; padding-right: 28px; }
  .savebar { padding-left: 28px; padding-right: 28px; }
}
@media (max-width: 1250px) {
  .card-toolbar { flex-wrap: wrap; }
  .card-toolbar .tabs { overflow-x: auto; scrollbar-width: none; max-width: 100%; }
  .card-toolbar .tabs a { white-space: nowrap; }
}
@media (max-width: 400px) {
  .sidebar > .btn-primary { width: 38px; padding: 6px 0 0; }
  .sidebar > .btn-primary span { display: none; }
}
@media (max-width: 560px) {
  .settings-grid .grid-2, .settings-grid .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .settings-grid .span-2 { grid-column: auto; }
}

/* Rozbalovací „Další údaje“ ve formuláři faktury */
details.more > summary { cursor: pointer; list-style: none; margin: 0; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: "+"; margin-left: auto; font: 800 20px var(--display); color: var(--primary); }
details.more[open] > summary { margin-bottom: 16px; }
details.more[open] > summary::after { content: "–"; }
details.more > summary small { font-family: "Nunito", sans-serif; font-size: 12px; font-weight: 700; }
.danger-zone { border-color: #ffc4bc; }
.danger-zone .card-title .ico { color: var(--red); }
.hint-warn { color: #b8342a; font-weight: 700; margin: -6px 0 12px; }

/* Přihlášení × registrace – přepínač a odlišný vzhled registrace */
.btn-sun { background: var(--sun); color: var(--ink); box-shadow: 0 3px 0 var(--sun-d); padding-top: 6px; }
.btn-sun:hover { background: #ffd95e; }
.btn-sun:active { box-shadow: 0 1px 0 var(--sun-d); }
.auth-tabs { display: flex; gap: 4px; padding: 4px; margin: 0 0 22px; background: #f6f1e7; border-radius: 999px; }
.auth-tabs a { flex: 1; text-align: center; padding: 8px 10px; border-radius: 999px; font-weight: 800; font-size: 14px; color: var(--muted); }
.auth-tabs a:hover { color: var(--ink); }
.auth-tabs a.active { background: #fff; color: var(--ink); box-shadow: 0 2px 0 rgba(31, 26, 61, .1); }
.auth-register .auth-tabs a.active { background: var(--sun); box-shadow: 0 2px 0 var(--sun-d); }
.auth-card.auth-register { border-top-width: 8px; border-top-color: var(--sun); }
.auth-perks { list-style: none; padding: 0; margin: 8px 0 20px; display: grid; gap: 6px; color: var(--text-2); font-size: 13.5px; }
.auth-perks li { display: flex; gap: 8px; align-items: flex-start; }
.auth-perks .ico, .auth-perks svg { color: var(--green); flex: none; margin-top: 2px; }
