/* Betónik work – vzhľad systému
   Farby vychádzajú z loga: betón, grafit a výstražná žltá ako akcent. */

:root {
  --bg: #e9e8e4;
  --surface: #ffffff;
  --surface-2: #f4f3f0;
  --line: #d3d0c9;
  --line-strong: #b9b5ad;
  --ink: #2b2925;
  --muted: #6b675f;
  --signal: #f2b300;
  --signal-dark: #c99400;
  --plus: #2f7a4c;
  --minus: #b0392b;
  --info: #3c6188;

  --font: "Barlow", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --font-head: "Barlow Condensed", "Arial Narrow", "Segoe UI", system-ui, sans-serif;

  --side-w: 236px;
  --radius: 6px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

h1, h2, h3 {
  font-family: var(--font-head);
  font-weight: 600;
  line-height: 1.15;
  margin: 0;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

a { color: var(--info); }
a:hover { color: var(--ink); }

:focus-visible {
  outline: 3px solid var(--signal);
  outline-offset: 2px;
}

.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.plus { color: var(--plus); }
.minus { color: var(--minus); }

/* ---------- Rozloženie ---------- */

.shell { display: flex; min-height: 100vh; }

.side {
  width: var(--side-w);
  flex: 0 0 var(--side-w);
  background: var(--ink);
  color: #e9e8e4;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem 1.25rem 1.5rem;
  color: #fff;
  text-decoration: none;
}
.side-brand img { width: 42px; height: 42px; border-radius: 5px; }
.side-brand span { font-family: var(--font-head); font-size: 1.45rem; font-weight: 700; letter-spacing: .02em; line-height: 1; }
.side-brand small { display: block; font-family: var(--font); font-size: .78rem; font-weight: 500; color: #a8a49b; letter-spacing: 0; margin-top: .2rem; }
.side-brand:hover { color: #fff; }

.side-nav { display: flex; flex-direction: column; padding: 0 .75rem; gap: 2px; }
.side-nav a {
  display: block;
  padding: .55rem .75rem .55rem .9rem;
  color: #d6d3cc;
  text-decoration: none;
  border-radius: 4px;
  border-left: 3px solid transparent;
  font-weight: 500;
}
.side-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-nav a.active { background: rgba(255,255,255,.09); color: #fff; border-left-color: var(--signal); }
.side-nav .gap { height: .9rem; }

.side-user {
  margin-top: auto;
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: .9rem;
}
.side-user strong { display: block; color: #fff; }
.side-user a, .side-user button {
  color: #b9b5ad;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.side-user a:hover, .side-user button:hover { color: #fff; }
.side-user .links { display: flex; gap: 1rem; margin-top: .4rem; }

.main { flex: 1; min-width: 0; padding: 2rem 2.5rem 4rem; }
.main-inner { max-width: 1180px; }

.topbar { display: none; }

@media (max-width: 900px) {
  .shell { display: block; }
  .side {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  body.nav-open .side { transform: none; }
  body.nav-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 20;
  }
  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--ink);
    color: #fff;
    padding: .6rem 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
  }
  .topbar img { height: 32px; width: 32px; border-radius: 4px; }
  .topbar button {
    background: none;
    border: 1px solid rgba(255,255,255,.3);
    color: #fff;
    border-radius: 4px;
    padding: .35rem .7rem;
    font: inherit;
  }
  .main { padding: 1.25rem 1rem 3rem; }
}

@media (prefers-reduced-motion: reduce) {
  .side { transition: none; }
}

/* ---------- Hlavička stránky ---------- */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.page-head p { margin: .3rem 0 0; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* ---------- Tlačidlá ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  line-height: 1.2;
}
.btn:hover { border-color: var(--ink); color: var(--ink); }
.btn-primary { background: var(--signal); border-color: var(--signal-dark); }
.btn-primary:hover { background: #ffc61a; }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-dark:hover { background: #45423c; color: #fff; }
.btn-danger { color: var(--minus); border-color: #e3bdb7; background: var(--surface); }
.btn-danger:hover { border-color: var(--minus); color: var(--minus); }
.btn-sm { padding: .3rem .6rem; font-size: .875rem; }
.btn-link { background: none; border: 0; padding: 0; color: var(--info); font: inherit; cursor: pointer; text-decoration: underline; }

form.inline { display: inline; }

/* ---------- Hlásenia ---------- */

.flash {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  border-left: 4px solid;
  background: var(--surface);
}
.flash-success { border-color: var(--plus); }
.flash-error { border-color: var(--minus); }
.flash ul { margin: .25rem 0 0; padding-left: 1.2rem; }

/* ---------- Panely a tabuľky ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.panel + .panel { margin-top: 1.25rem; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .9rem 1.1rem;
  border-bottom: 1px solid var(--line);
}
.panel-body { padding: 1.1rem; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: .6rem .8rem; text-align: left; vertical-align: top; }
table.data th {
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
}
table.data td { border-bottom: 1px solid #ebe9e5; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: #fbfaf8; }
table.data td.act { text-align: right; white-space: nowrap; }
table.data tfoot td { font-weight: 600; border-top: 2px solid var(--line); background: var(--surface-2); }
table.data .sub { display: block; font-size: .85rem; color: var(--muted); }
table.data th.num, table.data td.num { text-align: right; }

.empty { padding: 2.5rem 1.25rem; text-align: center; color: var(--muted); }
.empty .btn { margin-top: .8rem; }

/* Stavy */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before { content: ""; width: .55rem; height: .55rem; border-radius: 50%; background: var(--line-strong); }
.badge-new::before { background: var(--signal); }
.badge-confirmed::before { background: var(--info); }
.badge-production::before { background: #8a5cc2; }
.badge-delivered::before, .badge-accepted::before { background: var(--plus); }
.badge-invoiced::before { background: var(--ink); }
.badge-cancelled::before, .badge-rejected::before { background: var(--minus); }
.badge-sent::before { background: var(--info); }
.badge-draft::before { background: var(--line-strong); }

/* ---------- Súčty (prehľad, réžia) ---------- */

.figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 1.5rem;
}
.figure { padding: 1rem 1.2rem; border-right: 1px solid var(--line); }
.figure:last-child { border-right: 0; }
.figure span { display: block; font-size: .875rem; color: var(--muted); }
.figure strong {
  display: block;
  font-family: var(--font-head);
  font-size: 1.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-top: .15rem;
}
@media (max-width: 700px) {
  .figure { border-right: 0; border-bottom: 1px solid var(--line); }
  .figure:last-child { border-bottom: 0; }
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }
.grid-2 .panel + .panel { margin-top: 0; }

/* ---------- Filtre ---------- */

.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.filters input, .filters select { width: auto; min-width: 160px; }

.tabs { display: flex; gap: .25rem; flex-wrap: wrap; }
.tabs a {
  padding: .4rem .8rem;
  border-radius: 4px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
}
.tabs a:hover { color: var(--ink); background: var(--surface); }
.tabs a.active { background: var(--ink); color: #fff; }

.month-nav { display: flex; align-items: center; gap: .5rem; }
.month-nav strong { font-family: var(--font-head); font-size: 1.3rem; min-width: 9.5rem; text-align: center; text-transform: capitalize; }

/* ---------- Formuláre ---------- */

.form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; }
.form fieldset { border: 0; padding: 0; margin: 0 0 1.75rem; }
.form legend { font-family: var(--font-head); font-size: 1.2rem; font-weight: 600; padding: 0; margin-bottom: .8rem; }

.row { display: grid; gap: 1rem; grid-template-columns: repeat(12, 1fr); margin-bottom: 1rem; }
.col-12 { grid-column: span 12; }
.col-8 { grid-column: span 8; }
.col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; }
.col-3 { grid-column: span 3; }
.col-2 { grid-column: span 2; }
@media (max-width: 760px) {
  .col-8, .col-6, .col-4, .col-3 { grid-column: span 12; }
  .col-2 { grid-column: span 6; }
}

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
label .muted { font-weight: 400; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=datetime-local], input[type=month], input[type=search], input[type=tel], select, textarea {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: 2px solid var(--signal); outline-offset: 0; }
input[type=number] { font-variant-numeric: tabular-nums; }
textarea { min-height: 90px; resize: vertical; }
.is-invalid { border-color: var(--minus) !important; }
.error { color: var(--minus); font-size: .85rem; margin-top: .25rem; }
.hint { color: var(--muted); font-size: .85rem; margin-top: .25rem; }

.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.check input { width: 1.1rem; height: 1.1rem; accent-color: var(--ink); }

.form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 5px; overflow: hidden; }
.segmented label { margin: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: .5rem 1rem; cursor: pointer; font-weight: 600; background: #fff; }
.segmented input:checked + span { background: var(--ink); color: #fff; }
.segmented input:focus-visible + span { outline: 3px solid var(--signal); outline-offset: -3px; }

/* Položky ponuky */
.items-table input, .items-table select { padding: .4rem .5rem; }
.items-table td { padding: .4rem .35rem; vertical-align: middle; }
.items-table .w-qty { width: 90px; }
.items-table .w-unit { width: 80px; }
.items-table .w-price { width: 110px; }
.items-table .w-vat { width: 75px; }
.items-table .w-total { width: 110px; }
.totals { margin-left: auto; max-width: 340px; margin-top: 1rem; }
.totals div { display: flex; justify-content: space-between; padding: .3rem 0; font-variant-numeric: tabular-nums; }
.totals .grand { border-top: 2px solid var(--ink); margin-top: .3rem; padding-top: .5rem; font-size: 1.15rem; font-weight: 700; }

/* ---------- Detail (definičný zoznam) ---------- */

.details { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.5rem; margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }

/* ---------- Cenníky – výber ---------- */

.choice {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}
.choice .form h2 { margin-bottom: .3rem; }
.choice .form p { margin-top: 0; color: var(--muted); }

/* ---------- Stránkovanie ---------- */

.pager { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1.1rem; border-top: 1px solid var(--line); }
.pager .disabled { color: var(--line-strong); }

/* ---------- Prihlásenie ---------- */

.login {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background-color: var(--ink);
  /* Stopy debnenia: jemné vodorovné dosky v pozadí */
  background-image: repeating-linear-gradient(
    180deg,
    rgba(255,255,255,.025) 0 46px,
    rgba(0,0,0,.13) 46px 48px
  );
}
.login-logo { width: min(520px, 92vw); height: auto; display: block; margin-bottom: 2rem; filter: drop-shadow(0 12px 22px rgba(0,0,0,.45)); }
.login-form {
  width: min(400px, 100%);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.75rem;
  border-top: 5px solid var(--signal);
}
.login-form h1 { font-size: 1.6rem; margin-bottom: 1.25rem; }
.login-form .field { margin-bottom: 1rem; }
.login-form .btn { width: 100%; justify-content: center; padding: .75rem; font-size: 1rem; margin-top: .5rem; }
.login-foot { margin-top: 1.5rem; color: #a8a49b; font-size: .85rem; }

/* ---------- Hromadná úprava produktov ---------- */

.bulk-table td { padding: .3rem .3rem; }
.bulk-table input[type=text], .bulk-table input[type=number], .bulk-table select { padding: .35rem .45rem; font-size: .92rem; }
.bulk-table td:nth-child(2) { min-width: 220px; }
.bulk-table td:nth-child(3) { min-width: 150px; }
.bulk-table .w-check { width: 44px; text-align: center; }
.bulk-table .w-check input { width: 1.1rem; height: 1.1rem; accent-color: var(--ink); }
.bulk-table tr.selected td { background: #fff8e1; }
.bulk-table tr.changed td:first-child { box-shadow: inset 4px 0 0 var(--signal); }
.bulk-table tbody tr:hover td { background: #fbfaf8; }
.bulk-table tr.selected:hover td { background: #fff3cc; }
.bulk-save {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  border-top: 1px solid var(--line);
  position: sticky;
  bottom: 0;
  background: var(--surface);
}
[hidden] { display: none !important; }

/* ---------- Varianty produktov ---------- */

.variant-toggle {
  display: inline-block;
  margin-top: .25rem;
  padding: .1rem .5rem;
  font: inherit;
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
}
.variant-toggle::after { content: " ▾"; }
.variant-toggle[aria-expanded="true"]::after { content: " ▴"; }
.variant-toggle:hover { border-color: var(--ink); }
table.data tr.variant-row td { background: var(--surface-2); font-size: .92rem; }
table.data tr.variant-row td:first-child { padding-left: 2rem; }
.variant-name::before { content: "– "; color: var(--muted); }
