/* ===== Base ===== */
:root {
  /* Paleta oficial SAP'S STORE */
  --rose: #F2C4CE;          /* rosa suave (marca) */
  --nude: #F8EDE3;          /* nude / crema */
  --bg: #FDFAF6;            /* fondo */
  --surface: #ffffff;
  --surface-2: #FBF3EA;    /* hover cálido */
  --border: #F0E5DA;
  --text: #2B2424;         /* texto marrón oscuro */
  --muted: #A9998F;        /* gris cálido */
  --sidebar-bg: #2B2424;    /* barra lateral chocolate elegante */
  --brand: #C96E88;        /* rosa fuerte para botones (contraste con blanco) */
  --brand-2: #B85A76;      /* hover / activo */
  --green: #1f9d63;
  --green-bg: #e7f5ec;
  --red: #d05a6e;
  --red-bg: #fbeaee;
  --blue: #2f6fed;
  --amber: #cf8a3d;
  --shadow: 0 1px 3px rgba(43, 36, 36, .06), 0 8px 24px rgba(43, 36, 36, .06);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 15px; }

/* ===== Layout ===== */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px;
  background: var(--sidebar-bg);
  color: #F3E7DD;
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 20px;
  font-weight: 700; font-size: 19px; letter-spacing: .2px;
  color: #fff;
}
.brand .logo {
  width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(135deg, var(--rose), var(--brand));
  display: grid; place-items: center; font-size: 18px;
  box-shadow: 0 2px 8px rgba(201, 110, 136, .4);
}
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav button {
  display: flex; align-items: center; gap: 11px;
  background: transparent; border: 0; color: #E4D3C7;
  padding: 11px 12px; border-radius: 11px; text-align: left;
  font-size: 15px; width: 100%; transition: background .12s, color .12s;
}
.nav button .ic { width: 20px; text-align: center; font-size: 17px; }
.nav button:hover { background: rgba(242, 196, 206, .14); color: #fff; }
.nav button.active { background: var(--brand); color: #fff; font-weight: 600; box-shadow: 0 2px 10px rgba(201,110,136,.35); }
.sidebar .spacer { flex: 1; }
.sidebar .biz { font-size: 12px; color: var(--rose); padding: 10px; opacity: .85; }

.main { flex: 1; padding: 26px 30px; max-width: 1200px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-head h1 { margin: 0; font-size: 24px; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }

/* ===== Cards / grid ===== */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 22px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.card .label { color: var(--muted); font-size: 13px; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.card .value { font-size: 26px; font-weight: 700; }
.card .value.green { color: var(--green); }
.card .value.red { color: var(--red); }
.card .value.amber { color: var(--amber); }

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 20px; overflow: hidden;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.panel-head h2 { margin: 0; font-size: 17px; }
.panel-body { padding: 18px; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 34px 10px; }

/* ===== Badges ===== */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.gray { background: var(--nude); color: #8c7a6e; }
.badge.amber { background: #f7ead6; color: var(--amber); }

/* ===== Buttons ===== */
.btn {
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border: 0; padding: 10px 16px;
  border-radius: 11px; font-weight: 600; font-size: 14px;
  box-shadow: 0 2px 8px rgba(201, 110, 136, .28);
}
.btn:hover { filter: brightness(1.05); box-shadow: 0 3px 12px rgba(201, 110, 136, .38); }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; justify-content: center; }
.icon-btn { background: transparent; border: 0; color: var(--muted); font-size: 16px; padding: 4px 7px; border-radius: 7px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { color: var(--red); background: var(--red-bg); }

/* ===== Forms ===== */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface); color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--brand-2); outline-offset: -1px; border-color: var(--brand-2); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar input, .toolbar select { padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.toolbar .grow { flex: 1; min-width: 160px; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,25,40,.45);
  display: none; align-items: flex-start; justify-content: center;
  padding: 40px 16px; z-index: 50; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 16px; width: 100%; max-width: 560px;
  box-shadow: 0 20px 60px rgba(20,25,40,.3); animation: pop .16s ease;
}
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-body { padding: 20px; }
.modal-foot { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.close-x { background: transparent; border: 0; font-size: 22px; color: var(--muted); line-height: 1; }

/* Cart lines in sale modal */
.cart-line { display: grid; grid-template-columns: 1fr 70px 90px 34px; gap: 8px; align-items: center; margin-bottom: 8px; }
.cart-line .name { font-size: 14px; }
.cart-total { display: flex; justify-content: space-between; font-weight: 700; font-size: 18px; padding-top: 12px; border-top: 1px dashed var(--border); margin-top: 10px; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff; padding: 12px 20px; border-radius: 12px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }

/* ===== Pantalla de acceso ===== */
.login-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(160deg, var(--nude) 0%, var(--bg) 55%, var(--rose) 220%);
}
.login-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px;
  padding: 38px 32px; width: 100%; max-width: 380px; text-align: center;
  box-shadow: 0 10px 40px rgba(43, 36, 36, .10);
}
.login-logo {
  width: 60px; height: 60px; border-radius: 18px; margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--rose), var(--brand));
  display: grid; place-items: center; font-size: 30px;
  box-shadow: 0 4px 16px rgba(201, 110, 136, .35);
}
.login-box h1 { margin: 0 0 4px; font-size: 24px; }
.login-box p { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
.login-box input {
  width: 100%; padding: 13px 15px; border: 1px solid var(--border);
  border-radius: 12px; margin-bottom: 14px; text-align: center;
  font-size: 16px; background: var(--surface-2); color: var(--text);
}
.login-box input:focus { outline: 2px solid var(--brand); outline-offset: -1px; background: var(--surface); }
.login-box .btn { padding: 13px; font-size: 15px; }
.login-error { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 12px; }

/* ===== Responsive ===== */
@media (max-width: 820px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 0; z-index: 40;
    flex-direction: row; align-items: center; padding: 8px; overflow-x: auto;
  }
  .brand { padding: 6px 10px; }
  .sidebar .spacer, .sidebar .biz { display: none; }
  .nav { flex-direction: row; }
  .nav button span.txt { display: none; }
  .nav button { padding: 10px 12px; }
  .nav button .ic { font-size: 20px; }
  .main { padding: 18px 14px; }
  .row2, .row3 { grid-template-columns: 1fr; }
}

/* ===== Print (facturas) ===== */
@media print {
  .sidebar, .page-head, .no-print { display: none !important; }
  .main { padding: 0; }
  .panel { box-shadow: none; border: 0; }
}
