/* Connwai Facturacion: proprietary CSS (no third-party frameworks). */

@font-face {
  font-family: "DM Sans Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 1000;
  src: url("./fonts/dm-sans-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

@font-face {
  font-family: "DM Sans Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 1000;
  src: url("./fonts/dm-sans-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

:root {
  --background: #f6f6f4;
  --card: #ffffff;
  --border: #e5e7eb;

  --foreground: #111827;
  --muted-foreground: #6b7280;

  --primary: #f27c20;
  --primary-foreground: #3d2513;
  --secondary: #ffe7cf;
  --secondary-foreground: #3d2513;

  --success: #16a34a;
  --success-bg: #dcfce7;
  --success-foreground: #0f172a;

  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --warning-foreground: #0f172a;

  --error: #dc2626;
  --error-bg: #fee2e2;
  --error-foreground: #0f172a;

  --radius-m: 16px;
  --radius-pill: 999px;

  --shadow-soft: 0 1px 0 rgba(17, 24, 39, 0.04);

  --focus-ring: 0 0 0 3px rgba(242, 124, 32, 0.28);
  --focus-ring-strong: 0 0 0 3px rgba(242, 124, 32, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: "DM Sans Variable", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

:where(a, button, input, select, textarea, summary, [role="button"], .btn, .nav__item, .tab, .pageBtn):focus-visible {
  outline: none;
  box-shadow: var(--focus-ring-strong);
}

:where(input, select, textarea):focus-visible {
  box-shadow: var(--focus-ring);
  border-color: rgba(242, 124, 32, 0.45);
}

.srOnly {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skipLink {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 50;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  font-weight: 900;
  font-size: 13px;
  transform: translateY(-140%);
  transition: transform 120ms ease;
}

.skipLink:focus-visible {
  transform: translateY(0);
}

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

.sidebar {
  flex: 0 0 280px;
  width: 280px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: rgba(255, 255, 255, 0.55);
  border-right: 1px solid var(--border);
}

.main {
  flex: 1;
  padding: 32px;
  min-width: 0;
}

.authBrand {
  display: inline-flex;
  margin-bottom: 16px;
  text-decoration: none;
}

.authBrand:hover {
  text-decoration: none;
}

.authBrand__img {
  display: block;
  width: min(300px, 100%);
  height: auto;
}

.sidebar__logo {
  display: block;
  padding: 6px 8px 18px;
  text-decoration: none;
}

.sidebar__logo:hover {
  text-decoration: none;
}

.sidebar__logoImage {
  display: block;
  width: 196px;
  max-width: 100%;
  height: auto;
}

.sidebar__cta {
  margin: 6px 0 18px;
}

.sidebar__sectionLabel {
  font-size: 11px;
  font-weight: 800;
  color: #9ca3af;
  letter-spacing: 0.08em;
  padding: 10px 10px 8px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav__item {
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  color: #374151;
  font-weight: 700;
  font-size: 13px;
  min-width: 0;
}

.nav__item .icon {
  color: #6b7280;
}

.nav__item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav__item:hover {
  background: rgba(15, 23, 42, 0.04);
  text-decoration: none;
}

.nav__item--active {
  background: var(--secondary);
  color: var(--foreground);
}

.nav__item--active .icon {
  color: var(--primary);
}

.sidebar__footer {
  margin-top: auto;
  padding-top: 18px;
}

.userCard {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-m);
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.userCard__left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #e5e7eb;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  color: #374151;
}

.userMeta {
  line-height: 1.1;
}

.userMeta__name {
  font-weight: 800;
  font-size: 12px;
}

.userMeta__plan {
  font-weight: 700;
  font-size: 11px;
  color: var(--muted-foreground);
}

/* Typography */
.pageTitle {
  font-size: 28px;
  font-weight: 900;
  margin: 0;
}

.pageSubtitle {
  margin: 2px 0 0;
  color: var(--muted-foreground);
  font-weight: 600;
  font-size: 14px;
}

.hRow {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  min-width: 0;
}

.hActions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}

/* Components */
.btn {
  height: 40px;
  border-radius: var(--radius-pill);
  padding: 0 14px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  max-width: 100%;
  min-width: 0;
  white-space: nowrap;
}

.btn .icon {
  width: 18px;
  height: 18px;
}

.btn > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn:hover {
  background: #fbfbfc;
  border-color: rgba(15, 23, 42, 0.18);
  text-decoration: none;
}

.btn:active {
  transform: translateY(0.5px);
}

.btn--primary {
  background: var(--primary);
  border-color: transparent;
  color: var(--primary-foreground);
  box-shadow: none;
}

.btn--primary:hover {
  background: #d66e12;
}

.btn--secondary {
  background: var(--card);
  border-color: var(--border);
}

.btn--ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.btn--ghost:hover {
  background: rgba(15, 23, 42, 0.05);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-soft);
}

.card__p20 {
  padding: 20px;
}

.c-noticeStack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.c-notice {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.c-notice__message {
  min-width: 0;
}

.c-notice a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.c-notice--error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.c-notice--warning {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a3412;
}

.c-notice--success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.c-notice--info {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.c-notice--compact {
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12px;
}

.c-field-error {
  margin-top: 6px;
  color: var(--error);
  font-weight: 800;
  font-size: 12px;
  line-height: 1.35;
}

.expense-dropzone {
  border: 2px dashed #d1d5db;
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  background: #fcfcfb;
  transition: border-color 120ms ease, background-color 120ms ease;
  cursor: pointer;
}

.expense-dropzone:hover {
  border-color: #f3b37e;
  background: #fff7ef;
}

.expense-dropzone--active {
  border-color: var(--primary);
  background: #fff3e6;
}

.expense-upload-progress {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #f1f5f9;
  overflow: hidden;
  position: relative;
  isolation: isolate;
}

.expense-upload-progress__bar {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #fb923c, #f97316);
  transition: width 220ms cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
  overflow: hidden;
}

.expense-upload-progress__bar--busy {
  animation: expense-progress-glow 1.1s ease-in-out infinite alternate;
}

.expense-upload-progress__bar--busy::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-120%);
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.45) 45%, transparent 100%);
  animation: expense-progress-shimmer 1.3s linear infinite;
}

@keyframes expense-progress-shimmer {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(220%);
  }
}

@keyframes expense-progress-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(251, 146, 60, 0.15);
  }
  100% {
    box-shadow: 0 0 0 4px rgba(251, 146, 60, 0.05);
  }
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 900;
}

.badge--success {
  background: var(--success-bg);
  color: var(--success);
}

.badge--warning {
  background: var(--warning-bg);
  color: #92400e;
}

.badge--error {
  background: var(--error-bg);
  color: var(--error);
}

.badge--secondary {
  background: #eef2f7;
  color: #475569;
}

.input {
  height: 40px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--card);
  padding: 0 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--foreground);
  width: 100%;
}

.input::placeholder {
  color: #9ca3af;
  font-weight: 700;
}

.fieldRow {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.select {
  position: relative;
}

.select select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  height: 40px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--card);
  padding: 0 38px 0 14px;
  font-size: 13px;
  font-weight: 800;
  color: #374151;
  cursor: pointer;
}

.select:after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid #6b7280;
  border-bottom: 2px solid #6b7280;
  transform: translateY(-60%) rotate(45deg);
  pointer-events: none;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: var(--radius-pill);
  background: #f3f4f6;
  border: 1px solid var(--border);
  flex-wrap: wrap;
}

.tab {
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 900;
  color: #475569;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.tab--active {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--foreground);
}

.tab:hover {
  background: rgba(15, 23, 42, 0.05);
  text-decoration: none;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 900;
  color: #6b7280;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
  font-weight: 800;
  color: #0f172a;
  vertical-align: middle;
}

.table td.muted {
  color: #64748b;
  font-weight: 800;
}

.table td.right,
.table th.right {
  text-align: right;
}

.table td.actions {
  width: 1%;
  white-space: nowrap;
}

.invoiceLinesTableWrap {
  overflow: hidden;
  overflow-y: auto;
  max-height: 390px;
  border-radius: 14px;
  border: 1px solid var(--border);
}

.invoiceLinesTableWrap .table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--card);
}

.invoiceLineConceptCell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.invoiceLineConceptCell .input {
  flex: 1;
  min-width: 0;
}

.invoiceLineTaxSelect {
  display: inline-flex;
  width: 86px;
}

.invoiceLineAddBtn {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: #111827;
  font-size: 18px;
  line-height: 1;
  font-weight: 900;
  cursor: pointer;
}

.invoiceLineAddBtn:hover {
  background: #f8fafc;
}

.invoiceLineDeleteBtn {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: #6b7280;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.invoiceLineDeleteBtn:hover {
  background: #fff1f2;
  color: #b91c1c;
}

.menu {
  position: relative;
  display: inline-block;
}

.menu > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
}

.menu > summary::-webkit-details-marker {
  display: none;
}

.menu__content {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 180px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  padding: 6px;
  z-index: 20;
}

.menu__item {
  display: block;
  padding: 10px 10px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 13px;
  color: #0f172a;
}

.menu__item:hover {
  background: #f1f5f9;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
}

.pageBtn {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
}

.pageBtn:hover {
  background: rgba(15, 23, 42, 0.05);
  text-decoration: none;
}

.pageBtn--active {
  background: var(--secondary);
  border-color: transparent;
}

.muted {
  color: var(--muted-foreground);
  font-weight: 700;
}

.grid3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 18px;
}

/* Allow grid children to shrink below min-content width (prevents horizontal overflow with long tables/text). */
.grid2 > *,
.grid3 > * {
  min-width: 0;
}

.kpiLabel {
  font-size: 12px;
  font-weight: 900;
  color: #9ca3af;
}

.kpiValue {
  font-size: 22px;
  font-weight: 900;
  margin-top: 6px;
}

.kpiDelta {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 900;
}

.kpiDelta--primary {
  color: var(--primary);
}
.kpiDelta--success {
  color: var(--success);
}
.kpiDelta--warning {
  color: var(--warning);
}
.kpiDelta--error {
  color: var(--error);
}

.sectionTitleRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.sectionTitle {
  font-size: 14px;
  font-weight: 900;
  margin: 0;
}

.linkAction {
  font-size: 12px;
  font-weight: 900;
  color: var(--primary);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.listItem {
  border: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 12px;
  padding: 12px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.listItem__left {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.listItem__top {
  font-size: 13px;
  font-weight: 900;
}

.listItem__sub {
  font-size: 12px;
  font-weight: 800;
  color: #64748b;
  margin-top: 2px;
}

.listItem__right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  font-weight: 900;
  color: #0f172a;
}

.chartBars {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 180px;
  padding-top: 12px;
}

.bar {
  width: 16px;
  border-radius: 8px;
  background: rgba(242, 124, 32, 0.16);
  border: 1px solid rgba(242, 124, 32, 0.25);
}

.bar--active {
  background: rgba(242, 124, 32, 0.34);
}

.switchRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}

.switchLabel {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.switchTitle {
  font-size: 13px;
  font-weight: 900;
}

.switchDesc {
  font-size: 12px;
  font-weight: 800;
  color: #64748b;
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  display: inline-block;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch__track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #e5e7eb;
  transition: background 120ms ease;
}

.switch__thumb {
  position: absolute;
  top: 50%;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--card);
  transform: translateY(-50%);
  transition: transform 140ms ease;
  box-shadow: 0 1px 6px rgba(15, 23, 42, 0.2);
}

.switch input:checked + .switch__track {
  background: var(--primary);
  border-color: var(--primary);
}

.switch input:checked + .switch__track .switch__thumb {
  transform: translate(18px, -50%);
}

/* Responsive foundation */
@media (max-width: 1024px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 16px;
  }

  .sidebar__logo {
    padding: 0 0 12px;
  }

  .sidebar__cta {
    margin: 0 0 12px;
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }

  .nav__item {
    flex: 1 1 160px;
  }

  .main {
    padding: 22px 16px;
  }

  .grid2 {
    grid-template-columns: 1fr;
  }

  .grid3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  /* Tables: allow horizontal scrolling inside their local container (avoid page-level overflow). */
  .card > div[style*="overflow: hidden"][style*="border-radius: 14px"] {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
  }

  .grid3 {
    grid-template-columns: 1fr;
  }

  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Page spacing helpers */
.mt16 { margin-top: 16px; }
.mt18 { margin-top: 18px; }
.mt24 { margin-top: 24px; }
.mt32 { margin-top: 32px; }
