/* DermaCRM — hoja de estilos única (sin frameworks). Adaptable a computadora y teléfono. */
:root {
  --bg: #f7f3ee; --surface: #ffffff; --ink: #2f2520; --muted: #6a5b51; --line: #e4dbd1;
  --brand: #876b54; --brand-ink: #ffffff; --brand-soft: #f3ebe2; --accent: #b5776c;
  --ok: #1f7a46; --ok-bg: #e2f4e9; --bad: #b3261e; --bad-bg: #fbe5e3; --warn: #8a5a00; --warn-bg: #fdf0d3; --info: #1b5f8c; --info-bg: #e1eff9;
  --side: #3b2e27; --side-ink: #ecdfd3; --radius: 10px; --shadow: 0 1px 2px rgba(20,40,50,.08), 0 4px 14px rgba(20,40,50,.05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; } h2 { font-size: 1.1rem; margin: 0 0 .75rem; } h3 { font-size: 1rem; margin: 0 0 .5rem; }
small, .muted { color: var(--muted); } .right { text-align: right; } .nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }

/* Estructura */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 14px 10px 24px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 14px; font-weight: 700; font-size: 1.05rem; color: #fff; }
.side .brand b { background: var(--brand); color: var(--brand-ink); border-radius: 8px; padding: 2px 8px; }
.side .grp { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; opacity: .6; padding: 14px 12px 4px; }
.side a { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--side-ink); padding: 8px 12px; border-radius: 8px; text-decoration: none; }
.side a:hover { background: rgba(255,255,255,.07); }
.side a.on { background: var(--brand); color: var(--brand-ink); font-weight: 600; }
.side .cnt { background: var(--accent); color: #fff; border-radius: 999px; font-size: .72rem; padding: 0 7px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; padding: 10px 22px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top .grow { flex: 1; }
.top form.search { display: flex; gap: 6px; max-width: 420px; flex: 1; }
.top form.search input { flex: 1; }
.menu-btn { display: none; }
.content { padding: 22px; max-width: 1280px; width: 100%; margin: 0 auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Tarjetas y rejillas */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card > h2:first-child { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.grid { display: grid; gap: 16px; } .g2 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0,1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.kpi { display: block; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: inherit; text-decoration: none; }
.kpi:hover { border-color: var(--brand); text-decoration: none; }
.kpi .n { font-size: 1.7rem; font-weight: 700; line-height: 1.1; } .kpi .l { color: var(--muted); font-size: .85rem; }
.kpi.alert .n { color: var(--bad); }

/* Formularios */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; } .field.full { grid-column: 1 / -1; }
.field label { font-size: .85rem; font-weight: 600; } .field .req { color: var(--bad); } .field small { font-size: .78rem; }
.field.check label { font-weight: 500; display: flex; gap: 8px; align-items: flex-start; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; min-height: 40px; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; margin-top: 4px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
textarea { resize: vertical; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters .field { min-width: 150px; flex: 1 1 150px; max-width: 240px; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; border: 1px solid transparent; border-radius: 8px; padding: 8px 14px; min-height: 40px; cursor: pointer; text-decoration: none; background: var(--brand); color: var(--brand-ink); }
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--brand); border-color: var(--line); } .btn.ghost:hover { background: var(--brand-soft); }
.btn.danger { background: var(--bad); color: #fff; } .btn.secondary { background: var(--brand-soft); color: var(--brand); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Tablas */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:hover td { background: color-mix(in srgb, var(--brand-soft) 45%, transparent); }
.tbl tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.empty { color: var(--muted); padding: 14px 4px; margin: 0; }
.pager { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; } .pager-info { color: var(--muted); font-size: .85rem; margin-right: auto; }
.pg { padding: 5px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); } .pg.disabled { opacity: .45; }

/* Etiquetas y avisos */
.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); } .badge.info { background: var(--info-bg); color: var(--info); }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid transparent; }
.flash.success { background: var(--ok-bg); color: var(--ok); } .flash.danger { background: var(--bad-bg); color: var(--bad); } .flash.warning { background: var(--warn-bg); color: var(--warn); }
.banner { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.banner.bad { background: var(--bad-bg); color: var(--bad); } .banner.warn { background: var(--warn-bg); color: var(--warn); } .banner.ok { background: var(--ok-bg); color: var(--ok); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs a { padding: 8px 14px; border-radius: 8px 8px 0 0; color: var(--muted); text-decoration: none; border: 1px solid transparent; border-bottom: 0; }
.tabs a.on { background: var(--surface); color: var(--ink); border-color: var(--line); font-weight: 600; position: relative; top: 1px; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; } dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 14px; } .timeline li::before { content: ""; position: absolute; left: -22px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); border: 2px solid var(--surface); }
.timeline li.sys::before { background: var(--muted); }
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 480px; overflow-y: auto; padding: 4px; }
.bubble { max-width: 78%; padding: 8px 12px; border-radius: 12px; background: var(--brand-soft); } .bubble.out { align-self: flex-end; background: var(--brand); color: var(--brand-ink); } .bubble small { display: block; opacity: .75; }
.items td input { min-width: 70px; } .items td.desc input { min-width: 180px; }
.print-only { display: none; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; } .login .card { width: min(420px, 100%); }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 8px; } .cal .day { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px; min-height: 120px; } .cal .day h4 { margin: 0 0 6px; font-size: .85rem; }
.cal .day.today { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); } .appt { display: block; font-size: .82rem; padding: 4px 6px; margin-bottom: 4px; border-radius: 6px; background: var(--brand-soft); color: var(--ink); }
.appt.cancelled { opacity: .5; text-decoration: line-through; }

/* Teléfono */
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 25% 0 0; z-index: 40; transform: translateX(-105%); transition: transform .2s; height: 100vh; }
  body.nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
  .menu-btn { display: inline-flex; }
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .cal { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .content { padding: 14px 16px; } .top { padding: 8px 16px; }
  .g2, .g3 { grid-template-columns: 1fr; } .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; } .kpi { padding: 10px 12px; } .kpi .n { font-size: 1.35rem; }
  .top form.search { display: none; }
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; padding: 6px 8px; background: var(--surface); }
  .tbl td { border: 0; padding: 4px 4px; display: flex; gap: 10px; justify-content: space-between; text-align: right; }
  .tbl td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; text-transform: uppercase; text-align: left; flex: 0 0 38%; }
  .tbl tr:hover td { background: transparent; }
  .items td input, .items td select { min-width: 0; }
  dl.kv { grid-template-columns: 1fr; } dl.kv dt { margin-top: 6px; }
  .bubble { max-width: 92%; }
}
@media print {
  .side, .top, .no-print, .flash, .btn, .tabs, .filters, .pager { display: none !important; }
  .shell { display: block; } body { background: #fff; color: #000; } .card { box-shadow: none; border: 1px solid #bbb; break-inside: avoid; }
  .content { padding: 0; max-width: none; } .print-only { display: block; } .tbl th, .tbl td { padding: 4px 6px; font-size: 12px; } a { color: #000; }
}

/* Acceso */
.login { background: linear-gradient(135deg, #f7efe6, #e3d2bf 60%, #cdb9a2); }
.login .card { border-radius: 20px; padding: 28px; box-shadow: 0 18px 50px rgba(63,50,43,.18); }
.login .brand-mark { width: 64px; height: 64px; border-radius: 50%; background: #b9a58d; color: #fff; display: grid; place-content: center; text-align: center; line-height: 1.05; margin: 0 auto 14px; font-size: .5rem; letter-spacing: .24em; box-shadow: inset 0 0 0 2px rgba(255,255,255,.55); }
.login .brand-mark b { font-weight: 600; font-size: .6rem; }
.login h1 { font-family: Georgia, "Times New Roman", serif; text-align: center; font-weight: 600; }
.login .back { display: block; text-align: center; margin-top: 14px; font-size: .9rem; }

.items td select { min-width: 170px; }
@media (max-width: 640px) { .items td select { min-width: 0; } }
