/* Sistema visual compartido de Andloe Mobile. Los documentos impresos usan sus estilos propios. */
:root {
  --bg: #f2f5f9;
  --surface: #fff;
  --ink: #172b46;
  --muted: #4d6078;
  --line: #dce5ef;
  --primary: #1b57bd;
  --primary-strong: #164798;
  --navy: #102541;
  --accent: #087a62;
  --danger: #ad2739;
  --shadow: 0 2px 5px #142a4810;
  --ui-radius: 13px;
  --ui-control: 8px;
  --ui-inset: clamp(16px, 2.15vw, 32px);
  --ui-subtle: #f0f5fc;
  --ui-focus: #1662c8;
  --ui-nav-text: #dbe7f7;
}

body {
  background: var(--bg);
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
}

:where(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--ui-focus);
  outline-offset: 3px;
}

button, summary { touch-action: manipulation; }
button:disabled { cursor: not-allowed; }
button:active { transform: none; }
button:not(:disabled):active { filter: brightness(.94); }

.login-view {
  align-content: center;
  grid-template-columns: minmax(0, .88fr) minmax(0, 1.12fr);
  padding: clamp(24px, 5vw, 70px);
}

.login-brand-panel,
.login-form-panel {
  min-width: 0;
  box-shadow: none;
}

.login-brand-panel {
  min-height: 565px;
  padding: 48px;
  border-radius: 20px 0 0 20px;
  background-color: var(--navy);
  background-image:
    radial-gradient(ellipse at 18% 85%, #225598 0, transparent 52%),
    linear-gradient(145deg, #183b68, #102541 61%);
}

.login-brand-panel::after {
  inset: 0;
  width: auto;
  height: auto;
  border: 0;
  border-radius: 0;
  background-image:
    linear-gradient(#ffffff14 1px, transparent 1px),
    linear-gradient(90deg, #ffffff14 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(28deg, #000, transparent 85%);
  pointer-events: none;
}

.brand-lockup { justify-items: start; gap: 22px; text-align: left; }
.brand-lockup h1 { font-size: clamp(2rem, 4vw, 3.25rem); letter-spacing: -.045em; }
.brand-lockup .mark {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: #fff;
  color: var(--navy);
  box-shadow: none;
  font-size: 40px;
}

.login-form-panel {
  padding: clamp(28px, 5vw, 70px);
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 20px 20px 0;
  background: var(--surface);
}

.login-form-wrap { max-width: 390px; }
.login-heading { margin-bottom: 20px; text-align: left; }
.login-heading h2 { color: var(--ink); font-size: clamp(1.65rem, 3vw, 2.05rem); letter-spacing: -.035em; }
.login-view #companyCard { border-color: var(--line); border-radius: var(--ui-control); background: var(--ui-subtle); box-shadow: none; }
.login-view .company-icon { display: grid; place-items: center; }
.login-view .input-wrap { border-radius: var(--ui-control); box-shadow: none; }
.login-view .login-submit { border-radius: var(--ui-control); background: var(--primary); box-shadow: none; }

body:has(.app-view:not(.hidden)),
body.pos-mode .app-view:not(.hidden) { background: var(--bg); }

.app-view:not(.hidden) { --side-width: 226px; }
.app-view.nav-collapsed { --side-width: 68px; }
.app-view > .section { margin: 0 var(--ui-inset) 32px; }

.mobile-sidebar {
  padding: 16px 12px 14px;
  border-right: 1px solid #213b5c;
  background: var(--navy);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #4b6483 transparent;
}

.mobile-sidebar .mobile-sidebar-brand {
  padding: 4px 5px 16px;
  margin-bottom: 10px;
  border-bottom: 1px solid #304865;
  color: #fff;
}
.mobile-brand-mark {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: #edf4ff;
  color: var(--navy);
}
.mobile-sidebar-brand .mobile-sidebar-text,
.sidebar-user .mobile-sidebar-text { min-width: 0; }
.mobile-sidebar-brand small, .sidebar-user small { color: #acbed8; }
.mobile-sidebar .sidebar-user { color: var(--ui-nav-text); }
.sidebar-avatar { background: #2b466a; color: #edf4ff; }
.sidebar-footer { border-color: #304865; }

.mobile-sidebar :is(.nav-item, .nav-group-toggle, .sidebar-utility) {
  min-height: 44px;
  height: auto;
  padding: 9px 10px;
  border-radius: var(--ui-control);
  color: var(--ui-nav-text);
  font-size: .875rem;
  font-weight: 550;
}
.mobile-sidebar .nav-subitem { min-height: 39px; padding-block: 7px; }
.mobile-sidebar .nav-submenu { border-color: #456181; }
.mobile-sidebar :is(.nav-item, .nav-group-toggle, .sidebar-utility):hover:not(:disabled) {
  background: #243e5e;
  color: #fff;
}
.mobile-sidebar .nav-group-toggle.current { color: #c6ddff; }
.mobile-sidebar .nav-item.active {
  background: #284a75;
  color: #fff;
  font-weight: 700;
}
.mobile-sidebar .nav-item.active::before { background: #83b5ff; }
.mobile-sidebar [hidden] { display: none !important; }
.mobile-sidebar :focus-visible { outline-color: #a6caff; outline-offset: -2px; }
.mobile-sidebar #sidebarToggle { min-width: 32px; min-height: 38px; color: #d9e7fb; }

.mobile-skip-link {
  position: fixed;
  inset: 8px auto auto 8px;
  z-index: 92;
  border-radius: var(--ui-control);
  background: #fff;
  color: var(--primary-strong);
}
.mobile-skip-link:not(:focus) {
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.mobile-skip-link:focus { padding: 10px 14px; }
.mobile-nav-toggle, .mobile-nav-close, .sidebar-scrim { display: none; }

.app-view .topbar,
body.pos-mode .app-view .topbar {
  min-height: 72px;
  height: auto;
  margin: 0 0 20px;
  padding: 10px var(--ui-inset);
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  box-shadow: none;
}
.app-view .topbar-title h2 {
  color: var(--ink);
  font-size: clamp(1.15rem, 2vw, 1.55rem);
  letter-spacing: -.025em;
  overflow-wrap: anywhere;
}
.app-view .topbar-date { margin-bottom: 2px; color: var(--muted); }
.app-view .session-context-badge {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--ui-control);
  background: var(--ui-subtle);
}
.app-view .session-context-label { color: #215588 !important; }
.app-view .session-context-badge strong { color: var(--ink); }
body:not(.pos-mode) #posSessionLabel { display: none; }

/* Superficies y jerarquías que se repiten en los módulos. */
.app-view :is(.card, .panel, .filters, .commerce-card, .commerce-toolbar,
  .clients-heading, .clients-search, .clients-pager, .clients-stats article,
  .invoice-list-card, .invoice-status-card, .invoice-context-card, .invoice-checkout-sidebar,
  .cob-toolbar, .cob-stats article, .seller-heading, .seller-kpi,
  .mobile-db-card, .pos-card, .pos-cart-panel, .pos-products-panel, .multas-card) {
  border: 1px solid var(--line);
  border-radius: var(--ui-radius);
  background-color: var(--surface);
  box-shadow: var(--shadow);
}

.app-view :is(.commerce-heading h2, .clients-heading h2, .cob-header h2,
  .seller-heading h2, .invoice-page-heading h2, .multas-titulo) {
  color: var(--ink);
  font-size: clamp(1.4rem, 2.4vw, 1.9rem);
  line-height: 1.18;
  letter-spacing: -.032em;
}
.app-view :is(.commerce-heading p, .clients-heading p, .cob-header p, .seller-heading p) {
  color: var(--muted);
  line-height: 1.45;
}
.app-view :is(.commerce-heading, .clients-heading, .cob-header, .seller-heading) {
  min-width: 0;
  flex-wrap: wrap;
}
#cobrosSection > .cob-header {
  margin-bottom: 0;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--ui-radius);
  background: var(--surface);
  color: var(--ink);
}
#cobrosSection > .cob-header h2 { margin-bottom: 3px; }
#cobrosSection > .cob-header p { margin-bottom: 0; }
#cobrosSection .cob-stats, #cobrosSection #cobFilters { margin-block: 0; }
#cobFilters #cobClear { border: 1px solid var(--line); background: var(--surface); color: var(--primary-strong); }

.app-view :is(.primary-button, .invoice-primary-action):not(:disabled),
.app-view :is(#clientsNew, #cobNew, #commerceNewProduct, #sellerReport, #cobFilters button[type="submit"]):not(:disabled),
.app-view .clients-search button[type="submit"]:not(:disabled) {
  border-color: var(--primary);
  border-radius: var(--ui-control);
  background: var(--primary);
  color: #fff;
  box-shadow: none;
}
.app-view :is(.primary-button, .invoice-primary-action, #clientsNew, #cobNew, #commerceNewProduct):hover:not(:disabled),
.login-submit:hover:not(:disabled) { background: var(--primary-strong); }

.app-view :is(.table-wrap, .commerce-table, .commerce-table-wrap, .clients-table-wrap, .invoice-list-table-wrap,
  .cob-table, .pos-cart-table) {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}
.app-view :is(.table-wrap, .commerce-table, .commerce-table-wrap, .clients-table-wrap, .cob-table) {
  border-color: var(--line);
  border-radius: var(--ui-radius);
}
.app-view :is(.report-results-panel, .commerce-table, .commerce-table-wrap, .clients-table-wrap,
  .invoice-list-table-wrap, .cob-table, .pos-cart-table) th {
  border-color: var(--line);
  background: #edf3fa;
  color: #28415f;
  font-weight: 700;
  text-transform: none;
}
.app-view :is(.numeric, .numeric-cell, .importe, .num, .seller-kpi strong, .cob-stats strong,
  .clients-stats strong, .pos-grand-total, .invoice-status-card strong) { font-variant-numeric: tabular-nums; }

.app-view :is(dialog, .modal-dialog, .pos-dialog > div, .pos-dialog > form) { border-radius: var(--ui-radius); }
.app-view dialog::backdrop { background: #102541a8; }

#dashboardSection .dashboard-period-filter { margin: 0; padding: 12px 16px; gap: 10px; }
#dashboardSection .dashboard-period-filter label { color: var(--muted); font-size: .875rem; }
#dashboardSection .dashboard-period-filter select { border-radius: var(--ui-control); font-weight: 650; }
#dashboardSection :is(.dashboard-chart-panel, .seller-sales-panel) { min-width: 0; padding: clamp(12px, 1.6vw, 22px); }
#dashboardSection .metric-card { padding: clamp(12px, 1.7vw, 20px); min-height: 108px; }
#dashboardSection .metric-card::before { display: none; }
#dashboardSection .metric-card:first-child {
  border-color: var(--navy);
  background: var(--navy);
}
#dashboardSection .metric-card:first-child :is(.metric-label, .metric-trend em) { color: #d8e7ff; }
#dashboardSection .metric-card:first-child strong { color: #fff; }
#dashboardSection .metric-trend.positive { color: #137144; }
#dashboardSection .metric-trend.negative { color: #a62c38; }
#dashboardSection .metric-card:first-child .metric-trend { color: #d8e7ff; }
#dashboardSection .metric-card:first-child .metric-trend.positive { color: #80dfb6; }
#dashboardSection .metric-card:first-child .metric-trend.negative { color: #ffc1c7; }
#dashboardSection .metric-card:first-child .metric-icon { background: #274870; color: #d5e6ff; }
#dashboardSection .metric-icon { border-radius: 11px; }
#dashboardSection .seller-sales-heading h3 { color: var(--ink); }
#dashboardSection .seller-row {
  grid-template-columns: 20px 36px minmax(0, 1fr);
  gap: 8px;
  border-radius: var(--ui-control);
  background: var(--surface);
}
#dashboardSection .seller-avatar { width: 36px; height: 36px; border-radius: 9px; }
#dashboardSection .seller-info { display: block; padding: 0; background: transparent; }
#dashboardSection :is(.seller-line, .seller-meta) { gap: 4px 8px; flex-wrap: wrap; }
#dashboardSection .seller-line strong { white-space: normal; overflow-wrap: anywhere; }
#dashboardSection .seller-meta b { font-variant-numeric: tabular-nums; }
.dashboard-chart-details { margin-top: 12px; border-top: 1px solid var(--line); }
.dashboard-chart-details summary { width: fit-content; padding: 12px 0; color: var(--primary-strong); font-size: .88rem; font-weight: 650; cursor: pointer; }
.dashboard-chart-details table { min-width: 0; }
.dashboard-chart-details tbody th { position: static; background: transparent; color: var(--ink); text-transform: none; }

#reportsSection .report-filter-card .eyebrow { display: none; }
#reportsSection .report-results-panel .eyebrow { display: none; }
#reportsSection .report-filter-box { border-color: var(--line); background: var(--ui-subtle); }
#reportsSection .report-heading-icon, #reportsSection .current-company-icon {
  border-radius: 10px;
  background: var(--ui-subtle);
  color: var(--primary-strong);
}
body.pos-mode .pos-grand-total { border-radius: 0 0 var(--ui-radius) var(--ui-radius); }
body.pos-mode #posSection { grid-template-columns: minmax(0, 1fr); }
body.pos-mode .pos-product-lookup .pos-search { min-width: 0; }
body.pos-mode .app-view .pos-cart-table th { background: #edf3fa; color: #28415f; }
.mobile-multas, .multas-dialog {
  --multas-ink: var(--ink);
  --multas-muted: var(--muted);
  --multas-line: var(--line);
  --multas-blue: var(--primary);
  --multas-blue-soft: var(--ui-subtle);
  --multas-radius: var(--ui-radius);
}
.mobile-multas :is(.multas-saldo, .multas-heading) { background: var(--navy); }

@media (max-width: 1023px) {
  .app-view:not(.hidden) { grid-template-columns: minmax(0, 1fr); }
  .app-view .topbar, .app-view > .section { grid-column: 1; }
  .app-view .mobile-sidebar {
    display: none;
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, calc(100% - 40px));
    height: 100dvh;
    padding: 14px 12px max(14px, env(safe-area-inset-bottom));
    z-index: 91;
  }
  .app-view.nav-drawer-open .mobile-sidebar { display: flex; }
  body:has(.nav-drawer-open) { overflow: hidden; }
  .sidebar-scrim:not([hidden]) { display: block; position: fixed; inset: 0; background: #1025419e; z-index: 90; }
  .app-view.nav-collapsed .mobile-sidebar-text { display: revert; }
  .app-view.nav-collapsed .mobile-sidebar-brand { flex-wrap: nowrap; justify-content: flex-start; gap: 10px; }
  .app-view.nav-collapsed .mobile-sidebar :is(.nav-item, .nav-group-toggle, .sidebar-utility, .sidebar-user) {
    justify-content: flex-start;
    padding-inline: 10px;
  }
  .app-view.nav-collapsed .nav-submenu:not([hidden]) { display: grid; }
  .mobile-sidebar .nav-subitem { min-height: 44px; }
  .mobile-sidebar #sidebarToggle { display: none; }
  .mobile-nav-toggle, .mobile-nav-close {
    display: inline-grid;
    place-items: center;
    flex: 0 0 44px;
    width: 44px;
    min-height: 44px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--ui-control);
    background: var(--ui-subtle);
    color: var(--primary-strong);
  }
  .mobile-nav-toggle { order: -2; }
  .mobile-nav-close { margin-left: auto; border-color: #456181; background: #233e60; color: #fff; font-size: 1.4rem; }
  .mobile-nav-toggle svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; }
}

@media (max-width: 900px) {
  .login-view { grid-template-columns: minmax(0, 1fr); max-width: 550px; align-content: start; margin-inline: auto; padding: clamp(12px, 4vw, 30px); }
  .login-brand-panel { min-height: 0; padding: 20px; border-radius: 16px 16px 0 0; }
  .brand-lockup { display: flex; align-items: center; gap: 12px; }
  .brand-lockup .mark { width: 42px; height: 42px; font-size: 26px; border-radius: 9px; flex: none; }
  .brand-lockup h1 { font-size: clamp(1.45rem, 5.4vw, 2rem); }
  .login-form-panel { padding: 24px clamp(14px, 4.5vw, 30px); border-left: 1px solid var(--line); border-radius: 0 0 16px 16px; }
}

@media (max-width: 680px) {
  :root { --ui-inset: 12px; }
  .app-view .topbar, body.pos-mode .app-view .topbar { margin-bottom: 14px; min-height: 60px; gap: 8px; }
  .app-view .topbar-title, body.pos-mode .app-view .topbar-title { flex: 1 1 135px; width: auto; min-width: 0; }
  .app-view .topbar-title h2, body.pos-mode .app-view .topbar-title h2 { white-space: normal; font-size: 1.08rem; }
  .app-view .session-context-badge, body.pos-mode .app-view .session-context-badge {
    flex: 1 1 100%;
    max-width: 100%;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 3px 8px;
    order: 4;
  }
  .app-view .session-context-badge :is(strong, span) { white-space: normal; overflow-wrap: anywhere; }
  .app-view .session-context-label { display: none; }
  .app-view #invoiceTopBack { order: 2; }
  .app-view #invoiceTopBack, .app-view #posHeaderMenuButton { min-height: 44px; }
  body.pos-mode .pos-product-lookup { flex-wrap: wrap; }
  body.pos-mode .pos-toolbar .pos-action { min-height: 44px; }
  body.pos-mode .pos-cart-table:has(td.pos-empty) table { min-width: 0; }
  body.pos-mode .pos-cart-table:has(td.pos-empty) thead { display: none; }

  .app-view :is(.commerce-section, .reports-section) :is(input, select, textarea):not([type="checkbox"], [type="radio"]) {
    font-size: max(1rem, 16px);
  }
  .app-view :is(.commerce-section, .reports-section) :is(.primary-button, .invoice-primary-action) { min-height: 44px; }
  #reportsSection .report-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  #reportsSection .report-actions button { padding-inline: 8px; white-space: normal; }
  #reportsSection #consultReportButton { grid-column: 1 / -1; }
  #creditNoteIdSearch { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); align-items: end; }
  #creditNoteIdSearch button { grid-column: 1 / -1; }
  #creditNoteSearch input[type="date"] { min-width: 0; padding-inline: 8px; }
  #dashboardSection .dashboard-period-filter { padding: 10px 12px; }
  #dashboardSection .dashboard-period-filter select { min-width: 0; font-size: 1rem; }
  #cobrosSection > .cob-header { padding: 14px; }
  #cobrosSection > .cob-header button { width: 100%; min-height: 44px; }
  .app-view .cob-stats article { min-width: 0; padding: 12px; }
  .app-view .cob-stats strong { overflow-wrap: anywhere; }
}

@media (max-width: 680px) {
  #productsSection .commerce-table { border: 0; background: transparent; overflow: visible; }
  #productsSection .commerce-table table { display: block; min-width: 0; }
  #productsSection .commerce-table thead { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
  #commerceProductsBody { display: grid; gap: 8px; }
  #productsSection #commerceProductsBody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--ui-radius);
    background: var(--surface);
  }
  #productsSection #commerceProductsBody td {
    display: grid;
    justify-items: start;
    align-content: start;
    gap: 4px;
    width: auto;
    min-width: 0;
    padding: 0;
    border: 0;
    color: var(--ink);
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  #commerceProductsBody td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: .74rem; font-weight: 600; }
  #commerceProductsBody td:nth-child(2) { grid-column: 1 / -1; font-size: .92rem; font-weight: 700; }
  #productsSection #commerceProductsBody td:last-child { align-content: end; }
  #productsSection #commerceProductsBody .commerce-edit-button { min-height: 44px !important; }
  #productsSection #commerceNewProduct { width: 100%; }
  #productsSection .commerce-search :is(input, select) { min-height: 44px; font-size: 1rem; }
  #productsSection .commerce-search button { min-height: 44px; }
}

@media (min-width: 360px) and (max-width: 680px) {
  #dashboardSection .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  #dashboardSection .metric-card { grid-template-columns: minmax(0, 1fr); align-content: start; gap: 8px; }
  #dashboardSection .metric-card strong { margin-top: 5px; font-size: clamp(1rem, 9cqi, 1.28rem); }
  #dashboardSection .metric-icon { width: 34px; height: 34px; }
  #dashboardSection .metric-icon svg { width: 23px; height: 23px; }
  #dashboardSection .metric-trend { margin-top: 7px; gap: 4px; font-size: .74rem; }
}

@media (min-width: 1280px) {
  #dashboardSection { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; }
  #dashboardSection > :not(.dashboard-chart-panel, .seller-sales-panel) { grid-column: 1 / -1; }
  #dashboardSection .dashboard-chart-panel { grid-column: 1; }
  #dashboardSection .seller-sales-panel { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
  .app-view :is(.nav-group-chevron, .dashboard-skeleton span, .invoice-status-card),
  .login-view .login-spinner { animation: none; transition: none; }
}
