:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #15171a;
  --muted: #646b75;
  --border: #dde1e6;
  --primary: #1f5eff;
  --primary-ink: #ffffff;
  --success: #12965b;
  --warning: #c27a00;
  --danger: #d23b3b;
  --cash: #12965b;
  --card: #1f5eff;
  --cashless: #8a3ffc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 4px 16px rgba(0, 0, 0, 0.05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1114;
    --surface: #181b20;
    --surface-2: #22262c;
    --text: #eef0f3;
    --muted: #9aa2ad;
    --border: #2c3138;
    --primary: #4d7dff;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0 0 0.5em; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.num { font-variant-numeric: tabular-nums; }

/* ── Layout ───────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar .brand { font-weight: 700; }

/* Logo Burcor + "Guardarropa". El logo se pinta con una máscara para que
   tome el color del texto y se vea bien en modo claro y oscuro. */
.brand-lockup { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; flex: none; }
.brand-logo {
  display: inline-block; height: 22px; aspect-ratio: 697 / 361;
  background: currentColor;
  -webkit-mask: url(/img/burcor-icon.svg) no-repeat center / contain;
  mask: url(/img/burcor-icon.svg) no-repeat center / contain;
}
.brand-name { font-weight: 700; padding-left: 10px; border-left: 1px solid var(--border); line-height: 1.2; }
.brand-lockup.lg { gap: 14px; }
.brand-lockup.lg .brand-logo { height: 32px; }
.brand-lockup.lg .brand-name { font-size: 1.35rem; padding-left: 14px; }
.topbar .spacer { flex: 1; }
.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

/* ── Buttons & forms ──────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit; font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.05s, background 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn-success { background: var(--success); color: #fff; border-color: transparent; }
.btn-success:hover { background: var(--success); filter: brightness(1.08); }
.btn-danger { color: var(--danger); }
.btn-sm { padding: 6px 10px; font-size: 0.875rem; }
.btn-ghost { background: transparent; border-color: transparent; }

.field { display: grid; justify-items: start; }
label.field { justify-items: stretch; }
.field, label.field { display: grid; gap: 6px; font-weight: 600; font-size: 0.9rem; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="search"], select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; cursor: pointer; }
.switch input { appearance: none; width: 46px; height: 26px; border-radius: 13px; background: var(--border); position: relative; cursor: pointer; transition: background 0.15s; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left 0.15s; }
.switch input:checked { background: var(--success); }
.switch input:checked::after { left: 23px; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.segmented button { border: 0; background: var(--surface); color: var(--text); padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer; }
.segmented button.active { background: var(--primary); color: #fff; }

/* ── Tables ───────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.925rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
td.right, th.right { text-align: right; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); }
.badge.warn { background: color-mix(in srgb, var(--warning) 15%, transparent); color: var(--warning); }
.badge.bad { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.badge.info { background: color-mix(in srgb, var(--primary) 15%, transparent); color: var(--primary); }

.stat { display: grid; gap: 4px; }
.stat .label { color: var(--muted); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.stat .value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── Toast & modal ────────────────────────────────────────────── */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; width: min(92vw, 460px); }
.toast { padding: 12px 16px; border-radius: 10px; background: #15171a; color: #fff; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: var(--radius); padding: 24px; width: min(560px, 100%); max-height: 90vh; overflow: auto; }
.modal h2 { margin-bottom: 16px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── Login ────────────────────────────────────────────────────── */
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(400px, 100%); }
.error-box { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); padding: 10px 12px; border-radius: 10px; font-weight: 600; }

@media (max-width: 600px) {
  .container { padding: 16px; }
  .topbar { padding: 10px 16px; }
}
