  :root {
    --bg: #16181d; --panel: #1f232b; --panel2: #262b35; --border: #343b48;
    --text: #e8eaf0; --dim: #9aa3b2; --accent: #f0a232; --ok: #3dba6f; --warn: #e2574a; --blue: #4a90d9;
    --nueva: #25d366;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
  html, body { background: var(--bg); color: var(--text); font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; }
  body { min-height: 100dvh; }
  button { font-family: inherit; cursor: pointer; }
  .ic { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.2em; flex: 0 0 auto; }
  .oculto { display: none !important; }

  /* Login */
  #login { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px 16px; }
  #login img { width: 150px; margin-bottom: 10px; }
  #login input { width: min(320px, 100%); padding: 13px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font-size: 16px; }
  #login button { width: min(320px, 100%); padding: 13px; border-radius: 10px; border: none; background: var(--accent); color: #1a1a1a; font-size: 16px; font-weight: 700; }
  #login-err { color: var(--warn); font-size: 14px; min-height: 18px; }

  /* Cabecera + pestañas */
  header { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: calc(env(safe-area-inset-top) + 10px) 16px 0; border-bottom: 1px solid var(--border); }
  .cab { display: flex; align-items: center; gap: 10px; }
  .cab img { height: 30px; }
  .cab h1 { font-size: 18px; font-weight: 700; letter-spacing: .5px; flex: 1; }
  .icbtn { background: none; border: none; color: var(--dim); font-size: 21px; padding: 6px; border-radius: 8px; line-height: 1; }
  .icbtn.on { color: var(--accent); }
  .tabs { display: flex; margin-top: 10px; }
  .tab { flex: 1; background: none; border: none; color: var(--dim); font-size: 15px; font-weight: 600; padding: 10px 4px 11px; border-bottom: 3px solid transparent; display: flex; align-items: center; justify-content: center; gap: 7px; }
  .tab.activa { color: var(--accent); border-bottom-color: var(--accent); }
  .globo { background: var(--nueva); color: #0b1d10; font-size: 12px; font-weight: 800; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; }
  .globo:empty { display: none; }

  .aviso-bar { display: flex; align-items: center; gap: 10px; margin: 12px 16px 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); font-size: 14px; }
  .aviso-bar span { flex: 1; color: var(--dim); }
  .aviso-bar button { border: none; background: var(--accent); color: #1a1a1a; font-weight: 700; padding: 8px 12px; border-radius: 8px; font-size: 14px; }

  main { padding: 6px 16px calc(env(safe-area-inset-bottom) + 96px); max-width: 640px; margin: 0 auto; }
  .rango { color: var(--dim); font-size: 13px; margin: 14px 2px 2px; }
  .sep-semana { color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin: 22px 2px 0; display: flex; align-items: center; gap: 10px; }
  .sep-semana::after { content: ''; flex: 1; height: 1px; background: var(--border); }
  .vacio { color: var(--dim); text-align: center; padding: 48px 0; }

  /* Burbuja de un día (como el mensaje del grupo) */
  .dia { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; margin-top: 12px; overflow: hidden; }
  .dia.pasado { opacity: .55; }
  .dia-cab { display: flex; align-items: center; gap: 10px; padding: 12px 14px 8px; }
  .dia-cab h3 { font-size: 16px; font-weight: 800; letter-spacing: .5px; flex: 1; }
  .dia-cab.hoy h3 { color: var(--accent); }
  .dia-tot { display: flex; gap: 14px; white-space: nowrap; }
  .dia-tot span { display: flex; flex-direction: column; align-items: center; line-height: 1; }
  .dia-tot b { font-size: 22px; font-weight: 800; color: var(--text); }
  .dia-tot small { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .5px; margin-top: 3px; }
  .dia-vacio { color: var(--dim); font-size: 14px; padding: 2px 14px 12px; }
  .lin { display: flex; align-items: flex-start; gap: 8px; padding: 8px 14px; border-top: 1px solid transparent; position: relative; }
  .lin:active { background: var(--panel2); }
  .lin:last-child { padding-bottom: 12px; }
  .lin .txt { flex: 1; font-size: 15.5px; line-height: 1.35; min-width: 0; }
  .lin .nom { font-weight: 600; }
  .lin .det { color: var(--dim); }
  .lin .extra { color: var(--accent); white-space: nowrap; }
  .lin .hora { color: var(--dim); font-size: 12.5px; padding-top: 3px; white-space: nowrap; }
  .lin .ok-ic { color: var(--ok); }
  .lin.nueva { background: rgba(37, 211, 102, .08); }
  .lin.nueva::before { content: ''; position: absolute; left: 4px; top: 15px; width: 6px; height: 6px; border-radius: 3px; background: var(--nueva); }
  .lin.cancelada .txt, .lin.no_show .txt { text-decoration: line-through; color: var(--dim); }

  /* Calendario */
  .cal-nav { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 8px; }
  .cal-nav h2 { font-size: 17px; font-weight: 700; text-transform: capitalize; }
  .cal-nav .icbtn { font-size: 22px; color: var(--text); }
  .cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
  .cal .dsem { text-align: center; font-size: 12px; color: var(--dim); padding: 4px 0; }
  .cel { aspect-ratio: 1 / 1.05; border-radius: 10px; background: var(--panel); border: 1px solid transparent; color: var(--text); display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 6px; gap: 2px; position: relative; font-size: 14px; }
  .cel.fuera { background: transparent; color: #4b5260; }
  .cel.hoy { border-color: var(--accent); }
  .cel.sel { background: var(--accent); color: #1a1a1a; }
  .cel.sel .cnt { color: #1a1a1a; }
  .cel .cnt { font-size: 11.5px; font-weight: 700; color: var(--accent); }
  .cel.pasado .cnt { color: var(--dim); }
  .cel .pto { position: absolute; top: 5px; right: 6px; width: 7px; height: 7px; border-radius: 4px; background: var(--nueva); }

  /* Botón + */
  #fab { position: fixed; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 20px); width: 58px; height: 58px; border-radius: 29px; border: none; background: var(--accent); color: #1a1a1a; font-size: 28px; box-shadow: 0 6px 18px rgba(0,0,0,.45); z-index: 6; display: flex; align-items: center; justify-content: center; }
  #fab .ic { stroke-width: 2.2; }

  /* Hoja inferior (detalle / formulario) */
  .velo { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
  .hoja { background: var(--panel); width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; padding: 10px 18px calc(env(safe-area-inset-bottom) + 18px); max-height: 92dvh; overflow-y: auto; }
  .hoja .asa { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 0 auto 12px; }
  .hoja h2 { font-size: 21px; font-weight: 800; }
  .hoja .sub { color: var(--dim); font-size: 14.5px; margin-top: 3px; }
  .chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
  .chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--border); font-size: 14px; }
  .chip.confirmada { color: #8fe3ad; border-color: #2e5a3c; }
  .chip.cancelada, .chip.no_show { color: #f0b8a8; border-color: #6b2f1f; }
  .chip.sentada { color: #f0d9b8; border-color: #6b4a1f; }
  .nota { margin-top: 14px; padding: 10px 12px; border-radius: 10px; background: var(--bg); font-size: 15px; line-height: 1.4; }
  .tel { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: var(--bg); font-size: 20px; font-weight: 700; letter-spacing: .5px; }
  .tel > .ic { color: var(--dim); font-size: 18px; }
  .tel span { flex: 1; user-select: all; }
  .tel a { color: var(--accent); font-size: 22px; padding: 6px 8px; border-radius: 10px; border: 1px solid var(--border); display: flex; }
  .hist { color: var(--dim); font-size: 12.5px; margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
  .hist .cambio { display: block; color: var(--text); opacity: .8; margin-top: 1px; }
  .conf { text-align: center; padding: 10px 6px 4px; }
  .conf .ic { font-size: 34px; color: var(--warn); }
  .conf p { margin-top: 10px; font-size: 17px; line-height: 1.4; }
  .acc .borrar { background: var(--warn); border-color: var(--warn); color: #fff; font-weight: 700; }
  .acc { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
  .acc button, .acc a { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel2); color: var(--text); font-size: 15px; text-decoration: none; }
  .acc .ok { color: #8fe3ad; border-color: #2e5a3c; }
  .acc .dng { color: #f0b8a8; border-color: #6b2f1f; }
  .acc .prim { background: var(--accent); border-color: var(--accent); color: #1a1a1a; font-weight: 700; }

  .campo { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--dim); margin-top: 12px; }
  .campo input { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 16px; color-scheme: dark; font-family: inherit; }
  .fila { display: flex; gap: 10px; } .fila > * { flex: 1; min-width: 0; }
  .seg { display: flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
  .seg button { flex: 1; border: none; background: var(--bg); color: var(--dim); padding: 11px 4px; font-size: 15px; }
  .seg button.on { background: var(--accent); color: #1a1a1a; font-weight: 700; }
  .stepper { display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); padding: 4px 6px; color: var(--text); font-size: 15px; }
  .stepper .lbl { display: flex; align-items: center; gap: 7px; padding-left: 4px; color: var(--accent); }
  .stepper button { width: 36px; height: 36px; border-radius: 8px; border: none; background: var(--panel2); color: var(--text); font-size: 20px; }
  .stepper b { min-width: 22px; text-align: center; }

  #toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 92px); transform: translateX(-50%); background: #2d3340; color: var(--text); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 30; max-width: calc(100% - 32px); text-align: center; }

  /* Tortas / picadas: total de la semana arriba de todo */
  .total-sem { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: var(--accent); color: #1a1a1a; }
  .total-sem .ic { font-size: 30px; stroke-width: 1.9; }
  .total-sem b { font-size: 34px; font-weight: 800; line-height: 1; }
  .total-sem span { display: flex; flex-direction: column; font-size: 16px; font-weight: 700; }
  .total-sem small { font-size: 12.5px; font-weight: 600; opacity: .75; }

  /* Cartel "instalala como app" */
  .instalar { margin: calc(env(safe-area-inset-top) + 12px) 16px 0; padding: 12px 14px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--accent); }
  .inst-cab { display: flex; align-items: center; gap: 10px; }
  .inst-cab img { width: 34px; height: 34px; border-radius: 8px; }
  .inst-cab b { flex: 1; font-size: 16px; }
  .inst-cab .icbtn { font-size: 18px; }
  .instalar ol { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
  .instalar li { display: flex; align-items: center; gap: 10px; font-size: 15px; }
  .instalar li .n { width: 22px; height: 22px; border-radius: 11px; background: var(--accent); color: #1a1a1a; font-size: 13px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
  .instalar li .ic { color: var(--accent); font-size: 20px; }
  .inst-btn { margin-top: 12px; width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; border: none; border-radius: 10px; background: var(--accent); color: #1a1a1a; font-size: 16px; font-weight: 700; }
