:root{
  --bg:#F6F1E7;
  --surface:#FFFFFF;
  --ink:#26303D;
  --primary:#1F3A5F;
  --primary-dark:#14283F;
  --accent:#C1622D;
  --accent-light:#E8B896;
  --border:#E3DCCB;
  --muted:#8B8574;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
*{box-sizing:border-box;}
html,body{ height:100%; margin:0; }
body{ font-family:var(--sans); color:var(--ink); background:var(--bg); }
#app-mount{ min-height:100%; position:relative; overflow-x:hidden; }

.plot-grid{ position:absolute; inset:0; opacity:.35; pointer-events:none; z-index:0; }
.wrap{ position:relative; z-index:1; max-width:1180px; margin:0 auto; padding:28px 20px 60px; }

.topbar{ display:flex; align-items:center; justify-content:space-between; margin-bottom:22px; }
.brand{ display:flex; align-items:center; gap:10px; }
.brand-mark{ width:34px; height:34px; border-radius:8px; background:var(--primary); display:flex; align-items:center; justify-content:center; }
.brand-title{ font-weight:800; letter-spacing:.2px; font-size:18px; color:var(--primary-dark); }
.brand-sub{ font-size:11px; color:var(--muted); letter-spacing:.6px; text-transform:uppercase; }
.userbadge{ display:flex; align-items:center; gap:10px; font-size:13px; }
.pill{ background:var(--surface); border:1px solid var(--border); padding:6px 12px; border-radius:999px; font-size:12px; color:var(--primary-dark); font-weight:600; }
.btn{ border:none; cursor:pointer; font-family:var(--sans); font-weight:700; font-size:13px; padding:9px 16px; border-radius:8px; transition:transform .08s ease, opacity .15s ease; }
.btn:active{ transform:scale(.97); }
.btn-primary{ background:var(--accent); color:#fff; }
.btn-primary:hover{ opacity:.92; }
.btn-ghost{ background:transparent; color:var(--primary); border:1px solid var(--border); }
.btn-ghost:hover{ background:#fff; }
.btn-danger{ background:#fff; color:#B23A3A; border:1px solid #E7C6C6; }
.btn-sm{ padding:6px 10px; font-size:12px; border-radius:6px; }
.btn:disabled{ opacity:.5; cursor:not-allowed; }

.login-shell{ min-height:80vh; display:flex; align-items:center; justify-content:center; position:relative; z-index:1; }
.login-card{ width:380px; background:var(--surface); border:1px solid var(--border); border-radius:16px; padding:32px 30px; box-shadow:0 18px 40px -18px rgba(31,58,95,.35); }
.login-title{ font-size:21px; font-weight:800; color:var(--primary-dark); margin:0 0 2px; }
.login-sub{ font-size:13px; color:var(--muted); margin:0 0 22px; }
.field{ margin-bottom:14px; }
.field label{ display:block; font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.5px; color:var(--muted); margin-bottom:6px; }
.field select, .field input, .field textarea{ width:100%; padding:10px 12px; border-radius:8px; border:1px solid var(--border); font-family:var(--sans); font-size:14px; background:#fff; color:var(--ink); }
.field select:focus, .field input:focus, .field textarea:focus{ outline:2px solid var(--accent-light); border-color:var(--accent); }
.login-error{ color:#B23A3A; font-size:12.5px; margin:-4px 0 12px; min-height:14px; }
.login-btn{ width:100%; padding:11px 0; font-size:14px; margin-top:4px; }
.login-hint{ margin-top:16px; font-size:11.5px; color:var(--muted); line-height:1.5; }

.section-title{ font-size:12px; font-weight:800; text-transform:uppercase; letter-spacing:.7px; color:var(--muted); margin:26px 0 10px; }
.card{ background:var(--surface); border:1px solid var(--border); border-radius:14px; padding:18px; }
.grid-4{ display:grid; grid-template-columns:repeat(4,1fr); gap:14px; }
.grid-2{ display:grid; grid-template-columns:1fr 1fr; gap:14px; }
@media (max-width:820px){ .grid-4{grid-template-columns:1fr 1fr;} .grid-2{grid-template-columns:1fr;} }

/* ---------- Responsivo para celulares ---------- */
.table-wrap{ width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; border-radius:8px; }
.table-wrap table{ min-width:640px; }

@media (max-width:640px){
  .wrap{ padding:16px 12px 40px; }
  .topbar{ flex-wrap:wrap; gap:10px; }
  .brand-title{ font-size:16px; }
  .brand-sub{ display:none; }
  .userbadge{ width:100%; justify-content:space-between; }
  .pill{ font-size:11px; padding:5px 10px; }

  .login-card{ width:100%; max-width:340px; padding:24px 18px; }

  .grid-4{ grid-template-columns:1fr 1fr; gap:10px; }
  .stat{ padding:12px 14px; }
  .stat-num{ font-size:20px; }

  .tabs{ overflow-x:auto; -webkit-overflow-scrolling:touch; flex-wrap:nowrap; padding-bottom:4px; }
  .tab{ white-space:nowrap; padding:8px 12px; font-size:12.5px; }

  .toolbar{ flex-direction:column; align-items:stretch; gap:8px; }
  .toolbar > div:first-child{ margin-bottom:2px; }
  .search{ width:100%; }

  .card{ padding:14px; border-radius:12px; }
  table{ font-size:12px; }
  th, td{ padding:7px 8px; }

  .form-grid{ grid-template-columns:1fr; }
  .modal{ padding:18px; max-height:92vh; border-radius:12px; }
  .modal-overlay{ padding:0; align-items:flex-end; }
  .modal{ max-width:100%; width:100%; border-radius:16px 16px 0 0; }
  .modal-actions{ flex-direction:column-reverse; gap:8px; }
  .modal-actions .btn{ width:100%; }

  .vendor-list-row{ flex-direction:column; align-items:flex-start; gap:8px; }
  .vendor-list-row > div:last-child{ width:100%; display:flex; gap:8px; }
  .vendor-list-row .btn{ flex:1; }

  .toast{ left:12px; right:12px; transform:none; top:12px; font-size:13px; padding:12px 16px; animation:none; }

  .rank-row{ padding:9px 2px; }
}

@media (max-width:400px){
  .grid-4{ grid-template-columns:1fr; }
}


.stat{ padding:16px 18px; }
.stat-num{ font-family:var(--mono); font-size:26px; font-weight:700; color:var(--primary-dark); }
.stat-label{ font-size:11.5px; color:var(--muted); margin-top:4px; }

table{ width:100%; border-collapse:collapse; font-size:13px; }
th{ text-align:left; font-size:10.5px; text-transform:uppercase; letter-spacing:.4px; color:var(--muted); padding:8px 10px; border-bottom:2px solid var(--border); white-space:nowrap; }
td{ padding:8px 10px; border-bottom:1px solid var(--border); vertical-align:middle; }
tr:hover td{ background:#FBF8F1; }
.num-cell{ font-family:var(--mono); }

.badge{ display:inline-block; padding:3px 10px; border-radius:999px; font-size:11px; font-weight:700; white-space:nowrap; }
.rank-row{ display:flex; align-items:center; gap:10px; padding:8px 4px; border-bottom:1px solid var(--border); }
.rank-num{ width:24px; height:24px; border-radius:7px; display:flex; align-items:center; justify-content:center; font-size:11px; font-weight:800; background:var(--bg); color:var(--primary-dark); flex-shrink:0; }
.rank-num.gold{ background:#F4CD6A; }
.rank-num.silver{ background:#D6D6D6; }
.rank-num.bronze{ background:#D8A06E; color:#fff; }
.rank-name{ flex:1; font-size:13px; font-weight:600; }
.rank-val{ font-family:var(--mono); font-weight:700; color:var(--primary-dark); }

.empty{ padding:30px 10px; text-align:center; color:var(--muted); font-size:13px; }

.modal-overlay{ position:fixed; inset:0; background:rgba(20,26,35,.45); display:flex; align-items:center; justify-content:center; z-index:50; padding:16px; }
.modal{ background:#fff; border-radius:14px; width:100%; max-width:640px; max-height:88vh; overflow:auto; padding:26px; }
.modal h3{ margin:0 0 18px; font-size:17px; color:var(--primary-dark); }
.form-grid{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.form-grid .full{ grid-column:1 / -1; }
.modal-actions{ display:flex; justify-content:flex-end; gap:10px; margin-top:20px; }
.modal-error{ color:#B23A3A; font-size:12.5px; margin-bottom:10px; }

.tabs{ display:flex; gap:6px; margin-bottom:18px; }
.tab{ padding:8px 16px; border-radius:9px; font-size:13px; font-weight:700; cursor:pointer; color:var(--muted); border:1px solid transparent; }
.tab.active{ background:var(--surface); color:var(--primary-dark); border-color:var(--border); }

.vendor-list-row{ display:flex; align-items:center; justify-content:space-between; padding:12px 4px; border-bottom:1px solid var(--border); gap:10px; }
.vendor-list-row .v-name{ font-weight:700; font-size:13.5px; }
.vendor-list-row .v-meta{ font-size:11.5px; color:var(--muted); }

.toolbar{ display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:14px; flex-wrap:wrap; }
.search{ padding:9px 12px; border-radius:8px; border:1px solid var(--border); font-size:13px; width:220px; }
.loading{ text-align:center; padding:60px 20px; color:var(--muted); font-size:13px; }
.today-alert{
  display:flex; align-items:flex-start; gap:12px;
  background:#FFF4E0; border:2px solid #F0A93E; border-left:6px solid #C97A0F;
  border-radius:10px; padding:14px 16px; margin-bottom:16px;
}
.today-alert-icon{ font-size:22px; flex-shrink:0; line-height:1; }
.today-alert-title{ font-size:14.5px; font-weight:800; color:#8A5A00; margin-bottom:4px; }
.today-alert-body{ font-size:13px; color:#7A5300; line-height:1.6; }

.dup-alert{
  display:flex; align-items:flex-start; gap:12px;
  background:#FDEDEC; border:2px solid #E45B5B; border-left:6px solid #C42F2F;
  border-radius:10px; padding:14px 16px; margin-bottom:16px;
  box-shadow:0 8px 22px -10px rgba(196,47,47,.45);
  animation:dup-alert-pulse 1.4s ease-in-out 2;
}
.dup-alert-icon{
  width:30px; height:30px; border-radius:50%; background:#C42F2F; color:#fff;
  display:flex; align-items:center; justify-content:center; font-size:16px; font-weight:800;
  flex-shrink:0;
}
.dup-alert-title{ font-size:14.5px; font-weight:800; color:#8F1E1E; margin-bottom:4px; }
.dup-alert-body{ font-size:13px; color:#7A2626; line-height:1.6; }
@keyframes dup-alert-pulse{
  0%, 100%{ box-shadow:0 8px 22px -10px rgba(196,47,47,.45); }
  50%{ box-shadow:0 8px 30px -6px rgba(196,47,47,.8); }
}

.toast{
  position:fixed; top:24px; left:50%; transform:translateX(-50%);
  background:#1F5C29; color:#fff; padding:16px 28px; border-radius:12px;
  font-size:15px; font-weight:700; z-index:200; letter-spacing:.2px;
  box-shadow:0 20px 45px -12px rgba(15,84,66,.55); display:flex; align-items:center; gap:10px;
  animation:toast-in .25s ease-out;
}
.toast::before{ content:"✓"; display:inline-flex; align-items:center; justify-content:center; width:22px; height:22px; border-radius:50%; background:rgba(255,255,255,.25); font-size:13px; flex-shrink:0; }
.toast.error{ background:#B23A3A; box-shadow:0 20px 45px -12px rgba(178,58,58,.55); }
.toast.error::before{ content:"!"; }
@keyframes toast-in{
  from{ opacity:0; transform:translateX(-50%) translateY(-14px); }
  to{ opacity:1; transform:translateX(-50%) translateY(0); }
}

.cal-grid{ display:grid; grid-template-columns:repeat(7,1fr); gap:6px; }
.cal-dow{ text-align:center; font-size:11px; font-weight:800; color:var(--muted); text-transform:uppercase; padding-bottom:6px; }
.cal-cell{
  min-height:64px; border:1px solid var(--border); border-radius:8px; padding:6px 8px;
  cursor:pointer; background:#fff; transition:background .12s ease;
  display:flex; flex-direction:column; justify-content:flex-start;
}
.cal-cell:hover{ background:var(--bg); }
.cal-empty{ border:none; cursor:default; background:transparent; }
.cal-empty:hover{ background:transparent; }
.cal-daynum{ font-size:12.5px; font-weight:700; color:var(--ink); }
.cal-today .cal-daynum{ color:var(--accent); }
.cal-today{ border-color:var(--accent); }
.cal-has-citas{ background:#FFF8ED; }
.cal-count{ margin-top:6px; font-size:10.5px; font-weight:800; color:#8A5A00; background:#FCE7B0; border-radius:6px; padding:2px 6px; align-self:flex-start; }
.cal-selected{ outline:2px solid var(--primary); outline-offset:-2px; }

@media (max-width:640px){
  .cal-cell{ min-height:46px; padding:4px 5px; }
  .cal-daynum{ font-size:11px; }
  .cal-count{ font-size:9px; padding:1px 4px; }
  .cal-dow{ font-size:9.5px; }
}
