:root {
  --bg: #070912;
  --bg2: #0c1020;
  --panel: rgba(18, 22, 40, 0.62);
  --panel-strong: rgba(22, 27, 50, 0.85);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e9ecf8;
  --muted: #9aa3c0;
  --faint: #6b7394;
  --violet: #8b5cf6;
  --indigo: #6366f1;
  --teal: #2dd4bf;
  --rose: #fb7185;
  --amber: #fbbf24;
  --green: #34d399;
  --radius: 18px;
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.7);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: var(--font);
  background: radial-gradient(1200px 800px at 70% -10%, #1a1440 0%, transparent 60%),
              radial-gradient(900px 700px at -10% 110%, #0b2a3a 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }

/* Aurora background */
.aurora { position: fixed; inset: 0; pointer-events: none; filter: blur(80px); opacity: .55; z-index: 0; }
.aurora span { position: absolute; border-radius: 50%; mix-blend-mode: screen; animation: drift 22s ease-in-out infinite alternate; }
.aurora span:nth-child(1) { width: 520px; height: 520px; background: #5b21b6; top: -160px; left: 30%; }
.aurora span:nth-child(2) { width: 420px; height: 420px; background: #0e7490; bottom: -140px; left: -80px; animation-duration: 28s; }
.aurora span:nth-child(3) { width: 360px; height: 360px; background: #be185d; top: 40%; right: -120px; opacity: .5; animation-duration: 34s; }
@keyframes drift { to { transform: translate(60px, 40px) scale(1.15); } }

.glass {
  background: var(--panel);
  border: 1px solid var(--border);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}

.app { position: relative; display: grid; grid-template-columns: 290px 1fr 360px; grid-template-rows: minmax(0, 1fr);
  height: 100vh; height: 100dvh; overflow: hidden; }
.app > * { min-height: 0; }
:focus-visible { outline: 2px solid #a78bfa; outline-offset: 2px; }
.composer textarea:focus-visible, .field input:focus-visible { outline: 0; }

/* Sidebar */
.sidebar {
  display: flex; flex-direction: column; gap: 14px; padding: 20px 16px;
  background: linear-gradient(180deg, rgba(14,17,33,.85), rgba(10,12,24,.9));
  border-right: 1px solid var(--border);
  overflow-y: auto; overscroll-behavior: contain;
  --sb-pad: max(14px, env(safe-area-inset-bottom));
  padding-bottom: var(--sb-pad);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 10px; }
.logo {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 800; font-size: 20px; color: white;
  background: conic-gradient(from 210deg, var(--violet), var(--indigo), var(--teal), var(--violet));
  box-shadow: 0 8px 30px -6px rgba(139, 92, 246, .7), inset 0 0 0 1px rgba(255,255,255,.25);
}
.logo.big { width: 76px; height: 76px; border-radius: 24px; font-size: 36px; }
.brand-name { font-weight: 800; letter-spacing: -.02em; font-size: 18px; }
.brand-sub { color: var(--muted); font-size: 12px; }

.btn-new {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  padding: 12px 14px; border-radius: 14px; font-weight: 600;
  background: linear-gradient(135deg, rgba(139,92,246,.25), rgba(99,102,241,.18));
  border: 1px solid rgba(139, 92, 246, .45);
  transition: transform .2s, box-shadow .2s, background .2s;
}
.btn-new:hover { transform: translateY(-1px); box-shadow: 0 10px 30px -10px rgba(139,92,246,.8); }

.side-label { color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; margin: 10px 8px 0; font-weight: 700; }
.quick { display: flex; flex-direction: column; gap: 6px; }
.quick-item {
  display: flex; gap: 12px; align-items: center; text-align: left; padding: 10px; border-radius: 14px;
  border: 1px solid transparent; transition: background .2s, border-color .2s, transform .2s;
}
.quick-item:hover { background: rgba(255,255,255,.04); border-color: var(--border); transform: translateX(2px); }
.quick-item b { display: block; font-weight: 600; font-size: 14px; }
.quick-item small { color: var(--muted); font-size: 12px; }
.qi-icon { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.qi-violet { background: rgba(139,92,246,.16); color: #c4b5fd; }
.qi-rose { background: rgba(251,113,133,.14); color: #fda4af; }
.qi-teal { background: rgba(45,212,191,.14); color: #5eead4; }

.history-wrap { display: flex; flex-direction: column; gap: 6px; }
.history-wrap[hidden] { display: none; }
.history { display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow-y: auto; }
.history-item { display: flex; align-items: center; gap: 6px; border-radius: 10px; border: 1px solid transparent; transition: background .2s, border-color .2s; }
.history-item:hover, .history-item.active { background: rgba(255,255,255,.04); border-color: var(--border); }
.history-item .h-open { flex: 1; min-width: 0; text-align: left; padding: 11px 10px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item.active .h-open { color: inherit; }
.history-item .h-del { flex: none; width: 32px; height: 32px; margin-right: 4px; border-radius: 8px; color: var(--faint); opacity: 0; transition: opacity .2s, background .2s; }
.history-item:hover .h-del, .history-item .h-del:focus-visible { opacity: 1; }
.history-item .h-del:hover { background: rgba(251,113,133,.14); color: #fda4af; }

.mini-dash { border-radius: var(--radius); padding: 14px; display: flex; gap: 14px; align-items: center; cursor: pointer; transition: border-color .2s; min-height: 84px; }
.mini-dash:hover { border-color: var(--border-strong); }
.mini-dash .mini-meta { display: flex; flex-direction: column; gap: 3px; font-size: 13px; min-width: 0; }
.mini-dash .mini-meta span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-dash .mini-meta b { font-size: 15px; }
.mini-dash .mini-meta span { color: var(--muted); font-size: 12px; }

.side-foot { margin-top: auto; color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 8px; padding: 8px; }
.dot-safe { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 12px var(--amber); }

/* Main */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; overflow: hidden; }
.topbar { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 14px 22px; gap: 12px; }
.topbar-title { flex: 1; display: flex; justify-content: center; }
.pill-live { display: inline-flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: rgba(255,255,255,.03); }
.pill-live i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); animation: pulse 2s infinite; }
.pill-live.off i { background: var(--rose); box-shadow: 0 0 10px var(--rose); }
@keyframes pulse { 50% { opacity: .35; } }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--muted); border: 1px solid var(--border); background: rgba(255,255,255,.03); transition: color .2s, background .2s; }
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,.07); }
.only-mobile { display: none; }

.chat { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scroll-behavior: smooth; padding: 0 20px 20px; }
.chat { -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 18px); mask-image: linear-gradient(to bottom, transparent 0, #000 18px); }
.messages { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; padding-top: 8px; }

/* Empty state */
.empty { max-width: 720px; margin: 7vh auto 0; text-align: center; animation: rise .7s cubic-bezier(.2,.8,.2,1); }
.empty.hidden { display: none; }
.hero-orb { width: 120px; height: 120px; margin: 0 auto 22px; display: grid; place-items: center; border-radius: 50%;
  background: radial-gradient(circle, rgba(139,92,246,.35), transparent 70%); animation: float 6s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-8px); } }
.empty h1 { font-size: clamp(30px, 4.4vw, 46px); letter-spacing: -.035em; margin: 0 0 10px; font-weight: 800; }
.grad { background: linear-gradient(90deg, #c4b5fd, #818cf8 40%, #5eead4); -webkit-background-clip: text; background-clip: text; color: transparent; }
.empty p { color: var(--muted); font-size: 16px; margin: 0 auto 28px; max-width: 520px; line-height: 1.55; }
.chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.chip { text-align: left; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--border); background: rgba(255,255,255,.035);
  color: var(--text); font-size: 14px; transition: transform .25s, border-color .25s, background .25s; animation: rise .6s backwards; }
.chip:nth-child(2) { animation-delay: .06s; } .chip:nth-child(3) { animation-delay: .12s; } .chip:nth-child(4) { animation-delay: .18s; }
.chip:hover { transform: translateY(-2px); border-color: rgba(139,92,246,.5); background: rgba(139,92,246,.08); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* Messages */
.msg { display: flex; gap: 14px; animation: rise .35s cubic-bezier(.2,.8,.2,1); }
.msg.user { justify-content: flex-end; }
.bubble-user { background: linear-gradient(135deg, #6d4aff, #5145e5); padding: 12px 16px; border-radius: 18px 18px 4px 18px; max-width: 78%;
  box-shadow: 0 10px 30px -12px rgba(109, 74, 255, .8); line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.avatar { width: 32px; height: 32px; border-radius: 10px; flex: none; font-size: 15px; }
.msg.bot .content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.md { line-height: 1.65; font-size: 15.5px; color: #dfe3f3; overflow-wrap: anywhere; }
.md p { margin: 0 0 .7em; } .md p:last-child { margin-bottom: 0; }
.md strong { color: white; }
.md ul, .md ol { padding-left: 1.3em; margin: .3em 0 .8em; }
.md li { margin: .2em 0; }
.md code { font-family: var(--mono); font-size: .88em; background: rgba(255,255,255,.07); padding: 2px 6px; border-radius: 6px; }
.md table { border-collapse: collapse; margin: .6em 0; font-size: 14px; display: block; max-width: 100%; overflow-x: auto; }
.md pre { max-width: 100%; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; }
.md a { color: #a5b4fc; }
.cursor::after { content: ""; display: inline-block; width: 8px; height: 1.05em; vertical-align: -0.15em; margin-left: 2px; border-radius: 2px;
  background: linear-gradient(#c4b5fd, #818cf8); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.typing { display: inline-flex; gap: 5px; padding: 8px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #a5b4fc; animation: bounce 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-6px); opacity: 1; } }
.err { color: #fecdd3; background: rgba(251,113,133,.1); border: 1px solid rgba(251,113,133,.35); padding: 10px 14px; border-radius: 12px; font-size: 14px; }

/* Tool status */
.tool-pill { align-self: flex-start; display: inline-flex; align-items: center; gap: 10px; font-size: 13px; color: #c7d2fe; padding: 8px 14px; border-radius: 999px;
  background: linear-gradient(90deg, rgba(99,102,241,.12), rgba(139,92,246,.2), rgba(99,102,241,.12)); background-size: 200% 100%;
  border: 1px solid rgba(129,140,248,.35); animation: shimmer 2s linear infinite; }
.tool-pill.done { animation: none; color: var(--muted); background: rgba(255,255,255,.03); border-color: var(--border); }
.tool-pill.done .spinner { display: none; }
.tool-pill .check { display: none; color: var(--green); }
.tool-pill.done .check { display: inline; }
@keyframes shimmer { to { background-position: -200% 0; } }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(165,180,252,.3); border-top-color: #a5b4fc; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Receipt */
.receipt-wrap { perspective: 1200px; animation: unfold .7s cubic-bezier(.2,.8,.2,1); }
@keyframes unfold { from { opacity: 0; transform: rotateX(-14deg) translateY(16px); } }
.receipt { position: relative; max-width: 460px; color: #1d2135; background: linear-gradient(180deg, #fdfcf8, #f4f2ea); border-radius: 16px 16px 0 0;
  padding: 22px 22px 26px; box-shadow: 0 30px 60px -25px rgba(0,0,0,.8), 0 0 0 1px rgba(255,255,255,.4) inset; font-size: 14px; }
.receipt::after { content: ""; position: absolute; left: 0; right: 0; bottom: -12px; height: 12px;
  background: radial-gradient(circle at 10px 0, #f4f2ea 9px, transparent 9.5px) repeat-x; background-size: 20px 12px; }
.r-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; border-bottom: 1.5px dashed #cfcab9; padding-bottom: 14px; }
.r-letter { width: 54px; height: 54px; border: 2px solid #1d2135; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 30px; flex: none; }
.r-title { font-weight: 800; letter-spacing: .04em; font-size: 15px; }
.r-sub { color: #6b6f85; font-size: 12px; margin-top: 2px; }
.r-num { font-family: var(--mono); font-size: 12px; color: #4b4f66; margin-top: 6px; }
.r-sec { padding: 12px 0; border-bottom: 1.5px dashed #cfcab9; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.r-sec .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: #8a8ea3; font-weight: 700; }
.r-sec .v { font-weight: 600; font-size: 13.5px; }
.r-items { width: 100%; border-collapse: collapse; margin: 12px 0 4px; font-size: 13.5px; }
.r-items th { text-align: left; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: #8a8ea3; padding-bottom: 6px; }
.r-items td { padding: 6px 0; border-top: 1px solid #e6e2d4; }
.r-items .num { text-align: right; font-family: var(--mono); font-size: 12.5px; }
.r-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 10px; padding-top: 12px; border-top: 2px solid #1d2135; }
.r-total span { font-weight: 700; letter-spacing: .06em; font-size: 12px; text-transform: uppercase; }
.r-total b { font-size: 26px; letter-spacing: -.02em; font-family: var(--font); }
.stamp { position: absolute; top: 112px; right: 26px; transform: rotate(-12deg); border: 3px solid rgba(225, 29, 72, .65); color: rgba(225, 29, 72, .75);
  font-weight: 800; letter-spacing: .14em; padding: 4px 10px; border-radius: 8px; font-size: 13px; text-transform: uppercase; pointer-events: none; mix-blend-mode: multiply; background: rgba(253,252,248,.35); animation: stamp .5s .35s backwards cubic-bezier(.2,1.6,.4,1); }
@keyframes stamp { from { transform: rotate(-12deg) scale(2.2); opacity: 0; } }
.r-actions { display: flex; gap: 10px; margin-top: 18px; max-width: 460px; flex-wrap: wrap; }
.btn-emit { flex: 1; padding: 12px 16px; border-radius: 12px; font-weight: 700; background: rgba(255,255,255,.06); color: var(--faint);
  border: 1px dashed var(--border-strong); cursor: not-allowed; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.r-note { font-size: 12px; color: var(--muted); margin-top: 8px; max-width: 460px; }
.r-actions[hidden], .r-note[hidden] { display: none; }
.btn-emit.ready { color: white; cursor: pointer; border: 0; background: linear-gradient(135deg, var(--violet), var(--indigo));
  box-shadow: 0 10px 26px -10px rgba(139,92,246,.9); transition: transform .2s, opacity .2s; }
.btn-emit.ready:hover { transform: translateY(-1px); }
.btn-emit.ready:focus-visible { outline: 2px solid #c4b5fd; outline-offset: 2px; }
.stamp.pending { border-color: rgba(79,70,229,.6); color: rgba(79,70,229,.8); }
.stamp.issued { border-color: rgba(5,150,105,.7); color: rgba(5,150,105,.85); }
.stamp.warn { border-color: rgba(217,119,6,.7); color: rgba(217,119,6,.85); }
.r-state { flex: 1; border-radius: 14px; padding: 12px 14px; font-size: 14px; line-height: 1.5; max-width: 460px; }
.r-state.r-fail { border-radius: 14px; }
.r-state + .r-state { margin-top: 8px; }
.r-ok { background: rgba(52,211,153,.1); border: 1px solid rgba(52,211,153,.35); color: #d1fae5; }
.r-warn { background: rgba(251,191,36,.1); border: 1px solid rgba(251,191,36,.4); color: #fef3c7; }
.r-muted { background: rgba(255,255,255,.04); border: 1px solid var(--border); color: var(--muted); }
.r-progress { display: flex; gap: 10px; align-items: center; background: rgba(139,92,246,.1); border: 1px solid rgba(139,92,246,.35); color: #ddd6fe; }
.r-kv { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; font-size: 13px; }
.r-kv span { color: #a7f3d0; }
.r-kv b { font-family: var(--mono); font-size: 13px; word-break: break-all; text-align: right; }
.r-fail { border-radius: 14px; padding: 14px 16px; background: rgba(251,113,133,.08); border: 1px solid rgba(251,113,133,.3); color: #fecdd3; font-size: 14px; max-width: 460px; }

/* Comprobantes list card */
.list-card { border-radius: 16px; overflow-x: auto; max-width: 640px; animation: rise .4s; }
.list-card .lc-head { display: flex; justify-content: space-between; padding: 12px 16px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--border); }
.list-card table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.list-card td, .list-card th { padding: 9px 16px; text-align: left; }
.list-card th { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--faint); font-weight: 700; }
.list-card tbody tr { border-top: 1px solid var(--border); transition: background .2s; }
.list-card tbody tr:hover { background: rgba(255,255,255,.03); }
.list-card .num { text-align: right; font-family: var(--mono); font-size: 12.5px; }
.tag { font-size: 11px; padding: 3px 8px; border-radius: 999px; font-weight: 700; white-space: nowrap; }
.tag.f { background: rgba(52,211,153,.12); color: #6ee7b7; }
.tag.nc { background: rgba(251,113,133,.12); color: #fda4af; }
.tag.o { background: rgba(255,255,255,.08); color: var(--muted); }

/* Composer */
.composer { flex: none; margin: 0 auto 6px; width: min(780px, calc(100% - 40px)); border-radius: 22px; display: flex; align-items: flex-end; gap: 10px; padding: 10px 10px 10px 18px;
  box-shadow: var(--shadow); transition: border-color .2s, box-shadow .2s; }
.composer:focus-within { border-color: rgba(139,92,246,.55); box-shadow: 0 0 0 4px rgba(139,92,246,.12), var(--shadow); }
.composer textarea { flex: 1; resize: none; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 15.5px; line-height: 1.5; max-height: 200px; max-height: min(200px, 30dvh); overflow-y: auto; padding: 8px 0; min-width: 0; }
.composer textarea::placeholder { color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.send { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; color: white; flex: none;
  background: linear-gradient(135deg, var(--violet), var(--indigo)); box-shadow: 0 8px 24px -8px rgba(139,92,246,.9); transition: transform .2s, opacity .2s; }
.send:hover { transform: scale(1.06); }
.send:disabled { opacity: .4; transform: none; cursor: default; }
.disclaimer { flex: none; text-align: center; font-size: 11.5px; color: var(--faint); padding: 4px 16px max(14px, env(safe-area-inset-bottom)); }

/* Dashboard panel */
.dash { border-left: 1px solid var(--border); background: linear-gradient(180deg, rgba(14,17,33,.8), rgba(10,12,24,.88)); padding: 20px; overflow-y: auto; overscroll-behavior: contain; transition: transform .35s cubic-bezier(.2,.8,.2,1); }
.dash-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.dash-head h2 { margin: 0; font-size: 18px; letter-spacing: -.02em; }
.dash-body { display: flex; flex-direction: column; gap: 14px; }
.dash-loading { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 14px; padding: 30px 0; justify-content: center; }
.app.dash-hidden { grid-template-columns: 290px 1fr 0; }
.app.dash-hidden .dash { transform: translateX(100%); padding: 0; border: 0; overflow: hidden; }

.d-card { border-radius: var(--radius); padding: 16px; animation: rise .5s backwards; }
.d-card:nth-child(2) { animation-delay: .07s; } .d-card:nth-child(3) { animation-delay: .14s; } .d-card:nth-child(4) { animation-delay: .21s; }
.d-who { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.d-who .name { font-weight: 700; font-size: 14px; }
.d-who .act { color: var(--muted); font-size: 12px; margin-top: 2px; }
.cat-badge { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; font-size: 26px; font-weight: 800; flex: none; position: relative;
  background: linear-gradient(135deg, rgba(139,92,246,.35), rgba(45,212,191,.25)); border: 1px solid rgba(255,255,255,.18); box-shadow: 0 10px 30px -10px rgba(139,92,246,.8); }
.cat-badge small { position: absolute; bottom: -8px; font-size: 9px; letter-spacing: .14em; background: var(--bg2); padding: 1px 6px; border-radius: 6px; border: 1px solid var(--border); color: var(--muted); }

.ring-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0 2px; }
.ring { position: relative; width: 190px; height: 190px; }
.ring svg { transform: rotate(-90deg); }
.ring .track { stroke: rgba(255,255,255,.07); }
.ring .bar { transition: stroke-dashoffset 1.6s cubic-bezier(.2,.8,.2,1), stroke 1.6s; }
.ring .glow { opacity: .28; filter: blur(6px); }
.ring .center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .pct { font-size: 38px; font-weight: 800; letter-spacing: -.04em; }
.ring .pct-sub { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
.ring-legend { display: flex; justify-content: space-between; width: 100%; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.ring-legend b { display: block; color: var(--text); font-size: 15px; }
.ring-legend div:last-child { text-align: right; }
.meter-note { font-size: 12px; color: var(--muted); text-align: center; margin-top: 8px; }

.d-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); font-size: 13.5px; }
.d-row:first-child { border-top: 0; padding-top: 0; }
.d-row .lbl { color: var(--muted); }
.d-row .val { font-weight: 600; text-align: right; }
.d-big { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.d-k { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .12em; font-weight: 700; margin-bottom: 6px; }
.ok-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: var(--green); box-shadow: 0 0 8px var(--green); }
.warn-dot { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.d-err { color: #fecdd3; font-size: 14px; padding: 14px; border-radius: 14px; background: rgba(251,113,133,.08); border: 1px solid rgba(251,113,133,.3); }
.skeleton-line { height: 12px; border-radius: 6px; background: linear-gradient(90deg, rgba(255,255,255,.05), rgba(255,255,255,.12), rgba(255,255,255,.05)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; margin: 6px 0; }
.w60 { width: 60%; } .w40 { width: 40%; }

/* Inline dashboard in chat */
.inline-dash { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; border-radius: 18px; padding: 16px 18px; max-width: 560px; animation: rise .5s; }
.inline-dash .ring { width: 120px; height: 120px; }
.inline-dash .ring .pct { font-size: 24px; }

.scrim { display: none; }

/* Account footer */
.account { position: sticky; bottom: 0; /* sticks at the sidebar padding edge */ z-index: 2; flex: none; background: var(--panel-strong); box-shadow: 0 -14px 24px -8px rgba(8,10,20,.9);
  border-radius: var(--radius); padding: 12px; display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; align-items: center; }
.account::after { content: ""; position: absolute; left: -17px; right: -17px; top: calc(100% + 1px); height: var(--sb-pad, 14px); background: #0a0c18; pointer-events: none; }
.account[hidden], .reconnect[hidden] { display: none; }
.acc-avatar { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 14px; color: white;
  background: linear-gradient(135deg, rgba(139,92,246,.6), rgba(45,212,191,.45)); border: 1px solid rgba(255,255,255,.18); }
.acc-meta { display: flex; flex-direction: column; min-width: 0; }
.acc-meta b { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-meta span { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.acc-actions { grid-column: 1 / -1; display: flex; gap: 6px; }
.acc-btn { flex: 1; min-height: 40px; font-size: 12px; line-height: 1.2; padding: 7px 8px; border-radius: 10px; color: var(--muted); border: 1px solid var(--border); background: rgba(255,255,255,.03); transition: color .2s, background .2s, border-color .2s; }
.acc-btn:hover { color: var(--text); background: rgba(255,255,255,.07); }
.acc-btn.danger:hover { color: #fecdd3; background: rgba(251,113,133,.12); border-color: rgba(251,113,133,.35); }
.acc-btn[hidden] { display: none; }
.reconnect { border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; border-color: rgba(251,191,36,.35); background: rgba(251,191,36,.07); }
.reconnect b { color: #fde68a; font-size: 13px; }
.reconnect span { color: var(--muted); }
.btn-mini { align-self: flex-start; font-size: 12px; font-weight: 700; padding: 6px 12px; border-radius: 10px; background: linear-gradient(135deg, var(--violet), var(--indigo)); color: white; }

/* Auth (onboarding / login) */
body.auth-open .app, body.auth-open .scrim { filter: blur(6px) saturate(80%); pointer-events: none; user-select: none; }
.auth { position: fixed; inset: 0; z-index: 50; display: flex; padding: 20px; padding-bottom: max(20px, env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain;
  background: radial-gradient(900px 600px at 50% 0%, rgba(91,33,182,.35), transparent 65%), rgba(7,9,18,.55); animation: fade .35s ease; }
.auth[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.auth-card { position: relative; margin: auto; flex: none; width: min(440px, 100%); border-radius: 26px; padding: 28px 28px 22px; box-shadow: var(--shadow), 0 0 0 1px rgba(255,255,255,.04) inset;
  background: linear-gradient(180deg, rgba(24,28,52,.82), rgba(14,17,33,.86)); animation: rise .5s cubic-bezier(.2,.8,.2,1); }
.auth-card::before { content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(135deg, rgba(139,92,246,.55), rgba(45,212,191,.25) 50%, rgba(251,113,133,.25));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; }
.auth-close { position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; border-radius: 10px; color: var(--muted); font-size: 20px; line-height: 1; z-index: 1; }
.auth-close:hover { background: rgba(255,255,255,.07); color: var(--text); }
.auth-close[hidden] { display: none; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-title { font-size: 26px; letter-spacing: -.03em; margin: 0 0 8px; font-weight: 800; }
.auth-sub { color: var(--muted); font-size: 14px; line-height: 1.55; margin: 0 0 20px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span:first-child { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--faint); font-weight: 700; }
.field input { width: 100%; font: inherit; font-size: 15.5px; color: var(--text); padding: 12px 14px; border-radius: 14px; outline: 0;
  background: rgba(255,255,255,.04); border: 1px solid var(--border-strong); transition: border-color .2s, box-shadow .2s, background .2s; }
.field input:focus { border-color: rgba(139,92,246,.6); box-shadow: 0 0 0 4px rgba(139,92,246,.14); background: rgba(255,255,255,.06); }
.field input::placeholder { color: var(--faint); }
.field input:read-only { color: var(--muted); }
#authCuit { font-family: var(--mono); letter-spacing: .04em; }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 46px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: var(--faint); }
.pw-toggle:hover, .pw-toggle.on { color: var(--text); background: rgba(255,255,255,.06); }
.trust { display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; color: #a7f3d0; line-height: 1.5; padding: 10px 12px; border-radius: 12px;
  background: rgba(52,211,153,.07); border: 1px solid rgba(52,211,153,.22); }
.trust svg { flex: none; margin-top: 1px; color: var(--green); }
.consent { display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; color: var(--muted); line-height: 1.5; cursor: pointer; }
.consent[hidden] { display: none; }
.consent input { margin-top: 1px; width: 20px; height: 20px; accent-color: var(--violet); flex: none; }
.auth-error { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: #fecdd3; padding: 10px 12px; border-radius: 12px;
  background: rgba(251,113,133,.09); border: 1px solid rgba(251,113,133,.32); animation: rise .3s; }
.auth-error b { color: #ffe4e6; }
.auth-error.info { color: #c7d2fe; background: rgba(99,102,241,.1); border-color: rgba(129,140,248,.35); }
.auth-error.info b { display: none; }
.auth-error[hidden] { display: none; }
.btn-auth { display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 13px 16px; border-radius: 14px; font-weight: 700; font-size: 15px; color: white;
  background: linear-gradient(135deg, var(--violet), var(--indigo)); box-shadow: 0 12px 30px -10px rgba(139,92,246,.9); transition: transform .2s, opacity .2s; }
.btn-auth:hover { transform: translateY(-1px); }
.btn-auth:disabled { opacity: .75; cursor: progress; transform: none; }
.btn-auth .spinner { display: none; border-color: rgba(255,255,255,.35); border-top-color: white; }
.btn-auth.loading .spinner { display: inline-block; }
.auth-switch { margin-top: 16px; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.auth-switch[hidden] { display: none; }
.auth-switch button { color: #c4b5fd; font-weight: 700; }
.auth-switch button:hover { text-decoration: underline; }

/* Confirm modal */
body.modal-open .app { filter: blur(4px); }
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; overflow-y: auto; background: rgba(4,6,14,.6); backdrop-filter: blur(3px); animation: fade .25s; }
.modal[hidden] { display: none; }
.modal-card { width: min(420px, 100%); border-radius: 22px; padding: 22px; box-shadow: var(--shadow); background: linear-gradient(180deg, rgba(28,22,44,.92), rgba(16,14,30,.94)); border-color: rgba(251,113,133,.3); animation: rise .35s; }
.modal-card h2 { margin: 0 0 8px; font-size: 19px; letter-spacing: -.02em; }
.modal-card p { margin: 0 0 18px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.btn-ghost { min-height: 42px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: rgba(255,255,255,.06); }
.btn-danger { min-height: 42px; padding: 10px 14px; border-radius: 12px; font-weight: 700; color: white; background: linear-gradient(135deg, #e11d48, #be185d); box-shadow: 0 10px 26px -10px rgba(225,29,72,.9); }
.btn-danger:disabled { opacity: .6; cursor: progress; }
.modal-card.issue-card { border-color: rgba(139,92,246,.35); width: min(440px, 100%); }
.issue-summary { display: grid; gap: 8px; margin: 6px 0 14px; padding: 12px 14px; border-radius: 14px; background: rgba(255,255,255,.04); border: 1px solid var(--border); }
.issue-summary div { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.issue-summary span { color: var(--muted); }
.issue-summary b { text-align: right; overflow-wrap: anywhere; }
.modal-card p.issue-warn { color: #fde68a; background: rgba(251,191,36,.08); border: 1px solid rgba(251,191,36,.3); border-radius: 12px; padding: 10px 12px; }
.issue-status { display: flex; gap: 10px; align-items: center; margin: -6px 0 16px; font-size: 14px; color: #ddd6fe; }
.issue-status[hidden] { display: none; }
.issue-status.error { color: #fecdd3; }
.btn-issue { min-height: 42px; padding: 10px 14px; border-radius: 12px; font-weight: 700; color: white; background: linear-gradient(135deg, var(--violet), var(--indigo)); box-shadow: 0 10px 26px -10px rgba(139,92,246,.9); }
.btn-issue:disabled, .btn-ghost:disabled { opacity: .6; cursor: progress; }
.btn-issue[hidden] { display: none; }

/* Responsive */
@media (max-width: 1180px) {
  .app { grid-template-columns: 270px 1fr; }
  .app.dash-hidden { grid-template-columns: 270px 1fr; }
  .dash { position: fixed; right: 0; top: 0; bottom: 0; width: min(380px, 92vw); z-index: 30; box-shadow: var(--shadow);
    padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  .app.dash-hidden .dash { transform: translateX(105%); }
}
@media (max-width: 820px) {
  .app, .app.dash-hidden { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 86vw); z-index: 30; transform: translateX(-105%); transition: transform .35s cubic-bezier(.2,.8,.2,1); }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .only-mobile { display: grid; }
  .chips { grid-template-columns: 1fr; }
  .chat { padding: 0 14px 14px; }
  .topbar { padding: max(10px, env(safe-area-inset-top)) 14px 10px; }
  .composer { width: calc(100% - 24px); padding-left: 14px; }
  .composer textarea { font-size: 16px; } /* >= 16px avoids iOS zoom-on-focus */
  .empty { margin-top: 4vh; }
  .empty p { font-size: 15px; margin-bottom: 20px; }
  .hero-orb { width: 96px; height: 96px; margin-bottom: 14px; }
  .logo.big { width: 64px; height: 64px; font-size: 30px; border-radius: 20px; }
  .msg { gap: 10px; }
  .md { font-size: 15px; }
  .receipt { padding: 18px 16px 22px; }
  .stamp { top: 96px; right: 14px; }
  .inline-dash { padding: 14px; }
  .list-card td, .list-card th { padding: 9px 10px; white-space: nowrap; }
  .bubble-user { max-width: 88%; }
  .r-sec { grid-template-columns: 1fr; }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 20; backdrop-filter: blur(2px); }
  .inline-dash { grid-template-columns: 1fr; justify-items: center; text-align: center; }
}
@media (hover: none) {
  .history-item .h-del { opacity: .7; }
  .quick-item:hover, .chip:hover, .btn-new:hover, .send:hover { transform: none; }
}
/* Short viewports (landscape phones, on-screen keyboard open): keep the composer roomy */
@media (max-height: 520px) {
  .topbar { padding-top: 6px; padding-bottom: 6px; }
  .disclaimer { display: none; }
  .composer { margin-bottom: max(8px, env(safe-area-inset-bottom)); }
  .empty { margin-top: 12px; }
  .hero-orb { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Dashboard error retry button */
.d-err .btn-retry { display: inline-flex; align-items: center; justify-content: center; margin-top: 10px; min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid rgba(251,113,133,.45); background: rgba(251,113,133,.12); color: #fecdd3; font: inherit; font-weight: 600; cursor: pointer; }
.d-err .btn-retry:hover { background: rgba(251,113,133,.2); }
.d-err .btn-retry:focus-visible { outline: 2px solid #fda4af; outline-offset: 2px; }

/* --- Monotributo maximum alert (would become Responsable Inscripto) */
.r-alert { margin-top: 16px; max-width: 460px; border-radius: 14px; padding: 14px 16px; font-size: 14px; line-height: 1.5; }
.r-alert[hidden] { display: none; }
.r-alert .ra-title { font-weight: 800; font-size: 15px; margin-bottom: 4px; }
.r-alert .ra-lead { font-weight: 700; font-size: 15.5px; margin: 4px 0; }
.r-alert .ra-msg { opacity: .92; }
.r-alert .ra-nums { display: grid; gap: 2px; margin-top: 8px; font-size: 13px; }
.r-alert .ra-nums b { font-family: var(--mono); margin-left: 6px; }
.r-alert .ra-foot { margin-top: 8px; font-size: 13px; opacity: .9; }
.r-alert.critical { background: rgba(239,68,68,.18); border: 2px solid #ef4444; color: #fee2e2;
  box-shadow: 0 0 0 4px rgba(239,68,68,.15), 0 10px 30px rgba(239,68,68,.25); animation: ri-pulse 2s ease-in-out 3; }
.r-alert.critical .ra-title { color: #fecaca; text-transform: uppercase; letter-spacing: .02em; }
.r-alert.warning { background: rgba(251,191,36,.12); border: 1px solid rgba(251,191,36,.55); color: #fef3c7; }
.r-alert.unknown { background: rgba(251,191,36,.07); border: 1px dashed rgba(251,191,36,.45); color: #fde68a; }
@keyframes ri-pulse { 50% { box-shadow: 0 0 0 8px rgba(239,68,68,.08), 0 10px 30px rgba(239,68,68,.35); } }
@media (prefers-reduced-motion: reduce) { .r-alert.critical { animation: none; } }

.issue-ri { border-radius: 12px; padding: 12px 14px; margin: 0 0 14px; font-size: 14px; line-height: 1.5; }
.issue-ri[hidden], .ri-ack[hidden] { display: none; }
.issue-ri.critical { background: rgba(239,68,68,.18); border: 2px solid #ef4444; color: #fee2e2; }
.issue-ri.warning, .issue-ri.unknown { background: rgba(251,191,36,.1); border: 1px solid rgba(251,191,36,.45); color: #fef3c7; }
.ri-ack { display: flex; gap: 10px; align-items: flex-start; margin-top: 10px; font-weight: 700; cursor: pointer; }
.ri-ack input { width: 18px; height: 18px; margin-top: 2px; accent-color: #ef4444; flex: none; }

/* --- Print / PDF */
.btn-pdf { display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: 1; min-width: 200px;
  padding: 12px 16px; border-radius: 12px; border: 0; cursor: pointer; font-weight: 700; font-size: 15px; color: #052e1c;
  background: linear-gradient(135deg, #34d399, #10b981); box-shadow: 0 8px 24px rgba(16,185,129,.3); }
.btn-pdf:hover { transform: translateY(-1px); }
.btn-pdf:focus-visible { outline: 2px solid #a7f3d0; outline-offset: 2px; }
.btn-pdf:disabled { opacity: .75; cursor: progress; transform: none; }
.btn-pdf .spinner { width: 14px; height: 14px; }
.pdf-err { flex-basis: 100%; color: #fecdd3; font-size: 13px; }
.pdf-card { display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: center; padding: 14px 16px; border-radius: 16px; max-width: 460px; }
.pdf-card .pc-icon { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 12px;
  background: rgba(251,113,133,.15); color: #fecdd3; border: 1px solid rgba(251,113,133,.35); }
.pdf-card .pc-meta { flex: 1; display: grid; gap: 2px; min-width: 180px; }
.pdf-card .pc-meta span { color: var(--muted); font-size: 13px; }
.pdf-card .pc-actions { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 8px; }
