/* Colours are tokens. Dark is the default (html[data-theme=dark]); html[data-theme=light] = "denný režim".
   The theme comes from the cookie panel_theme (PanelContext::theme), the toggle is js/theme.js. */
:root, [data-theme=dark] {
  color-scheme: dark;
  --red: #f74040; --ok: #3fb96f; --err: #ff7b7b; --link: #6ea8fe;
  --ink: #e4e7ea; --muted: #99a2aa; --line: #2c3238; --soft: #0f1215;
  --surface: #171b1f; --surface-2: #1d2226; --hover: #20262b; --code: #252b31; --field: #3a4148; --dimmed: #6b737a;
  --ok-bg: #15301f; --err-bg: #3a1a1a; --warn-bg: #3a3014;
  --side: #121518; --side-ink: #c4cad0; --side-hover: #22282d; --side-line: #2c3238; --side-muted: #7f878e;
}
[data-theme=light] {
  color-scheme: light;
  --ok: #1f8a4c; --err: #c62828; --link: #1d63c9;
  --ink: #1f2328; --muted: #5b636b; --line: #e3e6e9; --soft: #f5f7f8;
  --surface: #fff; --surface-2: #fafbfc; --hover: #fafcff; --code: #eef0f2; --field: #c9ced3; --dimmed: #9aa1a7;
  --ok-bg: #e7f5ec; --err-bg: #fdecec; --warn-bg: #fdf6e3;
  --side: #23272b; --side-ink: #cfd4d8; --side-hover: #2f3439; --side-line: #3a4046; --side-muted: #8d959c;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; color: var(--ink); background: var(--soft); line-height: 1.5; }
a { color: var(--link); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; margin: 1.6rem 0 .6rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
code { background: var(--code); padding: 0 .3rem; border-radius: 3px; }

.shell { display: grid; grid-template-columns: 13rem 1fr; min-height: 100vh; }
.side { background: var(--side); border-right: 1px solid var(--line); color: var(--side-ink); display: flex; flex-direction: column; padding: 1rem .8rem; position: sticky; top: 0; height: 100vh; }
.side a { color: var(--side-ink); text-decoration: none; }
.brand { display: flex; align-items: center; gap: .55rem; font-size: 1.2rem; color: #fff !important; padding: .2rem .5rem 1.2rem; }
.brand img { width: 32px; height: auto; }
.brand b { color: var(--red); font-weight: 600; }
.side nav { display: flex; flex-direction: column; gap: .15rem; }
.side nav a, .side nav .soon { padding: .45rem .6rem; border-radius: 6px; }
.side nav a:hover { background: var(--side-hover); color: #fff; }
.side nav a.active { background: var(--red); color: #fff; }
.side nav .soon { opacity: .45; cursor: default; }
.me { margin-top: auto; border-top: 1px solid var(--side-line); padding: .8rem .6rem 0; display: flex; flex-direction: column; gap: .15rem; }
.me a.active { color: #fff; font-weight: 600; }
.me small { color: var(--side-muted); }
button.link { background: none; border: 0; color: var(--side-ink); padding: 0; cursor: pointer; font: inherit; text-decoration: underline; }
.content { padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 3rem; min-width: 0; }

.flash { padding: .6rem .9rem; border-radius: 6px; border-left: 4px solid; }
.flash.ok { background: var(--ok-bg); border-color: var(--ok); }
.flash.err { background: var(--err-bg); border-color: var(--red); }
.flash.warn { background: var(--warn-bg); border-color: #d4a017; }
.field-err { display: block; color: var(--err); font-size: .85rem; margin-top: .2rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.2rem; }
.card h2 { margin-top: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; margin: 1rem 0; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .9rem; margin: 0; }
dt { color: var(--muted); } dd { margin: 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 1rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .9rem 1.1rem; display: flex; flex-direction: column; }
.tile span { color: var(--muted); font-size: .9rem; } .tile b { font-size: 1.8rem; } .tile small { color: var(--muted); }

table.grid { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.grid th, .grid td { padding: .5rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.grid th { background: var(--surface-2); font-weight: 600; font-size: .85rem; color: var(--muted); }
.grid tbody tr:hover { background: var(--hover); }
.grid .num { text-align: right; white-space: nowrap; }
.grid tfoot td { border-bottom: 0; } .grid tr.total td { font-weight: 700; border-top: 2px solid var(--line); }
.grid tr.inactive td { color: var(--dimmed); }
.state { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .82rem; border: 1px solid var(--c); color: var(--ink);
         background: color-mix(in srgb, var(--c) 18%, var(--surface)); white-space: nowrap; }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .6rem; }
.filters input[name=q] { min-width: 16rem; }
input, select, textarea { font: inherit; padding: .4rem .55rem; border: 1px solid var(--field); border-radius: 6px; background: var(--surface); color: var(--ink); }
button, .button { font: inherit; padding: .45rem 1rem; border-radius: 6px; border: 1px solid var(--field); background: var(--surface); cursor: pointer; text-decoration: none; color: var(--ink); display: inline-block; }
.primary { background: var(--red); border-color: var(--red); color: #fff !important; }
.primary:hover { filter: brightness(1.07); }
.pager { display: flex; gap: 1rem; align-items: center; margin-top: 1rem; }

.form { max-width: 30rem; display: flex; flex-direction: column; gap: .8rem; }
.form label { display: flex; flex-direction: column; gap: .25rem; }
label.check { flex-direction: row !important; align-items: center; gap: .5rem !important; }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.login { width: 100%; max-width: 22rem; display: flex; flex-direction: column; gap: .8rem; }
.login-logo { width: 220px; height: auto; align-self: center; margin-bottom: .2rem; }
.login h1 { margin: 0; font-size: 1.15rem; text-align: center; color: var(--muted); font-weight: 500; }
.login label { display: flex; flex-direction: column; gap: .25rem; }

/* Invoicing, companies, customers */
.badge { display: inline-block; padding: 0 .45rem; border-radius: 999px; font-size: .78rem; border: 1px solid var(--line); color: var(--muted); vertical-align: middle; }
.badge.draft { border-color: #d4a017; color: #d4a017; }
.badge.issued { border-color: var(--ok); color: var(--ok); }
.badge.pay-paid { border-color: var(--ok); color: var(--ok); }
.badge.pay-partial, .badge.pay-unpaid { border-color: #d4a017; color: #d4a017; }
.badge.pay-overdue { border-color: var(--red); color: var(--red); }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
form.inline { display: inline; margin: 0; }
button.danger { border-color: var(--red); color: var(--red); background: transparent; }
button[disabled] { opacity: .45; cursor: not-allowed; }
.link-danger { background: none; border: 0; color: var(--muted); cursor: pointer; padding: .2rem .4rem; }
.link-danger:hover { color: var(--red); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: .7rem 1rem; align-content: start; margin-bottom: 1rem; }
.form-grid > h2, .form-grid > .wide { grid-column: 1 / -1; }
.form-grid label, .card > label { display: flex; flex-direction: column; gap: .25rem; }
.form-grid.narrow { max-width: 46rem; }
.card > label { margin: .6rem 0; }
.field-hint { color: var(--muted); font-size: .8rem; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .9rem .9rem; display: flex; flex-direction: column; gap: .45rem; }
legend { color: var(--muted); padding: 0 .3rem; }
.perms { display: flex; flex-direction: column; gap: .45rem; padding-left: 1.6rem; }
.grid.compact th, .grid.compact td { padding: .3rem .45rem; }
.grid td input, .grid td select { width: 100%; padding: .3rem .4rem; }
.grid td input.w-name { min-width: 16rem; }
input.num { text-align: right; }
.scroll-x { overflow-x: auto; }
.card + .card, section.card { margin-bottom: 1rem; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.push { margin-left: auto; }
img.preview { max-width: 100%; max-height: 7rem; background: #fff; padding: .4rem; border-radius: 6px; border: 1px solid var(--line); }
.lookup { position: relative; display: flex; flex-direction: column; gap: .3rem; }
.lookup input { width: 100%; }
.results { display: flex; flex-direction: column; gap: .2rem; }
.results .pick { text-align: left; padding: .35rem .6rem; }
.results .pick:hover { border-color: var(--red); }
.flash ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.tabs { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: 1rem; border-bottom: 1px solid var(--line); padding-bottom: .6rem; }
.tabs > a:not(.button) { padding: .35rem .7rem; border-radius: 6px; text-decoration: none; color: var(--ink); }
.tabs > a.active { background: var(--surface-2); font-weight: 600; }
.tabs .push { margin-left: auto; }
button.rpo { color: var(--link); font-size: .82rem; align-self: flex-start; }
.rpo-note { font-size: .78rem; color: var(--muted); }

/* Theme toggle: the button shows the mode you switch TO. */
.theme-toggle { text-decoration: none; display: inline-flex; align-items: center; gap: .35rem; }
[data-theme=dark] .theme-toggle .to-dark, [data-theme=light] .theme-toggle .to-light { display: none; }
.login-page .theme-toggle { position: fixed; top: 1rem; right: 1rem; color: var(--muted); }
.me .theme-toggle { margin: .2rem 0 .1rem; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .me { flex-direction: row; flex-wrap: wrap; align-items: center; gap: .8rem; }
  .grid { display: block; overflow-x: auto; }
}
