:root {
  --purple: #8864D1;
  --purple-dark: #6f4fb8;
  --purple-light: #f1ecfa;
  --bg: #f6f4fb;
  --text: #222;
  --muted: #777;
  --card: #ffffff;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Montserrat', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}

a { color: var(--purple); text-decoration: none; }
a:hover { color: var(--purple-dark); }

/* --- top bar --- */
.topbar {
  background: #fff;
  border-bottom: 1px solid #e8e4f2;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand img { height: 42px; display: block; }
.nav { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.nav a { text-decoration: none; font-weight: 600; font-size: 14px; color: var(--text); }
.nav a:hover { color: var(--purple); }
.nav .nav-shop { color: var(--purple); }
.nav .nav-muted { color: var(--muted); font-weight: 500; }

/* --- layout --- */
.container { max-width: 960px; margin: 0 auto; padding: 28px 16px 48px; }
h1 { font-size: 24px; font-weight: 700; margin: 0 0 6px; }
h2 { font-size: 17px; font-weight: 700; margin: 28px 0 12px; }
.subtitle { color: var(--muted); margin: 0 0 24px; }

/* --- cards --- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(60, 40, 110, 0.07);
}
.card-link { display: block; text-decoration: none; color: inherit; transition: box-shadow .15s; }
.card-link:hover { box-shadow: 0 4px 14px rgba(60, 40, 110, 0.14); }

.order-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.order-number { font-weight: 700; font-size: 16px; }
.order-dates { color: var(--muted); font-size: 14px; margin-top: 2px; }
.order-meta { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.order-total { margin-left: auto; font-weight: 700; }

/* --- badges --- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-reserved { background: var(--purple-light); color: var(--purple-dark); }
.badge-active   { background: #e3f4e6; color: #1e7c33; }
.badge-done     { background: #ececec; color: #666; }
.badge-new      { background: #fff4dd; color: #9a6b00; }
.badge-cancel   { background: #fdecec; color: #b23030; }
.badge-paid     { background: #e3f4e6; color: #1e7c33; }
.badge-partial  { background: #fff4dd; color: #9a6b00; }
.badge-due      { background: #fdecec; color: #b23030; }

/* --- buttons --- */
.btn {
  display: inline-block;
  background: var(--purple);
  color: #fff !important;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.35;
}
.btn:hover { background: var(--purple-dark); }
.btn-outline {
  background: #fff;
  color: var(--purple) !important;
  border: 1.5px solid var(--purple);
  padding: 5.5px 12.5px;
}
.btn-outline:hover { background: var(--purple-light); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* --- tables --- */
table.lines { width: 100%; border-collapse: collapse; margin-top: 8px; }
table.lines th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 8px 6px; border-bottom: 1px solid #eee;
}
table.lines td { padding: 9px 6px; border-bottom: 1px solid #f2f0f8; vertical-align: top; }
table.lines td.num { text-align: right; white-space: nowrap; }
table.lines th.num { text-align: right; }
.line-child td:first-child { padding-left: 26px; color: var(--muted); font-size: 14px; }

/* --- summary grid --- */
.summary { display: grid; grid-template-columns: 1fr auto; gap: 6px 24px; margin-top: 8px; }
.summary .label { color: var(--muted); }
.summary .value { text-align: right; font-weight: 600; }
.summary .total { font-size: 17px; font-weight: 700; color: var(--purple-dark); }

/* --- forms --- */
form.rv label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 5px; }
form.rv input[type=text], form.rv input[type=email], form.rv input[type=tel],
form.rv input[type=date], form.rv textarea, form.rv select {
  width: 100%; padding: 11px 13px; border: 1px solid #ddd6ee; border-radius: 10px;
  font-family: inherit; font-size: 15px; background: #fff;
}
form.rv input:focus, form.rv textarea:focus { outline: 2px solid var(--purple-light); border-color: var(--purple); }
/* pola w gridach/flexach moga sie kurczyc ponizej szerokosci wlasnej tresci (mobile!) */
form.rv input, form.rv select { min-width: 0; }
/* pola daty sa z natury szerokie (natywny picker) - globalnie kompaktowe */
form.rv input[type=date] { padding: 8px 6px; font-size: 13.5px; }
.form-note { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* --- alerts --- */
.alert { border-radius: 10px; padding: 13px 16px; margin-bottom: 16px; font-size: 14px; }
.alert-ok { background: #e3f4e6; color: #1e7c33; }
.alert-err { background: #fdecec; color: #b23030; }
.alert-info { background: var(--purple-light); color: var(--purple-dark); }

.empty { color: var(--muted); font-style: italic; padding: 8px 2px; }

/* --- footer --- */
.footer {
  max-width: 960px; margin: 0 auto; padding: 24px 16px 40px;
  color: var(--muted); font-size: 13px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.footer a { color: var(--purple); text-decoration: none; }

/* --- login --- */
.login-box { max-width: 440px; margin: 40px auto; }
.login-box .card { padding: 30px; }
.login-box h1 { text-align: center; }

@media (max-width: 560px) {
  .brand img { height: 34px; }
  .container { padding-top: 18px; }
  .card { padding: 16px; }
}

/* --- raporty: pomocnicze --- */
.eq { font-size: 12px; word-break: break-word; max-width: 100px; line-height: 1.4; }
.nowrap { white-space: nowrap; }
.num-strong { font-weight: 700; }

/* --- manager: kafelki nawigacji na dashboardzie --- */
.nav-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 6px 11px; background: #fff; border: 1px solid #e6e0f2; border-radius: 12px;
  text-decoration: none; color: var(--purple-dark); font-weight: 600; font-size: 12.5px;
  text-align: center; transition: box-shadow .15s, transform .15s;
}
.tile:hover { box-shadow: 0 4px 14px rgba(60, 40, 110, .14); transform: translateY(-1px); }
.tile .ico { font-size: 22px; line-height: 1; }

/* --- manager: dashboard - wyzsze, czytelniejsze wiersze ---
   height dziala w tabeli jak min-height: wiersze jednoliniowe dostaja te sama
   (podwojna) wysokosc co wiersze z zawijana trescia. */
table.dash td { padding: 8px; vertical-align: middle; height: 58px; }

/* --- manager: wiersze-karty (kolorowe, zaokraglone, z biala przerwa) ---
   Tlo wiersza podajemy przez --rowbg NA <tr> (style="--rowbg:#..."), a maluje je td:
   background na samym <tr> nie daje sie zaokraglic. Przerwy robi border-spacing. */
table.cards { border-collapse: separate; border-spacing: 0 6px; }
table.cards td { background: var(--rowbg, #f7f5fb); border-bottom: none; }
table.cards td:first-child { border-radius: 10px 0 0 10px; padding-left: 12px; }
table.cards td:last-child { border-radius: 0 10px 10px 0; padding-right: 12px; }
table.cards th { border-bottom: none; padding-bottom: 0; }

/* --- raporty: mobile --- */
/* Szerokie tabele przewijaja sie WEWNATRZ karty, nie cala strona.
   iOS Safari: wymaga max-width + zablokowania overflow na html/body,
   inaczej rozszerza caly viewport zamiast scrollowac kontener. */
html, body { overflow-x: hidden; }
.card { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
table.lines { width: 100%; }
.chart-box { position: relative; height: 420px; }
@media (max-width: 560px) {
  .chart-box { height: 460px; }           /* na telefonie wykres jeszcze wyzszy, nie splaszczony */
}

/* --- raporty: strona na pelna szerokosc (np. kalendarz) - minimalny padding --- */
.container.wide { max-width: none; padding-left: 6px; padding-right: 6px; }
@media (min-width: 561px) {
  .container.wide { padding-left: 12px; padding-right: 12px; }
}
