:root {
  --ink: #172126;
  --accent: #fccc27;
  --bg: #f5f6f6;
  --card: #fff;
  --text: #1d2428;
  --muted: #687174;
  --border: #e1e5e6;
  --input: #ccd2d4;
  --ok: #2b8a3e;
  --ok-bg: #ebfbee;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--text); text-underline-offset: 3px; }
h1 { font-size: 28px; letter-spacing: -.5px; font-weight: 650; margin: 0; }
h2 { font-size: 18px; font-weight: 650; margin: 0 0 14px; }
h3 { font-size: 15px; margin: 18px 0 6px; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13.5px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.prewrap { white-space: pre-wrap; }

.skip-link { position: absolute; left: 8px; top: -60px; background: #fff; padding: 8px 12px; z-index: 10; border-radius: 6px; }
.skip-link:focus { top: 8px; }
.env-banner { background: var(--accent); color: #172126; text-align: center; font-size: 12px; font-weight: 600; padding: 2px 8px; letter-spacing: .3px; }

/* Horní lišta */
.topbar { background: var(--ink); color: #fff; }
.topbar-inner { max-width: 1240px; margin: 0 auto; min-height: 62px; display: flex; align-items: center; gap: 22px; padding: 0 24px; }
.brand { display: flex; align-items: center; }
.brand img { height: 38px; max-width: 150px; object-fit: contain; display: block; }
.company-rockero .brand img { height: 34px; }
.topnav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topnav a { color: #e8eced; text-decoration: none; padding: 8px 14px; border-radius: 6px; font-weight: 500; }
.topnav a:hover, .topnav a[aria-current] { background: #ffffff18; color: var(--accent); }
.topnav a.disabled { opacity: .45; cursor: default; }
.topnav a.disabled:hover { background: none; color: #e8eced; }

.company-switch { display: flex; background: #ffffff14; border-radius: 9px; padding: 3px; gap: 2px; }
.company-switch form { margin: 0; }
.switch-btn { display: flex; align-items: center; gap: 7px; background: none; border: 0; color: #cfd6d8; padding: 6px 11px; border-radius: 7px; cursor: pointer; font: inherit; font-size: 14px; font-weight: 600; }
.switch-btn img { width: 20px; height: 20px; object-fit: contain; }
.switch-btn img.symbol-bytovak { width: 9px; }
.switch-btn[aria-pressed=true] { background: var(--accent); color: #172126; }
.switch-btn[aria-pressed=false]:hover { background: #ffffff1c; color: #fff; }

.account { position: relative; }
.account summary { list-style: none; cursor: pointer; width: 34px; height: 34px; border-radius: 50%; background: #ffffff22; display: grid; place-items: center; font-weight: 700; }
.account summary::-webkit-details-marker { display: none; }
.account-menu { position: absolute; right: 0; top: 44px; z-index: 5; min-width: 210px; background: #fff; color: var(--text); border: 1px solid var(--border); border-radius: 9px; box-shadow: 0 8px 24px #0002; padding: 12px 14px; display: grid; gap: 8px; }
.account-menu form { margin: 0; }
.link { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* Stránka */
.page { max-width: 1240px; margin: 0 auto; padding: 8px 24px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 26px 0 18px; }
.back { font-size: 13px; color: var(--muted); text-decoration: none; display: inline-block; margin-bottom: 4px; }
.back:hover { color: var(--text); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card { margin-top: 18px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.section-head h2 { margin: 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 500; }
.tabs a[aria-current] { color: var(--text); border-bottom-color: var(--ink); }
.tabs a:hover { color: var(--text); border-bottom-color: var(--border); background: #f3f5f5; border-radius: 6px 6px 0 0; }
.tabs a[aria-current]:hover { border-bottom-color: var(--ink); }

/* Tlačítka */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--input); background: #fff; color: var(--text); border-radius: 7px; padding: 8px 15px; font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f3f5f5; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #172126; }
.btn-primary:hover { filter: brightness(.95); background: var(--accent); }
.btn:disabled { opacity: .6; cursor: wait; }
button.primary { width: 100%; margin-top: 18px; }

/* Formuláře */
.form h2 { margin-top: 8px; padding-top: 6px; }
.form h2 ~ h2 { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--border); }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 22px; }
.field { min-width: 0; }
.field.wide { grid-column: 1 / -1; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 14px; margin: 6px 0; }
.req { color: var(--danger); }
input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file]), select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--input); background: #fff; border-radius: 6px; font: inherit; color: var(--text);
}
input[type=color] { width: 64px; height: 38px; padding: 2px; border: 1px solid var(--input); border-radius: 6px; background: #fff; }
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid #6b8fd1; outline-offset: 2px; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.helptext { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.field-error, .errorlist { display: block; color: var(--danger); font-size: 13px; margin-top: 4px; }
.errorlist { padding-left: 18px; }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); }
.narrow-form { max-width: 760px; }
.input-group { display: flex; gap: 8px; }
.ares-row { max-width: 420px; margin-bottom: 14px; }
.logo-preview { border-radius: 8px; padding: 14px 18px; display: inline-flex; min-width: 160px; }
.logo-preview img { height: 44px; max-width: 220px; object-fit: contain; }

/* Tabulky */
.tablewrap { overflow-x: auto; }
.table { border-collapse: collapse; width: 100%; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 13px 12px; border-bottom: 1px solid #eef1f1; vertical-align: top; }
.table tbody tr:hover { background: #fafbfb; }
.table td a { font-weight: 600; }
.table tr.archived td { color: var(--muted); }
.num { text-align: right; white-space: nowrap; }
.filter-bar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filter-bar input[type=search] { flex: 1 1 260px; width: auto; }
.filter-bar select { width: auto; }
.pager { display: flex; gap: 16px; justify-content: center; padding-top: 14px; font-size: 14px; }
.empty { text-align: center; padding: 50px 15px; }
.empty h3 { margin: 0 0 4px; font-size: 17px; }
.dl { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; margin: 0; }
.dl dt { color: var(--muted); font-size: 14px; }
.dl dd { margin: 0; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; border: 1px solid var(--border); background: #f3f5f5; padding: 2px 8px; border-radius: 6px; color: var(--muted); vertical-align: middle; }
.badge-ok { background: var(--ok-bg); border-color: #b2f2bb; color: var(--ok); }
.badge + .badge { margin-left: 4px; }

.messages { margin-top: 18px; }
.msg { padding: 10px 14px; border-radius: 8px; background: var(--ok-bg); color: var(--ok); border: 1px solid #b2f2bb; margin-bottom: 8px; font-size: 14px; }
.msg-error { background: var(--danger-bg); color: var(--danger); border-color: #fecdca; }

/* Přihlášení */
.auth { min-height: 85vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.narrow { width: 100%; max-width: 380px; }
.auth h1 { margin-bottom: 16px; }
.auth label { margin-top: 12px; }
.auth .btn-primary, .auth button.primary { width: 100%; margin-top: 18px; background: #172126; color: #fff; border: 0; border-radius: 7px; padding: 10px; font: inherit; font-weight: 600; cursor: pointer; }
.error { color: var(--danger); }

/* Stavy */
.badge-warn { background: #fff8e1; border-color: #ffe08a; color: #8a5a00; }
.badge-danger { background: var(--danger-bg); border-color: #fecdca; color: var(--danger); }
.badge-muted { background: #f3f5f5; }
.danger-text { color: var(--danger); }
.msg-warn { background: #fff8e1; color: #6b4600; border-color: #ffe08a; }

/* Faktury – seznam */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; text-decoration: none; display: grid; gap: 2px; }
.stat:hover { border-color: var(--input); }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 22px; font-weight: 650; letter-spacing: -.3px; }
.stat-danger .stat-value { color: var(--danger); }
.page-sub { margin: 4px 0 0; }

/* Faktury – formulář */
.lines { display: grid; gap: 8px; margin: 10px 0 12px; }
.line { display: grid; grid-template-columns: minmax(200px, 1fr) 80px 70px 120px 74px 84px 120px 34px; gap: 8px; align-items: center; }
.lines.no-vat .line { grid-template-columns: minmax(200px, 1fr) 80px 70px 120px 74px 130px 34px; }
.line[hidden] { display: none; }
.line-head { font-size: 12px; color: var(--muted); font-weight: 500; }
.line .num { text-align: right; font-weight: 600; white-space: nowrap; }
.line-errors { grid-column: 1 / -1; }
.line.has-error input { border-color: var(--danger); }
.icon-btn { border: 0; background: none; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 6px; }
.icon-btn:hover { background: #f1f3f3; color: var(--danger); }
.totals-wrap { display: grid; grid-template-columns: 1fr minmax(260px, 360px); gap: 24px; align-items: start; border-top: 1px solid var(--border); padding-top: 14px; margin-top: 8px; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 18px; margin: 0; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 18px; font-weight: 650; color: var(--text); border-top: 1px solid var(--border); padding-top: 6px; margin-top: 4px; }
.doc-sheet .totals { max-width: 380px; margin: 16px 0 0 auto; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; z-index: 3; }
.fields-1 { grid-template-columns: 1fr; }

/* Faktury – detail */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.doc-parties { margin-bottom: 14px; }
.dl-tight { grid-template-columns: 110px 1fr; font-size: 14px; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.head-actions form { margin: 0; }
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: 42px; z-index: 6; min-width: 220px; background: #fff; border: 1px solid var(--border); border-radius: 9px; box-shadow: 0 8px 24px #0002; padding: 6px; display: grid; }
.menu-list a, .menu-list button { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px; text-decoration: none; background: none; border: 0; font: inherit; font-size: 14px; color: var(--text); cursor: pointer; }
.menu-list a:hover, .menu-list button:hover { background: #f3f5f5; }
.menu-list form { margin: 0; }
.plain-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 10px; }
.plain-list li { border-bottom: 1px solid #eef1f1; padding-bottom: 10px; }
.row-actions { display: flex; gap: 12px; align-items: center; margin-top: 2px; }
.row-actions form { margin: 0; }
.pay-form summary { list-style: none; width: fit-content; }
.pay-form summary::-webkit-details-marker { display: none; }
.pay-form[open] summary { display: none; }
.pay-form form { margin-top: 4px; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: 14px; }

@media (max-width: 1000px) {
  .doc-layout { grid-template-columns: minmax(0, 1fr); }
  .line, .lines.no-vat .line { grid-template-columns: 1fr 1fr 1fr; }
  .line-head { display: none; }
  .line-desc { grid-column: 1 / -1; }
  .totals-wrap { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .topbar-inner { flex-wrap: wrap; gap: 10px 14px; padding: 10px 16px; }
  .brand { margin-right: auto; }
  .topnav { order: 5; flex-basis: 100%; }
  .topnav a { padding: 7px 10px; }
  .switch-btn span { display: none; }
  .page { padding: 4px 16px 40px; }
  .grid-2, .fields { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: stretch; }
  .card { padding: 16px; }
  h1 { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.advance-list { display: grid; gap: 8px; margin: 8px 0; }
.advance-list [hidden] { display: none; }
