/*
 * Spartans Office. Idea: una libreta de campaña. Neutros fríos, un solo acento carmesí (el rojo del escudo)
 * y una tipografía condensada para números y rótulos. El progreso se dibuja como segmentos, uno por día requerido.
 */
:root {
  --bg: #eff0f3;
  --surface: #ffffff;
  --sunken: #f5f6f8;
  --line: #dcdee4;
  --line-strong: #c3c7d0;
  --text: #15171c;
  --muted: #5b6270;
  --accent: #b3261e;
  --accent-ink: #ffffff;
  --accent-wash: #fbe7e5;
  --ok: #137a52;
  --ok-wash: #dcf2e8;
  --warn: #8a5a00;
  --discord: #5865f2;
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.75rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1013;
    --surface: #16191e;
    --sunken: #1c2026;
    --line: #2a2f37;
    --line-strong: #3b414c;
    --text: #eceef2;
    --muted: #99a1af;
    --accent: #ee6a5d;
    --accent-ink: #1b0b09;
    --accent-wash: #3a1d1a;
    --ok: #45c997;
    --ok-wash: #12352a;
    --warn: #e7b04d;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 var(--fs-md)/1.5 var(--font); font-optical-sizing: auto; }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }

/* Tipografía: rótulos y números condensados, texto corrido normal */
.label, nav button, .tag, .cal .h, .stat dt, th { font-stretch: 75%; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; font-size: var(--fs-xs); }
h1, h2 { font-stretch: 75%; font-weight: 700; letter-spacing: 0.01em; text-wrap: balance; }
h2 { font-size: var(--fs-lg); }
.muted { color: var(--muted); font-size: var(--fs-sm); }
.hide { display: none !important; }

/* Estructura */
main { max-width: 720px; margin: 0 auto; padding: 12px max(16px, env(safe-area-inset-right)) 112px max(16px, env(safe-area-inset-left)); padding-top: max(12px, env(safe-area-inset-top)); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; }
.panel + .panel, .panel + .section, .section + .panel { margin-top: 12px; }
.section { margin-top: 28px; }
.section > h2 { margin-bottom: 10px; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* Cabecera */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0 14px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mark { width: 36px; height: 36px; border-radius: var(--r-md); background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-stretch: 100%; font-weight: 800; font-size: 1.35rem; line-height: 1; flex: none; }
.wordmark { font-stretch: 70%; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; font-size: 1.05rem; white-space: nowrap; }
.who { display: flex; align-items: center; gap: 8px; }

/* Botones y campos */
button, .btn { font: inherit; font-weight: 600; font-size: var(--fs-sm); color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: 9px 14px; min-height: 40px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background-color 0.15s, border-color 0.15s, transform 0.06s; }
button:hover:not(:disabled), .btn:hover { border-color: var(--text); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: default; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.primary:hover:not(:disabled) { border-color: var(--accent); filter: brightness(1.08); }
.discord { background: var(--discord); border-color: var(--discord); color: #fff; }
.discord:hover { border-color: var(--discord) !important; filter: brightness(1.08); }
.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.ghost:hover:not(:disabled) { color: var(--text); border-color: var(--line); }
.danger { color: var(--accent); }
.small { min-height: 34px; padding: 6px 12px; font-size: var(--fs-xs); }
.wide { width: 100%; }
.icon { width: 18px; height: 18px; flex: none; }
.icon-btn { padding: 0; width: 40px; }
input { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: 9px 12px; min-height: 40px; min-width: 0; }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
input[type="number"] { width: 84px; }
input::placeholder { color: var(--muted); opacity: 0.8; }
.field { display: grid; gap: 6px; }
.field > .label { color: var(--muted); }

/* Avatares: el tono sale del nombre */
.avatar { --h: 210; width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-size: var(--fs-xs); color: #fff; background: hsl(var(--h) 42% 40%); flex: none; letter-spacing: 0.02em; }
.avatar.sm { width: 24px; height: 24px; font-size: 0.65rem; }
@media (prefers-color-scheme: dark) { .avatar { background: hsl(var(--h) 38% 36%); } }
.avatars { display: inline-flex; }
.avatars .avatar + .avatar { margin-left: -7px; box-shadow: 0 0 0 2px var(--surface); }

/* Navegación: barra inferior en el móvil, pestañas con subrayado en pantallas anchas */
nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; background: var(--surface); border-top: 1px solid var(--line); padding: 4px max(8px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
nav button { flex: 1; flex-direction: column; gap: 3px; min-height: 52px; border: 0; border-radius: var(--r-md); background: transparent; color: var(--muted); padding: 6px 4px; }
nav button:hover:not(:disabled) { color: var(--text); }
nav button.active { color: var(--accent); }
nav button.active .icon { stroke-width: 2.3; }
@media (min-width: 720px) {
  main { padding-bottom: 40px; }
  nav { position: static; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 0; margin-bottom: 20px; gap: 4px; }
  nav button { flex: 0 0 auto; flex-direction: row; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; }
  nav button.active { border-bottom-color: var(--accent); }
}

/* Mes: cifra grande + segmentos (uno por día requerido) */
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.month-nav h1 { font-size: var(--fs-xl); }
.summary { display: grid; gap: 14px; }
.big { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.big strong { font-stretch: 62%; font-weight: 800; font-size: 4.5rem; line-height: 0.9; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.big span { color: var(--muted); font-stretch: 75%; font-weight: 600; font-size: var(--fs-lg); }
.segments { display: flex; gap: 4px; }
.segments i { flex: 1; height: 12px; border-radius: 3px; background: var(--sunken); border: 1px solid var(--line); }
.segments i.done { background: var(--ok); border-color: var(--ok); }
.segments i.plan { background: transparent; border: 1.5px dashed var(--accent); }
.verdict { font-weight: 600; }
.verdict.ok { color: var(--ok); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); padding-top: 14px; margin: 0; }
.stat { min-width: 0; }
.stat + .stat { border-left: 1px solid var(--line); padding-left: 14px; }
.stat dt { color: var(--muted); }
.stat dd { margin: 2px 0 0; font-stretch: 75%; font-weight: 700; font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }

/* Calendario */
.cal { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.cal .h { text-align: center; color: var(--muted); padding-bottom: 2px; }
.day { position: relative; min-height: 58px; padding: 6px 4px; display: flex; flex-direction: column; justify-content: center; gap: 1px; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r-md); font-size: var(--fs-md); font-weight: 600; font-variant-numeric: tabular-nums; }
.day small { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.65rem; font-stretch: 75%; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); min-height: 1em; }
.day:hover:not(:disabled) { border-color: var(--text); }
.day.attended { background: var(--ok-wash); border-color: var(--ok); color: var(--ok); }
.day.attended small { color: var(--ok); }
.day.planned { background: var(--surface); border: 1.5px dashed var(--accent); color: var(--accent); }
.day.planned small { color: var(--accent); }
.day.today::after { content: ""; position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.day.holiday { cursor: default; opacity: 0.8; background: repeating-linear-gradient(135deg, var(--sunken) 0 5px, var(--line) 5px 6px); }
.day.holiday:disabled { opacity: 0.8; }
.day.blank { visibility: hidden; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 14px; color: var(--muted); font-size: var(--fs-xs); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--line-strong); }
.legend .k-done { background: var(--ok-wash); border-color: var(--ok); }
.legend .k-plan { border: 1.5px dashed var(--accent); }
.legend .k-today { border-radius: 50%; width: 7px; height: 7px; background: var(--accent); border: 0; }

/* Semana: una lista, no una tarjeta por día */
.list { padding: 0; overflow: hidden; }
.day-row { display: grid; grid-template-columns: 56px 1fr auto; gap: 4px 14px; padding: 16px 20px; border-top: 1px solid var(--line); align-items: start; }
.day-row:first-child { border-top: 0; }
.date { text-align: center; line-height: 1; padding-top: 2px; }
.date .label { display: block; color: var(--muted); }
.date strong { display: block; font-stretch: 62%; font-weight: 700; font-size: 2.1rem; font-variant-numeric: tabular-nums; margin-top: 3px; }
.date.is-today strong { color: var(--accent); }
.who-list { display: flex; align-items: center; gap: 8px; min-height: 28px; flex-wrap: wrap; }
.names { grid-column: 2 / -1; }
.cars { grid-column: 2 / -1; display: grid; gap: 6px; margin-top: 6px; }
.car { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 10px; border-radius: var(--r-md); background: var(--sunken); font-size: var(--fs-sm); }
.car .icon { color: var(--muted); }
.car .grow { overflow-wrap: anywhere; }
.offer { grid-column: 2 / -1; margin-top: 6px; }
.offer > .ghost { margin-left: -12px; }
.toggle { min-width: 84px; }
.toggle.on { background: var(--ok-wash); border-color: var(--ok); color: var(--ok); }

/* Equipo y cuenta */
.member { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.member:first-of-type { border-top: 0; }
.member .grow strong { display: block; overflow-wrap: anywhere; }
.tag { color: var(--accent); }
.holiday-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.holiday-item:first-of-type { border-top: 0; }
.holiday-item .when { font-stretch: 75%; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 4.5rem; }
.holiday-form { display: grid; gap: 8px; margin-top: 12px; }
.holiday-form input { width: 100%; }
@media (min-width: 600px) { .holiday-form { grid-template-columns: auto 1fr auto; } }
.invite { display: flex; gap: 8px; flex-wrap: wrap; }
.invite input { flex: 1; min-width: 180px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.presets button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* Entrada y bienvenida */
.hero { padding: 36px 4px 8px; position: relative; overflow: hidden; }
.hero .lambda { position: absolute; right: -10px; top: -30px; font-stretch: 100%; font-weight: 800; font-size: 15rem; line-height: 1; color: var(--accent); opacity: 0.07; pointer-events: none; user-select: none; }
.hero h1 { font-size: clamp(2.4rem, 10vw, 3.6rem); line-height: 0.98; text-transform: uppercase; max-width: 12ch; position: relative; }
.hero p { margin-top: 14px; max-width: 42ch; color: var(--muted); position: relative; }
.logins { display: grid; gap: 10px; margin-top: 24px; justify-items: start; position: relative; }
.logins .btn { min-width: 240px; min-height: 46px; }
.note { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: var(--fs-sm); max-width: 46ch; position: relative; }
.banner { display: flex; gap: 10px; align-items: center; background: var(--accent-wash); color: var(--accent); border-radius: var(--r-md); padding: 12px 14px; font-weight: 600; margin-top: 18px; position: relative; }

/* Carga y avisos */
.skeleton { height: 128px; border-radius: var(--r-lg); margin-bottom: 12px; background: linear-gradient(90deg, var(--surface) 25%, var(--sunken) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border: 1px solid var(--line); }
@keyframes shimmer { to { background-position: -200% 0; } }
#toast { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--r-md); max-width: min(92vw, 420px); display: none; z-index: 10; font-weight: 600; font-size: var(--fs-sm); }
#toast.error { background: var(--accent); color: var(--accent-ink); }
@media (min-width: 720px) { #toast { bottom: 24px; } }

/* Pantallas angostas */
@media (max-width: 460px) {
  .panel { padding: 16px; }
  .big strong { font-size: 3.8rem; }
  .day-row { grid-template-columns: 46px 1fr auto; padding: 14px 16px; gap: 4px 12px; }
  .date strong { font-size: 1.8rem; }
  .cal { gap: 4px; }
  .day { min-height: 52px; padding: 4px 2px; }
  .invite input { flex-basis: 100%; }
  .who .name { display: none; }
  .logins .btn { width: 100%; }
}
@media (pointer: coarse) { button, .btn, input { min-height: 44px; } .small { min-height: 40px; } }

/* Pantallas anchas: la semana en dos columnas */
@media (min-width: 900px) {
  main { max-width: 960px; }
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
  .grid-2 > .panel { margin-top: 0; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
