/* Pohrebná služba CRM — „matričná kniha“: atrament, slonovina, zlato sviečky */

:root {
  --ink: #14151b;
  --panel: #1d1f28;
  --panel-2: #242734;
  --line: rgba(236, 233, 225, 0.09);
  --line-strong: rgba(236, 233, 225, 0.18);
  --ivory: #ece9e1;
  --muted: #98959e;
  --gold: #c9a769;
  --gold-soft: rgba(201, 167, 105, 0.14);
  --sage: #8aa98f;
  --rose: #c98274;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Inter', -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--ink);
  color: var(--ivory);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 500; margin: 0; }
a { color: var(--gold); text-decoration: none; }
button { font-family: var(--sans); }
[hidden] { display: none !important; }

/* ---------- Prihlásenie ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(600px 400px at 50% 20%, rgba(201, 167, 105, 0.07), transparent 70%),
    var(--ink);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px; text-align: center;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 40px 32px;
}
.login-mark { font-size: 34px; }
.login-title { font-size: 30px; margin-top: 10px; letter-spacing: 0.01em; }
.login-sub { color: var(--muted); font-size: 13px; margin: 6px 0 26px; }
.form-error { color: var(--rose); font-size: 13px; min-height: 18px; margin: 10px 0 0; }

/* ---------- Layout ---------- */
#app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar {
  border-right: 1px solid var(--line);
  padding: 22px 14px; display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark { font-size: 20px; }
.brand-name { font-family: var(--serif); font-size: 19px; line-height: 1.15; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  color: var(--muted); padding: 9px 10px; border-radius: 7px; font-size: 14px;
  border-left: 2px solid transparent;
}
.nav a:hover { color: var(--ivory); background: rgba(255, 255, 255, 0.03); }
.nav a.active { color: var(--ivory); background: var(--gold-soft); border-left-color: var(--gold); }
.main { padding: 28px 34px 60px; max-width: 1200px; width: 100%; }

/* ---------- Komponenty ---------- */
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-title { font-size: 32px; }
.page-sub { color: var(--muted); font-size: 13px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; }
.card h3 { font-size: 20px; margin-bottom: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line-strong); background: transparent; color: var(--ivory);
  padding: 8px 14px; border-radius: 7px; font-size: 13.5px; font-weight: 500; cursor: pointer;
}
.btn:hover { border-color: var(--gold); color: var(--gold); }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #241d10; }
.btn-gold:hover { background: #d6b87e; color: #241d10; }
.btn-ghost { border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ivory); border-color: var(--line-strong); }
.btn-danger:hover { border-color: var(--rose); color: var(--rose); }
.btn-block { width: 100%; }
.btn-sm { padding: 4px 9px; font-size: 12.5px; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; letter-spacing: 0.02em; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--ink); color: var(--ivory);
  border: 1px solid var(--line-strong); border-radius: 7px; padding: 8px 10px; font-size: 14px;
  font-family: var(--sans);
}
.field select { padding-right: 28px; text-overflow: ellipsis; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--gold); outline-offset: -1px; border-color: transparent; }
.field textarea { min-height: 70px; resize: vertical; }

/* auto-fit: polia sa nikdy nestlačia pod čitateľnú šírku (Typ pohrebu, selecty…) */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 16px; }

/* formulár pridania položky — kategória má vždy plnú šírku textu */
.item-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; margin-top: 12px; }
.item-form .f-name { grid-column: 1 / -1; }
.item-form .f-cat { grid-column: 1 / -1; }
.item-form .f-note { grid-column: 1 / -1; }
.item-form .f-btn { grid-column: 1 / -1; }
@media (min-width: 560px) {
  .item-form { grid-template-columns: 1.4fr 0.9fr 0.7fr; }
  .item-form .f-name { grid-column: 1 / -1; }
  .item-form .f-cat { grid-column: 1; }
  .item-form .f-price { grid-column: 2; }
  .item-form .f-qty { grid-column: 3; }
  .item-form .f-note { grid-column: 1 / -1; }
}

/* ---------- Dashboard ---------- */
.widgets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.widget { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.widget .w-label { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.widget .w-main { font-family: var(--serif); font-size: 26px; line-height: 1.15; }
.widget .w-sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
#w-clock .w-main { font-variant-numeric: tabular-nums; }

.funeral-list { display: grid; gap: 12px; }
.funeral-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px 18px; cursor: pointer;
}
.funeral-item:hover { background: var(--panel-2); }
.funeral-when { text-align: center; min-width: 74px; }
.funeral-when .d { font-family: var(--serif); font-size: 26px; color: var(--gold); line-height: 1; }
.funeral-when .m { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.funeral-when .t { font-size: 13px; margin-top: 3px; font-variant-numeric: tabular-nums; }
.funeral-name { font-family: var(--serif); font-size: 20px; }
.funeral-meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.funeral-right { text-align: right; min-width: 140px; }

/* progress — tenká zlatá linka sviečky */
.progress { margin-top: 6px; }
.progress .p-track { height: 3px; background: var(--line-strong); border-radius: 2px; overflow: hidden; }
.progress .p-fill {
  height: 100%; width: 100%; background: linear-gradient(90deg, #8a6f3e, var(--gold)); border-radius: 2px;
  transform-origin: left; transform: scaleX(var(--p, 0)); transition: transform 0.4s ease;
}
.progress .p-label { font-size: 11.5px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.progress.done .p-fill { background: var(--sage); }

/* ---------- Tabuľky / zoznam klientov ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.toolbar input[type="search"], .toolbar select {
  background: var(--panel); color: var(--ivory); border: 1px solid var(--line-strong);
  border-radius: 7px; padding: 8px 10px; font-size: 13.5px; font-family: var(--sans);
}
.toolbar input[type="search"] { min-width: 220px; }

table.list { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.table-wrap { overflow-x: auto; border-radius: 10px; }
table.list th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted); font-weight: 500; padding: 10px 14px; border-bottom: 1px solid var(--line-strong);
  white-space: nowrap; cursor: pointer; user-select: none;
}
table.list th.no-sort { cursor: default; }
table.list td { padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 13.5px; vertical-align: middle; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover { background: var(--panel-2); }
table.list tbody tr:last-child td { border-bottom: none; }
td.name { font-family: var(--serif); font-size: 17px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 20px; border: 1px solid var(--line-strong); color: var(--muted); }
.tag.gold { color: var(--gold); border-color: rgba(201, 167, 105, 0.4); }
.tag.sage { color: var(--sage); border-color: rgba(138, 169, 143, 0.4); }

.empty { text-align: center; color: var(--muted); padding: 46px 20px; border: 1px dashed var(--line-strong); border-radius: 10px; }
.empty .e-title { font-family: var(--serif); font-size: 20px; color: var(--ivory); margin-bottom: 6px; }

/* ---------- Karta klienta ---------- */
.deceased-head { text-align: center; padding: 28px 20px 22px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); margin-bottom: 20px; position: relative; }
.deceased-head::after {
  content: ''; display: block; width: 120px; margin: 16px auto 0;
  border-top: 1px solid var(--gold); border-bottom: 1px solid var(--gold); height: 3px;
}
.deceased-name { font-family: var(--serif); font-size: 34px; font-weight: 500; }
.deceased-dates { color: var(--muted); font-size: 14px; margin-top: 6px; letter-spacing: 0.04em; }
.deceased-dates .cross { color: var(--gold); }
.deceased-funeral { font-size: 14px; margin-top: 10px; color: var(--ivory); }

.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.card-grid .span-2 { grid-column: 1 / -1; }

/* položky / budget */
.items-table { width: 100%; border-collapse: collapse; }
.items-table td, .items-table th { padding: 8px 8px; border-bottom: 1px solid var(--line); font-size: 13.5px; text-align: left; }
.items-table th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 500; }
.items-table td.num, .items-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.budget-total { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 8px 2px; }
.budget-total .t-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.budget-total .t-value { font-family: var(--serif); font-size: 30px; color: var(--gold); font-variant-numeric: tabular-nums; }

/* checklist */
.check-item { display: flex; align-items: flex-start; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.check-item:last-child { border-bottom: none; }
.check-item input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--gold); cursor: pointer; flex-shrink: 0; margin-top: 2px; }
.check-body { flex: 1; min-width: 0; }
.check-body label { display: block; cursor: pointer; font-size: 13.5px; }
.check-item.done .check-body label { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(201, 167, 105, 0.5); }
.check-note {
  width: 100%; background: transparent; border: none; border-bottom: 1px dashed transparent;
  color: var(--muted); font-size: 12.5px; font-family: var(--sans); padding: 2px 0; margin-top: 1px;
}
.check-note::placeholder { color: var(--muted); opacity: 0.45; }
.check-note:hover { border-bottom-color: var(--line-strong); }
.check-note:focus { outline: none; border-bottom-color: var(--gold); color: var(--ivory); }
.check-date { display: flex; flex-direction: column; gap: 1px; flex-shrink: 0; }
.check-date span { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.check-date input {
  background: var(--ink); border: 1px solid var(--line-strong); border-radius: 6px;
  color: var(--ivory); font-size: 12px; font-family: var(--sans); padding: 3px 6px; width: 130px;
  color-scheme: dark;
}
.check-date input:focus { outline: 2px solid var(--gold); outline-offset: -1px; }
.check-item .btn { opacity: 0; }
.check-item:hover .btn, .check-item:focus-within .btn { opacity: 1; }

.inline-form { display: flex; gap: 8px; margin-top: 10px; }
.inline-form input { flex: 1; background: var(--ink); color: var(--ivory); border: 1px solid var(--line-strong); border-radius: 7px; padding: 7px 10px; font-size: 13.5px; font-family: var(--sans); }

.share-box { background: var(--ink); border: 1px dashed var(--line-strong); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; word-break: break-all; margin-top: 10px; }

/* ---------- Platby & QR ---------- */
.pay-summary { display: flex; gap: 26px; flex-wrap: wrap; padding: 8px 0 14px; }
.pay-summary .p-lbl { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin-bottom: 2px; }
.pay-summary strong { font-family: var(--serif); font-size: 21px; font-weight: 500; font-variant-numeric: tabular-nums; }
.pay-ok { color: var(--sage); }
.pay-due { color: var(--gold); }
.item-form .f-pick { grid-column: 1 / -1; }
.row-off td { opacity: 0.5; }

.qr-pay { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.qr-img { width: 168px; height: 168px; background: #fff; border-radius: 8px; overflow: hidden; flex-shrink: 0; }
.qr-img svg { display: block; width: 100%; height: 100%; }
.qr-info .q-amount { font-family: var(--serif); font-size: 26px; color: var(--gold); font-variant-numeric: tabular-nums; }

/* ---------- Graf: tržby 6 mesiacov ---------- */
.chart { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; align-items: end; padding-top: 6px; }
.chart-col { text-align: center; min-width: 0; }
.chart-val { font-size: 11.5px; color: var(--ivory); min-height: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chart-track { height: 120px; display: flex; align-items: flex-end; justify-content: center; }
.chart-bar {
  width: 26px; height: calc(var(--h, 0) * 120px); min-height: 0;
  background: linear-gradient(180deg, var(--gold), #8a6f3e); border-radius: 4px 4px 0 0;
}
.chart-month { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-top: 6px; border-top: 1px solid var(--line-strong); padding-top: 5px; }
.chart-count { font-size: 12.5px; color: var(--ivory); font-variant-numeric: tabular-nums; }
.chart-legend { grid-column: 1 / -1; text-align: center; margin-top: 8px; }

/* ---------- Kalendár ---------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); text-align: center; padding: 4px 0; }
.cal-day { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; min-height: 86px; padding: 6px; }
.cal-day.cal-empty { background: transparent; border-color: transparent; }
.cal-day.is-today { border-color: var(--gold); }
.cal-num { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.cal-day.is-today .cal-num { color: var(--gold); font-weight: 600; }
.cal-funeral {
  display: block; width: 100%; text-align: left; background: var(--gold-soft); color: var(--ivory);
  border: none; border-radius: 6px; padding: 4px 6px; font-size: 11.5px; line-height: 1.3;
  cursor: pointer; margin-bottom: 4px; font-family: var(--sans);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-funeral:hover { background: rgba(201, 167, 105, 0.28); }
.cal-funeral.is-closed { opacity: 0.55; }
.cal-funeral .cf-time { color: var(--gold); font-variant-numeric: tabular-nums; }

/* ---------- Partneri ---------- */
.partner-item {
  display: flex; align-items: flex-start; gap: 12px; justify-content: space-between;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px;
}
.partner-item .btn { opacity: 0; }
.partner-item:hover .btn, .partner-item:focus-within .btn { opacity: 1; }

@media (max-width: 900px) {
  .cal-day { min-height: 56px; padding: 4px; }
  .cal-funeral { font-size: 10px; }
  .chart-bar { width: 16px; }
  .pay-summary { gap: 16px; }
}

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel-2); border: 1px solid var(--gold); color: var(--ivory);
  padding: 10px 18px; border-radius: 8px; font-size: 13.5px; opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s; z-index: 100; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { border-color: var(--rose); }

/* ---------- Responzívne ---------- */
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; padding: 12px 14px; border-right: none; border-bottom: 1px solid var(--line); }
  .brand-name { display: none; }
  .nav { flex-direction: row; overflow-x: auto; }
  .nav a { white-space: nowrap; border-left: none; border-bottom: 2px solid transparent; }
  .nav a.active { border-left: none; border-bottom-color: var(--gold); }
  .sidebar-foot { margin-left: auto; }
  .main { padding: 18px 14px 50px; }
  .widgets { grid-template-columns: 1fr 1fr; }
  .card-grid, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .funeral-item { grid-template-columns: auto 1fr; }
  .funeral-right { grid-column: 1 / -1; text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
