:root {
  --bg: #0f1116;
  --surface: #171a23;
  --surface-2: #1f232f;
  --border: #2a2f3d;
  --text: #e8eaf0;
  --text-dim: #9aa1b2;
  --accent: #6c8cff;
  --accent-2: #35d0a4;
  --danger: #ff6b6b;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

.login-box h1 {
  margin: 0 0 4px;
  font-size: 26px;
  letter-spacing: -0.5px;
}

.login-box .subtitle {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 24px;
}

input, select, textarea, button {
  font-family: inherit;
  font-size: 14px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  margin-bottom: 12px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  transition: opacity 0.15s;
}

button:hover { opacity: 0.9; }

button.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

button.danger { background: var(--danger); }

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
}

#app-shell {
  display: none;
  min-height: 100vh;
  grid-template-columns: 220px 1fr;
  display: grid;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
}

.brand {
  font-size: 20px;
  font-weight: 700;
  padding: 0 12px 20px;
  letter-spacing: -0.5px;
}

.brand span { color: var(--accent); }

.nav-item {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 2px;
  cursor: pointer;
}

.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); font-weight: 600; border-left: 3px solid var(--accent); }

.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  font-size: 12px;
  color: var(--text-dim);
}

main {
  padding: 28px 36px;
  overflow-y: auto;
}

h2 { margin-top: 0; font-size: 22px; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.stat-card .label { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.stat-card .value { font-size: 22px; font-weight: 700; }
.stat-card .value.positive { color: var(--accent-2); }
.stat-card .value.negative { color: var(--danger); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

th { color: var(--text-dim); font-weight: 600; font-size: 12px; text-transform: uppercase; }

tr:hover td { background: var(--surface-2); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.badge.abierto { background: rgba(255, 193, 7, 0.15); color: #ffc107; }
.badge.pagado { background: rgba(53, 208, 164, 0.15); color: var(--accent-2); }
.badge.presupuesto { background: rgba(108, 140, 255, 0.15); color: var(--accent); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 480px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal h3 { margin-top: 0; }

.item-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 8px;
  align-items: center;
}

.item-row input { margin-bottom: 8px; }

.text-dim { color: var(--text-dim); font-size: 13px; }
.mt-0 { margin-top: 0; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

#tour-start-link {
  display: block;
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  margin-bottom: 8px;
  cursor: pointer;
}
#tour-start-link:hover { text-decoration: underline; }
#logout-link { text-decoration: none; }

/* ---------- Tour guiado ---------- */
.tour-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: transparent;
}

.tour-spotlight {
  position: fixed;
  z-index: 201;
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(6, 7, 10, 0.72);
  border: 2px solid var(--accent);
  pointer-events: none;
  transition: top 0.25s ease, left 0.25s ease, width 0.25s ease, height 0.25s ease;
}

.tour-spotlight.center-mode {
  box-shadow: 0 0 0 9999px rgba(6, 7, 10, 0.72);
  border: none;
}

.tour-tooltip {
  position: fixed;
  z-index: 202;
  width: 300px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
  transition: top 0.25s ease, left 0.25s ease;
}

.tour-tooltip .tour-step-count {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}

.tour-tooltip h4 {
  margin: 0 0 8px;
  font-size: 16px;
}

.tour-tooltip p {
  margin: 0 0 16px;
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.5;
}

.tour-tooltip .tour-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.tour-tooltip .tour-actions button {
  padding: 7px 12px;
  font-size: 13px;
}

.tour-tooltip .tour-skip {
  background: none;
  color: var(--text-dim);
  padding: 7px 4px;
  font-weight: 500;
}
.tour-tooltip .tour-skip:hover { color: var(--text); opacity: 1; }

.tour-tooltip .tour-nav-group { display: flex; gap: 6px; }
