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

:root {
  --primary: #6c47ff;
  --primary-dark: #5535e0;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger:  #ef4444;
  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-600: #4b5563;
  --gray-800: #1f2937;
  --white:    #ffffff;
  --shadow:   0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.12);
  --radius:   10px;
}

body { font-family: system-ui, -apple-system, sans-serif; background: var(--gray-50); color: var(--gray-800); line-height: 1.5; }

/* ── Auth ── */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--primary) 0%, #9f7aea 100%); }
.auth-card  { background: var(--white); border-radius: 16px; padding: 2.5rem; width: 100%; max-width: 400px; box-shadow: var(--shadow-lg); }
.auth-logo  { text-align: center; margin-bottom: 2rem; }
.auth-logo h1 { font-size: 1.75rem; color: var(--primary); font-weight: 800; }
.auth-logo p  { color: var(--gray-400); font-size: .875rem; margin-top: .25rem; }

/* ── Form ── */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: .875rem; font-weight: 600; margin-bottom: .4rem; color: var(--gray-600); }
.form-group input  { width: 100%; padding: .65rem .9rem; border: 1.5px solid var(--gray-200); border-radius: var(--radius); font-size: .95rem; outline: none; transition: border-color .2s; }
.form-group input:focus { border-color: var(--primary); }
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .65rem 1.2rem; border: none; border-radius: var(--radius); font-size: .9rem; font-weight: 600; cursor: pointer; transition: background .2s, transform .1s; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-sm { padding: .35rem .8rem; font-size: .8rem; }
.btn-danger  { background: var(--danger);  color: var(--white); }
.btn-success { background: var(--success); color: var(--white); }
.btn-full { width: 100%; justify-content: center; }
.alert { padding: .75rem 1rem; border-radius: var(--radius); font-size: .875rem; margin-bottom: 1rem; }
.alert-error { background: #fee2e2; color: #991b1b; }

/* ── Layout ── */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--white); border-right: 1px solid var(--gray-200); padding: 1.5rem 0; display: flex; flex-direction: column; }
.sidebar-logo { padding: 0 1.25rem 1.5rem; font-size: 1.25rem; font-weight: 800; color: var(--primary); border-bottom: 1px solid var(--gray-100); }
.sidebar-logo span { font-size: .7rem; font-weight: 500; color: var(--gray-400); display: block; }
.nav-item { display: flex; align-items: center; gap: .65rem; padding: .7rem 1.25rem; color: var(--gray-600); text-decoration: none; font-size: .9rem; font-weight: 500; border-left: 3px solid transparent; transition: background .15s, color .15s; cursor: pointer; }
.nav-item:hover, .nav-item.active { background: var(--gray-50); color: var(--primary); border-left-color: var(--primary); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-bottom { margin-top: auto; padding: 1rem 1.25rem 0; border-top: 1px solid var(--gray-100); }
.main { padding: 2rem; overflow-y: auto; }

/* ── Topbar ── */
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.75rem; }
.topbar h2 { font-size: 1.35rem; font-weight: 700; }
.topbar .user-badge { display: flex; align-items: center; gap: .5rem; font-size: .875rem; color: var(--gray-600); }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: white; display: grid; place-items: center; font-size: .75rem; font-weight: 700; }

/* ── KPI cards ── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.75rem; }
.kpi-card { background: var(--white); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.kpi-card .label { font-size: .78rem; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: .04em; }
.kpi-card .value { font-size: 1.6rem; font-weight: 800; margin-top: .25rem; }
.kpi-card .sub   { font-size: .8rem; color: var(--gray-400); margin-top: .15rem; }
.kpi-card.success .value { color: var(--success); }
.kpi-card.warning .value { color: var(--warning); }
.kpi-card.primary .value { color: var(--primary); }

/* ── Table ── */
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 1.5rem; }
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.card-header h3 { font-size: 1rem; font-weight: 700; }
.filters { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.filters select, .filters input[type=date] { padding: .4rem .65rem; border: 1.5px solid var(--gray-200); border-radius: 8px; font-size: .825rem; outline: none; }
.filters select:focus, .filters input[type=date]:focus { border-color: var(--primary); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th { background: var(--gray-50); padding: .65rem 1rem; text-align: left; font-weight: 600; color: var(--gray-600); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--gray-200); }
tbody td { padding: .75rem 1rem; border-bottom: 1px solid var(--gray-100); }
tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }

/* ── Badges ── */
.badge { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-disponible { background: #d1fae5; color: #065f46; }
.badge-reclamado  { background: #dbeafe; color: #1e40af; }
.badge-confirmado { background: #ede9fe; color: #5b21b6; }
.badge-anulado    { background: #fee2e2; color: #991b1b; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--gray-400); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: .75rem; }
.empty-state p { font-size: .9rem; }

/* ── Loading ── */
.spinner { display: inline-block; width: 18px; height: 18px; border: 2.5px solid #ddd; border-top-color: var(--primary); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Amounts ── */
.amount { font-weight: 700; font-family: 'Courier New', monospace; }
.amount::before { content: 'S/ '; font-weight: 400; font-size: .8em; }

/* ── Toast ── */
#toast { position: fixed; bottom: 1.5rem; right: 1.5rem; background: var(--gray-800); color: var(--white); padding: .85rem 1.25rem; border-radius: var(--radius); font-size: .875rem; box-shadow: var(--shadow-lg); transform: translateY(100px); opacity: 0; transition: transform .3s, opacity .3s; z-index: 999; }
#toast.show { transform: translateY(0); opacity: 1; }
#toast.success { background: var(--success); }
#toast.error { background: var(--danger); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
