:root {
  --bg: #0f1117;
  --bg2: #151823;
  --card: #1a1e2b;
  --card2: #212636;
  --line: #2a3043;
  --text: #e9ecf5;
  --muted: #8b93a9;
  --accent: #7c6cff;
  --accent2: #9d91ff;
  --work: #2dd4bf;
  --work-bg: rgba(45, 212, 191, .12);
  --travel: #fbbf24;
  --travel-bg: rgba(251, 191, 36, .13);
  --pos: #4ade80;
  --neg: #f87171;
  --radius: 16px;
  --shadow: 0 10px 40px rgba(0,0,0,.35);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5fb; --bg2: #eceef7; --card: #ffffff; --card2: #f6f7fc; --line: #e1e4ef;
    --text: #171a26; --muted: #69718a; --accent: #5b4bff; --accent2: #6d5fff;
    --work: #0d9488; --work-bg: rgba(13,148,136,.1); --travel: #c27c03; --travel-bg: rgba(217,145,6,.12);
    --pos: #16a34a; --neg: #dc2626; --shadow: 0 10px 30px rgba(30,35,70,.10);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Manrope, system-ui, -apple-system, Segoe UI, sans-serif;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(124,108,255,.14), transparent 60%), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
.mono, .num { font-family: "JetBrains Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.spacer { flex: 1; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
h2 { font-size: 17px; margin: 22px 0 6px; }
h2:first-child { margin-top: 0; }
h3 { font-size: 15px; }

/* ── Botones ── */
.btn {
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--card2); color: var(--text);
  padding: 10px 16px; border-radius: 11px; cursor: pointer; transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #a35cff); border-color: transparent; color: #fff; box-shadow: 0 6px 20px rgba(124,108,255,.35); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--neg); }
.btn.danger:hover { border-color: var(--neg); }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn.chip.work { color: var(--work); background: var(--work-bg); border-color: transparent; }
.btn.chip.travel { color: var(--travel); background: var(--travel-bg); border-color: transparent; }
.icon-btn {
  font: inherit; font-size: 20px; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); }

/* ── Inputs ── */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
input, select {
  font: inherit; color: var(--text); background: var(--bg2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font-weight: 500; width: 100%; min-width: 0;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,108,255,.2); }
input[type=time], input[type=date] { font-family: "JetBrains Mono", monospace; }
label.check { flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-weight: 500; }
label.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 10px 0; }
.fields.three { grid-template-columns: 1.2fr .7fr 2fr; }
small { font-weight: 500; }

/* ── Login ── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line);
  border-radius: 22px; padding: 34px 28px; display: flex; flex-direction: column; gap: 16px; box-shadow: var(--shadow);
}
.login-card p { margin: -8px 0 6px; }
.alert { background: rgba(248,113,113,.12); color: var(--neg); padding: 10px 12px; border-radius: 10px; font-weight: 600; font-size: 14px; }

/* ── Topbar ── */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; letter-spacing: -.03em; }
.brand.big { font-size: 28px; }
.logo {
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent); position: relative; flex: none;
  box-shadow: 0 0 0 4px rgba(124,108,255,.2);
}
.brand.big .logo { width: 36px; height: 36px; }
.logo::before, .logo::after { content: ""; position: absolute; background: #fff; border-radius: 3px; left: 50%; top: 50%; }
.logo::before { width: 3px; height: 34%; transform: translate(-50%, -100%); }
.logo::after { width: 3px; height: 26%; transform-origin: top center; transform: translate(-50%, 0) rotate(-55deg); }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 18px;
  padding: 12px max(20px, calc((100vw - 1100px)/2)); backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 80%, transparent); border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 4px; background: var(--card); border: 1px solid var(--line); padding: 4px; border-radius: 12px; margin: 0 auto; }
.tabs button { font: inherit; font-weight: 600; font-size: 14px; border: 0; background: none; color: var(--muted); padding: 7px 16px; border-radius: 9px; cursor: pointer; }
.tabs button.active { background: var(--accent); color: #fff; }
.logout { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; }
.logout:hover { color: var(--text); }

.container { max-width: 1100px; margin: 0 auto; padding: 22px 20px 80px; }
.view { display: none; animation: fade .25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }

/* ── Mes ── */
.month-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.month-bar h1 { font-size: 26px; min-width: 230px; text-align: center; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; position: relative; overflow: hidden; }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.stat .value { font-family: "JetBrains Mono", monospace; font-size: 24px; font-weight: 600; margin-top: 4px; }
.stat .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat.hl { background: linear-gradient(140deg, rgba(124,108,255,.25), rgba(163,92,255,.08)); border-color: rgba(124,108,255,.45); }
.stat::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--c, transparent); }

/* ── Lista días ── */
.days { display: flex; flex-direction: column; gap: 6px; }
.week-sep { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 14px 4px 4px; }
.day {
  display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 13px; padding: 10px 14px;
  cursor: pointer; transition: .12s; text-align: left; font: inherit; color: inherit; width: 100%;
}
.day:hover { border-color: var(--accent); transform: translateX(2px); }
.day.empty { background: transparent; border-style: dashed; opacity: .7; }
.day.empty:hover { opacity: 1; }
.day.off { opacity: .55; }
.day.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.day-date { display: flex; flex-direction: column; line-height: 1.1; }
.day-date .n { font-size: 22px; font-weight: 800; font-family: "JetBrains Mono", monospace; }
.day-date .w { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.day-body { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.seg-chip { font-family: "JetBrains Mono", monospace; font-size: 12.5px; font-weight: 600; padding: 4px 9px; border-radius: 7px; }
.seg-chip.trabajo { background: var(--work-bg); color: var(--work); }
.seg-chip.viaje { background: var(--travel-bg); color: var(--travel); }
.seg-chip.viaje::before { content: "✈ "; }
.tag { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; background: var(--card2); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.day-note { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.day-tot { display: flex; align-items: center; gap: 10px; font-family: "JetBrains Mono", monospace; font-size: 14px; }
.diff { font-weight: 600; padding: 3px 8px; border-radius: 7px; font-size: 13px; min-width: 62px; text-align: center; }
.diff.pos { color: var(--pos); background: rgba(74,222,128,.12); }
.diff.neg { color: var(--neg); background: rgba(248,113,113,.12); }
.diff.zero { color: var(--muted); background: var(--card2); }
.timeline { position: relative; height: 6px; border-radius: 4px; background: var(--card2); width: 100%; flex-basis: 100%; margin-top: 4px; overflow: hidden; }
.timeline i { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.timeline i.trabajo { background: var(--work); }
.timeline i.viaje { background: var(--travel); }

/* ── Modal ── */
.modal {
  border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 20px; padding: 0;
  width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 24px); box-shadow: var(--shadow);
}
.modal.small-modal { width: min(560px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(5,7,12,.6); backdrop-filter: blur(4px); }
.modal form { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.date-title { font-size: 20px; font-weight: 700; border: 0; background: transparent; padding: 2px 0; width: auto; }
.date-title:focus { box-shadow: none; }
.seg-head { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.seg-list { display: flex; flex-direction: column; gap: 8px; }
.seg-row { display: grid; grid-template-columns: 112px 128px 14px 128px 1fr 44px 34px; gap: 8px; align-items: center; background: var(--bg2); padding: 8px; border-radius: 12px; border-left: 3px solid var(--work); }
.seg-row.viaje { border-left-color: var(--travel); }
.seg-row .arrow { color: var(--muted); text-align: center; }
.seg-row .dur { font-family: "JetBrains Mono", monospace; font-size: 13px; color: var(--muted); text-align: right; }
.seg-row .icon-btn { width: 34px; height: 34px; font-size: 15px; }
.kind-sw { display: flex; background: var(--card); border-radius: 9px; padding: 3px; border: 1px solid var(--line); }
.kind-sw button { flex: 1; font: inherit; font-size: 12px; font-weight: 700; border: 0; background: none; color: var(--muted); padding: 6px 4px; border-radius: 7px; cursor: pointer; }
.kind-sw button.on.trabajo { background: var(--work-bg); color: var(--work); }
.kind-sw button.on.viaje { background: var(--travel-bg); color: var(--travel); }
.seg-row.tipo { grid-template-columns: 112px 128px 14px 128px 34px; }
.seg-row input[type=time] { padding: 9px 8px; }
.empty-segs { color: var(--muted); font-size: 14px; padding: 14px; text-align: center; border: 1px dashed var(--line); border-radius: 12px; }

.preview { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; background: var(--bg2); border-radius: 14px; padding: 12px; }
.preview div { display: flex; flex-direction: column; }
.preview span { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.preview b { font-family: "JetBrains Mono", monospace; font-size: 17px; font-weight: 600; }
.modal-foot { display: flex; gap: 10px; align-items: center; padding-top: 6px; }

/* ── Ajustes ── */
.settings { max-width: 760px; margin: 0 auto; }
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin: 10px 0; }
.week-grid label { text-align: center; }
.week-grid input { text-align: center; font-family: "JetBrains Mono", monospace; }
.seg-toggle { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin: 10px 0; }
.seg-toggle label { cursor: pointer; }
.seg-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.seg-toggle span { display: flex; flex-direction: column; gap: 3px; padding: 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg2); height: 100%; }
.seg-toggle b { color: var(--text); font-size: 14px; }
.seg-toggle small { color: var(--muted); font-weight: 500; }
.seg-toggle input:checked + span { border-color: var(--accent); background: rgba(124,108,255,.1); }
.seg-toggle.compact span { padding: 10px 12px; }
.form-foot { margin-top: 22px; display: flex; justify-content: flex-end; }

/* ── Bolsa ── */
.bolsa-hero { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px;
  background: linear-gradient(140deg, rgba(124,108,255,.22), rgba(45,212,191,.06)); border-color: rgba(124,108,255,.4); }
.hero-num { font-family: "JetBrains Mono", monospace; font-size: 46px; font-weight: 600; letter-spacing: -.03em; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--card2); border-radius: 8px; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .num { font-weight: 600; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
table.mt { width: 100%; border-collapse: collapse; font-size: 14px; }
table.mt th { text-align: left; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.mt td { padding: 9px 6px; border-bottom: 1px solid var(--line); font-family: "JetBrains Mono", monospace; }
table.mt td:first-child { font-family: inherit; font-weight: 600; text-transform: capitalize; }
table.mt th:not(:first-child), table.mt td:not(:first-child) { text-align: right; }

/* ── Toast ── */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; transition: .25s;
  background: var(--card2); border: 1px solid var(--line); padding: 11px 18px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow); z-index: 100; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { color: var(--neg); border-color: var(--neg); }

/* ── Responsive ── */
@media (max-width: 760px) {
  .topbar { gap: 10px; padding: 10px 14px; }
  .brand { font-size: 0; gap: 0; }
  .tabs button { padding: 7px 11px; font-size: 13px; }
  .container { padding: 16px 12px 80px; }
  .month-bar h1 { font-size: 21px; min-width: 0; flex: 1; }
  .month-bar .spacer { display: none; }
  .month-bar #csvBtn { display: none; }
  .month-bar #addTodayBtn { width: 100%; }
  .stat .value { font-size: 20px; }
  .day { grid-template-columns: 46px 1fr; }
  .day-tot { grid-column: 1 / -1; justify-content: flex-end; }
  .day-note { max-width: 100%; }
  .fields.three { grid-template-columns: 1fr 1fr; }
  .fields.three label:last-child { grid-column: 1 / -1; }
  .seg-row { grid-template-columns: 1fr 1fr 34px; }
  .seg-row .kind-sw { grid-column: 1 / -1; }
  .seg-row .arrow { display: none; }
  .seg-row .note-in { grid-column: 1 / -1; order: 5; }
  .seg-row .dur { order: 6; text-align: left; }
  .seg-row .icon-btn { order: 7; justify-self: end; grid-column: 3; }
  .seg-row.tipo { grid-template-columns: 1fr 1fr 34px; }
  .preview { grid-template-columns: 1fr 1fr; }
  .week-grid { grid-template-columns: repeat(4, 1fr); }
  .seg-toggle, .grid2 { grid-template-columns: 1fr; }
  .hero-num { font-size: 36px; }
  .modal form { padding: 16px; }
}

.travel-hero { background: linear-gradient(140deg, rgba(248,113,113,.14), rgba(251,191,36,.06)); border-color: rgba(248,113,113,.35); }
.year-mini { display: grid; grid-template-columns: auto auto; gap: 4px 16px; align-items: baseline; }
.year-mini span { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.year-mini b { font-family: "JetBrains Mono", monospace; font-weight: 600; font-size: 17px; text-align: right; }
.rate-hint { background: var(--bg2); border-radius: 10px; padding: 10px 14px; font-size: 14px; }
.rate-hint b { font-family: "JetBrains Mono", monospace; color: var(--accent2); }
input:disabled { opacity: .45; }
@media (max-width: 760px) { .travel-hero { flex-direction: column; align-items: flex-start; } }
