/* ---------- Fuentes (self-hosted, sin llamadas externas) ---------- */
@font-face {
  font-family: "Montserrat";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/montserrat-500.woff2") format("woff2");
}
@font-face {
  font-family: "Montserrat";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/montserrat-600.woff2") format("woff2");
}
@font-face {
  font-family: "Montserrat";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/montserrat-700.woff2") format("woff2");
}
@font-face {
  font-family: "Montserrat";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/static/fonts/montserrat-800.woff2") format("woff2");
}
@font-face {
  font-family: "Montserrat";
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url("/static/fonts/montserrat-900.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/jbmono-400.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/jbmono-600.woff2") format("woff2");
}

/* ---------- Tokens ---------- */
:root {
  /* bg/surface/border/text moved from a warm-beige palette to the brand
     kit's neutral gray family — --surface is the kit's exact "Pure White"
     swatch (kit-logo.html, "Colores Exactos"), --text is the kit's exact
     Deep Black #0A0A0A. --bg/--surface-2/--border/--text-muted are neutral
     grays derived to match that family (kit only speces a dark theme, so
     these have no direct kit equivalent — chosen for AA contrast on white). */
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f0f0f0;
  --border: #e2e2e2;
  --text: #0a0a0a;
  --text-muted: #5c5c5c;

  /* --accent = the kit's "Primary" #EF561A (kit exact). --accent-hover is
     the kit's own gradient dark stop #D14612 (kit exact, from the logo
     radial gradient). --accent-soft is the kit's tonal-50 swatch #FFF5F0
     (kit exact, from the "Escala tonal Primary" row). */
  --accent: #ef561a;
  --accent-hover: #d14612;
  --accent-soft: #fff5f0;

  --ok: #1f9d55;
  --ok-soft: #e4f6ea;
  --danger: #c0392b;
  --danger-soft: #fbe9e6;
  --warn: #b4790f;
  --warn-soft: #fbf1de;

  /* Three radii instead of one, matching the kit's tokens section exactly:
     --radius-btn 5px, --radius-input 2px, --radius-card 12px. */
  --radius-btn: 5px;
  --radius-input: 2px;
  --radius-card: 12px;
  --shadow: 0 1px 2px rgba(10, 10, 10, 0.04), 0 4px 14px rgba(10, 10, 10, 0.06);

  --font-display: "Montserrat", ui-sans-serif, -apple-system, "Segoe UI", sans-serif;
  --font-body: -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* --bg/--surface/--surface-2 are the kit's own three dark layers,
       reused as-is: --surface-3 (#1f1f1f) as the page bg, --surface-2
       (#262626) as the raised card layer, --surface (#333333, the kit's
       OFFICIAL token) as a further-raised layer — all three kit exact,
       from kit-todo.html's own :root and its --surface-2/--surface-3
       (the kit page's internal layering, beyond the exported token list,
       but consistent with it). --border/--text/--text-muted are kit
       exact. */
    --bg: #1f1f1f;
    --surface: #262626;
    --surface-2: #333333;
    --border: rgba(255, 255, 255, .08);
    --text: #ffffff;
    --text-muted: #a6a6a6;

    /* Kit exact primary #EF561A (previously the app brightened this to
       #ff7a3d for dark mode — the kit doesn't do that, it uses one orange
       everywhere, so this now matches). --accent-hover reuses the kit's
       own lighter gradient stop #FF7A3D — which happens to be the exact
       value this token held before, so the swap is really just a rename
       of what it means, not a new invented color. */
    --accent: #ef561a;
    --accent-hover: #ff7a3d;
    --accent-soft: #3a2417;
    --ok: #35c077;
    --ok-soft: #163425;
    --danger: #e5604a;
    --danger-soft: #3a1e17;
    --warn: #e3a73b;
    --warn-soft: #362a12;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 4px 14px rgba(0, 0, 0, 0.28);
  }
}
:root[data-theme="dark"] {
  --bg: #1f1f1f;
  --surface: #262626;
  --surface-2: #333333;
  --border: rgba(255, 255, 255, .08);
  --text: #ffffff;
  --text-muted: #a6a6a6;
  --accent: #ef561a;
  --accent-hover: #ff7a3d;
  --accent-soft: #3a2417;
  --ok: #35c077;
  --ok-soft: #163425;
  --danger: #e5604a;
  --danger-soft: #3a1e17;
  --warn: #e3a73b;
  --warn-soft: #362a12;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 4px 14px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.01em; margin: 0 0 4px; }
h1 { font-size: 1.5rem; font-weight: 900; }
h2 { font-size: 0.95rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

.container { max-width: 1080px; margin: 0 auto; padding: 28px 20px 60px; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 900; font-size: 1.05rem; }
.brand img { height: 30px; width: auto; display: block; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 8px 12px;
  border-radius: var(--radius-btn);
  text-decoration: none;
}
.topbar nav a:hover { background: var(--surface-2); color: var(--text); }
.topbar nav a.active { color: var(--accent); background: var(--accent-soft); }
.user-menu { display: flex; align-items: center; gap: 14px; color: var(--text-muted); font-size: 0.9rem; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font: inherit;
  font-weight: 600;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- Login ---------- */
.login-box {
  max-width: 380px;
  margin: 88px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 36px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-box img { height: 44px; margin-bottom: 16px; }
.login-box h1 { margin-bottom: 24px; }
.login-box form { text-align: left; }

/* ---------- Forms ---------- */
form label {
  display: block;
  margin-bottom: 14px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
}
form input, form select, form textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 9px 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  color: var(--text);
  font: inherit;
  font-family: var(--font-body);
}
form input:focus, form select:focus, form textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
form button, .btn {
  background: var(--accent);
  color: #0a0a0a;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-btn);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
form button:hover, .btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #a52d20; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 0.9rem; }
.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); }
.alert-ok { background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok); }

/* ---------- Layout helpers ---------- */
.toolbar { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.toolbar form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin: 0; }
.toolbar label { margin-bottom: 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card h2 { margin-top: 0; }
.card ul { list-style: none; padding: 0; margin: 0; }
.card li { padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.card li:last-child { border-bottom: none; }
.muted { color: var(--text-muted); }
.mono { font-family: var(--font-mono); }

/* ---------- Tabla ---------- */
table { width: 100%; border-collapse: collapse; margin-top: 4px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
th { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { font-family: var(--font-mono); text-align: right; font-variant-numeric: tabular-nums; }
.actions-cell { text-align: right; white-space: nowrap; }

/* ---------- Badges tipo "sello de ticket" ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: var(--font-mono);
}
.badge-pending { background: var(--accent-soft); color: var(--accent); }
.badge-done { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Ticket / comprobante ---------- */
.ticket {
  max-width: 420px;
  margin: 40px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.ticket-header {
  padding: 24px 28px 18px;
  border-bottom: 1px dashed var(--border);
  text-align: center;
}
.ticket-header img { height: 40px; margin-bottom: 10px; }
.ticket-header .biz { font-family: var(--font-display); font-weight: 900; font-size: 1.1rem; }
.ticket-header .biz-sub { color: var(--text-muted); font-size: 0.8rem; }
.ticket-id {
  display: inline-block;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 6px;
  letter-spacing: 0.03em;
}
.ticket-body { padding: 20px 28px; }
.ticket-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.ticket-row:last-child { border-bottom: none; }
.ticket-row .label { color: var(--text-muted); }
.ticket-row .value { font-family: var(--font-mono); text-align: right; }
.ticket-total { display: flex; justify-content: space-between; padding: 14px 0 0; font-weight: 700; font-size: 1.05rem; }
.ticket-total .value { font-family: var(--font-mono); }
.ticket-footer { padding: 16px 28px 24px; text-align: center; color: var(--text-muted); font-size: 0.78rem; }
.ticket-cut {
  height: 0;
  border-top: 1px dashed var(--border);
  position: relative;
}

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .container { padding: 0; max-width: 100%; }
  .ticket { box-shadow: none; border: 1px solid #ccc; margin: 0 auto; }
}

/* ---------- WhatsApp ---------- */
.btn-whatsapp {
  background: #25d366;
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-whatsapp:hover { background: #1eb959; text-decoration: none; }

/* ---------- Formularios plegables ("+ Nuevo...") ---------- */
details.disclosure { margin: 4px 0 24px; }
details.disclosure > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #0a0a0a;
  padding: 10px 18px;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 0.88rem;
  user-select: none;
}
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary:hover { background: var(--accent-hover); }
details.disclosure > summary::before { content: "+"; font-size: 1.05em; line-height: 1; }
details.disclosure[open] > summary::before { content: "\2013"; }
details.disclosure[open] > summary { background: var(--surface-2); color: var(--text); }
details.disclosure .card { margin-top: 12px; margin-bottom: 0; }

/* ---------- Tablas responsive ---------- */
.table-wrap { overflow-x: auto; }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; padding: 10px 14px; }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; }
  .container { padding: 18px 14px 40px; }
  .toolbar { align-items: stretch; }
  .toolbar > a.btn, .toolbar > form > button, .login-box { width: 100%; }
  table { font-size: 0.82rem; }
  th, td { padding: 8px 6px; }
}
