:root {
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --accent: #2563eb;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #dbe5ec;
  --text: #172026;
  --muted: #617080;
  --danger: #b42318;
  --ok: #12715b;
  --warn: #9a6700;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { width: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); min-width: 320px; }
button, input, select, textarea { font: inherit; }
button, .button-link { border: 1px solid var(--line); background: #fff; color: var(--text); min-height: 36px; padding: 8px 12px; border-radius: 6px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; text-align: center; white-space: normal; line-height: 1.25; }
img, canvas, iframe { max-width: 100%; }
button:hover { border-color: var(--primary); }
button.primary, .primary { background: var(--primary); color: #fff; border-color: var(--primary); }
button.danger { background: #fff5f5; color: var(--danger); border-color: #f0b5ad; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; min-height: 38px; padding: 8px 10px; background: #fff; color: var(--text); }
textarea { resize: vertical; min-height: 86px; }
label { display: grid; gap: 6px; font-weight: 650; color: #263545; }
small { color: var(--muted); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; color: #435366; }
td:first-child, th:first-child { white-space: nowrap; }
td:last-child, th:last-child { white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand > div { display: grid; gap: 3px; min-width: 0; }
.brand strong, .brand small { display: block; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; }
.public-hero .brand { align-items: flex-start; }
.public-hero .brand strong { font-size: 18px; margin-top: 3px; }
.public-hero .brand small { margin-top: 5px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 8px; background: var(--primary); color: #fff; font-weight: 800; }
.brand.large .brand-mark { width: 48px; height: 48px; }
.logo-img { width: 52px; height: 52px; border-radius: 8px; object-fit: contain; background: #fff; border: 1px solid var(--line); }
.public-shell { min-height: 100vh; background: linear-gradient(135deg, #e6f4f1, #f7fbff); padding: 22px; }
.public-card { width: 100%; max-width: 1040px; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; box-shadow: 0 18px 52px rgba(15, 40, 60, .12); }
.public-hero { padding: 32px; display: grid; gap: 16px; border-bottom: 1px solid var(--line); }
.public-admin-bar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.public-hero h1 { margin: 6px 0 0; font-size: clamp(28px, 4vw, 44px); line-height: 1.12; overflow-wrap: break-word; word-break: normal; }
.public-steps { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); }
.public-steps > div { background: #f8fbfd; padding: 20px 18px; min-height: 92px; }
.step-title { display: flex; gap: 14px; align-items: flex-start; }
.step-title span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 800; flex: 0 0 auto; }
.step-title div { display: grid; gap: 4px; }
.step-title b, .step-title small { display: block; line-height: 1.25; }
.booking-form { padding: 28px; display: grid; gap: 28px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.full { grid-column: 1 / -1; }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.calendar-day { display: grid; gap: 4px; min-height: 70px; text-align: left; background: #fff; }
.calendar-day.selected { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.calendar-day.disabled { opacity: .45; cursor: not-allowed; }
.time-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.time-grid button.selected { background: var(--primary); color: #fff; }
.time-grid button:disabled { opacity: .55; background: #f1f5f9; color: #64748b; cursor: not-allowed; }
.time-grid button small { display: block; margin-top: 3px; font-size: 11px; line-height: 1.1; color: inherit; }
.success { padding: 18px; border: 1px solid #a7e0cf; background: #ecfdf5; color: #14532d; border-radius: 8px; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, #e6f4f1, #edf4ff); }
.login-panel { width: min(460px, 100%); background: #fff; padding: 28px; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 22px 50px rgba(15, 40, 60, .12); display: grid; gap: 16px; }
.initial-users { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
.app { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 100vh; width: 100%; }
.sidebar { background: #102a2a; color: #dcebea; padding: 18px 16px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; min-width: 0; }
.sidebar .brand small { color: #b8cfcc; }
.nav { display: grid; gap: 8px; overflow: auto; padding-right: 4px; }
.nav-item { width: 100%; display: flex; align-items: center; justify-content: flex-start; color: #e7f4f2; background: transparent; border-color: transparent; text-align: left; min-height: 40px; padding: 10px 12px; }
.nav-item b { white-space: normal; overflow: visible; text-overflow: clip; font-size: 14px; line-height: 1.25; }
.nav-item.active, .nav-item:hover { background: rgba(255,255,255,.11); border-color: rgba(255,255,255,.08); }
.topbar { min-height: 64px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 22px; position: sticky; top: 0; z-index: 5; }
.content { min-width: 0; }
.main { padding: 22px; display: grid; gap: 18px; min-width: 0; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; min-width: 0; }
.metric span { display: block; color: var(--muted); font-size: 13px; }
.metric strong { display: block; font-size: 24px; margin-top: 6px; }
.panel h2, .panel h3 { margin: 0 0 12px; }
.panel table { table-layout: auto; }
.panel td, .panel th { overflow-wrap: normal; word-break: normal; hyphens: none; }
.panel td:nth-child(3), .panel th:nth-child(3) { white-space: nowrap; }
.panel td:nth-child(5), .panel td:nth-child(6), .panel td:nth-child(7) { white-space: nowrap; }
.panel table td:last-child { white-space: nowrap; min-width: 180px; }
.panel table td:last-child button { margin: 0; min-width: 0; max-width: 100%; padding: 7px 10px; }
.table-actions { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; white-space: nowrap; }
.table-actions button { min-height: 34px; font-size: 14px; }
.whatsapp-message { display: block; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whatsapp-message + small { display: block; margin-top: 4px; }
.whatsapp-list { display: grid; gap: 10px; }
.whatsapp-card { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(320px, 1.45fr); gap: 14px; align-items: start; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.whatsapp-card-main { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; align-items: start; }
.whatsapp-card small { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; line-height: 1.2; }
.whatsapp-card strong, .whatsapp-card span { display: block; line-height: 1.25; overflow-wrap: anywhere; }
.whatsapp-card-message { min-width: 0; }
.whatsapp-card-message p { margin: 0 0 4px; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.panel-head, .toolbar { display: flex; gap: 10px; justify-content: space-between; align-items: center; flex-wrap: wrap; margin-bottom: 12px; min-width: 0; }
.toolbar input, .toolbar select { width: auto; min-width: 220px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.badge { display: inline-flex; align-items: center; min-height: 24px; border-radius: 999px; padding: 3px 10px; background: #eaf7f4; color: var(--ok); font-weight: 750; font-size: 12px; }
.badge.warn { background: #fff7e6; color: var(--warn); }
.badge.danger { background: #fff1f0; color: var(--danger); }
.actions { display: flex; gap: 7px; flex-wrap: wrap; }
.users-editor { display: grid; gap: 14px; }
.user-edit-card { border: 1px solid var(--line); border-radius: 8px; padding: 14px; background: #fff; }
.user-edit-card h3 { margin: 0 0 12px; font-size: 16px; }
.user-edit-card input, .user-edit-card select { min-width: 0; }
.user-edit-card label { min-width: 0; }
.request-list { display: grid; gap: 12px; }
.request-card { border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: block; background: #fff; min-width: 0; overflow: visible; }
.request-card .actions { display: flex; justify-content: flex-start; align-items: center; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; position: static; clear: both; }
.request-card .actions button { min-width: 108px; width: auto; min-height: 38px; padding: 8px 12px; flex: 0 0 auto; }
.request-main { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; min-width: 0; align-items: start; width: 100%; }
.request-main span { display: block; min-width: 0; overflow: visible; overflow-wrap: break-word; word-break: normal; line-height: 1.35; }
.request-main b { display: block; margin-bottom: 3px; white-space: nowrap; }
.agenda-board { display: grid; gap: 10px; }
.appointment { border-left: 5px solid var(--primary); background: #fff; border: 1px solid var(--line); border-left-color: var(--primary); border-radius: 8px; padding: 14px; display: grid; grid-template-columns: 120px 1fr auto; gap: 12px; min-width: 0; }
.patient-layout { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 16px; }
.patient-list { display: grid; gap: 8px; }
.patient-link { text-align: left; background: #fff; }
.details { display: grid; grid-template-columns: 180px 1fr; gap: 8px 14px; }
.details dt { color: var(--muted); font-weight: 750; }
.details dd { margin: 0; min-width: 0; overflow-wrap: break-word; word-break: normal; }
.odontogram { display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 8px; }
.tooth { min-height: 64px; display: grid; gap: 3px; place-items: center; }
.tooth.caries { background: #fff1f0; border-color: #f2a7a0; }
.tooth.restauracion { background: #eff6ff; border-color: #9ec3ff; }
.tooth.corona { background: #fef7cd; border-color: #eed060; }
.tooth.endodoncia { background: #f3e8ff; border-color: #c79cef; }
.tooth.ausente { background: #f1f5f9; color: #64748b; }
.tooth.selected { box-shadow: inset 0 0 0 2px var(--primary); }
.tooth-detail { margin-top: 14px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.legend span { border: 1px solid var(--line); border-radius: 999px; padding: 5px 9px; background: #fff; font-size: 12px; }
.notice { border-left: 4px solid var(--primary); background: #f2fbf8; padding: 12px; border-radius: 6px; }
.print-area { background: #fff; border: 1px solid var(--line); padding: 24px; border-radius: 8px; }
.pdf-frame { width: 100%; min-height: 72vh; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
canvas.signature { width: 100%; height: 180px; border: 1px dashed var(--line); border-radius: 8px; background: #fff; touch-action: none; }
@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .request-main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .appointment { grid-template-columns: 1fr; }
  .patient-layout { grid-template-columns: 1fr; }
}
@media (max-width: 920px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 12px; gap: 12px; }
  .sidebar > .brand { align-items: center; }
  .nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: visible; gap: 8px; padding: 0; }
  .nav-item { width: 100%; min-width: 0; justify-content: center; text-align: center; }
  .nav-item b { font-size: 13px; }
  .sidebar > button[data-logout] { align-self: stretch; }
  .topbar { position: static; align-items: flex-start; flex-wrap: wrap; }
  .content { width: 100%; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .odontogram { grid-template-columns: repeat(8, minmax(0, 1fr)); }
}
@media (min-width: 1200px) {
  .public-steps { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 760px) {
  .public-shell { padding: 10px; }
  .public-card { border-radius: 8px; overflow: visible; }
  .public-hero { padding: 20px; }
  .public-hero h1 { font-size: 30px; }
  .public-steps > div { padding: 16px; min-height: auto; }
  .booking-form { padding: 18px; gap: 18px; }
  .topbar { padding: 14px; }
  .topbar button { width: 100%; }
  .main { padding: 14px; }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-item { min-height: 38px; padding: 8px; }
  .metrics, .grid-2, .grid-3, .form-grid, .public-steps { grid-template-columns: 1fr; }
  .metrics { gap: 10px; }
  .metric { padding: 13px; }
  .metric strong { font-size: 21px; }
  .calendar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .odontogram { grid-template-columns: repeat(4, 1fr); }
  .request-card { grid-template-columns: 1fr; }
  .request-main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .request-card .actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .request-card .actions button { width: 100%; min-width: 0; }
  .appointment { padding: 12px; }
  .actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .actions button, .actions .button-link { width: 100%; }
  .toolbar input, .toolbar select { width: 100%; min-width: 0; }
  .toolbar button { width: 100%; }
  .details { grid-template-columns: 1fr; }
  th, td { padding: 8px 6px; overflow-wrap: normal; word-break: normal; hyphens: none; font-size: 12px; }
  table { min-width: 560px; width: 100%; table-layout: auto; }
  .panel > div[style*="overflow"] { margin-left: -6px; margin-right: -6px; padding: 0 6px 4px; overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
  .panel { padding: 14px; }
  .login-panel { padding: 22px; }
  .brand.large .brand-mark { width: 42px; height: 42px; }
}
@media (max-width: 430px) {
  .public-hero h1 { font-size: 27px; }
  .calendar { grid-template-columns: 1fr; }
  .actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .request-main { grid-template-columns: 1fr; }
  .request-card .actions { grid-template-columns: 1fr; }
  .time-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .time-grid button { width: 100%; }
  .odontogram { grid-template-columns: repeat(4, 1fr); }
  .tooth { min-height: 58px; }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-item { min-width: 0; padding: 9px 10px; }
  .metric, .panel { border-radius: 7px; }
  table { min-width: 520px; }
}
@media print {
  .sidebar, .topbar, .toolbar, button { display: none !important; }
  .app { display: block; }
  .main { padding: 0; }
  .panel, .print-area { border: 0; }
}

/* Pulido visual para presentacion comercial */
body { background: #f3f6f8; }
button, .button-link, input, select, textarea { transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease; }
button:hover, .button-link:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(15, 40, 60, .08); }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 118, 110, .13); }
.sidebar { background: linear-gradient(180deg, #0b302f, #092423); box-shadow: inset -1px 0 0 rgba(255,255,255,.06); }
.sidebar .brand { padding: 4px 2px 10px; border-bottom: 1px solid rgba(255,255,255,.08); }
.nav-item { border-radius: 7px; }
.nav-item.active { background: rgba(255,255,255,.15); box-shadow: inset 3px 0 0 #5eead4; }
.topbar { box-shadow: 0 6px 20px rgba(15, 40, 60, .05); }
.main { max-width: 1440px; width: 100%; }
.metric, .panel, .request-card, .appointment, .user-edit-card, .tooth-detail, .print-area { box-shadow: 0 10px 26px rgba(15, 40, 60, .055); }
.metric { position: relative; overflow: hidden; border-color: #d8e5ea; }
.metric::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--primary); opacity: .9; }
.metric span { padding-left: 4px; }
.metric strong { color: #0f2f2d; letter-spacing: 0; }
.panel { border-color: #d8e5ea; }
.panel h2 { color: #0f2f2d; font-size: 22px; line-height: 1.2; }
th { background: #f8fafc; color: #334155; font-weight: 800; }
tbody tr:hover { background: #fbfefd; }
.badge { white-space: nowrap; }
.public-shell { background: radial-gradient(circle at top left, rgba(20,184,166,.18), transparent 36%), linear-gradient(135deg, #e8f5f4, #f7fbff); }
.public-card { border-color: #d5e6ec; }
.public-hero { background: linear-gradient(180deg, #ffffff, #fbfdfd); }
.public-hero h1 { color: #0d2322; }
.public-steps > div { background: #f7fbfc; }
.calendar-day, .tooth { border-color: #d7e5ec; }
.calendar-day:not(.disabled):hover, .tooth:hover { border-color: var(--primary); box-shadow: 0 8px 18px rgba(15, 40, 60, .08); }
.appointment { border-left-width: 6px; }
.actions button { min-width: 92px; }
.panel table td:last-child { white-space: nowrap; }
.panel table td:last-child button { margin: 0; }
.table-actions { display: flex; gap: 6px; flex-wrap: nowrap; }
.request-card .actions button { min-width: 108px; }
@media (max-width: 760px) {
  .main { max-width: none; }
  .sidebar .brand { border-bottom: 0; }
  .nav-item.active { box-shadow: inset 0 -3px 0 #5eead4; }
  .metric, .panel { box-shadow: 0 7px 18px rgba(15, 40, 60, .045); }
  .panel h2 { font-size: 20px; }
  .actions button { min-width: 0; }
  .request-card .actions button { min-width: 0; }
  .table-actions { flex-wrap: wrap; }
  .panel table td:last-child { min-width: 160px; }
  .whatsapp-message { max-width: 220px; }
  .whatsapp-card { grid-template-columns: 1fr; }
  .whatsapp-card-main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
