/**
 * Bridge: clases del ERP (Tailwind / componentes) → look de staging shell.css
 */
:root {
  /* Aliases usados por vistas ERP existentes */
  --color-primary: var(--nav);
  --color-primary-hover: var(--nav2);
  --color-primary-soft: var(--blue-lt);
  --color-bg: var(--bg);
  --color-surface: var(--surface);
  --color-border: var(--border);
  --color-border-strong: var(--border2);
  --color-text: var(--t1);
  --color-text-muted: var(--t3);
  --color-text-subtle: var(--t4);
  --color-success: var(--green);
  --color-success-soft: var(--green-lt);
  --color-warning: var(--amber);
  --color-warning-soft: var(--amber-lt);
  --color-danger: var(--red);
  --color-danger-soft: var(--red-lt);
  --color-info: var(--blue);
  --color-info-soft: var(--blue-lt);
  --font-sans: 'Figtree', sans-serif;
  --font-display: 'Syne', 'Figtree', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --text-xs: 11px;
  --text-sm: 12px;
  --text-base: 13px;
  --text-lg: 15px;
  --text-xl: 16px;
  --text-2xl: 18px;
  --text-3xl: 22px;
  --radius-sm: var(--rsm);
  --radius-md: var(--rsm);
  --radius-lg: var(--r);
  --radius-xl: var(--r);
  --shadow-sm: var(--sh);
  --shadow-md: var(--sh-md);
  --shadow-lg: var(--sh-md);
}

[x-cloak] { display: none !important; }

/* App shell: top navigation (browser-like) */
html, body.app-shell, body.s3-shell {
  height: 100%;
  background: var(--bg);
  color: var(--t1);
  font-family: 'Figtree', sans-serif;
  font-size: 13px;
  margin: 0;
}

/* Hub /admin: sidebar layout (staging shell hides bare #app until JS login) */
#app.s3-app {
  display: grid;
  grid-template-columns: 220px 1fr;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

#app.s3-app-top {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: visible;
  background: var(--bg);
}
#app.s3-app-top > .s3-main {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.s3-chrome {
  flex-shrink: 0;
  background: var(--nav);
  color: #fff;
  box-shadow: var(--sh-md);
  z-index: 60;
  overflow: visible;
  position: relative;
}

.s3-chrome-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  min-height: 56px;
}

.s3-chrome-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.s3-chrome-brand .logo-mark {
  margin: 0;
  width: 34px;
  height: 34px;
}
.s3-chrome-brand .brand-name {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  line-height: 1.1;
}
.s3-chrome-brand .brand-sub {
  font-size: 9px;
  color: rgba(255,255,255,.35);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-top: 2px;
}

.s3-chrome-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: rgba(255,255,255,.92);
  margin-left: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.s3-chrome-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.s3-chrome-select {
  padding: 5px 10px !important;
  font-size: 12px !important;
  width: auto !important;
  min-width: 130px;
  background: rgba(255,255,255,.08) !important;
  border-color: rgba(255,255,255,.18) !important;
  color: #fff !important;
}
.s3-chrome-select option { color: var(--t1); background: var(--surface); }
.s3-chrome-actions .btn-ghost {
  color: rgba(255,255,255,.8);
  border-color: rgba(255,255,255,.2);
}
.s3-chrome-actions .btn-ghost:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}
.s3-chrome-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 8px;
  border-left: 1px solid rgba(255,255,255,.12);
}
.s3-chrome-user .u-av {
  width: 28px;
  height: 28px;
  font-size: 10px;
}
.s3-chrome-user .u-name {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,.85);
  line-height: 1.2;
}
.s3-chrome-user .logout-btn {
  color: rgba(255,255,255,.4);
  font-size: 10px;
}
.s3-chrome-user .logout-btn:hover { color: rgba(255,255,255,.75); }
.s3-chrome-burger {
  display: none;
  background: none;
  border: 1px solid rgba(255,255,255,.2);
  color: #fff;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 16px;
  cursor: pointer;
}

/* Horizontal menubar — overflow visible so dropdowns are not clipped */
.s3-chrome-nav {
  background: var(--nav2);
  border-bottom: 1px solid rgba(255,255,255,.06);
  overflow: visible;
  position: relative;
  z-index: 70;
}
.s3-menubar {
  position: relative;
  overflow: visible;
}
.s3-menubar-scroll {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 2px;
  padding: 0 10px;
  overflow: visible;
}
.s3-menubar-item {
  position: relative;
  flex-shrink: 0;
}
.s3-menubar-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 10px 12px;
  background: transparent;
  border: none;
  color: rgba(255,255,255,.62);
  font-family: 'Figtree', sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.s3-menubar-btn:hover,
.s3-menubar-btn.active,
.s3-menubar-btn.is-open,
.s3-menubar-btn[aria-expanded="true"] {
  color: #fff;
  background: rgba(255,255,255,.08);
}
.s3-menubar-btn.active {
  border-bottom-color: rgba(255,255,255,.55);
}
.s3-menubar-caret {
  font-size: 9px;
  opacity: .55;
}
.s3-menubar-panel {
  position: absolute;
  top: calc(100% - 1px);
  left: 0;
  min-width: 260px;
  max-width: 340px;
  max-height: min(70vh, 520px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--r) var(--r);
  box-shadow: var(--sh-md);
  padding: 6px;
  z-index: 80;
}
.s3-menubar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--t2);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 500;
}
.s3-menubar-link:hover {
  background: var(--surface2);
  color: var(--t1);
}
.s3-menubar-link.active {
  background: var(--blue-lt);
  color: var(--blue);
  font-weight: 700;
}
.s3-menubar-link--child {
  padding-left: 28px;
  font-size: 11.5px;
  color: var(--t3);
}
.s3-menubar-glyph {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  opacity: .85;
}
.s3-menubar-empty {
  padding: 10px 14px;
  color: rgba(255,255,255,.35);
  font-size: 12px;
}

.s3-main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.s3-main .content,
#app.s3-app-top .content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

@media (max-width: 768px) {
  #app.s3-app {
    grid-template-columns: 1fr;
    height: 100dvh;
  }
}

@media (max-width: 900px) {
  .s3-chrome-title { display: none; }
  .s3-chrome-user-meta { display: none; }
  .s3-chrome-burger { display: inline-flex; }
  .s3-chrome-nav {
    display: none;
    max-height: min(70vh, 520px);
    overflow: auto;
  }
  .s3-chrome-nav.is-open { display: block; }
  .s3-menubar-scroll {
    flex-direction: column;
    align-items: stretch;
    padding: 8px;
  }
  .s3-menubar-panel {
    position: static;
    max-width: none;
    width: 100%;
    border-radius: var(--r);
    margin: 0 0 6px;
    box-shadow: none;
  }
  .s3-menubar-btn {
    width: 100%;
    justify-content: space-between;
    border-bottom: none;
    border-radius: 6px;
  }
}

/* Buttons: map ERP variants onto shell */
.btn-secondary {
  background: transparent;
  color: var(--t2);
  border: 1px solid var(--border2);
}
.btn-secondary:hover { background: var(--surface2); }
.btn-success { background: var(--green); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-xs { padding: 3px 8px; font-size: 10px; }
.btn-lg { padding: 10px 18px; font-size: 13px; }

/* Cards / surfaces */
.app-surface,
.card-erp {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--sh);
}
.app-input,
input.app-input,
select.app-input,
textarea.app-input,
.receipt-form-input,
.invoice-line-input {
  padding: 8px 11px;
  border: 1px solid var(--border2);
  border-radius: var(--rsm);
  font-family: 'Figtree', sans-serif;
  font-size: 13px;
  color: var(--t1);
  background: var(--surface);
  outline: none;
  width: 100%;
  min-height: unset;
  line-height: 1.4;
  box-shadow: none;
}
.app-input:focus,
.receipt-form-input:focus,
.invoice-line-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(27, 74, 107, .1);
  outline: none;
}

/* Page headers → Syne like staging topbar title */
.s3-page-header h1,
.page-title-erp {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--t1);
  letter-spacing: 0;
}

/* Badges → staging pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 9.5px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-success { background: var(--green-lt); color: var(--green); }
.badge-warning { background: var(--amber-lt); color: var(--amber); }
.badge-danger { background: var(--red-lt); color: var(--red); }
.badge-info { background: var(--blue-lt); color: var(--blue); }
.badge-neutral { background: var(--surface2); color: var(--t3); }

/* KPI / stat cards */
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
  box-shadow: var(--sh);
  position: relative;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.kpi-stripe {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--r) var(--r) 0 0;
}
.kpi-lbl {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--t3);
  margin-bottom: 6px;
}
.kpi-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  font-weight: 600;
  color: var(--t1);
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
.kpi-sub { font-size: 10px; color: var(--t3); margin-top: 4px; }

/* Tables inside ERP content: staging look */
.content table thead th,
.card table thead th,
.app-surface table thead th {
  padding: 8px 8px;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--t3);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.content table tbody td,
.card table tbody td,
.app-surface table tbody td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--t2);
  font-size: 13px;
}

/* Nav children under staging nav-item */
.nav-child-wrap {
  margin: 0 8px 4px 26px;
  padding-left: 8px;
  border-left: 1px solid rgba(255,255,255,.12);
}
.nav-child-wrap a {
  display: block;
  padding: 5px 8px;
  margin: 1px 0;
  border-radius: 5px;
  font-size: 11px;
  color: rgba(255,255,255,.45);
  text-decoration: none;
}
.nav-child-wrap a:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.85); }
.nav-child-wrap a.active { background: rgba(255,255,255,.1); color: #fff; font-weight: 600; }

.nav-item .ni-svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: .85;
}
.nav-item.active .ni-svg { opacity: 1; }

.sidebar-search-wrap { padding: 8px 10px 4px; }
.sidebar-search-wrap input {
  width: 100%;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.85);
  font-size: 12px;
  font-family: 'Figtree', sans-serif;
  outline: none;
}
.sidebar-search-wrap input::placeholder { color: rgba(255,255,255,.3); }

/* Kill Tailwind “dashboard chrome” that fights shell */
.bg-white\/95, .backdrop-blur { background: var(--surface) !important; backdrop-filter: none !important; }
.bg-slate-50, .bg-gray-50, .bg-gray-100 { background: var(--surface2) !important; }
.border-slate-200, .border-gray-200 { border-color: var(--border) !important; }
.text-slate-500, .text-gray-500, .text-slate-400, .text-gray-400 { color: var(--t3) !important; }
.text-slate-700, .text-gray-700, .text-slate-800, .text-gray-800 { color: var(--t2) !important; }
.text-slate-900, .text-gray-900 { color: var(--t1) !important; }

/* Primary color utilities remap (Tailwind CDN primary-*) */
.bg-primary-600 { background-color: var(--nav) !important; }
.hover\:bg-primary-700:hover { background-color: var(--nav2) !important; }
.text-primary-600, .text-primary-700 { color: var(--nav) !important; }
.focus\:ring-primary-500:focus {
  --tw-ring-color: rgba(27, 74, 107, .25) !important;
  box-shadow: 0 0 0 3px rgba(27, 74, 107, .12) !important;
}

/* Login page uses shell login-wrap */
body.s3-login {
  background: var(--bg);
  min-height: 100vh;
  margin: 0;
}

