@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600&family=Ubuntu+Mono:wght@400;700&display=swap');

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f0f0f0;
  --text2: #999;
  --text3: #555;
  --green: #23c47a;
  --green-dim: rgba(35, 196, 122, 0.12);
  --green-border: rgba(35, 196, 122, 0.25);
  --red: #ff5c5c;
  --red-dim: rgba(255, 92, 92, 0.1);
  --red-border: rgba(255, 92, 92, 0.25);
  --amber: #f0a500;
  --amber-dim: rgba(240, 165, 0, 0.1);
  --amber-border: rgba(240, 165, 0, 0.25);
  --blue: #4d9ef5;
  --blue-dim: rgba(77, 158, 245, 0.1);
  --blue-border: rgba(77, 158, 245, 0.2);
  --purple: #a78bfa;
  --purple-dim: rgba(167, 139, 250, 0.1);
}

[data-theme="light"] {
  --bg: #f0f0f7;
  --surface: #ffffff;
  --surface2: #e8e8f2;
  --border: rgba(80, 80, 180, 0.12);
  --border-strong: rgba(80, 80, 180, 0.25);
  --text: #1a1a2e;
  --text2: #5555880;
  --text3: #aaaacc;
  --green: #009e7f;
  --green-dim: rgba(0, 158, 127, 0.08);
  --green-border: rgba(0, 158, 127, 0.2);
  --red: #e03e3e;
  --red-dim: rgba(224, 62, 62, 0.08);
  --red-border: rgba(224, 62, 62, 0.2);
  --amber: #c47d00;
  --amber-dim: rgba(196, 125, 0, 0.08);
  --amber-border: rgba(196, 125, 0, 0.2);
  --blue: #4a5aee;
  --blue-dim: rgba(74, 90, 238, 0.08);
  --blue-border: rgba(74, 90, 238, 0.18);
  --purple: #9333ea;
  --purple-dim: rgba(147, 51, 234, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* Loading */
#loading {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  flex-direction: column;
  gap: 12px;
}

#loading .spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--surface2);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

#loading p {
  font-size: 13px;
  color: var(--text2);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Layout */
.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 .5rem;
}

.logo-icon {
  width: 28px;
  height: 28px;
  background: var(--green);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.logo-text {
  font-size: 15px;
  font-weight: 600;
}

.logo-sub {
  font-size: 11px;
  color: var(--text2);
}

nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.nav-item.active {
  background: var(--surface2);
  color: var(--text);
}

.sidebar-footer {
  margin-top: auto;
  font-size: 11px;
  color: var(--text3);
  padding: 0 .5rem;
  line-height: 1.6;
}

.sync-status {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  text-align: center;
  margin-top: 8px;
}

.sync-status.ok {
  color: var(--green);
}

.sync-status.err {
  color: var(--red);
}

main {
  padding: 2rem;
  overflow-y: auto;
}

.pane {
  display: none;
}

.pane.active {
  display: block;
}

.page-title {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: .25rem;
}

.page-sub {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 1.75rem;
}

/* Grids */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.125rem;
}

.card.green {
  border-color: var(--green-border);
  background: linear-gradient(135deg, var(--surface) 60%, rgba(35, 196, 122, 0.05));
}

.card.red {
  border-color: var(--red-border);
}

.card.amber {
  border-color: var(--amber-border);
}

/* Metrics */
.metric-lbl {
  font-size: 11px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 4px;
}

.metric-val {
  font-size: 24px;
  font-weight: 600;
  font-family: 'Ubuntu Mono', monospace;
}

.metric-val.green {
  color: var(--green);
}

.metric-val.red {
  color: var(--red);
}

.metric-sub {
  font-size: 11px;
  color: var(--text2);
  margin-top: 3px;
}

/* Bars */
.bar-wrap {
  background: var(--surface2);
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
  margin: 10px 0 6px;
}

.bar {
  height: 100%;
  border-radius: 4px;
  transition: width .4s cubic-bezier(.4, 0, .2, 1);
}

.bar-nums {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}

.bar-spent {
  color: var(--text2);
  font-family: 'Ubuntu Mono', monospace;
}

.bar-rest {
  color: var(--text3);
  font-family: 'Ubuntu Mono', monospace;
}

.bar-rest.over {
  color: var(--red);
  font-weight: 500;
}

/* Banners */
.banner {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.5;
  margin: 1rem 0;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.banner.ok {
  background: var(--green-dim);
  border: 1px solid var(--green-border);
  color: var(--green);
}

.banner.warn {
  background: var(--amber-dim);
  border: 1px solid var(--amber-border);
  color: var(--amber);
}

.banner.bad {
  background: var(--red-dim);
  border: 1px solid var(--red-border);
  color: var(--red);
}

.banner.info {
  background: var(--blue-dim);
  border: 1px solid var(--blue-border);
  color: var(--blue);
}

.sec {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin: 1.5rem 0 .75rem;
}

/* Form */
.form-add {
  display: grid;
  grid-template-columns: 1fr 100px 130px 130px 40px;
  gap: 8px;
  align-items: center;
}

input[type=text],
input[type=number],
select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  padding: 0 10px;
  height: 36px;
  width: 100%;
  outline: none;
  transition: border .15s;
}

input:focus,
select:focus {
  border-color: var(--border-strong);
}

select option {
  background: #1a1a1a;
}

.btn-theme {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 12px;
  padding: 6px 10px;
  cursor: pointer;
  font-family: 'Plus Jakarta Sans', sans-serif;
  transition: all .15s;
  width: 100%;
  text-align: left;
}

.btn-theme:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-add {
  width: 36px;
  height: 36px;
  background: var(--green);
  border: none;
  border-radius: var(--radius-sm);
  color: #000;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
  transition: opacity .15s;
}

.btn-add:hover {
  opacity: .85;
}

.btn-add:disabled {
  opacity: .4;
  cursor: not-allowed;
}

/* Expense list */
.list-hd {
  display: grid;
  grid-template-columns: 1fr 90px 100px 100px 32px;
  gap: 8px;
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 0 2px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}

.exp-row {
  display: grid;
  grid-template-columns: 1fr 90px 100px 100px 32px;
  gap: 8px;
  align-items: center;
  padding: 7px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.exp-row:last-child {
  border-bottom: none;
}

.exp-d {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.exp-m {
  font-family: 'Ubuntu Mono', monospace;
  font-weight: 500;
}

.pill {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 500;
  display: inline-block;
  white-space: nowrap;
}

.pill-yo {
  background: var(--blue-dim);
  color: var(--blue);
  border: 1px solid var(--blue-border);
}

.pill-vi {
  background: var(--purple-dim);
  color: var(--purple);
  border: 1px solid rgba(167, 139, 250, .2);
}

.pill-nu {
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border);
}

.pill-bb {
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border);
}

.btn-del {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color .15s;
}

.btn-del:hover {
  color: var(--red);
}

.empty-state {
  text-align: center;
  padding: 2rem 0;
  color: var(--text3);
  font-size: 13px;
}

/* Tarjetas */
.tc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.tc-head {
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tc-name {
  font-size: 13px;
  font-weight: 600;
}

.tc-corte {
  font-size: 11px;
  color: var(--text2);
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: 20px;
}

.tc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.tc-row .label {
  color: var(--text2);
}

.tc-row .amount {
  font-family: 'Ubuntu Mono', monospace;
  font-weight: 500;
}

.tc-total {
  background: var(--surface2);
  padding: 10px 1rem;
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  border-top: 1px solid var(--border);
}

.tc-reserva {
  padding: 10px 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text2);
}

.tc-reserva .rv {
  font-family: 'Ubuntu Mono', monospace;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

/* Cheat sheet */
.quinc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.quinc-row:last-child {
  border-bottom: none;
}

.qn {
  font-size: 14px;
  font-weight: 500;
}

.qn.green {
  color: var(--green);
}

.qs {
  font-size: 11px;
  color: var(--text2);
  margin-top: 2px;
}

.qa {
  text-align: right;
}

.qa-amt {
  font-size: 20px;
  font-weight: 600;
  font-family: 'Ubuntu Mono', monospace;
}

.qa-mes {
  font-size: 11px;
  color: var(--text2);
  margin-top: 1px;
}

.total-quinc {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  padding: 12px 0 0;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  color: var(--text2);
}

.total-quinc span:last-child {
  color: var(--green);
}

/* Fijos */
.fijo-row {
  display: grid;
  grid-template-columns: 1fr 100px 120px 110px;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  align-items: center;
}

.fijo-row:last-child {
  border-bottom: none;
}

.fijo-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 500;
  display: inline-block;
}

.tag-green {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid var(--green-border);
}

.tag-amber {
  background: var(--amber-dim);
  color: var(--amber);
  border: 1px solid var(--amber-border);
}

.tag-red {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red-border);
}

/* MX5 */
.mx5-bar-wrap {
  background: var(--surface2);
  border-radius: 4px;
  height: 10px;
  overflow: hidden;
  margin-bottom: 8px;
}

.mx5-bar {
  height: 100%;
  background: var(--green);
  border-radius: 4px;
  transition: width .4s;
}

.mx5-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text2);
  font-family: 'Ubuntu Mono', monospace;
}

.sim-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.sim-row input {
  width: 120px;
}

.sim-result {
  font-size: 13px;
  color: var(--text2);
}

.sim-result strong {
  color: var(--green);
}

/* Misc */
.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 12px;
  padding: 5px 12px;
  cursor: pointer;
  font-family: 'Plus Jakarta Sans', sans-serif;
  transition: all .15s;
}

.btn-ghost:hover {
  border-color: var(--red-border);
  color: var(--red);
}

.tope-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.tope-row label {
  font-size: 12px;
  color: var(--text2);
  min-width: 140px;
}

.tope-row input {
  width: 110px;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

.mono {
  font-family: 'Ubuntu Mono', monospace;
}

/* Mobile */
@media(max-width:700px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .grid-4 {
    grid-template-columns: 1fr 1fr;
  }

  .form-add {
    grid-template-columns: 1fr 90px;
    gap: 6px;
  }

  .form-add .btn-add {
    grid-column: 1/-1;
    width: 100%;
  }

  .list-hd,
  .exp-row {
    grid-template-columns: 1fr 80px 80px 28px;
  }

  .list-hd span:nth-child(3),
  .exp-row span:nth-child(3) {
    display: none;
  }

  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 100;
  }

  .mobile-nav button {
    flex: 1;
    padding: 10px 4px 14px;
    background: none;
    border: none;
    color: var(--text2);
    font-size: 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
  }

  .mobile-nav button.active {
    color: var(--green);
  }

  .mobile-nav button span {
    font-size: 18px;
  }

  main {
    padding: 1rem 1rem 5rem;
  }
}

@media(min-width:701px) {
  .mobile-nav {
    display: none;
  }
}
