/* ===== Gabinety Stomatologiczne Dziadeccy — kolorystyka z logo ===== */
:root {
  --brand-dark: #1A181C;
  --brand-dark-2: #26232A;
  --brand-dark-3: #332F38;
  --brand-orange: #EF8000;
  --brand-orange-dark: #C96C00;
  --brand-orange-light: #FFF3E3;
  --bg: #F6F5F3;
  --card: #FFFFFF;
  --text: #1A181C;
  --text-muted: #6E6A75;
  --border: #E4E1DD;
  --danger: #D64545;
  --success: #2E9E5B;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(26,24,28,.08), 0 4px 16px rgba(26,24,28,.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
.hidden { display: none !important; }

/* ===== Logowanie ===== */
.login-screen {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--brand-dark) 0%, #2B2733 60%, #3A3040 100%);
  padding: 20px;
}
.login-card {
  background: var(--card); border-radius: 16px; padding: 36px 40px; width: 100%; max-width: 420px;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.login-logo { display: block; max-width: 280px; margin: 0 auto 6px; }
.login-subtitle { text-align: center; color: var(--text-muted); margin-bottom: 28px; font-size: 13px; letter-spacing: .4px; text-transform: uppercase; }
.login-card label { display: block; margin-bottom: 14px; font-weight: 600; font-size: 13px; color: var(--brand-dark); }
.login-card input {
  width: 100%; margin-top: 5px; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 15px; transition: border-color .15s;
}
.login-card input:focus { outline: none; border-color: var(--brand-orange); }
.login-info { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; line-height: 1.5; }
.totp-input { text-align: center; font-size: 24px !important; letter-spacing: 8px; font-family: monospace; }
.qr-box { text-align: center; margin-bottom: 10px; }
.qr-box img { width: 190px; height: 190px; border: 1px solid var(--border); border-radius: 8px; }
.secret-box { text-align: center; font-size: 11px; color: var(--text-muted); margin-bottom: 14px; word-break: break-all; }
.secret-box code { background: var(--bg); padding: 2px 6px; border-radius: 4px; }
.login-footer { color: rgba(255,255,255,.45); font-size: 12px; margin-top: 24px; text-align: center; }

/* ===== Przyciski ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border: none; border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all .15s; font-family: inherit;
}
.btn-primary { background: var(--brand-orange); color: #fff; }
.btn-primary:hover { background: var(--brand-orange-dark); }
.btn-dark { background: var(--brand-dark); color: #fff; }
.btn-dark:hover { background: var(--brand-dark-3); }
.btn-ghost { background: transparent; color: inherit; border: 1px solid var(--border); }
.btn-ghost:hover { background: rgba(0,0,0,.05); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-block { width: 100%; margin-top: 8px; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.form-error { color: var(--danger); font-size: 13px; margin: 8px 0; padding: 8px 10px; background: #FDECEC; border-radius: 6px; }

/* ===== Układ aplikacji ===== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; background: var(--brand-dark); color: #fff; display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 10;
}
.sidebar-logo { background: #fff; margin: 14px; padding: 10px 12px; border-radius: 10px; }
.sidebar-logo img { width: 100%; display: block; }
.nav { flex: 1; padding: 10px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  color: rgba(255,255,255,.75); text-decoration: none; font-weight: 500; font-size: 14px; transition: all .15s;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--brand-orange); color: #fff; font-weight: 600; }
.nav-ico { width: 20px; text-align: center; font-size: 14px; opacity: .9; }
.sidebar-bottom { padding: 14px; border-top: 1px solid rgba(255,255,255,.1); display: flex; flex-direction: column; gap: 6px; }
.sidebar-bottom .btn-ghost { color: rgba(255,255,255,.8); border-color: rgba(255,255,255,.2); }
.sidebar-bottom .btn-ghost:hover { background: rgba(255,255,255,.1); }
.user-badge { margin-bottom: 4px; }
.user-name { font-weight: 600; font-size: 13.5px; }
.user-role { font-size: 11.5px; color: var(--brand-orange); text-transform: uppercase; letter-spacing: .5px; }

.main { flex: 1; margin-left: 230px; padding: 28px 32px; max-width: 1400px; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 24px; font-weight: 700; color: var(--brand-dark); }
.page-title small { display: block; font-size: 13px; font-weight: 400; color: var(--text-muted); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== Karty / tabele ===== */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.card h3 { font-size: 15px; margin-bottom: 14px; color: var(--brand-dark); }
.cards-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; border-left: 4px solid var(--brand-orange); }
.stat-value { font-size: 26px; font-weight: 700; color: var(--brand-dark); }
.stat-label { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); padding: 8px 10px; border-bottom: 2px solid var(--border); }
.tbl td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover { background: var(--brand-orange-light); }

.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge-zaplanowana { background: #E8F0FE; color: #1A56DB; }
.badge-potwierdzona { background: #E3F6EC; color: #1E7E46; }
.badge-odbyta { background: #EDEBF0; color: #554F5E; }
.badge-odwolana { background: #FDECEC; color: #C03838; }
.badge-nieobecnosc { background: #FFF2E0; color: #B35F00; }
.badge-paid { background: #E3F6EC; color: #1E7E46; }
.badge-unpaid { background: #FDECEC; color: #C03838; }
.doctor-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* ===== Formularze ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.fld label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 4px; color: var(--brand-dark); }
.fld input, .fld select, .fld textarea {
  width: 100%; padding: 8px 10px; border: 1.5px solid var(--border); border-radius: 7px; font-size: 14px; font-family: inherit; background: #fff;
}
.fld input:focus, .fld select:focus, .fld textarea:focus { outline: none; border-color: var(--brand-orange); }
.fld textarea { resize: vertical; min-height: 60px; }
.form-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(26,24,28,.55); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 760px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.modal-sm { max-width: 460px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 17px; color: var(--brand-dark); }
.modal-close { background: none; border: none; font-size: 16px; cursor: pointer; color: var(--text-muted); padding: 4px 8px; border-radius: 6px; }
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 22px 24px; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 200; background: var(--brand-dark); color: #fff;
  padding: 12px 20px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.3); font-size: 14px;
  border-left: 4px solid var(--brand-orange);
}
.toast.toast-error { border-left-color: var(--danger); }

/* ===== Diagram zębów ===== */
.tooth-chart-wrap { text-align: center; }
.tooth-chart { max-width: 560px; width: 100%; }
.tooth text { font-size: 10px; fill: var(--text-muted); pointer-events: none; font-family: inherit; }
.tooth-zone { stroke: #E0DCD6; stroke-width: 1; transition: stroke .1s, stroke-width .1s; }
.tooth-outline { stroke: #B9B4AE; stroke-width: 1.3; pointer-events: none; }
.tooth-chart.interactive .tooth-zone { cursor: pointer; }
.tooth-chart.interactive .tooth-zone:hover { stroke: var(--brand-orange); stroke-width: 2.2; }
.tooth-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; justify-content: center; margin-top: 10px; }
.tooth-legend span { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-muted); }
.tooth-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.arch-label { font-size: 11px; fill: var(--text-muted); font-family: inherit; }

.teeth-marks-list { margin-top: 12px; }
.teeth-marks-list .mark-row { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
.mark-tooth-no { font-weight: 700; min-width: 30px; color: var(--brand-dark); }
.mark-cat, .mark-surface { padding: 6px 8px; border: 1.5px solid var(--border); border-radius: 7px; font-size: 13px; background: #fff; min-width: 130px; }
.mark-note { flex: 1; min-width: 120px; padding: 6px 9px; border: 1.5px solid var(--border); border-radius: 7px; font-size: 13px; }
.mark-cat:focus, .mark-surface:focus, .mark-note:focus { outline: none; border-color: var(--brand-orange); }
.teeth-marks-list .mark-row { flex-wrap: wrap; }

/* ===== Terminarz ===== */
.cal-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.cal-range { font-weight: 700; font-size: 16px; min-width: 220px; text-align: center; color: var(--brand-dark); }
.cal-grid { display: grid; grid-template-columns: 56px repeat(5, 1fr); background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.cal-head { padding: 10px 6px; text-align: center; font-weight: 600; font-size: 13px; border-bottom: 2px solid var(--border); background: #FBFAF9; }
.cal-head.today { color: var(--brand-orange); }
.cal-head small { display: block; font-weight: 400; color: var(--text-muted); font-size: 11px; }
.cal-time { font-size: 11px; color: var(--text-muted); text-align: right; padding: 2px 8px 0 0; border-right: 1px solid var(--border); height: 44px; }
.cal-cell { border-right: 1px solid #F0EEEA; border-bottom: 1px solid #F0EEEA; height: 44px; position: relative; cursor: pointer; }
.cal-cell:hover { background: var(--brand-orange-light); }
.cal-col { position: relative; }
.cal-visit {
  position: absolute; left: 3px; right: 3px; border-radius: 6px; padding: 3px 7px; font-size: 11.5px;
  color: #fff; overflow: hidden; cursor: pointer; z-index: 2; box-shadow: 0 1px 3px rgba(0,0,0,.2); line-height: 1.25;
}
.cal-visit:hover { filter: brightness(1.1); z-index: 3; }
.cal-visit b { display: block; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.cal-visit.cancelled { opacity: .45; text-decoration: line-through; }

/* ===== Pacjent — szczegóły ===== */
.patient-layout { display: grid; grid-template-columns: 340px 1fr; gap: 18px; align-items: start; }
.patient-info-list { font-size: 13.5px; }
.patient-info-list div { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.patient-info-list div:last-child { border-bottom: none; }
.patient-info-list b { color: var(--text-muted); font-weight: 500; flex-shrink: 0; }
.patient-info-list span { text-align: right; }
.alert-allergy { background: #FDECEC; color: #B13232; border-radius: 8px; padding: 8px 12px; font-size: 13px; margin-top: 10px; font-weight: 600; }
.anamnesis-list { font-size: 13.5px; }
.anamnesis-list div { padding: 7px 0; border-bottom: 1px dashed var(--border); }
.anamnesis-list div:last-child { border-bottom: none; }
.anamnesis-list b { display: block; color: var(--text-muted); font-weight: 500; font-size: 12px; margin-bottom: 2px; }
.anamnesis-list span { white-space: pre-wrap; }
.form-section-label { font-weight: 700; color: var(--brand-dark); font-size: 13px; padding-top: 4px; border-top: 1px solid var(--border); margin-top: 2px; }
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 14px; }
.tab { padding: 9px 18px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--text-muted); border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tab.active { color: var(--brand-orange); border-bottom-color: var(--brand-orange); }

.search-row { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search-row input, .search-row select { padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 14px; background: #fff; }
.search-row input { flex: 1; min-width: 220px; }
.search-row input:focus, .search-row select:focus { outline: none; border-color: var(--brand-orange); }

.muted { color: var(--text-muted); }
.text-right { text-align: right; }
.empty-state { text-align: center; color: var(--text-muted); padding: 30px 10px; font-size: 14px; }
.price { font-weight: 700; white-space: nowrap; }

.proc-picker { display: flex; gap: 8px; align-items: flex-end; }
.proc-picker select { flex: 1; }

/* ===== Przełącznik diagramu / widoku ===== */
.chart-toggle { display: inline-flex; gap: 4px; background: var(--bg); border-radius: 8px; padding: 3px; }

/* ===== Plan leczenia ===== */
.plan-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.plan-card.plan-inactive { opacity: .65; background: #FAFAF8; }
.plan-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.plan-status { padding: 5px 8px; border: 1.5px solid var(--border); border-radius: 7px; font-size: 12.5px; background: #fff; }
.plan-done td { color: var(--text-muted); }
.plan-done td:nth-child(2) { text-decoration: line-through; }
.plan-add-row { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.plan-add-row select { flex: 2; min-width: 180px; }
.plan-add-row input { width: 90px; }
.plan-add-row select, .plan-add-row input { padding: 7px 9px; border: 1.5px solid var(--border); border-radius: 7px; font-size: 13px; background: #fff; }
.plan-add-row select:focus, .plan-add-row input:focus { outline: none; border-color: var(--brand-orange); }
.plan-sums { display: flex; gap: 20px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 13px; flex-wrap: wrap; }
.cat-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ===== Załączniki badań ===== */
.file-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.file-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--brand-orange-light); border-radius: 14px; padding: 2px 8px; font-size: 12px; }
.file-chip a { color: var(--brand-orange-dark); text-decoration: none; font-weight: 600; }
.file-chip a:hover { text-decoration: underline; }
.chip-x { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 11px; padding: 2px 4px; border-radius: 4px; }
.chip-x:hover { background: rgba(0,0,0,.08); color: var(--danger); }

/* ===== Raporty — wykres ===== */
.bar-chart { display: flex; align-items: flex-end; gap: 14px; padding: 10px 4px 0; overflow-x: auto; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 52px; }
.bar { width: 34px; background: linear-gradient(180deg, var(--brand-orange), var(--brand-orange-dark)); border-radius: 6px 6px 2px 2px; }
.bar-val { font-size: 11px; font-weight: 700; color: var(--brand-dark); }
.bar-label { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

@media (max-width: 900px) {
  .sidebar { width: 64px; }
  .sidebar-logo { display: none; }
  .nav-item span:not(.nav-ico) { display: none; }
  .main { margin-left: 64px; padding: 16px; }
  .patient-layout { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ===== Telefon / wąski ekran ===== */
.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }
.cal-scroll { overflow: visible; }

@media (max-width: 768px) {
  /* Górny pasek z hamburgerem */
  .mobile-topbar {
    display: flex; align-items: center; gap: 12px;
    position: fixed; top: 0; left: 0; right: 0; height: 54px; z-index: 30;
    background: var(--card); border-bottom: 1px solid var(--border); padding: 0 12px;
    box-shadow: 0 1px 3px rgba(26,24,28,.08);
  }
  .mobile-menu-btn { background: none; border: none; font-size: 26px; line-height: 1; color: var(--brand-dark); cursor: pointer; padding: 2px 8px; }
  .mobile-topbar-logo { height: 32px; }

  /* Sidebar jako wysuwana szuflada */
  .sidebar {
    width: 250px; transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.45);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-logo { display: block; }
  .nav-item span:not(.nav-ico) { display: inline; }
  .nav-item { padding: 13px 14px; font-size: 15px; }   /* większe cele dotykowe */
  .sidebar-bottom .btn { padding: 11px 14px; }

  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45);
    z-index: 25; opacity: 0; pointer-events: none; transition: opacity .22s;
  }
  .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

  /* Treść pod paskiem, bez lewego marginesu */
  .main { margin-left: 0; padding: 14px; padding-top: 68px; }

  .page-header { margin-bottom: 16px; gap: 10px; }
  .page-title { font-size: 20px; }
  .page-actions { width: 100%; }

  /* Szerokie tabele przewijane w poziomie wewnątrz karty */
  .card { padding: 16px; }
  .card:has(.tbl) { overflow-x: auto; }
  .tbl { min-width: 480px; }

  /* Terminarz — przewijanie poziome tygodnia */
  .cal-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .cal-grid { min-width: 600px; }

  /* Modale na pełną szerokość */
  .modal-backdrop { padding: 10px; }
  .modal-header { padding: 14px 16px; }
  .modal-body { padding: 16px; }
  .form-footer { flex-wrap: wrap; }
  .form-footer .btn { flex: 1 1 auto; min-width: 130px; }

  .login-card { padding: 26px 20px; }
  .toast { left: 14px; right: 14px; bottom: 14px; }
}
