/* App Portal & Admin Styles */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── Design tokens ────────────────────────────────────────────── */
:root {
  --bg-base:       #0a0909;
  --bg-surface:    #111010;
  --bg-card:       #181616;
  --bg-card-hover: #1f1d1d;

  --accent:        #c9f135;
  --accent-dim:    rgba(201,241,53,0.07);
  --accent-glow:   rgba(201,241,53,0.18);

  --text-primary:   #f0efec;
  --text-secondary: #7a7772;
  --text-muted:     #3f3d39;

  --border:        rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.13);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
  --shadow:    0 4px 24px rgba(0,0,0,0.7);

  --font-display: 'Space Grotesk', sans-serif;
  --font-body:    'DM Sans', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  --radius-sm: 6px;
  --radius:    8px;
  --radius-lg: 12px;
  --transition: 140ms ease;

  --sidebar-width: 220px;
}

html[data-theme="light"] {
  --bg-base:       #f4f2ef;
  --bg-surface:    #eae8e4;
  --bg-card:       #e2dfd9;
  --bg-card-hover: #d9d6d0;

  --accent:      #4d7600;
  --accent-dim:  rgba(77,118,0,0.08);
  --accent-glow: rgba(77,118,0,0.15);

  --text-primary:   #18160f;
  --text-secondary: #5a5751;
  --text-muted:     #9a9690;

  --border:        rgba(0,0,0,0.07);
  --border-strong: rgba(0,0,0,0.13);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07);
  --shadow:    0 4px 24px rgba(0,0,0,0.1);
}

/* ─── Animations ───────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0);   }
}
@keyframes statIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}
@keyframes rowIn {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0);    }
}
@keyframes orbDrift1 {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(-70px, 80px) scale(1.12); }
}
@keyframes orbDrift2 {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(90px, -60px) scale(0.88); }
}

/* ─── Reset ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; }

/* ─── Scrollbar ────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Focus ────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ─── Background effects ───────────────────────────────────────── */
.bg-effects {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  will-change: transform;
}
.bg-orb--1 {
  width: 700px; height: 600px;
  background: radial-gradient(circle, rgba(201,241,53,0.07) 0%, transparent 65%);
  top: -200px; right: -80px;
  animation: orbDrift1 20s ease-in-out infinite alternate;
}
.bg-orb--2 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(52,211,153,0.045) 0%, transparent 65%);
  bottom: -80px; right: 180px;
  animation: orbDrift2 26s ease-in-out infinite alternate;
}
html[data-theme="light"] .bg-orb--1 {
  background: radial-gradient(circle, rgba(77,118,0,0.08) 0%, transparent 65%);
}
html[data-theme="light"] .bg-orb--2 {
  background: radial-gradient(circle, rgba(16,185,129,0.06) 0%, transparent 65%);
}

/* ─── App shell ────────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; position: relative; z-index: 1; }

/* ─── Sidebar ──────────────────────────────────────────────────── */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
  /* subtle dot grid texture */
  background-image: radial-gradient(circle, var(--border) 1px, transparent 1px);
  background-size: 20px 20px;
  background-color: var(--bg-surface);
}

.sidebar-logo {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text-primary);
  margin-bottom: 30px;
  display: block;
  padding: 0 6px;
}
.sidebar-logo .dot { color: var(--accent); }

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

.sidebar-link {
  font-family: var(--font-display);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 8px 10px;
  border-radius: var(--radius);
  transition: background var(--transition), color var(--transition);
  display: flex;
  align-items: center;
  gap: 9px;
}
.sidebar-link svg { opacity: 0.6; flex-shrink: 0; transition: opacity var(--transition); }
.sidebar-link:hover { background: var(--bg-card); color: var(--text-primary); }
.sidebar-link:hover svg { opacity: 1; }
.sidebar-link.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(201,241,53,0.15);
}
.sidebar-link.active svg { opacity: 1; color: var(--accent); }
html[data-theme="light"] .sidebar-link.active {
  box-shadow: inset 0 0 0 1px rgba(77,118,0,0.2);
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.sidebar-email {
  font-size: 0.7rem;
  color: var(--text-muted);
  word-break: break-all;
  padding: 0 6px;
  font-family: var(--font-mono);
}
.sidebar-logout {
  font-size: 0.8rem;
  color: var(--text-secondary);
  transition: color var(--transition), background var(--transition);
  padding: 6px 10px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-logout:hover { color: var(--text-primary); background: var(--bg-card); }

/* ─── Main content ─────────────────────────────────────────────── */
.app-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 44px 52px;
  max-width: 1120px;
  animation: fadeUp 0.28s ease;
  position: relative;
}
/* Top accent glow */
.app-main::before {
  content: '';
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: 320px;
  background: radial-gradient(ellipse 70% 50% at 60% -10%, var(--accent-glow) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

/* ─── Page header ──────────────────────────────────────────────── */
.page-title {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
  line-height: 1.2;
}
.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 36px;
}

/* ─── Dashboard header ─────────────────────────────────────────── */
.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

/* ─── Section header ───────────────────────────────────────────── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  margin-top: 40px;
}
.section-title {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ─── Back link ────────────────────────────────────────────────── */
.back-link {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 28px;
  transition: color var(--transition);
}
.back-link:hover { color: var(--text-secondary); }

/* ─── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: border-color var(--transition);
}
.card + .card { margin-top: 16px; }
.card-title {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.card-meta { font-size: 0.8rem; color: var(--text-muted); }

/* ─── Badges ───────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.68rem;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
}
.badge::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.badge-en_progreso   { background: rgba(201,241,53,0.1);  color: #c9f135; }
.badge-revision      { background: rgba(251,191,36,0.1);  color: #fbbf24; }
.badge-entregado     { background: rgba(52,211,153,0.1);  color: #34d399; }
.badge-mantenimiento { background: rgba(139,92,246,0.1);  color: #8b5cf6; }
.badge-borrador      { background: rgba(130,130,130,0.1); color: #909090; }
.badge-enviada       { background: rgba(251,191,36,0.1);  color: #fbbf24; }
.badge-pagada        { background: rgba(52,211,153,0.1);  color: #34d399; }

html[data-theme="light"] .badge-en_progreso { background: rgba(77,118,0,0.1); color: #4d7600; }

/* ─── Table ────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  font-family: var(--font-display);
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr {
  transition: background var(--transition);
  animation: rowIn 0.3s ease both;
}
.data-table tbody tr:nth-child(1)  { animation-delay: 0.04s; }
.data-table tbody tr:nth-child(2)  { animation-delay: 0.08s; }
.data-table tbody tr:nth-child(3)  { animation-delay: 0.12s; }
.data-table tbody tr:nth-child(4)  { animation-delay: 0.16s; }
.data-table tbody tr:nth-child(5)  { animation-delay: 0.20s; }
.data-table tbody tr:nth-child(6)  { animation-delay: 0.24s; }
.data-table tbody tr:nth-child(7)  { animation-delay: 0.28s; }
.data-table tbody tr:nth-child(8)  { animation-delay: 0.32s; }
.data-table tbody tr:nth-child(9)  { animation-delay: 0.36s; }
.data-table tbody tr:nth-child(10) { animation-delay: 0.40s; }
.data-table tbody tr:hover td { background: var(--bg-card-hover); }
.data-table a { color: var(--text-primary); }
.data-table a:hover { color: var(--accent); }

.table-link { color: var(--text-muted); font-size: 0.8rem; transition: color var(--transition); }
.table-link:hover { color: var(--accent); }

/* ─── Mono utility ─────────────────────────────────────────────── */
.mono {
  font-family: var(--font-mono);
  font-size: 0.875em;
  letter-spacing: -0.01em;
}

/* ─── Forms ────────────────────────────────────────────────────── */
.form-stack { display: flex; flex-direction: column; gap: 20px; max-width: 620px; }

.field-label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 7px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.field-input, .field-select, .field-textarea {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}
.field-input:focus, .field-select:focus, .field-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.field-input::placeholder, .field-textarea::placeholder { color: var(--text-muted); }
.field-textarea { min-height: 100px; resize: vertical; line-height: 1.6; }

/* ─── Buttons ──────────────────────────────────────────────────── */
.btn-app {
  font-family: var(--font-display);
  font-size: 0.84rem;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  border: none;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.btn-app:hover  { opacity: 0.88; }
.btn-app:active { transform: scale(0.97); }

.btn-primary-app { background: var(--accent); color: #0c0b0b; }
.btn-primary-app:hover { opacity: 1; box-shadow: 0 0 0 3px var(--accent-glow); }

.btn-ghost { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border-strong); }
.btn-ghost:hover { opacity: 1; border-color: var(--text-muted); }

.btn-outline-app { background: transparent; color: var(--text-primary); border: 1px solid var(--border-strong); }
.btn-outline-app:hover { opacity: 1; border-color: var(--text-muted); }

/* ─── Alerts ───────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 20px;
  border-left: 3px solid currentColor;
}
.alert-error   { background: rgba(239,68,68,0.07);  color: #f87171; }
.alert-success { background: rgba(52,211,153,0.07); color: #34d399; }

/* ─── Stats ────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 36px; }

.stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: border-color var(--transition), transform var(--transition);
  animation: statIn 0.4s ease both;
}
.stats-grid .stat-box:nth-child(1) { animation-delay: 0.04s; }
.stats-grid .stat-box:nth-child(2) { animation-delay: 0.09s; }
.stats-grid .stat-box:nth-child(3) { animation-delay: 0.14s; }
.stats-grid .stat-box:nth-child(4) { animation-delay: 0.19s; }
.stats-grid .stat-box:nth-child(5) { animation-delay: 0.24s; }
.stat-box:hover { border-color: var(--border-strong); transform: translateY(-1px); }

.stat-box-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon-green  { background: rgba(52,211,153,0.1); color: #34d399; }
.stat-icon-yellow { background: rgba(251,191,36,0.1);  color: #fbbf24; }

.stat-box-num {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.15;
  margin-bottom: 3px;
  letter-spacing: -0.02em;
}
.stat-box-label { font-size: 0.74rem; color: var(--text-muted); }

/* ─── Invoice totals ───────────────────────────────────────────── */
.totals-block {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.totals-row {
  display: flex;
  gap: 48px;
  font-size: 0.84rem;
  color: var(--text-secondary);
}
.totals-label { min-width: 140px; text-align: right; }
.totals-value { font-family: var(--font-mono); min-width: 90px; text-align: right; }
.totals-row--total {
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1rem;
  padding-top: 10px;
  border-top: 1px solid var(--border-strong);
  margin-top: 2px;
}
.totals-row--total .totals-value { font-size: 1rem; }

/* ─── Timeline ─────────────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; }
.timeline-item {
  display: flex;
  gap: 18px;
  padding-bottom: 28px;
  position: relative;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: 14px; top: 30px; bottom: 0;
  width: 1px;
  background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  font-family: var(--font-display);
}
.timeline-content { flex: 1; padding-top: 4px; }
.timeline-title { font-family: var(--font-display); font-size: 0.9rem; font-weight: 600; margin-bottom: 3px; }
.timeline-text  { font-size: 0.84rem; color: var(--text-secondary); line-height: 1.5; }
.timeline-date  { font-size: 0.7rem; color: var(--text-muted); margin-top: 5px; font-family: var(--font-mono); }

/* ─── Project status bar ───────────────────────────────────────── */
.status-bar {
  display: flex;
  margin: 24px 0 36px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.status-step {
  flex: 1;
  padding: 10px 8px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  transition: background var(--transition), color var(--transition);
}
.status-step:last-child { border-right: none; }
.status-step.active { background: var(--accent); color: #0c0b0b; }
.status-step.done   { background: var(--accent-dim); color: var(--accent); }

/* ─── Theme toggle ─────────────────────────────────────────────── */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 7px 10px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 500;
  width: 100%;
  text-align: left;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 4px;
}
.theme-toggle:hover { background: var(--bg-card); color: var(--text-primary); }
html[data-theme="light"] .icon-moon { display: none; }
html[data-theme="dark"]  .icon-sun  { display: none; }

/* ─── Login ────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
}
.login-logo {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text-primary);
  margin-bottom: 32px;
  display: block;
}
.login-logo .dot { color: var(--accent); }
.login-title { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; margin-bottom: 6px; }
.login-sub { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 28px; }

/* ─── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-main { margin-left: 0; padding: 24px 20px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .dash-header { flex-direction: column; align-items: flex-start; gap: 14px; }
}
