:root {
  --bg: #060606;
  --rail: #0E0E0E;
  --tile: #161616;
  --tile-2: #1F1F1F;
  --tile-3: #2A2A2A;
  --line: #262626;
  --text: #F2F2EF;
  --muted: #8C8C88;
  --dim: #5C5C58;

  --green: #2EE62E;
  --green-ink: #050F05;
  --white: #F2F2EF;
  --gray-1: #D8DBDE;
  --gray-2: #B3B6B9;
  --gray-3: #8D9093;
  --blue: #7C93FF;
  --amber: #F6C453;
  --red: #FF6A5A;

  --r: 26px;
  --r-sm: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border: 0; border-radius: 999px; padding: 11px 20px; cursor: pointer;
  background: var(--tile-2); color: var(--text); font-size: 14px; font-weight: 500;
  transition: transform .12s, background .15s, filter .15s; white-space: nowrap;
}
.btn:hover { background: var(--tile-3); }
.btn:active { transform: scale(.98); }
.btn.white { background: var(--white); color: #0A0A0A; }
.btn.white:hover { filter: brightness(.92); }
.btn.green { background: var(--green); color: var(--green-ink); }
.btn.green:hover { filter: brightness(.92); }
.btn.big { padding: 8px 8px 8px 24px; font-size: 16px; justify-content: space-between; }
.btn.danger { color: var(--red); }
.ico-circle { width: 42px; height: 42px; border-radius: 50%; background: var(--green-ink); color: var(--green); display: grid; place-items: center; }

.icon-btn, .round {
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; background: var(--tile-2); color: var(--text);
  transition: background .15s, transform .15s;
}
.icon-btn:hover, .round:hover { background: var(--tile-3); }
.round.white { background: var(--white); color: #0A0A0A; }
.round.green { background: var(--green); color: var(--green-ink); }
.round.dark { background: #0A0A0A; color: var(--white); }
.round:hover svg { transform: translate(1px, -1px); }
.round svg { transition: transform .15s; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.15fr 1fr; gap: 14px; padding: 14px; }
.login-art {
  background: var(--green); color: var(--green-ink); border-radius: var(--r);
  padding: 40px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; overflow: hidden;
}
.login-logo { width: 64px; height: 64px; border-radius: 50%; background: var(--green-ink); display: grid; place-items: center; }
.login-logo img { width: 30px; filter: invert(1); }
.login-kicker { margin: 0 0 12px; font-size: 14px; font-weight: 500; }
.login-title { margin: 0; font-weight: 300; font-size: clamp(44px, 6vw, 88px); line-height: .98; letter-spacing: -.04em; }
.steps { display: flex; align-items: flex-end; gap: 10px; height: 160px; }
.steps i { flex: 1; border-radius: 20px; display: block; }
.steps i:nth-child(1) { height: 26%; background: rgba(5, 15, 5, .10); }
.steps i:nth-child(2) { height: 38%; background: rgba(5, 15, 5, .22); }
.steps i:nth-child(3) { height: 54%; background: rgba(5, 15, 5, .40); }
.steps i:nth-child(4) { height: 74%; background: rgba(5, 15, 5, .65); }
.steps i:nth-child(5) { height: 100%; background: var(--green-ink); }
.login-box { background: var(--tile); border-radius: var(--r); display: grid; place-items: center; padding: 40px 24px; }
.login-form { width: min(380px, 100%); display: grid; gap: 18px; }
.login-form h2 { margin: 0; font-size: 32px; font-weight: 500; letter-spacing: -.02em; }
.login-form > p { margin: -10px 0 8px; }
.login-error { color: var(--red); margin: 0; min-height: 1.2em; font-size: 14px; }
.check { display: flex; gap: 10px; align-items: center; font-size: 14px; color: var(--muted); cursor: pointer; }
.check input { accent-color: var(--green); width: 16px; height: 16px; }

/* ---------- Forms ---------- */
label.f { display: grid; gap: 8px; font-size: 13px; color: var(--muted); }
.in {
  font: inherit; font-size: 15px; color: var(--text);
  background: var(--tile-2); border: 1px solid transparent; border-radius: 14px;
  padding: 13px 16px; outline: none; width: 100%; transition: border-color .15s, background .15s;
}
.in:focus { border-color: var(--green); background: #1A1A1A; }
.in::placeholder { color: var(--dim); }
select.in { appearance: none; cursor: pointer; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238C8C88' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 16px; }
input[type="date"].in { color-scheme: dark; }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: 92px 1fr; min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; background: var(--rail);
  display: flex; flex-direction: column; align-items: center; gap: 28px; padding: 22px 0;
}
.rail-logo { width: 52px; height: 52px; border-radius: 50%; background: var(--green); display: grid; place-items: center; }
.rail-logo img { width: 24px; }
#nav { display: flex; flex-direction: column; gap: 10px; }
#nav a, .rail-btn {
  width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; position: relative;
  color: var(--muted); background: transparent; border: 0; cursor: pointer; transition: background .15s, color .15s;
}
#nav a:hover, .rail-btn:hover { color: var(--text); background: var(--tile-2); }
#nav a.active { background: var(--white); color: #0A0A0A; }
#nav a b { position: absolute; top: 4px; right: 4px; min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px; background: var(--green); color: var(--green-ink); font-size: 11px; display: grid; place-items: center; }
#nav a .tip { position: absolute; left: 60px; background: var(--white); color: #0A0A0A; font-size: 12px; padding: 5px 10px; border-radius: 8px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 10; }
#nav a:hover .tip { opacity: 1; }
.rail-btn { margin-top: auto; background: var(--tile-2); }

.main-wrap { min-width: 0; padding: 20px 28px 64px; }
.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.search-pill { display: flex; align-items: center; gap: 10px; background: var(--tile); border-radius: 999px; padding: 0 18px; height: 48px; width: min(380px, 100%); color: var(--muted); }
.search-pill input { background: none; border: 0; outline: none; color: var(--text); font: inherit; width: 100%; }
.date-pill { font-size: 14px; font-weight: 500; padding: 0 6px; white-space: nowrap; }
.top-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--green); color: var(--green-ink); font-weight: 600; font-size: 14px; display: grid; place-items: center; }

main { max-width: 1400px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { margin: 0; font-size: clamp(30px, 3.2vw, 42px); font-weight: 500; letter-spacing: -.03em; line-height: 1.05; }
.page-head p { margin: 8px 0 0; color: var(--muted); }
.page-head .back { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.page-head .back:hover { color: var(--text); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- Tiles ---------- */
.bento { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; margin-bottom: 14px; }
.tile { background: var(--tile); border-radius: var(--r); padding: 22px 24px; min-width: 0; position: relative; }
.tile.white { background: var(--white); color: #0A0A0A; }
.tile.green { background: var(--green); color: var(--green-ink); }
.tile.g1 { background: var(--gray-1); color: #0A0A0A; }
.tile.g2 { background: var(--gray-2); color: #0A0A0A; }
.tile.g3 { background: var(--gray-3); color: #0A0A0A; }
.tile.t3 { background: var(--tile-3); }
.s3 { grid-column: span 3; } .s4 { grid-column: span 4; } .s5 { grid-column: span 5; }
.s6 { grid-column: span 6; } .s7 { grid-column: span 7; } .s8 { grid-column: span 8; } .s12 { grid-column: span 12; }
.s2 { grid-column: span 2; }
.r2 { grid-row: span 2; }

.tile-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.tile-head h3 { margin: 0; font-size: 16px; font-weight: 500; }
.tile-head .muted { font-size: 13px; }
.label { font-size: 14px; }
.kpi { display: flex; flex-direction: column; justify-content: space-between; min-height: 172px; }
.kpi .tile-head { margin-bottom: 0; }
.kpi .v { font-size: clamp(30px, 2.6vw, 40px); font-weight: 300; letter-spacing: -.03em; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.kpi .sub { font-size: 12px; opacity: .6; margin-top: 8px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; padding: 3px 9px; border-radius: 999px; letter-spacing: 0; }
.badge.up { background: rgba(46, 230, 46, .16); color: var(--green); }
.badge.down { background: rgba(255, 106, 90, .16); color: var(--red); }
.tile.white .badge.up { background: #CFF7CF; color: #0F6A0F; }
.tile.white .badge.down { background: #FFD9D4; color: #A3291C; }

/* Big number tiles */
.huge { font-size: clamp(48px, 5vw, 76px); font-weight: 300; letter-spacing: -.05em; line-height: 1; font-variant-numeric: tabular-nums; }
.huge small { font-size: .38em; letter-spacing: -.01em; margin-left: 8px; }
.stack { display: flex; flex-direction: column; justify-content: space-between; gap: 18px; min-height: 230px; }
.stack p { margin: 0; font-size: 14px; }
.stack p em { font-style: normal; color: var(--green); }

/* Monthly chart */
.chart { display: grid; grid-template-columns: repeat(12, 1fr); gap: 10px; align-items: end; height: 250px; margin-top: 8px; }
.chart .col { display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; height: 100%; gap: 10px; position: relative; }
.chart .bar { border-radius: 12px; background: var(--tile-3); min-height: 6px; transition: background .15s; }
.chart .bar.has { background: #3B3B3B; }
.chart .bar.now { background: var(--green); }
.chart .col:hover .bar.has { background: var(--white); }
.chart .col:hover .bar.now { background: var(--green); filter: brightness(1.1); }
.chart span { font-size: 11px; color: var(--muted); text-align: center; }
.chart .tip { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(100% - 22px); background: var(--white); color: #0A0A0A; font-size: 12px; font-weight: 500; padding: 4px 8px; border-radius: 8px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .15s; }
.chart .col:hover .tip { opacity: 1; }

/* Pipeline blocks */
.pipe { display: flex; align-items: flex-end; gap: 8px; height: 120px; margin-top: 14px; }
.pipe div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; height: 100%; }
.pipe i { display: block; border-radius: 14px; min-height: 14px; }
.pipe span { font-size: 11px; font-weight: 500; }

/* Lists in tiles */
.rows { display: flex; flex-direction: column; gap: 8px; }
.row-link { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 14px 16px; border-radius: var(--r-sm); background: var(--tile-2); transition: background .15s; }
.row-link:hover { background: var(--tile-3); }
.row-link .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-link .a { text-align: right; font-variant-numeric: tabular-nums; }
.row-link .m { font-size: 12px; color: var(--muted); }
.empty { padding: 18px; border-radius: var(--r-sm); background: var(--tile-2); color: var(--muted); font-size: 14px; }

/* Client mosaic */
.mosaic .tile { min-height: 150px; display: flex; flex-direction: column; justify-content: space-between; gap: 18px; transition: transform .15s; }
.mosaic .tile:hover { transform: translateY(-2px); }
.mosaic .name { font-size: 14px; font-weight: 500; }
.mosaic .amt { font-size: clamp(22px, 2vw, 30px); font-weight: 300; letter-spacing: -.03em; }
.mosaic .pct { font-size: 12px; opacity: .65; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin: 30px 0 14px; }
.section-title h2 { margin: 0; font-size: 24px; font-weight: 400; letter-spacing: -.02em; }

/* Stat tiles with colored cap */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--tile); border-radius: 22px; overflow: hidden; border: 0; padding: 0; text-align: left; cursor: pointer; outline: 2px solid transparent; outline-offset: 2px; transition: outline-color .15s, transform .15s; }
.stat:hover { transform: translateY(-2px); }
.stat.on { outline-color: var(--white); }
.stat .cap { padding: 10px 18px; font-size: 14px; font-weight: 500; color: #0A0A0A; }
.stat .body { padding: 16px 18px 20px; display: flex; align-items: center; gap: 12px; }
.stat .n { font-size: 34px; font-weight: 400; letter-spacing: -.02em; }
.stat .m { font-size: 12px; color: var(--muted); }
.cap-all { background: var(--white); }
.cap-gray { background: var(--gray-2); }
.cap-blue { background: var(--blue); }
.cap-green { background: var(--green); }
.cap-amber { background: var(--amber); }
.cap-red { background: var(--red); }

/* Tables */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .search-pill { background: var(--tile); height: 44px; }
.toolbar .count { color: var(--muted); font-size: 14px; }
.toolbar .count b { color: var(--text); font-weight: 500; }
.toolbar .actions { margin-left: auto; }
.table-tile { background: var(--tile); border-radius: var(--r); padding: 10px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 500; padding: 14px 16px; background: var(--tile-2); white-space: nowrap; }
th:first-child { border-radius: 14px 0 0 14px; } th:last-child { border-radius: 0 14px 14px 0; }
td { padding: 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tr.go { cursor: pointer; }
tr.go:hover td { background: rgba(255, 255, 255, .03); }
td .sub { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
td a:hover { color: var(--green); }
.nw { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { border-top: 1px solid var(--line); border-bottom: 0; font-weight: 500; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 5px 12px; border-radius: 999px; white-space: nowrap; }
.s-borrador, .s-rechazado { background: rgba(179, 182, 185, .14); color: var(--gray-2); }
.s-enviado { background: rgba(124, 147, 255, .16); color: var(--blue); }
.s-aceptado, .s-pagada { background: rgba(46, 230, 46, .14); color: var(--green); }
.s-pendiente { background: rgba(246, 196, 83, .16); color: var(--amber); }
.s-aceptado { background: rgba(246, 196, 83, .16); color: var(--amber); }
.s-facturado { background: rgba(46, 230, 46, .14); color: var(--green); }

/* Year pills */
.tabs-pill { display: inline-flex; gap: 4px; padding: 4px; background: var(--tile); border-radius: 999px; }
.tabs-pill button { border: 0; background: transparent; color: var(--muted); padding: 8px 14px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 500; }
.tabs-pill button:hover { color: var(--text); }
.tabs-pill button.on { background: var(--white); color: #0A0A0A; }

/* Expenses */
.x-round { width: 32px; height: 32px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; }
.x-round:hover { background: rgba(255, 106, 90, .16); color: var(--red); }
.empty-big { padding: 48px 24px; text-align: center; display: grid; gap: 16px; justify-items: center; }
.empty-big p { margin: 0; color: var(--muted); max-width: 520px; }
.empty-big .huge { color: var(--dim); }
.s-vencida { background: rgba(255, 106, 90, .16); color: var(--red); }

.note { display: flex; gap: 14px; align-items: center; padding: 12px 12px 12px 20px; border-radius: 999px; background: var(--tile); font-size: 14px; color: var(--muted); margin-bottom: 18px; flex-wrap: wrap; }
.note strong { color: var(--text); font-weight: 500; }
.note .btn { margin-left: auto; }

/* Client detail */
.facts { display: grid; gap: 8px; margin: 0; }
.facts div { background: var(--tile-2); border-radius: var(--r-sm); padding: 12px 16px; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.facts a:hover { color: var(--green); }

/* Quote editor */
.editor { display: grid; grid-template-columns: 1fr 340px; gap: 14px; align-items: start; }
.fields { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.fields .wide { grid-column: 1 / -1; }
.in.title { font-size: 22px; font-weight: 400; letter-spacing: -.02em; padding: 16px 18px; }
.lines { min-width: 560px; }
.lines td { padding: 6px 4px; border-bottom: 0; }
.lines th { padding: 10px 12px; }
.lines .in { padding: 11px 12px; border-radius: 12px; }
.lines .in.r { text-align: right; }
.lines .x { width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 20px; }
.lines .x:hover { background: rgba(255, 106, 90, .16); color: var(--red); }
.add-line { margin-top: 12px; }
.side-stack { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 20px; }
.total-tile .huge { font-size: clamp(40px, 3.6vw, 54px); margin: 6px 0 18px; }
.total-tile .line { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid rgba(5, 15, 5, .14); font-variant-numeric: tabular-nums; font-size: 14px; }
.side-stack .btn { width: 100%; justify-content: space-between; }
.side-stack .tile .btn + .btn { margin-top: 8px; }

/* Dialog */
dialog { border: 0; padding: 0; border-radius: var(--r); width: min(560px, calc(100vw - 32px)); background: var(--tile); color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, .7); backdrop-filter: blur(4px); }
dialog form { padding: 30px; display: grid; gap: 16px; }
dialog h3 { margin: 0 0 6px; font-weight: 500; font-size: 28px; letter-spacing: -.02em; }
dialog .row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--white); color: #0A0A0A; padding: 12px 22px; border-radius: 999px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); z-index: 50;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .s3 { grid-column: span 6; }
  .s4, .s5, .s7 { grid-column: span 6; }
  .s6.r2, .s8 { grid-column: span 12; }
  .r2 { grid-row: auto; }
  .editor { grid-template-columns: 1fr; }
  .side-stack { position: static; }
  .mosaic .s4 { grid-column: span 12; }
  .mosaic .s2 { grid-column: span 3; }
}
@media (max-width: 760px) {
  .login { grid-template-columns: 1fr; }
  .login-art { padding: 28px; }
  .steps { height: 90px; }
  .app { grid-template-columns: 1fr; }
  .rail { position: fixed; z-index: 20; top: auto; bottom: 0; left: 0; right: 0; height: 72px; flex-direction: row; justify-content: space-around; padding: 0 12px; gap: 0; border-top: 1px solid var(--line); }
  .rail-logo { display: none; }
  #nav { flex-direction: row; gap: 6px; }
  #nav a .tip { display: none; }
  .rail-btn { margin: 0; }
  .main-wrap { padding: 16px 16px 100px; }
  .date-pill { display: none; }
  .bento { grid-template-columns: repeat(2, 1fr); }
  .bento > * { grid-column: span 2 !important; }
  .bento > .s3 { grid-column: span 1 !important; }
  .mosaic > .s2 { grid-column: span 1 !important; }
  .tile { padding: 18px; }
  .kpi { min-height: 150px; }
  .kpi .v { font-size: 26px; }
  .chart { gap: 4px; height: 190px; }
  .chart .bar { border-radius: 6px; }
  .chart span { font-size: 9px; }
  .fields { grid-template-columns: 1fr 1fr; }
  .fields .cli { grid-column: 1 / -1; }
  dialog .row { grid-template-columns: 1fr; }
  .note { border-radius: var(--r-sm); }
  .toolbar .search-pill { width: 100%; }
}
@media (max-width: 420px) {
  .bento > .s3 { grid-column: span 2 !important; }
}
