:root {
  --bg: #f4f0e9; --bg2: #ffffff; --bg3: #efe9df; --bg4: #faf8f4;
  --border: #e5dfd4; --border2: #cfc6b7;
  --text: #17150f; --text2: #3d3930; --muted: #7c7568;
  --accent: #a3813a; --accent2: #b8860b; --blue: #2a5fc4; --green: #2f8a5a; --red: #cf3a3a;
  --ink: #17150f; --ink2: #2b2822;
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 12px 34px rgba(48,38,18,.10); --shadow-sm: 0 2px 10px rgba(48,38,18,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, "Segoe UI", Inter, Roboto, sans-serif; }
a { color: var(--blue); cursor: pointer; text-decoration: none; }
h1, h2, h3 { margin: 0 0 10px; letter-spacing: -.3px; }
h2 { font-size: 24px; font-weight: 750; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; margin-bottom: 12px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.blad { color: var(--red); }
.ok { color: var(--green); }
label { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--border2); border-radius: 10px; background: var(--bg2); color: var(--text); font: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(163,129,58,.15); }
textarea { min-height: 90px; resize: vertical; }
.btn { border: 1px solid var(--border2); background: var(--bg2); color: var(--text); padding: 8px 14px; border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 500; font-family: inherit; transition: .15s; }
.btn:hover { background: var(--bg3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--ink2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text2); }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 8px; }
.btn-duzy { width: 100%; padding: 12px; font-size: 15px; margin-top: 14px; }
.btn-danger { color: var(--red); border-color: #efc9c9; }
.btn-danger:hover { background: #fdf1f1; }
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px; box-shadow: var(--shadow-sm); }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kpi { background: var(--bg4); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.kpi-value { font-size: 22px; font-weight: 750; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.kpi-label { font-size: 12px; color: var(--muted); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar label { margin: 0; }
.toolbar input, .toolbar select { width: auto; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); background: var(--bg4); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr.klik { cursor: pointer; } tr.klik:hover td { background: var(--bg4); }
tfoot td { font-weight: 700; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.s-zaplanowana { background: #e7effc; color: #2a5fc4; }
.s-odbyta { background: #e3f3ea; color: #2f8a5a; }
.s-nieodbyta { background: #fdecec; color: #cf3a3a; }
.s-odwolana { background: var(--bg3); color: var(--muted); text-decoration: line-through; }
.s-oczekuje { background: #fff4d6; color: #8a6414; }
.s-aktywny { background: #e3f3ea; color: #2f8a5a; }
.s-zablokowany { background: #fdecec; color: #cf3a3a; }
details.section { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 10px; background: var(--bg2); }
details.section > summary { cursor: pointer; padding: 10px 14px; font-weight: 600; list-style: none; }
details.section > summary::before { content: '+ '; color: var(--accent); }
details.section[open] > summary::before { content: '− '; }
details.section .section-body { padding: 8px 14px 14px; border-top: 1px solid var(--border); }
.info-box { background: var(--bg4); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); padding: 10px 14px; margin: 10px 0; }
.info-box.red { border-left-color: var(--red); }
.info-box.green { border-left-color: var(--green); }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { background: var(--bg2); border: 1px solid var(--border); border-radius: 18px; padding: 28px 30px; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
.login-box .logo { font-size: 20px; font-weight: 800; margin-bottom: 18px; }
.login-box h2 { font-size: 20px; }

/* layout */
#app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--bg2); border-right: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .logo { font-size: 18px; font-weight: 800; padding: 6px 12px 18px; }
#nav a { display: block; padding: 9px 12px; border-radius: 10px; color: var(--text2); font-weight: 500; margin-bottom: 2px; }
#nav a:hover { background: var(--bg3); }
#nav a.active { background: var(--ink); color: #fff; }
.sidebar-foot { margin-top: auto; padding: 14px 12px 0; border-top: 1px solid var(--border); font-size: 13px; }
.sidebar-foot a { display: block; margin-top: 6px; color: var(--text2); }
main { padding: 26px 30px; max-width: 1300px; }
.badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; text-align: center; margin-left: 4px; }
#nav a.active .badge { background: #fff; color: var(--ink); }
.hamburger { display: none; }
.sidebar-overlay { display: none; }

/* toast / modal */
.toast { position: fixed; bottom: 22px; right: 22px; background: var(--bg2); border: 1px solid var(--accent); border-radius: 12px; padding: 12px 16px; box-shadow: var(--shadow); z-index: 1000; max-width: 380px; }
.overlay { position: fixed; inset: 0; background: rgba(23,21,15,.45); display: flex; align-items: center; justify-content: center; z-index: 900; padding: 16px; }
.modal { background: var(--bg2); border-radius: 16px; padding: 22px; max-width: 460px; width: 100%; }
.modal-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

@media print { .sidebar, .hamburger, .toolbar, .btn { display: none !important; } #app { grid-template-columns: 1fr; } main { padding: 0; } .card { box-shadow: none; } }
@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -260px; width: 250px; transition: left .2s; z-index: 800; }
  body.menu-otwarte .sidebar { left: 0; }
  body.menu-otwarte .sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 700; }
  .hamburger { display: block; position: fixed; top: 10px; left: 10px; z-index: 850; border: 1px solid var(--border2); background: var(--bg2); border-radius: 10px; padding: 6px 10px; font-size: 18px; }
  main { padding: 56px 14px 24px; }
  .tp-dzien { flex-direction: column; gap: 4px; } .tp-data { padding-top: 0; }
  .mk-dzien { flex-direction: column; gap: 6px; } .mk-nazwa { padding-top: 0; }
  .msg { max-width: 92%; }
}

/* statusy */
.st-nowy { background: #fff4d6; color: #8a6414; }
.st-praca { background: #eef0f3; color: #4a5260; }
.st-spotkanie { background: #e7effc; color: #2a5fc4; }
.st-noshow { background: #fdecec; color: #cf3a3a; }
.st-zaint { background: #f1e8ff; color: #6b3fc4; }
.st-sprzedaz { background: #e3f3ea; color: #2f8a5a; }
.st-zamkniete { background: var(--bg3); color: var(--muted); }

/* kanban */
.kanban { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.kol { flex: 0 0 250px; background: var(--bg4); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; }
.kol-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 700; padding: 4px 6px 8px; }
.kol-head .ile { background: var(--bg2); border: 1px solid var(--border); border-radius: 999px; padding: 0 7px; font-size: 11px; }
.karta { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 10px; margin-bottom: 7px; cursor: pointer; font-size: 13px; }
.karta:hover { border-color: var(--accent); }
.karta b { display: block; font-size: 14px; }
.karta .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.karta .alert { color: var(--red); font-weight: 600; }
.karta .powrot { color: #8a6414; font-weight: 600; }

/* karta klienta (modal) */
.km-overlay { position: fixed; inset: 0; background: rgba(23,21,15,.45); z-index: 900; display: flex; justify-content: flex-end; }
.km { background: var(--bg); width: min(880px, 100%); height: 100%; overflow-y: auto; padding: 20px 24px 40px; box-shadow: -8px 0 30px rgba(0,0,0,.15); }
.km-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.km-head h2 { margin: 0; }
.akcje { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.hist { font-size: 12px; max-height: 260px; overflow-y: auto; }
.hist div { padding: 4px 0; border-bottom: 1px dashed var(--border); }
.lista-dnia .wiersz { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); cursor: pointer; flex-wrap: wrap; }
.lista-dnia .wiersz:hover b { color: var(--accent); }
.lista-dnia .wiersz:last-child { border-bottom: 0; }
.zad { display: flex; gap: 8px; align-items: center; padding: 5px 0; }
.zad.done { text-decoration: line-through; color: var(--muted); }
.tabela-stat td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
tr.klik { cursor: pointer; } tr.klik:hover td { background: var(--bg4); }
.pre { white-space: pre-wrap; font-size: 13px; background: var(--bg4); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
@media (max-width: 860px) { .km { width: 100%; padding: 16px 14px 40px; } .kol { flex-basis: 220px; } }
