:root {
    --ink: #242127;
    --muted: #716b75;
    --paper: #fffdf8;
    --line: #e9e2dc;
    --accent: #7b3157;
    --accent-dark: #59213e;
    --sports: #21109b;
    --sports-soft: #817cf4;
    --sports-dark: #180878;
    --store: #89c4ca;
    --store-dark: #397981;
    --success: #2f6f55;
    --shadow: 0 18px 50px rgba(64, 43, 53, .09);
}

.theme-libra-sports {
    --accent: var(--sports);
    --accent-dark: var(--sports-dark);
    --accent-soft: #eeecff;
    --sidebar-bg: #190c6d;
    --page-glow: rgba(129, 124, 244, .18);
}
.theme-libra-store {
    --accent: var(--store-dark);
    --accent-dark: #245d64;
    --accent-soft: #e4f4f5;
    --sidebar-bg: #397981;
    --page-glow: rgba(137, 196, 202, .22);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--ink);
    background: radial-gradient(circle at 86% 0%, var(--page-glow, rgba(123,49,87,.08)), transparent 30%), #f4f0eb;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar { padding: 24px 22px; color: white; background: var(--sidebar-bg, #272129); }
.brand { margin-bottom: 34px; font-family: Georgia, serif; font-size: 22px; letter-spacing: .08em; }
.sidebar-brand { display: grid; place-items: center; height: 112px; margin-bottom: 21px; border-radius: 14px; background: rgba(255,255,255,.96); overflow: hidden; }
.sidebar-brand img { display: block; width: auto; max-width: 88%; height: 96px; object-fit: contain; }
.theme-libra-store .sidebar-brand img { height: 88px; }
.business-chip { padding: 13px; margin-bottom: 24px; border: 1px solid rgba(255,255,255,.2); border-radius: 12px; background: rgba(255,255,255,.09); }
.business-chip small { display: block; margin-bottom: 4px; opacity: .65; }
.sidebar nav a { display: block; padding: 11px 12px; margin: 4px 0; border-radius: 9px; color: rgba(255,255,255,.78); text-decoration: none; }
.sidebar nav a.active, .sidebar nav a:hover { color: white; background: rgba(255,255,255,.09); }
.sidebar nav a small { float: right; margin-top: 2px; font-size: 9px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; opacity: .5; }
.sidebar nav a.disabled-link { cursor: default; opacity: .58; }
.sidebar nav a.disabled-link:hover { background: transparent; }
.sidebar-bottom { margin-top: 32px; }
.link-button { padding: 0; border: 0; color: rgba(255,255,255,.72); background: transparent; cursor: pointer; }
.content { padding: 30px clamp(20px, 4vw, 56px); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(30px, 4vw, 44px); font-weight: 500; }
.eyebrow { margin: 0 0 7px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.button { display: inline-block; padding: 11px 16px; border: 0; border-radius: 9px; color: white; background: var(--accent); font-weight: 700; text-decoration: none; cursor: pointer; }
.button:hover { background: var(--accent-dark); }
.button.secondary { color: var(--ink); background: white; border: 1px solid var(--line); }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.card { padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); box-shadow: var(--shadow); }
.metric-label { color: var(--muted); font-size: 13px; }
.metric-value { margin-top: 8px; font-size: 29px; font-weight: 750; }
.metric-wide { grid-column: span 2; }
.empty-panel { margin-top: 18px; padding: 30px; text-align: center; }
.empty-panel p { max-width: 520px; margin: 10px auto 20px; color: var(--muted); line-height: 1.55; }
.guest-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 10%, rgba(129,124,244,.22), transparent 35%), radial-gradient(circle at 90% 88%, rgba(137,196,202,.3), transparent 38%), #f4f3f1; }
.auth-card { width: min(100%, 430px); padding: 34px; border: 1px solid var(--line); border-radius: 20px; background: var(--paper); box-shadow: var(--shadow); }
.dual-brand { display: flex; align-items: center; justify-content: center; gap: 20px; min-height: 115px; margin-bottom: 25px; }
.dual-brand img { display: block; width: auto; object-fit: contain; }
.dual-brand-sports { height: 112px; }
.dual-brand-store { height: 92px; }
.dual-brand-divider { width: 1px; height: 66px; background: var(--line); }
.dual-brand.compact { min-height: 82px; margin-bottom: 20px; }
.dual-brand.compact .dual-brand-sports { height: 80px; }
.dual-brand.compact .dual-brand-store { height: 68px; }
.auth-card h1 { margin-bottom: 8px; font-size: 34px; }
.lead { margin: 0 0 25px; color: var(--muted); line-height: 1.5; }
label { display: block; margin: 16px 0 6px; font-size: 13px; font-weight: 700; }
input { width: 100%; padding: 12px 13px; border: 1px solid #d9d0ca; border-radius: 9px; background: white; font: inherit; }
input:focus { outline: 3px solid rgba(123,49,87,.13); border-color: var(--accent); }
textarea, select { width: 100%; padding: 12px 13px; border: 1px solid #d9d0ca; border-radius: 9px; background: white; font: inherit; }
textarea { min-height: 90px; resize: vertical; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.view-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.view-tabs a { padding: 9px 14px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: white; text-decoration: none; font-weight: 700; }
.view-tabs a.active { color: white; border-color: var(--accent); background: var(--accent); }
.expense-filters { margin-bottom: 18px; }
.expense-filters form { display: grid; grid-template-columns: minmax(220px,2fr) minmax(150px,1fr) auto; gap: 14px; align-items: end; }
.expense-filters .button { margin: 0; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 15px; margin-top: 18px; }
.pagination .disabled { opacity: .45; pointer-events: none; }
.search { display: flex; gap: 8px; width: min(100%, 430px); }
.search .button { margin: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
.subtle { color: var(--muted); font-size: 13px; }
.text-link { color: var(--accent); font-weight: 700; text-decoration: none; }
.grid-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.grid-form .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; }
.section-grid { display: grid; grid-template-columns: minmax(280px, .8fr) minmax(0, 1.5fr); gap: 18px; align-items: start; }
.notice-success { padding: 12px 14px; margin-bottom: 16px; border-radius: 9px; color: var(--success); background: #e3f2eb; }
.badge { display: inline-block; padding: 4px 8px; border-radius: 999px; background: #eee8e3; font-size: 12px; }
.amount { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 750; }
.summary-card { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.summary-card .metric-value { color: var(--accent); }
.order-metrics { margin-bottom: 18px; }
.order-metrics .metric-value { font-size: clamp(20px, 2.3vw, 29px); }
.order-section { margin-top: 18px; }
.order-section h2 { margin-top: 0; }
.order-section .button { margin-top: 18px; }
.profitability-strip { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 18px; margin-bottom: 18px; background: var(--accent-soft,#f4eff2); }
.profitability-strip span, .profitability-strip strong { display: block; }
.profitability-strip strong { margin-top: 5px; font-size: 17px; }
.status-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.status-badge { display: inline-block; padding: 5px 9px; border-radius: 999px; color: #4f4951; background: #ece8e4; font-size: 11px; font-weight: 750; white-space: nowrap; }
.status-design, .status-awaiting_approval { color: #38258d; background: #e9e5ff; }
.status-production, .status-materials { color: #145a66; background: #dff2f4; }
.status-ready, .status-confirmed, .status-paid, .status-delivered { color: #246146; background: #dff1e8; }
.status-awaiting_deposit, .status-partial_payment { color: #83551e; background: #f8ead4; }
.status-on_hold, .status-cancelled { color: #8b3340; background: #f8e2e5; }
.order-status-panel { display: grid; grid-template-columns: minmax(180px,.7fr) minmax(280px,1.3fr); gap: 22px; align-items: end; margin-bottom: 18px; }
.order-status-panel span, .order-status-panel strong { display: block; margin-top: 5px; }
.inline-control { display: flex; gap: 9px; }
.inline-control .button { margin: 0; }
.balance-callout { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; margin-top: 18px; background: var(--accent-soft,#f4eff2); }
.balance-callout span, .balance-callout strong { display: block; }
.balance-callout strong { margin-top: 5px; font-size: 21px; }
.reference-panel { margin-bottom: 18px; }
.inline-delete { display: inline; margin-left: 9px; }
.inline-delete button { padding: 0; border: 0; color: #9a3444; background: transparent; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.item-status-form { min-width: 170px; }
.item-status-form select { min-width: 160px; margin: 0 0 5px; padding: 7px 9px; font-size: 13px; }
.item-status-form button { padding: 0; border: 0; background: transparent; cursor: pointer; }
.club-heading, .club-name-cell { display: flex; align-items: center; gap: 14px; }
.club-heading img { width: 76px; height: 76px; object-fit: contain; border-radius: 12px; background: white; }
.club-name-cell img { width: 42px; height: 42px; object-fit: contain; border-radius: 8px; background: white; }
.button.danger { color: #8a2638; border-color: #e4aeba; background: #fff4f6; }
.portal-access-card { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; margin-bottom: 22px; }
.portal-access-card h2 { margin-bottom: 5px; }
.portal-access-card form { margin: 0; }
.portal-link-box { grid-column: 1 / -1; padding: 15px; border-radius: 12px; background: var(--soft); }
.portal-body { min-height: 100vh; background: #f5f5ff; }
.portal-page { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 45px; }
.portal-header { display: flex; align-items: center; gap: 24px; margin-bottom: 22px; }
.portal-header img { width: 112px; height: 90px; object-fit: contain; }
.portal-header h1 { margin: 3px 0; }
.portal-preview-banner { padding: 13px 16px; margin-bottom: 20px; border-radius: 10px; color: #24176d; background: #e4e0ff; }
.portal-preview-banner a { color: inherit; font-weight: 700; }
.portal-metrics { grid-template-columns: repeat(4, minmax(0,1fr)); }
.portal-footer { padding: 22px 0 8px; color: var(--muted); text-align: center; font-size: 13px; }
.auth-card .button { width: 100%; margin-top: 22px; }
.alert { padding: 12px 14px; margin: 15px 0; border-radius: 9px; color: #782f3b; background: #f8e3e7; }
.field-error { margin-top: 6px; color: #9a3444; font-size: 13px; font-weight: 700; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: #c74b61; box-shadow: 0 0 0 3px rgba(199,75,97,.12); }
.business-list { display: grid; gap: 12px; }
.business-option { display: flex; align-items: center; gap: 16px; width: 100%; padding: 13px 16px; border: 1px solid var(--line); border-radius: 13px; text-align: left; background: white; cursor: pointer; transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease; }
.business-option:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(43,34,54,.09); }
.business-option.sports-option:hover { border-color: var(--sports); }
.business-option.store-option:hover { border-color: var(--store-dark); }
.business-option img { width: 58px; height: 58px; object-fit: contain; }
.business-option .business-copy { display: block; margin: 0; }
.business-option strong, .business-option small { display: block; }
.business-option small { margin-top: 5px; color: var(--muted); font-size: 13px; }
.access-help { margin: 17px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; text-align: center; }

/* Vista de gestión compacta: conserva legibilidad y muestra más información por pantalla. */
@media (min-width: 901px) {
    .shell { grid-template-columns: 225px 1fr; }
    .sidebar { padding: 18px; }
    .sidebar-brand { height: 90px; margin-bottom: 15px; border-radius: 12px; }
    .sidebar-brand img { height: 76px; }
    .theme-libra-store .sidebar-brand img { height: 70px; }
    .business-chip { padding: 11px; margin-bottom: 16px; }
    .sidebar nav a { padding: 9px 10px; margin: 3px 0; }
}
.content { padding: 22px clamp(16px, 3vw, 38px); }
.topbar { margin-bottom: 18px; }
h1 { font-size: clamp(28px, 3.5vw, 38px); }
.button { padding: 9px 13px; }
.metrics { gap: 12px; }
.card { padding: 15px; }
.metric-value { margin-top: 5px; font-size: 24px; }
label { margin: 11px 0 5px; }
input, textarea, select { padding: 9px 11px; }
th, td { padding: 9px 8px; }
.section-grid { gap: 12px; }
.order-metrics, .profitability-strip, .order-status-panel, .reference-panel { margin-bottom: 12px; }
.order-section { margin-top: 12px; }
.profitability-strip { gap: 12px; }
.order-status-panel { gap: 16px; }
.reference-panel .button { margin-top: 10px; }
.item-details { max-width: 560px; margin-top: 4px; line-height: 1.35; }
.pricing-intro { display: grid; grid-template-columns: minmax(220px,.55fr) minmax(0,1.45fr); gap: 22px; margin-bottom: 12px; }
.pricing-intro h2, .quick-quote h2, .product-cost-card h2 { margin: 0 0 5px; }
.pricing-settings { display: grid; grid-template-columns: repeat(5,minmax(110px,1fr)); gap: 10px; align-items: end; }
.pricing-settings label { min-height: 32px; }
.pricing-settings .button { margin-bottom: 1px; }
.quick-quote { margin-bottom: 12px; background: var(--accent-soft,#f4eff2); }
.quick-quote-controls { display: grid; grid-template-columns: minmax(260px,2fr) minmax(100px,.5fr); gap: 12px; }
.quote-results { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-top: 14px; }
.quote-results div { padding: 11px; border-radius: 10px; background: rgba(255,255,255,.78); }
.quote-results span, .quote-results strong, .cost-profile-row span, .cost-profile-row strong { display: block; }
.quote-results span, .cost-profile-row span { color: var(--muted); font-size: 12px; }
.quote-results strong { margin-top: 4px; font-size: 20px; }
.product-cost-grid, .profile-edit-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.product-cost-heading, .cost-profile-row, .profile-title { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.product-cost-heading { margin-bottom: 9px; }
.product-cost-heading h2 { margin-top: 7px; }
.cost-profile-row { padding: 9px 0; border-top: 1px solid var(--line); }
.cost-profile-row > div:first-child { flex: 1; }
.badge.warning { color: #83551e; background: #f8ead4; }
.cost-help { margin: 12px 0; }
.profile-title { align-items: end; }
.profile-title > div:first-child { flex: 1; }
.profile-edit-grid .button { margin-top: 12px; }
.supplier-comparison { margin-bottom: 12px; }
.supplier-comparison h2 { margin: 0; }
.supplier-comparison details summary { cursor: pointer; }
.supplier-comparison details[open] summary { margin-bottom: 9px; }
.offer-form { min-width: 560px; padding: 10px 0; }
.new-offer { margin-top: 12px; }
.new-offer > form { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.new-offer > summary { width: max-content; list-style: none; }
.expense-scope-picker { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
.expense-scope-picker > label:first-child { grid-column: 1/-1; }
.radio-card { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: white; cursor: pointer; }
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft,#f4eff2); }
.radio-card input { width: auto; margin-top: 3px; }
.radio-card span, .radio-card small { display: block; }
.radio-card small { margin-top: 3px; color: var(--muted); font-weight: 400; }
.shared-allocation-box { padding: 13px; border-radius: 11px; background: var(--accent-soft,#f4eff2); }
.allocation-inputs { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.allocation-summary { display: flex; gap: 20px; margin-top: 12px; }
.over-allocated, .pending-value, .pending-text { color: #9a3444; }
.expense-summary { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)) auto; align-items: end; }

@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { padding: 17px 20px; }
    .sidebar-brand { width: 110px; height: 72px; margin-bottom: 8px; }
    .sidebar-brand img, .theme-libra-store .sidebar-brand img { height: 64px; }
    .business-chip { margin-bottom: 0; }
    .sidebar nav { display: none; }
    .sidebar-bottom { position: absolute; top: 18px; right: 20px; margin: 0; }
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .section-grid { grid-template-columns: 1fr; }
    .profitability-strip { grid-template-columns: 1fr; }
    .order-status-panel, .balance-callout { grid-template-columns: 1fr; }
    .portal-access-card { grid-template-columns: 1fr; }
    .pricing-intro { grid-template-columns: 1fr; }
    .pricing-settings { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .product-cost-grid, .profile-edit-grid { grid-template-columns: 1fr; }
    .expense-summary { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .portal-link-box { grid-column: auto; }
}

@media (max-width: 520px) {
    .metrics { grid-template-columns: 1fr; }
    .metric-wide { grid-column: auto; }
    .topbar { align-items: flex-start; flex-direction: column; }
    .auth-card { padding: 25px; }
    .dual-brand { gap: 13px; min-height: 88px; }
    .dual-brand-sports { height: 88px; }
    .dual-brand-store { height: 72px; }
    .grid-form { grid-template-columns: 1fr; }
    .grid-form .full { grid-column: auto; }
    .toolbar { align-items: stretch; flex-direction: column; }
    .expense-filters form { grid-template-columns: 1fr; }
    .portal-metrics { grid-template-columns: 1fr; }
    .portal-header { align-items: flex-start; }
    .pricing-settings, .quick-quote-controls, .quote-results { grid-template-columns: 1fr; }
    .product-cost-heading, .cost-profile-row, .profile-title { align-items: stretch; flex-direction: column; }
    .expense-scope-picker, .allocation-inputs, .expense-summary { grid-template-columns: 1fr; }
}
