@font-face { font-family: Inter; src: url(fonts/Inter-Regular.otf); font-weight: 400; font-display: swap; }
@font-face { font-family: Inter; src: url(fonts/Inter-Medium.otf); font-weight: 500; font-display: swap; }
@font-face { font-family: Inter; src: url(fonts/Inter-SemiBold.otf); font-weight: 600; font-display: swap; }
@font-face { font-family: Inter; src: url(fonts/Inter-Bold.otf); font-weight: 700; font-display: swap; }

:root {
  --primary: #1fa9bd;
  --primary-ink: #13808f;
  --secondary: #5cc8a0;
  --grad: linear-gradient(90deg, var(--primary), var(--secondary));
  --ink: #0f1b24;
  --muted: #5d6b78;
  --line: #dfe6ec;
  --soft: #f4f8fa;
  --bg: #eef3f6;
  --card: #ffffff;
  --ok: #18a058;
  --warn: #c98a00;
  --bad: #e5484d;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 27, 36, .06), 0 4px 16px rgba(15, 27, 36, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: Inter, system-ui, sans-serif; color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.45; }
a { color: var(--primary-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all; }
.label { font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--primary-ink); }

/* Estructura */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #cfd8df; padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.side .brand img { width: 38px; height: auto; background: #fff; border-radius: 8px; padding: 3px; }
.side .brand b { color: #fff; font-size: 15px; display: block; }
.side .brand span { font-size: 11px; color: #8da0ad; }
.side a { color: #cfd8df; padding: 9px 12px; border-radius: 8px; display: flex; gap: 10px; align-items: center; font-weight: 500; }
.side a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.side a.on { background: rgba(31, 169, 189, .18); color: #fff; }
.side a.on::before { content: ""; width: 3px; height: 16px; border-radius: 2px; background: var(--grad); margin-left: -6px; }
.side .grow { flex: 1; }
.side .who { border-top: 1px solid rgba(255, 255, 255, .08); padding: 12px 8px 0; font-size: 12px; }
.side .who b { color: #fff; display: block; font-size: 13px; }
.main { padding: 26px 32px 60px; max-width: 1280px; width: 100%; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.env { display: inline-flex; gap: 6px; align-items: center; font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 99px; background: #fff3d6; color: #8a5a00; }
.env.prod { background: #dcf6e8; color: #0d6b3a; }

/* Tarjetas */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { padding: 18px 20px; }
.stat .v { font-size: 24px; font-weight: 700; margin-top: 6px; }
.stat.hl { background: var(--grad); color: #fff; }
.stat.hl .label { color: rgba(255, 255, 255, .85); }

/* Botones y campos */
button, .btn { font: inherit; font-weight: 600; border: 0; border-radius: 9px; padding: 9px 16px; cursor: pointer; background: var(--soft); color: var(--ink); display: inline-flex; gap: 8px; align-items: center; justify-content: center; white-space: nowrap; }
button:hover, .btn:hover { filter: brightness(.97); text-decoration: none; }
button.primary, .btn.primary { background: var(--grad); color: #fff; }
button.dark { background: var(--ink); color: #fff; }
button.danger { background: #fde8e8; color: var(--bad); }
button.ghost { background: transparent; color: var(--primary-ink); padding: 6px 10px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); min-width: 0; }
label.f.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-weight: 500; font-size: 13px; }
input, select, textarea { font: inherit; color: var(--ink); border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 9px 11px; width: 100%; min-width: 0; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31, 169, 189, .35); border-color: var(--primary); }
.err { color: var(--bad); font-size: 12px; font-weight: 500; }
.form { display: grid; gap: 14px; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.form > .s1 { grid-column: span 1; } .form > .s2 { grid-column: span 2; } .form > .s3 { grid-column: span 3; } .form > .s4 { grid-column: span 4; } .form > .s6 { grid-column: span 6; }
.form h3 { grid-column: span 6; margin: 8px 0 -4px; font-size: 13px; }

/* Tablas */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; }
table.t th { text-align: left; font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--soft); }
table.t .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t .c { text-align: center; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* Estados */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-aceptado { background: #dcf6e8; color: #0d6b3a; }
.st-aceptado_notificaciones { background: #e6f4ff; color: #0b5c99; }
.st-rechazado { background: #fde8e8; color: #b42318; }
.st-pendiente, .st-por_enviar { background: #fff3d6; color: #8a5a00; }
.st-error_envio { background: #f1e8fd; color: #6b2fb3; }
.msg { border-radius: 10px; padding: 10px 12px; font-size: 13px; display: flex; gap: 10px; align-items: flex-start; }
.msg + .msg { margin-top: 8px; }
.msg b { font-family: ui-monospace, monospace; font-size: 12px; }
.msg.rechazo { background: #fde8e8; }
.msg.notificacion { background: #e6f4ff; }
.msg.error { background: #f1e8fd; }
.msg.info { background: var(--soft); }

/* Modal y avisos */
.backdrop { position: fixed; inset: 0; background: rgba(15, 27, 36, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 16px; width: min(760px, 100%); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal.wide { width: min(1100px, 100%); }
.modal header { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.modal .body { padding: 20px 22px; }
.modal footer { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow); z-index: 60; max-width: 420px; }
.toast.bad { background: var(--bad); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-color: var(--primary); }
.tabs a:hover { text-decoration: none; color: var(--ink); }

/* Emisión */
.lines td { padding: 6px 6px; }
.lines input, .lines select { padding: 7px 8px; }
.lines .w-code { width: 120px; } .lines .w-qty { width: 80px; } .lines .w-money { width: 130px; } .lines .w-pct { width: 74px; } .lines .w-tax { width: 120px; }
.totals { min-width: 300px; }
.totals .r { display: flex; justify-content: space-between; padding: 5px 0; color: var(--muted); }
.totals .r b { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }
.totals .grand { margin-top: 8px; background: var(--grad); color: #fff; border-radius: 12px; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; }
.totals .grand b { font-size: 20px; }
.pdf { width: 100%; height: 78vh; border: 0; border-radius: 8px; background: var(--soft); }
.combo { position: relative; }
.combo .opts { position: absolute; z-index: 20; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); max-height: 280px; overflow-y: auto; margin-top: 4px; }
.combo .opts div { padding: 9px 12px; cursor: pointer; }
.combo .opts div:hover, .combo .opts div.on { background: var(--soft); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 10%, rgba(31, 169, 189, .18), transparent 40%), radial-gradient(circle at 90% 90%, rgba(92, 200, 160, .18), transparent 45%), var(--bg); }
.login .card { width: min(400px, 100%); padding: 32px; }
.login img.logo { width: 120px; display: block; margin: 0 auto 18px; }
.login h1 { text-align: center; margin-bottom: 4px; }
.login p.sub { text-align: center; margin: 0 0 22px; }
.login form { display: grid; gap: 14px; }
.code { letter-spacing: .4em; text-align: center; font-size: 20px; font-weight: 600; }
.qr { display: block; margin: 8px auto; border-radius: 10px; border: 1px solid var(--line); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .side .grow, .side .who { display: none; }
  .main { padding: 18px 16px 40px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .form { grid-template-columns: 1fr; }
  .form > * { grid-column: span 1 !important; }
}
