:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #182434;
  --muted: #667085;
  --line: #d8e0ea;
  --brand: #0f6b63;
  --brand-strong: #0a4e48;
  --accent: #b7791f;
  --danger: #b42318;
  --ok: #067647;
  --shadow: 0 12px 30px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
button, input, select, textarea { font: inherit; }
button {
  border: 0;
  border-radius: 7px;
  padding: 10px 13px;
  background: var(--brand);
  color: white;
  cursor: pointer;
  font-weight: 650;
}
button.secondary { background: #e8edf3; color: var(--ink); }
button.danger { background: var(--danger); }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button:disabled { opacity: .55; cursor: not-allowed; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  background: white;
  color: var(--ink);
}
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 650; }
textarea { min-height: 78px; resize: vertical; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-box {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}
.login-box h1 { margin: 0 0 6px; font-size: 28px; }
.login-box p { margin: 0 0 22px; color: var(--muted); }
.stack { display: grid; gap: 14px; }
.error { color: var(--danger); font-weight: 650; }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
}
.sidebar {
  background: #152334;
  color: white;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.brand { font-size: 20px; font-weight: 800; }
.brand span { display: block; font-size: 12px; font-weight: 600; color: #afbdcc; margin-top: 3px; }
.nav { display: grid; gap: 6px; }
.nav button {
  text-align: left;
  background: transparent;
  color: #d7e0ea;
  border: 1px solid transparent;
}
.nav button.active, .nav button:hover {
  background: rgba(255,255,255,.09);
  border-color: rgba(255,255,255,.12);
  color: white;
}
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; font-size: 12px; color: #afbdcc; }

.content { min-width: 0; }
.topbar {
  height: 66px;
  background: white;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.topbar h2 { margin: 0; font-size: 22px; }
.page { padding: 24px; display: grid; gap: 18px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.toolbar .grow { flex: 1 1 260px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 12px;
}
.metric {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.metric small { color: var(--muted); font-weight: 700; }
.metric strong { display: block; margin-top: 8px; font-size: 22px; }
.metric.ok strong { color: var(--ok); }
.metric.warn strong { color: var(--accent); }
.metric.bad strong { color: var(--danger); }

.panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
  overflow: hidden;
}
.panel-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.panel-head h3 { margin: 0; font-size: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
}
.form-grid .wide { grid-column: span 2; }
.form-grid .full { grid-column: 1 / -1; }
.actions { display: flex; justify-content: flex-end; gap: 10px; padding: 0 16px 16px; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 13px; }
th { color: var(--muted); background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 750;
  background: #eef2f6;
}
.status.PAGADO { color: var(--ok); background: #e7f6ee; }
.status.PENDIENTE { color: var(--accent); background: #fff4df; }
.status.ANULADO, .status.INCOBRABLE { color: var(--danger); background: #ffeceb; }
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #111827;
  color: white;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 2; }
  .nav { grid-template-columns: repeat(2, 1fr); }
  .metrics, .grid2, .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .topbar { padding: 0 16px; }
  .page { padding: 16px; }
}
