/* MAHŌ Hub — same palette as the public website */
:root {
  --ivory: #f7f3ec; --white: #fffdf9; --sand: #ece4d6; --line: #ddd3c2;
  --ink: #1d2433; --muted: #5d6475; --navy: #14275e; --navy-2: #1f3a80; --gold: #b08d57;
  --ok: #2f7d4f; --warn: #b7791f; --bad: #b23a3a; --info: #2d5bb8;
  --radius: 12px;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--ivory); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: var(--navy-2); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; color: var(--navy); margin: 0 0 .4em; line-height: 1.15; }
h1 { font-size: 2rem; } h2 { font-size: 1.5rem; } h3 { font-size: 1.2rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Layout */
.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #d6dcec; padding: 22px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--serif); color: #fff; font-size: 1.6rem; letter-spacing: .14em; padding: 0 10px 18px; }
.brand img { flex: none; }
.brand small { display: block; font: 600 .6rem/1 var(--sans); letter-spacing: .3em; color: var(--gold); margin-top: 2px; }
.side a { color: #d6dcec; text-decoration: none; padding: 9px 12px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; }
.side a:hover { background: rgba(255,255,255,.07); }
.side a.active { background: rgba(255,255,255,.13); color: #fff; }
.side .badge { background: var(--gold); color: #fff; font-size: .72rem; padding: 1px 7px; border-radius: 99px; }
.side .spacer { flex: 1; }
.made-by { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: .68rem; letter-spacing: .04em; color: var(--muted); text-decoration: none; opacity: .75; transition: opacity .2s; }
.made-by:hover { opacity: 1; }
.made-by img { display: block; height: 34px; width: auto; border-radius: 5px; }
.side a.made-by { justify-content: flex-start; color: #8a96b8; padding: 14px 12px 0; gap: 5px; }
.side a.made-by:hover { background: none; }
.side a.made-by img { height: 30px; }
.login-credit { text-align: center; margin-top: 22px; }
.login-credit .made-by img { box-shadow: 0 0 0 1px var(--line); }
.main { padding: 28px 32px 60px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }

/* Cards and grids */
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g2 { grid-template-columns: 1fr 1fr; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stat strong { display: block; font-family: var(--sans); font-weight: 600; font-size: 1.7rem; color: var(--navy); line-height: 1.1; }
.stat span { color: var(--muted); font-size: .85rem; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr.click { cursor: pointer; } tr.click:hover td { background: #fbf8f2; }

/* Pills */
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--sand); color: var(--ink); white-space: nowrap; }
.s-booked { background: #e6ecf8; color: var(--info); } .s-confirmed { background: #e3f1e8; color: var(--ok); }
.s-arrived { background: #fff3d6; color: var(--warn); } .s-completed { background: #e8e8e8; color: #444; }
.s-no_show, .s-late_cancel { background: #f8e3e3; color: var(--bad); } .s-cancelled { background: #eee; color: #777; text-decoration: line-through; }
.blood { background: #f8e3e3; color: var(--bad); } .dosha { background: #efe7d6; color: #7a5a22; }

/* Buttons and forms */
.btn { border: 0; border-radius: 99px; padding: 9px 18px; font: 600 .88rem var(--sans); cursor: pointer; background: var(--navy); color: #fff; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: var(--navy-2); }
.btn.ghost { background: transparent; color: var(--navy); border: 1px solid var(--navy); }
.btn.gold { background: var(--gold); } .btn.danger { background: var(--bad); } .btn.ok { background: var(--ok); }
.btn.sm { padding: 5px 12px; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; color: var(--ink); }
textarea { min-height: 80px; }
.form { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.form .full { grid-column: 1 / -1; }
.check { display: block; font-weight: 500; color: var(--ink); font-size: .9rem; }
.check input { width: auto; margin: 0 8px 0 0; vertical-align: -2px; }

/* Calendar */
.cal { display: grid; border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: var(--white); }
.cal-head { position: sticky; top: 0; background: var(--white); z-index: 2; font-size: .78rem; font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); text-align: center; }
.cal-time { font-size: .72rem; color: var(--muted); padding: 2px 6px; border-top: 1px solid var(--line); }
.cal-col { position: relative; border-left: 1px solid var(--line); }
.cal-slot { border-top: 1px solid #efe9de; height: 24px; }
.cal-slot:hover { background: #f4efe5; cursor: pointer; }
.appt { position: absolute; left: 3px; right: 3px; border-radius: 8px; padding: 4px 7px; font-size: .74rem; line-height: 1.25; overflow: hidden; cursor: pointer; background: #e6ecf8; border-left: 3px solid var(--info); }
.appt.confirmed { background: #e3f1e8; border-color: var(--ok); } .appt.arrived { background: #fff3d6; border-color: var(--warn); }
.appt.completed { background: #ececec; border-color: #888; } .appt.no_show, .appt.late_cancel { background: #f8e3e3; border-color: var(--bad); }
.appt b { display: block; }

/* Leads board */
.board { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 12px; overflow-x: auto; }
.lane { background: var(--sand); border-radius: var(--radius); padding: 10px; min-height: 300px; }
.lane h3 { font-size: 1rem; display: flex; justify-content: space-between; }
.chat { max-height: 55vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px; }
.bubble { max-width: 80%; padding: 8px 12px; border-radius: 12px; word-break: break-word; }
.bubble .txt { white-space: pre-wrap; }
.bubble.in { align-self: flex-start; background: var(--sand); }
.bubble.out { align-self: flex-end; background: var(--white); border: 1px solid var(--line); }
.lead { background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; cursor: pointer; font-size: .86rem; }

/* Links panel */
.links { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.links a { display: flex; align-items: center; gap: 10px; background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 12px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: .88rem; }
.links a:hover { border-color: var(--navy-2); }
.links .ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-size: .8rem; flex: none; }
.ico.stripe { background: #635bff; } .ico.clinic { background: var(--navy); }

/* Modal and toast */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 39, 94, .35); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--white); border-radius: 16px; padding: 24px; width: min(760px, 100%); max-height: 90vh; overflow: auto; min-width: 0; }
.modal select, .modal input { max-width: 100%; min-width: 0; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 10px; z-index: 60; max-width: 420px; }
.toast.err { background: var(--bad); }
.empty { color: var(--muted); padding: 20px; text-align: center; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin: 16px 0; overflow-x: auto; }
.tabs button { flex: none; } #tab .card { overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; font: 600 .88rem var(--sans); color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--navy); border-color: var(--gold); }
.notice { background: #fff6e0; border: 1px solid #ecd9a8; border-radius: 10px; padding: 10px 14px; font-size: .86rem; }

/* Login and public pages */
.center { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: min(380px, 100%); }
.pub { max-width: 760px; margin: 0 auto; padding: 32px 20px 60px; }
.pub header { text-align: center; margin-bottom: 28px; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.slots button { padding: 9px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; font: 600 .88rem var(--sans); color: var(--navy); }
.slots > span { grid-column: 1 / -1; }
.slots button.on { background: var(--navy); color: #fff; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 16px; background: var(--white); }
legend { font-family: var(--serif); font-size: 1.2rem; color: var(--navy); padding: 0 6px; font-weight: 600; }
.legal-foot { font-size: .75rem; color: var(--muted); text-align: center; margin-top: 30px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .brand { padding: 4px 10px; font-size: 1.2rem; width: 100%; }
  .side .spacer { display: none; }
  .side a.made-by { width: 100%; padding: 8px 12px 4px; }
  .main { padding: 18px 14px; }
  .g4 { grid-template-columns: 1fr 1fr; } .g3, .g2, .form { grid-template-columns: 1fr; }
  .card { overflow-x: auto; }
  .sig-grid { grid-template-columns: 1fr; }
}
.login-logo { text-align: center; margin-bottom: 22px; }
.login-logo .lw { font-family: var(--serif); font-size: 2rem; font-weight: 600; letter-spacing: .16em; color: var(--navy); margin-top: 8px; }
.login-logo .ls { font: 600 .62rem/1 var(--sans); letter-spacing: .32em; color: var(--gold); margin-top: 4px; }

/* Products and suppliers */
.good { color: var(--ok) !important; } .bad { color: var(--bad) !important; }
.notice.bad { background: #fbeaea; border-color: #ecc3c3; }
.notice.ok-n { background: #e9f4ed; border-color: #bfdcc9; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 14px; font: 600 .8rem var(--sans); color: var(--muted); cursor: pointer; }
.chips button.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.meter { display: inline-block; width: 70px; height: 8px; background: var(--sand); border-radius: 99px; overflow: hidden; vertical-align: middle; margin-right: 6px; }
.meter i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.meter.mid i { background: var(--warn); } .meter.low i { background: var(--bad); }
.vbars { display: flex; align-items: flex-end; gap: 14px; height: 170px; padding-top: 10px; }
.vbar { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.vbar .cols { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.vbar .cols i { width: 38%; max-width: 26px; border-radius: 6px 6px 0 0; min-height: 2px; transition: height .4s; }
.vbar span { font-size: .75rem; color: var(--muted); margin-top: 6px; text-transform: capitalize; }
i.rev { background: #d4ad6a; } i.pro { background: var(--navy); }
.legend { display: flex; gap: 16px; font-size: .78rem; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.hbar { display: grid; grid-template-columns: 1.2fr 2fr auto; gap: 10px; align-items: center; font-size: .86rem; margin: 9px 0; }
.hbar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar div { height: 10px; background: var(--sand); border-radius: 99px; overflow: hidden; }
.hbar div i { display: block; height: 100%; background: linear-gradient(90deg, #d4ad6a, var(--gold)); border-radius: 99px; }
.sup-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.sup { border-left: 4px solid var(--ok); display: flex; flex-direction: column; gap: 4px; }
.sup.missing, .sup.expired { border-left-color: var(--bad); } .sup.expiring { border-left-color: var(--warn); } .sup.na { border-left-color: #999; }
#plist { overflow-x: auto; }

/* Precios */
.price-group { margin-bottom: 14px; }
.price-group h3 { margin-top: 0; }
.pick { width: 28px; padding-right: 0; }
.pick input { width: 18px; height: 18px; cursor: pointer; }
.pickbar { position: sticky; bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.18); z-index: 20; }
.pickbar[hidden] { display: none; }
.pickbar .btn.ghost { color: #fff; border-color: rgba(255,255,255,.5); }
.nowrap { white-space: nowrap; }
.consent-text { white-space: pre-wrap; background: var(--sand); border-radius: 10px; padding: 14px; max-height: 320px; overflow: auto; font-size: .88rem; margin-top: 10px; line-height: 1.5; }
.sig canvas { width: 100%; height: 130px; border: 1px dashed var(--line); border-radius: 10px; background: #fff; display: block; margin-bottom: 6px; }
.sig-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 16px; }
.sig-print img { width: 100%; max-width: 320px; height: auto; border-bottom: 1px solid #333; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 560px; }
@media print {
  .side, .topbar .row, #pq, .tabs, .toast, .pickbar, .pick, [data-copy], [data-void], .no-print { display: none !important; }
  .consent-text { max-height: none; overflow: visible; background: none; padding: 0; }
  .app { display: block; }
  .main { padding: 0; }
  .card { border: 0; padding: 0 0 10px; break-inside: avoid; }
  .clamp { display: none; }
}

/* Marketing templates */
.tpl-h { margin: 22px 0 10px; font-size: 1rem; color: var(--navy); }
.tpl-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.tpl { display: flex; flex-direction: column; gap: 4px; border-top: 3px solid var(--gold); }
.tpl-name { font-weight: 600; color: var(--navy); }
.tpl-subj { font-size: .88rem; font-style: italic; margin: 6px 0 2px; }

/* Search-as-you-type list for patient (and other) pickers */
.picker { position: fixed; z-index: 100; display: none; background: var(--white); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(20, 39, 94, .18); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.picker-item { padding: 11px 12px; cursor: pointer; border-bottom: 1px solid var(--sand); font-size: .95rem; }
.picker-item:last-child { border-bottom: 0; }
.picker-item:hover, .picker-item.on { background: var(--sand); }
.picker-more { padding: 9px 12px; font-size: .8rem; color: var(--muted); }
.btn.ghost.danger { background: transparent; color: var(--bad); border-color: var(--bad); }

/* Agenda: Día / Semana / Mes */
.seg { display: inline-flex; border: 1px solid var(--navy); border-radius: 99px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 7px 14px; font: 600 .82rem var(--sans); color: var(--navy); cursor: pointer; }
.seg button.on { background: var(--navy); color: #fff; }
.cal-head.today { color: var(--navy); background: #f4efe5; }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); overflow: hidden; }
.month-head { font-size: .75rem; font-weight: 600; text-align: center; padding: 8px 2px; border-bottom: 1px solid var(--line); color: var(--muted); }
.month-day { min-height: 104px; padding: 6px; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); cursor: pointer; overflow: hidden; }
.month-day:nth-child(7n + 1) { border-left: 0; }
.month-day:hover { background: #faf6ee; }
.month-day.other { background: #faf8f4; color: #b3ab9c; }
.month-day.today .month-num { color: #fff; background: var(--navy); border-radius: 99px; padding: 0 7px; display: inline-block; }
.month-num { font-weight: 600; font-size: .85rem; margin-bottom: 4px; }
.month-count { margin-left: 6px; font-size: .68rem; font-weight: 600; background: var(--sand); color: var(--navy); border-radius: 99px; padding: 1px 6px; }
.month-appt { font-size: .72rem; padding: 2px 5px; margin-bottom: 2px; border-radius: 5px; background: #e6ecf8; border-left: 2px solid var(--info); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.month-appt.confirmed { background: #e3f1e8; border-color: var(--ok); } .month-appt.arrived { background: #fff3d6; border-color: var(--warn); }
.month-appt.completed { background: #ececec; border-color: #888; } .month-appt.no_show { background: #f8e3e3; border-color: var(--bad); }
@media (max-width: 700px) { .month-day { min-height: 64px; padding: 3px; } .month-appt { display: none; } .month-count { display: inline-block; margin: 2px 0 0; } }

/* Blocked time and closed days on the agenda */
.blocked { position: absolute; left: 0; right: 0; z-index: 0; overflow: hidden; padding: 2px 6px; font-size: .7rem; color: #6b6458; cursor: pointer;
  background: repeating-linear-gradient(45deg, #ece6da, #ece6da 6px, #f6f2ea 6px, #f6f2ea 12px); border-top: 2px solid #c9bfae; }
.cal-col .appt { z-index: 1; }
.closed-day { position: absolute; inset: 0; z-index: 0; background: rgba(160, 60, 60, .07); pointer-events: none; display: flex; justify-content: center; padding-top: 6px; font-size: .72rem; color: var(--bad); }
.month-closed { font-size: .7rem; color: var(--bad); font-weight: 600; }
.month-block { font-size: .7rem; color: #6b6458; background: #ece6da; border-radius: 4px; padding: 1px 4px; margin: 1px 0; cursor: pointer; }
.wa-media { display: block; max-width: min(260px, 100%); max-height: 320px; border-radius: 10px; margin: 4px 0; }
audio.wa-media { width: 260px; max-width: 100%; }

/* "Más": actions used now and then, folded away until asked for */
details.more > summary { cursor: pointer; list-style: none; display: inline-flex; }
details.more > summary::-webkit-details-marker { display: none; }
details.more[open] > summary { margin-bottom: 8px; }
.more-box { border-top: 1px solid var(--line); padding-top: 10px; display: grid; gap: 10px; }
.more-box .row > .small.muted:first-child { min-width: 96px; }
.btn.lg { padding: 12px 28px; font-size: 1rem; }
.next-step { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.side details.more > summary { color: #d6dcec; padding: 9px 12px; border-radius: 8px; width: 100%; justify-content: space-between; align-items: center; }
.side details.more > summary:hover { background: rgba(255,255,255,.07); }
.side details.more[open] > summary { margin-bottom: 0; }
.side .more-links { display: flex; flex-direction: column; gap: 4px; }
.side .more-links a { padding-left: 22px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.chat-msgs { display: grid; gap: 4px; margin: 4px 0 6px; }
@media (max-width: 900px) {
  .side details.more { width: 100%; }
  .side .more-links { flex-direction: row; flex-wrap: wrap; }
  .side .more-links a { padding-left: 12px; }
}
