/* Estilo inspirado en apple.com / macOS */
:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --line: #d2d2d7;
  --line-soft: #e8e8ed;
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --link: #0066cc;
  --green: #1d8a3a;
  --green-bg: #e3f5e8;
  --orange: #c45500;
  --orange-bg: #fff1e0;
  --red: #e30000;
  --nav: rgba(251, 251, 253, 0.8);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --card: #1c1c1e;
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #8e8e93;
    --line: #424245;
    --line-soft: #2c2c2e;
    --blue: #0a84ff;
    --blue-hover: #409cff;
    --link: #2997ff;
    --green: #30d158;
    --green-bg: rgba(48, 209, 88, 0.15);
    --orange: #ff9f0a;
    --orange-bg: rgba(255, 159, 10, 0.15);
    --red: #ff453a;
    --nav: rgba(22, 22, 23, 0.8);
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000;
  --card: #1c1c1e;
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #8e8e93;
  --line: #424245;
  --line-soft: #2c2c2e;
  --blue: #0a84ff;
  --blue-hover: #409cff;
  --link: #2997ff;
  --green: #30d158;
  --green-bg: rgba(48, 209, 88, 0.15);
  --orange: #ff9f0a;
  --orange-bg: rgba(255, 159, 10, 0.15);
  --red: #ff453a;
  --nav: rgba(22, 22, 23, 0.8);
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.47;
  letter-spacing: -0.022em;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

.logo-dot { width: 22px; height: 22px; border-radius: 7px; background: linear-gradient(135deg, #34c759, #0071e3); display: inline-block; flex: none; }

main { max-width: 1024px; margin: 0 auto; padding: 0 22px 80px; }

/* Encabezados */
.hero { padding: 56px 0 28px; }
.eyebrow { color: var(--text-2); font-size: 17px; font-weight: 600; margin: 0 0 4px; }
h1 { font-size: 48px; line-height: 1.08; font-weight: 700; letter-spacing: -0.03em; margin: 0; }
h2 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin: 48px 0 16px; display: flex; align-items: center; gap: 12px; }
h2 .sub { font-size: 17px; color: var(--text-2); font-weight: 400; letter-spacing: -0.02em; }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.subtitle { color: var(--text-2); font-size: 21px; margin: 8px 0 0; letter-spacing: -0.02em; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 980px; cursor: pointer;
  font: inherit; font-size: 15px; font-weight: 400; letter-spacing: -0.01em;
  padding: 9px 20px; background: var(--blue); color: #fff; white-space: nowrap;
  transition: background .2s, transform .1s;
}
.btn:hover { background: var(--blue-hover); text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn.ghost { background: transparent; color: var(--link); border: 1px solid var(--link); }
.btn.ghost:hover { background: var(--link); color: #fff; }
.btn.gray { background: var(--line-soft); color: var(--text); }
.btn.gray:hover { background: var(--line); }
.btn.danger { background: transparent; color: var(--red); }
.btn.danger:hover { background: rgba(255, 59, 48, .1); }
.btn.sm { font-size: 13px; padding: 5px 14px; }
.btn.green { background: var(--green); }
.btn.round { width: 34px; height: 34px; padding: 0; font-size: 20px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* Tarjetas */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px 28px; }
.grid { display: grid; gap: 16px; }
.grid.k4 { grid-template-columns: repeat(4, 1fr); }
.grid.k3 { grid-template-columns: repeat(3, 1fr); }
.grid.k2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 860px) { .grid.k4 { grid-template-columns: repeat(2, 1fr); } .grid.k3 { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .grid.k2, .grid.k4 { grid-template-columns: 1fr; } h1 { font-size: 36px; } .hero { padding-top: 36px; } }

.stat .label { font-size: 14px; color: var(--text-2); font-weight: 600; letter-spacing: -0.01em; }
.stat .value { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .foot { font-size: 13px; color: var(--text-3); margin-top: 6px; line-height: 1.5; }
.stat.green .value { color: var(--green); }
.stat.orange .value { color: var(--orange); }
.stat.dark { background: var(--text); color: var(--bg); }
.stat.dark .label, .stat.dark .foot { color: var(--bg); opacity: .7; }

.progress { height: 6px; border-radius: 3px; background: var(--line-soft); overflow: hidden; margin-top: 12px; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, #34c759, #30b0c7); border-radius: 3px; }

/* Lista de meses */
.months a.card { display: block; color: var(--text); transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s; }
.months a.card:hover { text-decoration: none; transform: translateY(-3px) scale(1.01); box-shadow: 0 10px 40px rgba(0,0,0,.1); }
.months .mname { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.months .myear { color: var(--text-3); font-weight: 400; }
.months .row { display: flex; justify-content: space-between; font-size: 14px; margin-top: 6px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.months .row b { color: var(--text); font-weight: 600; }
.months .add { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; color: var(--link); border: 2px dashed var(--line); background: transparent; box-shadow: none; min-height: 160px; }

/* Tablas tipo lista agrupada */
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list table { width: 100%; border-collapse: collapse; font-size: 15px; }
.list th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); font-weight: 600; padding: 14px 20px 10px; border-bottom: 1px solid var(--line-soft); }
.list td { padding: 12px 20px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; font-variant-numeric: tabular-nums; }
.list tr:last-child td { border-bottom: 0; }
.list tbody tr { transition: background .15s; }
.list tbody tr:hover { background: rgba(0, 0, 0, .025); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .list tbody tr:hover { background: rgba(255,255,255,.04); } }
:root[data-theme="dark"] .list tbody tr:hover { background: rgba(255,255,255,.04); }
.list tfoot td { font-weight: 600; background: var(--bg); border-bottom: 0; }
.list .num { text-align: right; }
.list .muted { color: var(--text-3); }
.list .empty { text-align: center; color: var(--text-3); padding: 40px 20px; }
.list .clickable { cursor: pointer; }
.table-wrap { overflow-x: auto; }

.who { display: flex; align-items: center; gap: 12px; font-weight: 500; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: #fff; background: linear-gradient(135deg, #a1a1a6, #6e6e73); flex: none; letter-spacing: 0; }
.avatar.M { background: linear-gradient(135deg, #bf5af2, #ff375f); }
.avatar.E { background: linear-gradient(135deg, #5ac8fa, #0071e3); }
.avatar.lg { width: 72px; height: 72px; font-size: 26px; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; padding: 3px 10px; border-radius: 980px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--green); background: var(--green-bg); }
.pill.pend { color: var(--orange); background: var(--orange-bg); }
.pill.tag { color: var(--text-2); background: var(--line-soft); }
.pill.tag::before { display: none; }

.row-actions { display: flex; gap: 4px; justify-content: flex-end; opacity: .9; }
.icon-btn { background: none; border: 0; cursor: pointer; padding: 6px 8px; border-radius: 8px; color: var(--text-3); font-size: 15px; line-height: 1; }
.icon-btn:hover { background: var(--line-soft); color: var(--text); text-decoration: none; }
form.inline { display: inline; margin: 0; }

/* Segmented control */
.segmented { display: inline-flex; background: var(--line-soft); padding: 2px; border-radius: 9px; }
.segmented button { border: 0; background: transparent; font: inherit; font-size: 13px; padding: 5px 14px; border-radius: 7px; cursor: pointer; color: var(--text); }
.segmented button.on { background: var(--card); box-shadow: 0 1px 4px rgba(0,0,0,.12); font-weight: 500; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin: 32px 0 0; gap: 12px; flex-wrap: wrap; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 40px 0 14px; gap: 12px; }
.section-head h2 { margin: 0; }

/* Mes pager */
.pager { display: flex; align-items: center; gap: 8px; }
.pager a, .pager span { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--line-soft); color: var(--text); font-size: 17px; }
.pager a:hover { background: var(--line); text-decoration: none; }
.pager span { opacity: .35; }

/* Formularios */
.form-card { max-width: 560px; margin: 0 auto; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; letter-spacing: -0.01em; }
.field input[type=text], .field input[type=number], .field input[type=date], .field input[type=search], .field select, .field textarea, .search {
  width: 100%; font: inherit; font-size: 17px; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  transition: border-color .2s, box-shadow .2s; appearance: none; -webkit-appearance: none;
}
.field select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2386868b' stroke-width='1.6' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
.field input:focus, .field select:focus, .field textarea:focus, .search:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0, 113, 227, .2); }
.field .help { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.field .err, .errorlist { color: var(--red); font-size: 13px; margin: 6px 0 0; padding: 0; list-style: none; }
.field.check { display: flex; align-items: center; gap: 10px; }
.field.check label { margin: 0; font-size: 15px; color: var(--text); font-weight: 400; }
.field.check input { width: 20px; height: 20px; accent-color: var(--blue); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 26px; gap: 10px; flex-wrap: wrap; }
.quick-today { font-size: 13px; margin-top: 6px; display: inline-block; cursor: pointer; color: var(--link); background: none; border: 0; padding: 0; }
.search { max-width: 320px; border-radius: 980px; padding: 9px 16px; font-size: 15px; }

/* Mensajes (toast) */
.toasts { position: fixed; top: max(16px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--nav); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid var(--line-soft); box-shadow: 0 8px 30px rgba(0,0,0,.12); padding: 10px 20px; border-radius: 980px; font-size: 14px; animation: toast 3.6s ease forwards; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-10px); } 8%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-10px); visibility: hidden; } }

.notes { white-space: pre-line; color: var(--text-2); font-size: 15px; }
.footer { text-align: center; color: var(--text-3); font-size: 12px; padding: 40px 0; }
.hide { display: none !important; }

/* Forma de pago: efectivo / bizum */
.pay-choice { display: inline-flex; background: var(--line-soft); padding: 2px; border-radius: 980px; gap: 2px; }
.pay-choice button { border: 0; font: inherit; font-size: 12px; font-weight: 500; padding: 5px 11px; border-radius: 980px; cursor: pointer; background: transparent; color: var(--text); white-space: nowrap; transition: background .15s, color .15s; }
.pay-choice button.ef:hover { background: var(--green); color: #fff; }
.pay-choice button.bz:hover { background: #00b2a9; color: #fff; }
.pill.metodo-EF { color: var(--green); background: var(--green-bg); }
.pill.metodo-BZ { color: #00a19a; background: rgba(0, 178, 169, .13); }
.pill.metodo-EF::before, .pill.metodo-BZ::before { display: none; }
.field.seg > div { display: inline-flex; background: var(--line-soft); padding: 3px; border-radius: 11px; gap: 2px; }
.field.seg > div > div { display: contents; }
.field.seg > div label { margin: 0; padding: 8px 22px; border-radius: 9px; font-size: 15px; font-weight: 500; color: var(--text); cursor: pointer; transition: background .15s; }
.field.seg > div label input { position: absolute; opacity: 0; pointer-events: none; }
.field.seg > div label:has(input:checked) { background: var(--card); box-shadow: 0 1px 4px rgba(0,0,0,.14); }
.field.seg > label { display: block; }

/* Login y salir */
.login { max-width: 380px; margin: 0 auto; text-align: center; padding-top: 64px; }
.login-icon { border-radius: 18px; box-shadow: 0 6px 20px rgba(0,0,0,.15); }
.login h1 { margin-top: 18px; }
.login-card { text-align: left; margin-top: 28px; }
.field input[type=password] { width: 100%; font: inherit; font-size: 17px; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.field input[type=password]:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0,113,227,.2); }
.err { color: var(--red); font-size: 14px; }

/* Móvil */
@media (max-width: 640px) {
  main { padding: 0 16px 60px; }
  .card { padding: 20px; }
  .stat .value { font-size: 28px; }
  h2 { font-size: 24px; flex-wrap: wrap; }
  .list th, .list td { padding: 10px 12px; }
  .list .muted { display: none; }
  .list th:nth-child(4) { display: none; }
  .pay-choice button { padding: 6px 9px; }
  .field-row { grid-template-columns: 1fr; }
}

/* ───────── Menú lateral de meses (plegable) ───────── */
:root { --sb-w: 68px; --sb-open: 236px; --tab-h: 62px; }
body.con-menus { padding-left: var(--sb-w); padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); transition: padding-left .25s ease; }
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 30; width: var(--sb-w);
  display: flex; flex-direction: column;
  padding: max(10px, env(safe-area-inset-top)) 10px calc(var(--tab-h) + env(safe-area-inset-bottom) + 10px);
  background: var(--nav); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-right: 1px solid var(--line-soft); overflow: hidden;
  transition: width .25s ease, box-shadow .25s ease;
}
.sb-top { display: flex; align-items: center; gap: 10px; height: 44px; margin-bottom: 8px; flex: none; }
.sb-toggle { width: 48px; height: 40px; flex: none; border: 0; border-radius: 10px; background: transparent; color: var(--text); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.sb-toggle:hover { background: var(--line-soft); }
.sb-logo { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 19px; color: var(--text); white-space: nowrap; }
.sb-logo:hover { text-decoration: none; }
.sb-list { flex: 1; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; display: flex; flex-direction: column; gap: 2px; }
.sb-list::-webkit-scrollbar { display: none; }
.sb-year { font-size: 11px; font-weight: 600; color: var(--text-3); padding: 14px 0 4px; text-align: center; letter-spacing: .02em; flex: none; }
.sb-year:first-child { padding-top: 4px; }
.sb-item { display: flex; align-items: center; gap: 12px; height: 40px; border-radius: 10px; color: var(--text); white-space: nowrap; flex: none; transition: background .15s; }
.sb-item:hover { background: var(--line-soft); text-decoration: none; }
.sb-ico { width: 48px; flex: none; text-align: center; font-size: 13px; font-weight: 500; }
.sb-item.on { background: var(--text); color: var(--bg); }
.sb-item.on .sb-ico { font-weight: 600; }
.sb-add { color: var(--link); margin-top: 6px; }
.sb-add .sb-ico { font-size: 18px; }
.sb-text { font-size: 15px; opacity: 0; transition: opacity .15s; }
.sb-short { display: inline; }
.sb-year .sb-text { display: none; font-size: 12px; }
.sb-empty { font-size: 13px; color: var(--text-3); padding: 8px 12px; margin: 0; }
.sb-backdrop { position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, .3); opacity: 0; pointer-events: none; transition: opacity .25s; }

body.sb-open .sidebar { width: var(--sb-open); }
body.sb-open .sb-text { opacity: 1; }
body.sb-open .sb-year { text-align: left; padding-left: 14px; }
body.sb-open .sb-year .sb-text { display: inline; }
body.sb-open .sb-year .sb-short { display: none; }
@media (min-width: 901px) { body.con-menus.sb-open { padding-left: var(--sb-open); } }
@media (max-width: 900px) {
  body.sb-open .sidebar { box-shadow: 0 0 40px rgba(0, 0, 0, .25); }
  body.sb-open .sb-backdrop { opacity: 1; pointer-events: auto; }
}

/* ───────── Menú principal fijo abajo ───────── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: flex; justify-content: center; gap: 4px;
  background: var(--nav); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line-soft);
}
.tabbar a, .tabbar button {
  flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-3); font: inherit; font-size: 11px; font-weight: 500; letter-spacing: 0;
  background: none; border: 0; cursor: pointer; padding: 0;
}
.tabbar form { flex: 1; max-width: 120px; display: flex; margin: 0; }
.tabbar form button { max-width: none; }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a:hover, .tabbar button:hover { color: var(--text); text-decoration: none; }
.tabbar a.on { color: var(--blue); }
.tabbar .tema .sol, :root[data-theme="dark"] .tabbar .tema .luna { display: none; }
:root[data-theme="dark"] .tabbar .tema .sol { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tabbar .tema .luna { display: none; }
  :root:not([data-theme="light"]) .tabbar .tema .sol { display: block; }
}

/* Borrado rápido, tarifas y días */
.icon-btn.del:hover { color: var(--red); background: rgba(255, 59, 48, .1); }
.icon-btn svg { display: block; }
.tarifa-info { font-size: 12px; color: var(--text-3); font-weight: 400; margin-top: 2px; }
.muted-inline { color: var(--text-3); font-size: 13px; white-space: nowrap; }
.list tr.off td { opacity: .55; }
.chips { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-size: 14px; padding: 6px 16px; border-radius: 980px; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.chip:hover { border-color: var(--blue); }
.chip.on { background: var(--blue); border-color: var(--blue); color: #fff; }
#calculo:empty { display: none; }
#calculo { font-size: 14px; color: var(--text); font-weight: 500; }

@media (max-width: 640px) {
  :root { --sb-w: 56px; }
  .sidebar { padding-left: 6px; padding-right: 6px; }
  .sb-toggle, .sb-ico { width: 44px; }
  main { padding: 0 12px 40px; }
  .footer { display: none; }
  table.tarifas .col-tipo, table.tarifas .col-cli { display: none; }
  .tarifa-info.dias-ej { white-space: normal; max-width: 150px; margin-left: auto; }
}
