body { background: var(--rubor); font-size: 1rem; }
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

/* Barra lateral */
.side { background: var(--papel); border-right: 1px solid var(--linea); padding: 20px 16px; display: flex; flex-direction: column; gap: 24px; position: sticky; top: 0; height: 100vh; }
.side__brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--serif); font-size: 1.3rem; padding: 0 8px; }
.side__brand img { mix-blend-mode: multiply; }
.side__nav { display: grid; gap: 4px; }
.side__nav button { text-align: left; min-height: 42px; padding: 0 12px; border-radius: var(--r-s); border: 0; background: none; font-weight: 600; color: var(--ciruela-suave); cursor: pointer; }
.side__nav button:hover { background: var(--rubor); }
.side__nav button.is-on { background: var(--frambuesa-velo); color: var(--frambuesa-hondo); }
.side__user { margin-top: auto; display: flex; gap: 10px; align-items: center; padding: 12px 8px 0; border-top: 1px solid var(--linea); font-size: .9rem; }
.side__user span:not(.avatar) { display: block; color: var(--ciruela-suave); font-size: .85rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--frambuesa); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }

.gcal { border: 1px solid var(--linea); border-radius: var(--r-m); padding: 14px; font-size: .9rem; display: grid; gap: 8px; }
.gcal strong { display: flex; align-items: center; gap: 8px; }
.gcal strong::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--eucalipto); box-shadow: 0 0 0 3px var(--eucalipto-velo); }
.gcal.is-syncing strong::before { background: var(--aviso); box-shadow: 0 0 0 3px var(--aviso-velo); }
.gcal p { margin: 0; color: var(--ciruela-suave); }
.gcal button { justify-self: start; background: none; border: 0; padding: 0; font-weight: 600; color: var(--frambuesa-hondo); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* Zona principal */
.main { padding: 24px clamp(16px, 3vw, 36px) 48px; min-width: 0; }
.bar { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.bar h1 { font-size: 2rem; margin: 0; }
.bar p { margin: 4px 0 0; color: var(--ciruela-suave); }
.bar__actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.weeknav { display: flex; gap: 4px; align-items: center; margin-right: 8px; }
.iconbtn { width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--linea); background: var(--papel); cursor: pointer; font-size: 1.2rem; line-height: 1; }
.iconbtn:hover { border-color: var(--frambuesa); }

.today { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.today > div { background: var(--papel); border: 1px solid var(--linea); border-radius: var(--r-m); padding: 14px 16px; }
.today dt { font-size: .85rem; color: var(--ciruela-suave); }
.today dd { margin: 2px 0 0; font-family: var(--serif); font-size: 1.35rem; line-height: 1.25; }
.today dd small { font-family: var(--sans); font-size: .9rem; color: var(--ciruela-suave); display: block; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .85rem; color: var(--ciruela-suave); margin-bottom: 12px; }
.lg::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -2px; border-left: 3px solid; }
.lg--web::before { background: var(--frambuesa-velo); border-color: var(--frambuesa); }
.lg--manual::before { background: #efe8ee; border-color: var(--ciruela); }
.lg--compania::before { background: var(--eucalipto-velo); border-color: var(--eucalipto); }
.lg--google::before { background: #eef0f3; border-color: #7a8291; }
.lg--block::before { background: repeating-linear-gradient(135deg, #e9dde3 0 3px, #fff 3px 6px); border-color: #a8949f; }

/* Semana */
.week { background: var(--papel); border: 1px solid var(--linea); border-radius: var(--r-m); overflow-x: auto; }
.week__grid { display: grid; grid-template-columns: 56px repeat(5, minmax(150px, 1fr)); min-width: 820px; }
.week__head { position: sticky; top: 0; z-index: 3; background: var(--papel); border-bottom: 1px solid var(--linea); padding: 10px 10px 8px; }
.week__head strong { display: block; font-weight: 600; text-transform: capitalize; }
.week__head span { font-size: .85rem; color: var(--ciruela-suave); }
.week__head.is-today strong { color: var(--frambuesa-hondo); }
.week__head.is-today { box-shadow: inset 0 -3px 0 var(--frambuesa); }
.week__corner { border-bottom: 1px solid var(--linea); }
.axis { position: relative; }
.axis span { position: absolute; right: 8px; transform: translateY(-50%); font-size: .75rem; color: var(--ciruela-suave); font-variant-numeric: tabular-nums; }
.col { position: relative; border-left: 1px solid var(--linea); background: repeating-linear-gradient(135deg, #faf6f8 0 6px, #f5eef2 6px 12px); cursor: copy; }
.col .open { position: absolute; left: 0; right: 0; background: var(--papel); }
.col .hline { position: absolute; left: 0; right: 0; border-top: 1px solid #f1e7ec; pointer-events: none; }
.col .now { position: absolute; left: 0; right: 0; border-top: 2px solid var(--frambuesa); z-index: 2; pointer-events: none; }
.col .now::before { content: ""; position: absolute; left: -5px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--frambuesa); }

.ev { position: absolute; left: 4px; right: 4px; z-index: 1; border-radius: 8px; border: 0; border-left: 4px solid; padding: 4px 8px; text-align: left; overflow: hidden; cursor: pointer; font-size: .8rem; line-height: 1.25; display: block; }
.ev strong { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev span { display: block; color: var(--ciruela-suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev:hover { filter: brightness(.97); box-shadow: 0 2px 8px -2px rgba(52, 23, 43, .25); z-index: 2; }
.ev--web { background: var(--frambuesa-velo); border-color: var(--frambuesa); }
.ev--manual { background: #efe8ee; border-color: var(--ciruela); }
.ev--compania { background: var(--eucalipto-velo); border-color: var(--eucalipto); }
.ev--google { background: #eef0f3; border-color: #7a8291; }
.ev--block { background: repeating-linear-gradient(135deg, #efe4ea 0 5px, #fbf7f9 5px 10px); border-color: #a8949f; }
.ev .pending { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--aviso); }
.ev.is-new { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 3px var(--frambuesa); } }

/* Lista */
.list { background: var(--papel); border: 1px solid var(--linea); border-radius: var(--r-m); padding: 8px 0; }
.list__filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px 16px; border-bottom: 1px solid var(--linea); }
.list h3 { font-family: var(--sans); font-weight: 700; font-size: .95rem; margin: 0; padding: 18px 16px 8px; color: var(--ciruela-suave); }
.row { display: grid; grid-template-columns: 70px 1.4fr 1fr 130px 110px; gap: 12px; align-items: center; padding: 12px 16px; border-top: 1px solid #f3eaef; width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; cursor: pointer; }
.row:hover { background: var(--rubor); }
.row time { font-weight: 700; font-variant-numeric: tabular-nums; }
.row small { display: block; color: var(--ciruela-suave); }
.row.is-cancelled { opacity: .55; }
.row.is-cancelled strong { text-decoration: line-through; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--rubor); white-space: nowrap; justify-self: start; }
.badge--web { background: var(--frambuesa-velo); color: var(--frambuesa-hondo); }
.badge--manual { background: #efe8ee; color: var(--ciruela); }
.badge--compania { background: var(--eucalipto-velo); color: #1f4f48; }
.badge--ok::before, .badge--pending::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--eucalipto); }
.badge--pending::before { background: var(--aviso); }
.badge--off { color: #a3281c; background: #fbe9e7; }
.empty { padding: 32px 16px; color: var(--ciruela-suave); }

/* Detalle */
.drawer { position: fixed; inset: 0; z-index: 60; }
.drawer__scrim { position: absolute; inset: 0; background: rgba(52, 23, 43, .28); }
.drawer__panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(440px, 100%); background: var(--papel); padding: 28px 24px; overflow-y: auto; box-shadow: -12px 0 40px -12px rgba(52, 23, 43, .3); animation: slide .22s ease-out; }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer__close { position: absolute; top: 16px; right: 16px; }
.drawer h2 { font-size: 1.6rem; margin: 8px 40px 4px 0; }
.drawer .when { color: var(--ciruela-suave); margin-bottom: 20px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 10px 16px; margin: 0 0 24px; }
.kv dt { color: var(--ciruela-suave); font-size: .9rem; }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.drawer__actions { display: grid; gap: 10px; }
.drawer__actions .btn { width: 100%; }
.btn--danger { background: none; border-color: #e7c2bd; color: #a3281c; }
.btn--danger:hover { background: #fbe9e7; border-color: #a3281c; }
.move { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 16px; border-radius: var(--r-m); background: var(--rubor); margin-bottom: 12px; }
.move .full { grid-column: 1 / -1; }
.info { padding: 12px 14px; border-radius: var(--r-s); background: #eef0f3; font-size: .92rem; color: #3d4450; margin-bottom: 16px; }

/* Modal */
.modal { width: min(520px, calc(100% - 32px)); border: 0; border-radius: var(--r-l); padding: 28px; box-shadow: 0 30px 80px -20px rgba(52, 23, 43, .45); }
.modal::backdrop { background: rgba(52, 23, 43, .35); }
.modal h2 { font-size: 1.6rem; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--rubor); border-radius: 999px; margin-bottom: 20px; }
.tabs button { flex: 1; min-height: 38px; border: 0; border-radius: 999px; background: none; font-weight: 600; color: var(--ciruela-suave); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--papel); color: var(--ciruela); box-shadow: 0 1px 3px rgba(52, 23, 43, .15); }
.mgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mgrid .full { grid-column: 1 / -1; }
.modal__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal .error-msg:empty { display: none; }
.fixed-note { font-size: .9rem; color: var(--ciruela-suave); margin: 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 140%); opacity: 0; pointer-events: none; background: var(--ciruela); color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 600; transition: transform .25s, opacity .25s; z-index: 80; }
.toast.is-on { transform: translate(-50%, 0); opacity: 1; }

/* Historial del paciente en el detalle */
.hist__title { font-family: var(--sans); font-weight: 700; font-size: 1rem; margin: 28px 0 4px; padding-top: 20px; border-top: 1px solid var(--linea); }
.hist__empty { color: var(--ciruela-suave); font-size: .92rem; margin: 0 0 8px; }
.hist { list-style: none; margin: 0; padding: 0; }
.hist button { width: 100%; display: grid; grid-template-columns: 96px 1fr auto; gap: 10px; align-items: baseline; padding: 10px 6px; border: 0; border-bottom: 1px solid #f3eaef; background: none; text-align: left; cursor: pointer; font-size: .92rem; }
.hist button:hover { background: var(--rubor); }
.hist time { font-weight: 700; font-variant-numeric: tabular-nums; }
.hist em { font-style: normal; font-size: .8rem; color: var(--ciruela-suave); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--linea); }
  .side__nav { display: flex; }
  .gcal, .side__user { display: none; }
  .today { grid-template-columns: 1fr; }
  .row { grid-template-columns: 60px 1fr; }
  .row > :nth-child(n+3) { grid-column: 2; }
  .mgrid { grid-template-columns: 1fr; }
}

/* Solicitudes pendientes */
.side__nav button { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.count:empty { display: none; }
.count { min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px; background: var(--aviso); color: #fff; font-size: .8rem; display: inline-grid; place-items: center; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; padding: 14px 18px; border-radius: var(--r-m); background: var(--aviso-velo); color: #6b3f00; border: 1px solid #f0d6a8; text-decoration: none; }
.banner span { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.banner:hover { border-color: var(--aviso); }

.today > button { text-align: left; font: inherit; color: inherit; cursor: pointer; background: var(--papel); border: 1px solid var(--linea); border-radius: var(--r-m); padding: 14px 16px; }
.today > button:hover { border-color: var(--aviso); }
.today__pending.has-pending { background: var(--aviso-velo); border-color: #f0d6a8; }
.today__pending.has-pending dd { color: #6b3f00; }

.lg--wait::before { background: var(--aviso-velo); border-color: var(--aviso); }
.ev--wait { background: repeating-linear-gradient(135deg, #fdf1dc 0 6px, #fbe7c4 6px 12px); border-color: var(--aviso); outline: 1.5px dashed var(--aviso); outline-offset: -1.5px; }
.badge--wait { background: var(--aviso-velo); color: var(--aviso); }
.badge--off { color: #a3281c; background: #fbe9e7; }

.requests { display: grid; gap: 12px; }
.requests__bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--ciruela-suave); font-size: .95rem; }
.req { display: grid; grid-template-columns: 72px 1fr auto; gap: 18px; align-items: start; background: var(--papel); border: 1px solid var(--linea); border-left: 4px solid var(--aviso); border-radius: var(--r-m); padding: 18px; }
.req__date { display: grid; justify-items: center; padding: 10px 0; border-radius: 12px; background: var(--aviso-velo); color: #6b3f00; line-height: 1.1; }
.req__date strong { font-family: var(--serif); font-weight: 400; font-size: 1.8rem; color: var(--ciruela); }
.req__date span { font-size: .8rem; }
.req h3 { font-size: 1.35rem; margin: 0 0 4px; }
.req__what { font-weight: 600; margin: 0 0 4px; }
.req__meta { color: var(--ciruela-suave); font-size: .92rem; margin: 0 0 8px; }
.req__notes { margin: 0 0 12px; padding: 10px 14px; border-radius: var(--r-s); background: var(--rubor); font-size: .95rem; }
.req__actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.req__open { white-space: nowrap; }
.deny { margin-top: 8px; padding: 14px; border-radius: var(--r-m); background: #fdf4f2; border: 1px solid #f1d4cf; display: grid; gap: 10px; }
.deny__title { margin: 0; font-weight: 600; }
.deny__title .hint { font-weight: 400; color: var(--ciruela-suave); font-size: .88rem; }
.deny__reasons { display: grid; gap: 6px; }
.deny__reasons label { display: flex; gap: 8px; align-items: center; font-size: .95rem; cursor: pointer; }
.deny__reasons input { accent-color: #a3281c; width: 18px; height: 18px; }
.deny__actions { display: flex; gap: 12px; align-items: center; }
.empty-state { background: var(--papel); border: 1px dashed var(--linea); border-radius: var(--r-m); padding: 32px; text-align: center; }
.empty-state p { color: var(--ciruela-suave); max-width: 52ch; margin: 0 auto; }
.requests__sub { font-family: var(--sans); font-weight: 700; font-size: 1rem; margin: 20px 0 0; color: var(--ciruela-suave); }
.answered { list-style: none; margin: 0; padding: 0; background: var(--papel); border: 1px solid var(--linea); border-radius: var(--r-m); overflow: hidden; }
.answered button { width: 100%; display: grid; grid-template-columns: 110px 1fr 1.4fr auto; gap: 12px; align-items: center; padding: 12px 16px; border: 0; border-top: 1px solid #f3eaef; background: none; text-align: left; cursor: pointer; }
.answered li:first-child button { border-top: 0; }
.answered button:hover { background: var(--rubor); }
.answered em { font-style: normal; font-size: .85rem; color: var(--ciruela-suave); }
.pendbox { padding: 14px; border-radius: var(--r-m); background: var(--aviso-velo); margin-bottom: 20px; }
.pendbox p { margin: 0 0 10px; color: #6b3f00; font-size: .95rem; }

/* Correos */
.mailrow { grid-template-columns: 110px 1fr 150px 100px; }
.mailrow time { font-weight: 500; font-size: .9rem; color: var(--ciruela-suave); }
.mailmeta { font-size: .92rem; }
.email { border: 1px solid var(--linea); border-radius: var(--r-m); padding: 24px; background: #fff; box-shadow: var(--sombra); }
.email__logo { width: 96px; height: auto; margin: 0 auto 16px; mix-blend-mode: multiply; }
.email__details { width: 100%; border-collapse: collapse; margin: 12px 0 18px; font-size: .95rem; }
.email__details th { text-align: left; font-weight: 500; color: var(--ciruela-suave); padding: 7px 12px 7px 0; vertical-align: top; width: 110px; border-bottom: 1px solid #f3eaef; }
.email__details td { padding: 7px 0; font-weight: 600; border-bottom: 1px solid #f3eaef; }
.email__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.email__att { font-size: .9rem; color: var(--ciruela-suave); }
.email__note { font-size: .92rem; color: var(--ciruela-suave); }
.email__sign { margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--linea); font-size: .85rem; color: var(--ciruela-suave); }

@media (max-width: 900px) {
  .side__nav { flex-wrap: wrap; }
  .req { grid-template-columns: 56px 1fr; }
  .req__open { grid-column: 2; justify-self: start; }
  .answered button { grid-template-columns: 1fr; gap: 2px; }
  .mailrow { grid-template-columns: 1fr; }
}

/* Pantalla de acceso al panel */
.gate { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; background: var(--rubor); }
.gate__card { width: min(420px, 100%); background: var(--papel); border-radius: var(--r-l); box-shadow: var(--sombra); padding: 32px 28px; text-align: center; display: grid; gap: 10px; }
.gate__card img { margin: 0 auto; mix-blend-mode: multiply; }
.gate__card h1 { font-size: 1.7rem; margin: 4px 0 0; }
.gate__lead { color: var(--ciruela-suave); margin: 0; }
#gate-google { display: flex; justify-content: center; min-height: 0; }
.gate__test { display: grid; gap: 8px; text-align: left; padding: 14px; border-radius: var(--r-m); background: var(--aviso-velo); }
.gate__test label { font-weight: 600; font-size: .9rem; }
.gate__note { margin: 0; font-size: .88rem; color: var(--ciruela-suave); }

/* Paciente conocida o nueva en el alta de citas */
.who-hint { font-size: .88rem; color: var(--ciruela-suave); min-height: 1.2em; }
.who-hint.is-known { color: #1f4f48; font-weight: 600; }
.gate__form { display: grid; gap: 8px; text-align: left; }
.gate__form label { font-weight: 600; font-size: .9rem; }
.gate__code { font-size: 1.4rem; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.gate__info { margin: 0 0 4px; font-size: .92rem; color: #1f4f48; background: var(--eucalipto-velo); padding: 10px 12px; border-radius: var(--r-s); }
.gate__or { display: flex; align-items: center; gap: 10px; color: var(--ciruela-suave); font-size: .88rem; margin: 6px 0 0; }
.gate__or::before, .gate__or::after { content: ""; flex: 1; border-top: 1px solid var(--linea); }
.gate .error-msg:empty { display: none; }
