:root {
  --teal-900: #0B4F4E;
  --teal-700: #0E7C7B;
  --teal-500: #16A19E;
  --teal-100: #E3F3F2;
  --coral: #E8734A;
  --coral-light: #FBE7DE;
  --ink: #1F2937;
  --ink-light: #5B6472;
  --bg: #F5F8F8;
  --white: #FFFFFF;
  --border: #E1E8E7;
  --danger: #D64545;
  --danger-light: #FBE3E3;
  --success: #2E9E5B;
  --success-light: #E3F6EA;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Manrope', -apple-system, system-ui, sans-serif;
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  background: var(--teal-900);
  color: white;
  padding: 16px 20px;
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 800; font-size: 19px; letter-spacing: -0.02em; }

.badge {
  font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 20px;
}
.badge-online { background: var(--teal-500); color: white; }
.badge-offline { background: var(--coral); color: white; }

.screen { padding-bottom: 90px; }
.hidden { display: none !important; }

main#main-content { max-width: 560px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}

.login-card { max-width: 380px; margin: 60px auto; }
.login-card h1 { font-size: 22px; margin: 0 0 16px; }

input, select, textarea {
  width: 100%; padding: 13px 14px; margin: 6px 0;
  border-radius: 10px; border: 1.5px solid var(--border);
  font-size: 16px; font-family: inherit; color: var(--ink);
  background: var(--white);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--teal-500);
}
label { font-size: 13px; font-weight: 700; color: var(--ink-light); margin-top: 10px; display: block; }

button { font-family: inherit; cursor: pointer; border: none; }
.btn-primary {
  width: 100%; padding: 14px; margin: 8px 0;
  background: var(--teal-700); color: white;
  border-radius: 10px; font-weight: 700; font-size: 16px;
}
.btn-primary:active { background: var(--teal-900); }
.btn-secondary {
  width: 100%; padding: 14px; margin: 8px 0;
  background: var(--teal-100); color: var(--teal-900);
  border-radius: 10px; font-weight: 700; font-size: 15px;
}
.btn-danger {
  padding: 10px 14px; background: var(--danger-light); color: var(--danger);
  border-radius: 8px; font-weight: 700; font-size: 13px;
}

.error-text { color: var(--danger); font-size: 14px; margin: 8px 0 0; }

.section-title {
  font-size: 13px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--teal-700); margin: 4px 0 10px;
}

.list-item {
  padding: 14px 4px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer;
}
.list-item:last-child { border-bottom: none; }
.list-item:active { background: var(--teal-100); }
.list-item-name { font-weight: 700; font-size: 15px; }
.list-item-sub { font-size: 13px; color: var(--ink-light); }

.pill {
  font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 20px;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.pill-planifie { background: var(--teal-100); color: var(--teal-900); }
.pill-en_cours { background: var(--coral-light); color: var(--coral); }
.pill-termine { background: var(--success-light); color: var(--success); }
.pill-annule { background: var(--danger-light); color: var(--danger); }
.pill-admin { background: var(--coral-light); color: var(--coral); }
.pill-secretaire { background: var(--teal-100); color: var(--teal-900); }
.pill-infirmiere { background: var(--success-light); color: var(--success); }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--white); border-top: 1px solid var(--border);
  display: flex; padding: 6px 0 max(6px, env(safe-area-inset-bottom));
  z-index: 10;
}
.nav-item {
  flex: 1; background: none; display: flex; flex-direction: column;
  align-items: center; gap: 2px; padding: 8px 0;
  color: var(--ink-light); font-size: 11px; font-weight: 700;
}
.nav-item.active { color: var(--teal-700); }
.nav-icon { font-size: 20px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(11,79,78,0.4);
  display: flex; align-items: flex-end; justify-content: center; z-index: 100;
}
.modal-sheet {
  background: var(--white); width: 100%; max-width: 560px;
  border-radius: 20px 20px 0 0; padding: 20px;
  max-height: 88vh; overflow-y: auto;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px;
}
.modal-header h2 { margin: 0; font-size: 18px; }
.close-btn {
  background: var(--bg); width: 32px; height: 32px; border-radius: 50%;
  font-size: 16px; color: var(--ink-light);
}

.banner {
  padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; font-size: 14px; font-weight: 600;
}
.banner-error { background: var(--danger-light); color: var(--danger); }
.banner-success { background: var(--success-light); color: var(--success); }

.fab {
  position: fixed; bottom: 84px; right: 20px;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--coral); color: white; font-size: 26px;
  box-shadow: 0 4px 14px rgba(232,115,74,0.4);
  z-index: 20;
}

/* --- Extension v3 --- */
.form-section {
  font-size: 12px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--teal-500);
  margin: 18px 0 4px; padding-top: 10px; border-top: 1px solid var(--border);
}
.form-section:first-of-type { border-top: none; margin-top: 4px; padding-top: 0; }

.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: white; padding: 12px 20px; border-radius: 30px;
  font-size: 14px; font-weight: 600; z-index: 200; opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; }

.spinner {
  width: 22px; height: 22px; border: 3px solid var(--teal-100);
  border-top-color: var(--teal-700); border-radius: 50%;
  animation: spin 0.7s linear infinite; margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 24px 10px; color: var(--ink-light); font-size: 14px; }

.soin-card {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px;
}
.soin-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.soin-type { font-weight: 700; font-size: 14px; }
.soin-date { font-size: 12px; color: var(--ink-light); }
.soin-obs { font-size: 13px; color: var(--ink); margin: 6px 0; }
.soin-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.soin-actions button {
  font-size: 12px; padding: 7px 10px; border-radius: 8px;
  background: var(--teal-100); color: var(--teal-900); font-weight: 700;
}
.soin-photos-thumbs { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.soin-photos-thumbs img {
  width: 52px; height: 52px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border);
}
.tag-signed { color: var(--success); font-weight: 700; font-size: 12px; }
.tag-unsigned { color: var(--ink-light); font-weight: 700; font-size: 12px; }

#signature-canvas {
  border: 1.5px dashed var(--border); border-radius: 10px; width: 100%; touch-action: none; background: white;
}

/* --- Extension v3 --- */
.form-section {
  font-size: 12px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--teal-500);
  margin: 18px 0 4px; padding-top: 10px; border-top: 1px solid var(--border);
}
.form-section:first-of-type { border-top: none; margin-top: 4px; padding-top: 0; }

.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: white; padding: 12px 20px; border-radius: 30px;
  font-size: 14px; font-weight: 600; z-index: 200; opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; }

.spinner {
  width: 22px; height: 22px; border: 3px solid var(--teal-100);
  border-top-color: var(--teal-700); border-radius: 50%;
  animation: spin 0.7s linear infinite; margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 24px 10px; color: var(--ink-light); font-size: 14px; }

.soin-card {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px;
}
.soin-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.soin-type { font-weight: 700; font-size: 14px; }
.soin-date { font-size: 12px; color: var(--ink-light); }
.soin-obs { font-size: 13px; color: var(--ink); margin: 6px 0; }
.soin-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.soin-actions button {
  font-size: 12px; padding: 7px 10px; border-radius: 8px;
  background: var(--teal-100); color: var(--teal-900); font-weight: 700;
}
.soin-photos-thumbs { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.soin-photos-thumbs img {
  width: 52px; height: 52px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border);
}
.tag-signed { color: var(--success); font-weight: 700; font-size: 12px; }
.tag-unsigned { color: var(--ink-light); font-weight: 700; font-size: 12px; }

#signature-canvas {
  border: 1.5px dashed var(--border); border-radius: 10px; width: 100%; touch-action: none; background: white;
}
