/* =====================================================================
   Sistema de Sastrería y Alquiler — hoja de estilos principal
   ===================================================================== */
:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1f2937;
  --ink-soft: #6b7280;
  --line: #e5e7eb;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --ok: #059669;
  --warn: #d97706;
  --danger: #dc2626;
  --sidebar: #111827;
  --sidebar-soft: #1f2937;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 650; }

/* ------------------------------ LAYOUT ------------------------------ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px; flex: 0 0 250px;
  background: var(--sidebar);
  color: #e5e7eb;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: .7rem; align-items: center; padding: 1.1rem 1rem; border-bottom: 1px solid #1f2937; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  background: var(--primary); color: #fff; font-weight: 800; font-size: 1.2rem;
}
.brand strong { display: block; font-size: .95rem; color: #fff; }
.brand small { color: #9ca3af; font-size: .75rem; }

.nav { display: flex; flex-direction: column; padding: .8rem .6rem; gap: .15rem; overflow-y: auto; }
.nav a {
  color: #d1d5db; padding: .65rem .8rem; border-radius: 9px; font-size: .92rem;
  display: flex; align-items: center; gap: .6rem; text-decoration: none;
}
.nav a:hover { background: var(--sidebar-soft); color: #fff; text-decoration: none; }
.nav a.active { background: var(--primary); color: #fff; }
.nav a.logout { margin-top: auto; color: #fca5a5; }
.nav a.logout:hover { background: #7f1d1d; color: #fff; }
.nav .ico { width: 18px; flex: 0 0 18px; text-align: center; font-size: 1rem; line-height: 1; opacity: .95; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: .8rem 1.2rem; display: flex; align-items: center; gap: 1rem;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 1.15rem; margin: 0; flex: 1; }
.topbar .user { display: flex; align-items: center; gap: .5rem; color: var(--ink-soft); font-size: .9rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 700; }
.btn-menu { display: none; background: none; border: 0; font-size: 1.4rem; cursor: pointer; }

.page { padding: 1.2rem; flex: 1; }
.footer { padding: .9rem 1.2rem; color: var(--ink-soft); font-size: .8rem; border-top: 1px solid var(--line); }

/* ------------------------------ TARJETAS ---------------------------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.1rem; margin-bottom: 1.1rem;
}
.card > h2, .card > h3 { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; flex-wrap: wrap; }
.card-title-row h2, .card-title-row h3 { margin: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.1rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.stat .label { color: var(--ink-soft); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.5rem; font-weight: 700; margin-top: .2rem; }
.stat .hint { font-size: .82rem; color: var(--ink-soft); }

/* ------------------------------ GRID / FORM ------------------------- */
.grid { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-medidas { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.campo { display: flex; flex-direction: column; gap: .25rem; }
.campo > span { font-size: .82rem; color: var(--ink-soft); font-weight: 600; }
.campo.full { grid-column: 1 / -1; }
input[type=text], input[type=number], input[type=password], input[type=date], input[type=time],
input[type=datetime-local], input[type=email], select, textarea {
  width: 100%; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; font: inherit; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #c7d2fe; border-color: var(--primary); }
textarea { min-height: 80px; resize: vertical; }
.check-inline { display: flex; align-items: center; gap: .45rem; font-size: .9rem; }
.check-inline input { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem; margin: 0 0 1rem; }
legend { font-weight: 700; padding: 0 .4rem; color: var(--primary-dark); }

/* ------------------------------ BOTONES ----------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem; justify-content: center;
  padding: .55rem .95rem; border-radius: 9px; border: 1px solid transparent;
  background: var(--primary); color: #fff; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; line-height: 1.2;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-sm { padding: .35rem .6rem; font-size: .84rem; border-radius: 8px; }
.btn-light { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-light:hover { background: #f3f4f6; color: var(--ink); }
.btn-ok { background: var(--ok); } .btn-ok:hover { background: #047857; }
.btn-warn { background: var(--warn); } .btn-warn:hover { background: #b45309; }
.btn-danger { background: var(--danger); } .btn-danger:hover { background: #b91c1c; }
.btn-block { width: 100%; }
.acciones { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ------------------------------ TABLAS ------------------------------ */
.tabla-wrap { overflow-x: auto; }
table.tabla { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.tabla th, table.tabla td { padding: .6rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.tabla th { background: #f9fafb; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
table.tabla tbody tr:hover { background: #f9fafb; }
table.tabla td.num, table.tabla th.num { text-align: right; white-space: nowrap; }
table.tabla .nowrap { white-space: nowrap; }

/* ------------------------------ BADGES ------------------------------ */
.badge { display: inline-block; padding: .2rem .55rem; border-radius: 999px; font-size: .76rem; font-weight: 700; }
.badge-ok { background: #d1fae5; color: #065f46; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-muted { background: #f3f4f6; color: #4b5563; }

/* ------------------------------ ALERTAS ----------------------------- */
.alert { padding: .75rem 1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid; font-size: .92rem; }
.alert-ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info { background: #eef2ff; border-color: #c7d2fe; color: #3730a3; }

/* ------------------------------ MEDIDAS ----------------------------- */
.medida-grupo { margin-bottom: 1rem; }
.medida-titulo { color: var(--primary-dark); border-bottom: 2px solid #eef2ff; padding-bottom: .3rem; }
.medida-resumen { margin-bottom: .9rem; }
.medida-resumen h4 { color: var(--primary-dark); margin-bottom: .4rem; }
.medida-lista { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .4rem; }
.medida-item { background: #f9fafb; border: 1px solid var(--line); border-radius: 8px; padding: .35rem .6rem;
  display: flex; justify-content: space-between; gap: .5rem; font-size: .88rem; }
.medida-item span { color: var(--ink-soft); }

/* ------------------------------ VARIOS ------------------------------ */
.muted { color: var(--ink-soft); }
.text-ok { color: var(--ok); font-weight: 600; }
.text-danger { color: var(--danger); font-weight: 600; }
.sin-datos { text-align: center; color: var(--ink-soft); padding: 1.5rem; }
.filtros { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; }
.filtros .campo { min-width: 150px; }
.totales { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.total-box { border: 1px solid var(--line); border-radius: 10px; padding: .8rem; background: #f9fafb; }
.total-box .label { font-size: .8rem; color: var(--ink-soft); text-transform: uppercase; }
.total-box .value { font-size: 1.25rem; font-weight: 700; }
.hint-inline { font-size: .8rem; color: var(--ink-soft); }
.pill { display:inline-block; background:#eef2ff; color:#3730a3; border-radius:999px; padding:.15rem .55rem; font-size:.78rem; font-weight:600; }
.divisor { height: 1px; background: var(--line); margin: 1rem 0; }
.acciones-fila { display: flex; gap: .35rem; flex-wrap: wrap; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 3px solid var(--line); padding: .1rem 0 .9rem .9rem; position: relative; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: .35rem; width: 11px; height: 11px;
  border-radius: 50%; background: var(--primary); }
.timeline li.ok::before { background: var(--ok); }
.timeline li.warn::before { background: var(--warn); }
.timeline li.danger::before { background: var(--danger); }

/* ------------------------------ LOGIN ------------------------------- */
.login-page { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #1e1b4b, #4f46e5); padding: 1rem; }
.login-box { background: #fff; border-radius: 16px; padding: 2rem; width: min(420px, 100%); box-shadow: 0 20px 40px rgba(0,0,0,.25); }
.login-box .logo { width: 56px; height: 56px; border-radius: 14px; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 1.6rem; font-weight: 800; margin: 0 auto 1rem; }
.login-box h1 { text-align: center; font-size: 1.3rem; }
.login-box p.sub { text-align: center; color: var(--ink-soft); margin-top: -.3rem; margin-bottom: 1.4rem; font-size: .9rem; }
.login-box .campo { margin-bottom: .9rem; }

/* ------------------------------ RESPONSIVE -------------------------- */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: -260px; z-index: 50; transition: left .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .sidebar.open { left: 0; }
  .btn-menu { display: block; }
  .page { padding: .9rem; }
}
@media print {
  .sidebar, .topbar, .footer, .no-print, .btn-menu { display: none !important; }
  .layout { display: block; }
  .page { padding: 0; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; padding: 0; }
}
