/* ============================================================
   Výpočet prodeje – vánoční stromky
   ------------------------------------------------------------
   Theme: dark green "forest" card UI with per-category row colors.
   Layout: single .wrap column, KPI grid on top, one items table.
   ============================================================ */

:root{
  --bg:#06140e;--text:#e8f5ee;--muted:#9bc7b2;--card:#0a1c14;--line:#133322;
  --btn:#0e2a1d;--btn-accent:#29c374;--btn-accent-2:#1ea663;

  /* Per-category row backgrounds (must match trClass() in app.js) */
  --smrk:#e6f5e9;--borovice:#dff6ea;--jedle:#C1FFC1;--kvetinac:#FFE4B5;
  --stojan:#eef1f4;--haluzimelo:#fff8d9;--sluzby:#efe5da;--kusy:#ffe9d6;
  --akce:var(--jedle);--treefood:#efe6ff;--jumbo:#e8dcc4;
  --text-dark:#0b1a12;
  --mark-saved-bg:#FF6347; /* highlight for rows with qty > 0 */
}

*{box-sizing:border-box}
html,body{margin:0;background:var(--bg);color:var(--text);font:16px/1.45 system-ui,Segoe UI,Roboto,Arial,sans-serif}
.wrap{max-width:1100px;margin:14px auto;padding:0 12px}
h1{margin:0;font-size:1.6rem}
.card{background:var(--card);border:1px solid var(--line);border-radius:16px;padding:14px;margin:10px 0}
.topbar{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:12px}
.reset-btn{padding:10px 14px;border-radius:12px;border:1px solid var(--line);background:#163a28;color:#e8f5ee;font-weight:700;cursor:pointer}
.reset-btn:active{transform:scale(.98)}
.reset-zone{display:flex;align-items:center;gap:10px}
#resetConfirm{font-weight:800;color:#fff;white-space:nowrap}

/* --- KPI cards (responsive: 1 col -> 2 -> 3) --- */
.kpis{display:grid;gap:8px}
@media(min-width:720px){.kpis{grid-template-columns:repeat(2,1fr)}}
@media(min-width:1100px){.kpis{grid-template-columns:repeat(3,1fr)}}
.kpi{background:#092416;border:1px solid var(--line);border-radius:14px;padding:10px}
.kpi h3{margin:0 0 6px;font-size:.95rem;color:var(--muted)}
.kpi .v{font-size:1.35rem;font-weight:900}
.mono{font-family:ui-monospace,Menlo,Consolas,monospace;font-variant-numeric:tabular-nums}

/* --- Items table --- */
.table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch;border-radius:12px}
.table{width:100%;border-collapse:collapse;table-layout:fixed;min-width:720px}
.table thead th{position:sticky;top:0;background:var(--card);z-index:2;color:var(--text)}
.table th,.table td{border-bottom:1px solid var(--line);padding:8px;text-align:right;vertical-align:middle}
th.col-id,td.col-id{text-align:center}
th.col-name,td.col-name{text-align:left}
th.col-price,td.col-price{text-align:center}
th.col-qty,td.col-qty{text-align:center}
th.col-sum,td.col-sum{text-align:center}
.col-id{width:10%}.col-name{width:auto}.col-price{width:15%}.col-qty{width:20%}.col-sum{width:20%}
.table tbody td{color:var(--text-dark)}
.rowid{display:inline-block;font-weight:700;background:#123624;color:#c6f6d5;padding:2px 8px;border-radius:999px;margin-right:10px}

/* Per-category row colors — keys must match categories in config.js CATS */
tr.row-smrk td{background:var(--smrk)}
tr.row-borovice td{background:var(--borovice)}
tr.row-jedle td{background:var(--jedle)}
tr.row-kvetinac td{background:var(--kvetinac)}
tr.row-stojan td{background:var(--stojan)}
tr.row-haluzimelo td{background:var(--haluzimelo)}
tr.row-sluzby td{background:var(--sluzby)}
tr.row-akce td{background:var(--akce)}
tr.row-treefood td{background:var(--treefood)}
tr.row-jumbo td{background:var(--jumbo)}

/* Quantity stepper: [−] [input] [+] */
.qtyctrl{display:grid;grid-template-columns:38px minmax(44px,1fr) 38px;gap:.35rem;align-items:center;justify-items:center;max-width:220px;margin:0 auto}
.qtyctrl .btn{width:38px;height:38px;border:1px solid var(--line);background:var(--btn);color:#e8f5ee;border-radius:12px;font-weight:800;cursor:pointer}
.btn.plus{background:linear-gradient(0deg,var(--btn-accent-2),var(--btn-accent))}
.btn.minus{background:#163a28}
.qtyctrl .qty{width:100%;height:38px;text-align:center;background:#f2f7f4;border:1px solid var(--line);color:var(--text-dark);border-radius:10px;font-weight:800}

/* Row highlight: green on hover; tomato when it has qty > 0 ("mark-saved") */
.table tbody tr:not(.mark-saved):hover td{background:#29c374!important;color:#fff!important}
.table tbody tr.mark-saved td{background:var(--mark-saved-bg)!important;color:var(--text-dark)!important}
.table tbody tr.mark-saved:hover td{background:var(--mark-saved-bg)!important;color:var(--text-dark)!important}
.table thead th{background:linear-gradient(#0a1c14,#0a1c14);box-shadow:0 1px 0 var(--line)}

/* Mobile: compress stepper, pin qty column to the right, shorten headers
   via data-mobile attr rendered in ::after */
@media (max-width:640px){
  .qtyctrl{grid-template-columns:32px minmax(44px,1fr) 32px}
  .qtyctrl .btn,.qtyctrl .qty{height:32px}
  th.col-qty,td.col-qty{position:sticky;right:0;z-index:4}
  td.col-qty{box-shadow:-6px 0 8px rgba(0,0,0,.18)}
  th.col-price,th.col-sum,th.col-qty{position:relative;overflow:hidden;white-space:nowrap;font-size:0}
  th.col-price::after,th.col-sum::after,th.col-qty::after{content:attr(data-mobile);position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:0 6px;color:var(--text);font-size:.95rem;line-height:1.2;pointer-events:none}
  .table{min-width:680px}
}
#agQty,#abQty{display:inline-block;min-width:2ch;text-align:center}
.section-title{margin:0 0 8px;font-size:1.1rem}

/* Spawn-style qty cell (rows C, C1..Cn): same 3-column grid as normal
   rows so +/− buttons stay aligned with the rest of the table.
   .spawn-pad fills the unused column. */
.qty-view{display:flex;align-items:center;justify-content:center;font-weight:800}
.spawn-pad{visibility:hidden}

/* Jumbo price modal */
.modal-backdrop{position:fixed;inset:0;background:rgba(0,0,0,.6);display:flex;align-items:center;justify-content:center;z-index:50;padding:16px}
.modal-backdrop[hidden]{display:none}
.modal{background:var(--card);border:1px solid var(--line);border-radius:16px;padding:18px;width:min(360px,100%);display:grid;gap:12px}
.modal-title{font-weight:800;font-size:1.05rem}
#jumboPrice{height:44px;text-align:right;background:#f2f7f4;border:1px solid var(--line);border-radius:10px;color:var(--text-dark);font-weight:800;padding:0 10px;font-size:1.1rem;width:100%}
#jumboPrice.bad{outline:2px solid #ff6347}
.modal-warn{color:#ff8a75;font-weight:700;font-size:.9rem;margin-top:-6px}
.modal-actions{display:flex;gap:8px;justify-content:flex-end}
.modal-actions button{padding:10px 18px;border-radius:12px;border:1px solid var(--line);background:#163a28;color:#e8f5ee;font-weight:700;cursor:pointer}
.modal-actions .ok{background:linear-gradient(0deg,var(--btn-accent-2),var(--btn-accent))}
