/* ─── TOKENS (Midori v2) ─── */
:root {
  --fondo:        #F7F6F2;
  --superficie:   #FFFFFF;
  --borde:        #E5E2DC;
  --borde-fuerte: #C8C4BC;
  --texto:        #1C1C1A;
  --muted:        #7A7670;
  --dim:          #B0ACA6;
  --acento:       #4D7C5C;
  --acento-bg:    #EBF3EE;
  --error:        #B94040;
  --error-bg:     #FDF0EE;
  --libre:        #F1EFEA;
}
[data-theme="dark"] {
  --fondo:        #0E0E0C;
  --superficie:   #161613;
  --borde:        #272720;
  --borde-fuerte: #3A3A30;
  --texto:        #F0EDE8;
  --muted:        #8A8780;
  --dim:          #504E48;
  --acento:       #6EAB7E;
  --acento-bg:    #1A2E1F;
  --error:        #E07060;
  --error-bg:     #2A1A18;
  --libre:        #1C1C18;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
  background: var(--fondo);
  color: var(--texto);
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  padding: 40px 24px 120px;
  transition: background 0.2s, color 0.2s;
}
button, input { font-family: inherit; }
a { color: var(--acento); }
.wrap { max-width: 1180px; margin: 0 auto; }
.wrap--narrow { max-width: 760px; }

/* ─── TOP BAR ─── */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 34px; gap: 12px; }
.brand { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.brand span { color: var(--acento); }
.topbar__actions { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar__user { font-size: 12.5px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.theme-toggle {
  flex-shrink: 0; width: 36px; height: 20px; background: var(--borde);
  border-radius: 10px; border: none; cursor: pointer; position: relative; transition: background 0.2s;
}
.theme-toggle::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px;
  background: var(--muted); border-radius: 50%; transition: transform 0.2s, background 0.2s;
}
[data-theme="dark"] .theme-toggle { background: var(--acento-bg); }
[data-theme="dark"] .theme-toggle::after { transform: translateX(16px); background: var(--acento); }

/* ─── HEADER ─── */
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--acento); margin-bottom: 10px; }
h1 { font-size: clamp(30px, 6vw, 44px); font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; margin-bottom: 14px; overflow-wrap: anywhere; }
h1 span { color: var(--acento); }
.intro { font-size: 15px; color: var(--muted); max-width: 64ch; line-height: 1.6; }

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 14px; font-weight: 600; padding: 11px 20px; border-radius: 6px;
  border: 1px solid transparent; cursor: pointer; line-height: 1; letter-spacing: -0.01em;
  transition: opacity 0.1s, background 0.1s, border-color 0.1s, color 0.1s;
  -webkit-tap-highlight-color: transparent; white-space: nowrap; text-decoration: none;
}
.btn:active { opacity: 0.75; }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn--primary   { background: var(--acento); color: #fff; border-color: var(--acento); }
[data-theme="dark"] .btn--primary { color: #F7F6F2; }
.btn--secondary { background: transparent; border-color: var(--borde); color: var(--muted); }
.btn--secondary:hover:not(:disabled) { border-color: var(--borde-fuerte); color: var(--texto); }
.btn--ghost     { background: transparent; color: var(--muted); }
.btn--ghost:hover:not(:disabled) { background: var(--borde); color: var(--texto); }
.btn--danger    { background: transparent; border-color: var(--borde); color: var(--error); }
.btn--danger:hover:not(:disabled) { border-color: var(--error); }
.btn--stop      { background: var(--error); border-color: var(--error); color: #fff; }
.btn--sm   { font-size: 12px; padding: 7px 13px; }
.btn--lg   { font-size: 16px; padding: 15px 34px; }
.btn--full { width: 100%; }

.icon-btn {
  width: 28px; height: 28px; flex-shrink: 0; display: grid; place-items: center; border: none; background: none;
  color: var(--dim); border-radius: 6px; cursor: pointer; font-size: 14px;
}
.icon-btn:hover { background: var(--borde); color: var(--texto); }

/* ─── LAYOUT ─── */
.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; margin-top: 40px; align-items: start; }
.side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 16px; }
.main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.panel { background: var(--superficie); border: 1px solid var(--borde); border-radius: 8px; padding: 18px 18px 20px; transition: background 0.2s, border-color 0.2s; }
.panel__head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.panel__title { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--acento); }
.panel__meta { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }
.hint { font-size: 12.5px; color: var(--dim); line-height: 1.55; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ─── FORMULARIOS ─── */
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; letter-spacing: 0.02em; }
.form-input {
  width: 100%; min-width: 0; background: var(--fondo); border: 1px solid var(--borde); border-radius: 6px; color: var(--texto);
  font-size: 14px; padding: 9px 12px; transition: border-color 0.1s;
}
.form-input:focus { outline: none; border-color: var(--acento); }
.form-input::placeholder { color: var(--dim); }
.form-input--sm { font-size: 13px; padding: 6px 10px; }
.form-stack { display: flex; flex-direction: column; gap: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.add-block { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--borde); }
.form-err { font-size: 13px; color: var(--error); }

/* ─── ESTADO EN LÍNEA ─── */
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex-shrink: 0; position: relative; }
.dot.is-on { background: var(--acento); }
.dot.is-on::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--acento);
  opacity: 0; animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse { 0% { transform: scale(0.5); opacity: 0.7; } 100% { transform: scale(1.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .dot.is-on::after { animation: none; } }
.status {
  display: inline-flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; color: var(--muted);
  padding: 6px 12px 6px 11px; border-radius: 999px; border: 1px solid var(--borde); background: var(--superficie);
}
.status.is-on { color: var(--acento); border-color: var(--acento); background: var(--acento-bg); }

/* ─── LISTA DE PROYECTOS ─── */
.projs { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.proj {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; background: none;
  border: 1px solid transparent; border-radius: 6px; cursor: pointer; color: var(--texto); text-align: left;
}
.proj:hover { background: var(--fondo); }
.proj.is-active { border-color: var(--acento); background: var(--acento-bg); }
.proj__name { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj__h { font-size: 12.5px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.sum { list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.sum li { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); }
.sum b { color: var(--texto); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ─── DETALLE ─── */
.detail-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.proj-title { font-size: clamp(26px, 5vw, 36px); font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; overflow-wrap: anywhere; }

.timer { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 30px 18px 28px; text-align: center; }
.timer.is-on { border-color: var(--acento); }
.timer__label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.timer__clock {
  font-size: clamp(48px, 12vw, 76px); font-weight: 700; letter-spacing: -0.04em; line-height: 1;
  font-variant-numeric: tabular-nums; color: var(--dim);
}
.timer.is-on .timer__clock { color: var(--texto); }
.timer__earn { font-size: 14px; font-weight: 600; color: var(--acento); font-variant-numeric: tabular-nums; min-height: 1.4em; }
.timer .btn { margin-top: 6px; min-width: 180px; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat__label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--acento); }
.stat__val { font-size: clamp(20px, 3.4vw, 28px); font-weight: 700; letter-spacing: -0.03em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat__sub { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }

.share { display: flex; gap: 8px; }
.share .form-input { font-size: 13px; color: var(--muted); }

/* ─── HISTORIAL ─── */
.hist { list-style: none; display: flex; flex-direction: column; }
.hist__row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: 4px 14px;
  padding: 10px 0; border-top: 1px solid var(--borde); font-size: 13px;
}
.hist__row:first-child { border-top: none; }
.hist__when { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.hist__when b { font-weight: 600; }
.hist__when span { color: var(--muted); font-variant-numeric: tabular-nums; }
.hist__dur { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hist__eur { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hist__note { grid-column: 1 / -1; }
.hist__note-text { grid-column: 1 / -1; color: var(--muted); font-size: 12.5px; }
.hist__row.is-live .hist__when b { color: var(--acento); }
.hist__row.is-prior .hist__when b { color: var(--muted); }
.hist--client .hist__row { grid-template-columns: minmax(0, 1fr) auto auto; }

.manual { margin-bottom: 12px; }
.manual > summary { list-style: none; cursor: pointer; display: inline-flex; }
.manual > summary::-webkit-details-marker { display: none; }
.manual__body { margin-top: 12px; padding: 14px; border: 1px solid var(--borde); border-radius: 6px; background: var(--fondo); }
.manual__body .form-input { background: var(--superficie); }

.empty { padding: 60px 20px; text-align: center; }
.empty h2 { font-size: 20px; letter-spacing: -0.02em; margin-bottom: 6px; }

.login { max-width: 380px; margin: 60px auto 0; }

/* ─── FLOTANTES ─── */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px); z-index: 400; opacity: 0;
  background: var(--texto); color: var(--fondo); font-size: 13px; font-weight: 500; padding: 10px 16px; border-radius: 6px;
  transition: opacity 0.2s, transform 0.2s; pointer-events: none; max-width: calc(100vw - 32px);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

.foot { margin-top: 28px; font-size: 12px; color: var(--dim); text-align: center; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; }
}
@media (max-width: 560px) {
  body { padding: 28px 16px 100px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats .stat:last-child { grid-column: 1 / -1; }
  .share { flex-wrap: wrap; }
  .hist__row { grid-template-columns: minmax(0, 1fr) auto auto; }
  .hist__eur { display: none; }
  .hist--client .hist__row { grid-template-columns: minmax(0, 1fr) auto auto; }
  .hist--client .hist__eur { display: inline; }
}
