:root {
  --wine: #7a1f3d;
  --wine-dark: #5a142c;
  --wine-soft: #f6eef1;
  --cream: #faf8f5;
  --ink: #2a2326;
  --line: #e8e2dc;
  --sidebar-w: 248px;
  --bs-primary: var(--wine);
  --bs-primary-rgb: 122, 31, 61;
  --bs-link-color: var(--wine);
  --bs-link-color-rgb: 122, 31, 61;
  --bs-link-hover-color: var(--wine-dark);
  --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-body-color: var(--ink);
  --bs-border-color: var(--line);
}
body { background: var(--cream); font-size: .925rem; }
.text-wine { color: var(--wine) !important; }
.btn-primary { --bs-btn-bg: var(--wine); --bs-btn-border-color: var(--wine); --bs-btn-hover-bg: var(--wine-dark); --bs-btn-hover-border-color: var(--wine-dark); --bs-btn-active-bg: var(--wine-dark); --bs-btn-disabled-bg: var(--wine); --bs-btn-disabled-border-color: var(--wine); }
.btn-outline-primary { --bs-btn-color: var(--wine); --bs-btn-border-color: var(--wine); --bs-btn-hover-bg: var(--wine); --bs-btn-hover-border-color: var(--wine); --bs-btn-active-bg: var(--wine-dark); }
.pagination { --bs-pagination-active-bg: var(--wine); --bs-pagination-active-border-color: var(--wine); --bs-pagination-color: var(--wine); }
.form-control:focus, .form-select:focus { border-color: #c48a9d; box-shadow: 0 0 0 .2rem rgba(122, 31, 61, .15); }
.form-check-input:checked { background-color: var(--wine); border-color: var(--wine); }
.nav-tabs .nav-link.active { color: var(--wine); font-weight: 600; }
.nav-tabs .nav-link { color: #6c6267; }

.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: #fff; border-right: 1px solid var(--line); position: fixed; inset: 0 auto 0 0; overflow-y: auto; z-index: 1040; transition: transform .2s; }
.sidebar .brand { display: flex; align-items: center; gap: .65rem; padding: 1rem 1.1rem; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); }
.sidebar .brand span { display: flex; flex-direction: column; line-height: 1.1; }
.sidebar .brand strong { color: var(--wine); font-size: 1.1rem; letter-spacing: .04em; }
.sidebar .brand small { color: #8a7f84; font-size: .72rem; }
.sidebar nav { padding: .5rem .6rem 2rem; }
.nav-group { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #9b9095; padding: 1rem .6rem .3rem; font-weight: 600; }
.sidebar .nav-link { display: flex; align-items: center; gap: .65rem; padding: .42rem .6rem; border-radius: .45rem; color: #4a4044; font-size: .88rem; }
.sidebar .nav-link i { font-size: 1rem; width: 1.1rem; text-align: center; color: #9b8a91; }
.sidebar .nav-link:hover { background: var(--wine-soft); color: var(--wine); }
.sidebar .nav-link.active { background: var(--wine); color: #fff; }
.sidebar .nav-link.active i { color: #fff; }
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1030; background: rgba(250, 248, 245, .92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); padding: .6rem 1.5rem; display: flex; align-items: center; gap: 1rem; }
.topbar .search { position: relative; flex: 1; max-width: 560px; }
.topbar .search i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: #9b9095; }
.topbar .search input { padding-left: 2.2rem; background: #fff; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--wine); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .85rem; }
.content { padding: 1.5rem; flex: 1; max-width: 1500px; width: 100%; }
.footer { padding: 1rem 1.5rem; color: #9b9095; font-size: .75rem; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.45rem; font-weight: 650; margin: 0; }
.crumbs { font-size: .78rem; margin-bottom: .2rem; }
.crumbs a { color: #8a7f84; text-decoration: none; }
.crumbs a:hover { color: var(--wine); }
.card { border-color: var(--line); border-radius: .7rem; box-shadow: 0 1px 2px rgba(42, 35, 38, .03); }
.table-list thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: #7d7176; font-weight: 600; background: #fcfbf9; border-bottom-color: var(--line); white-space: nowrap; }
.table-list thead th a { color: inherit; text-decoration: none; }
.table-list tbody tr[data-href] { cursor: pointer; }
.table-list td { border-color: #f1ece7; }
.detail dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: #8a7f84; font-weight: 600; }
.detail dd { margin: 0; font-size: .95rem; }
.filters .form-label { font-size: .72rem; }
.thumb { height: 140px; object-fit: cover; }
.avisos-menu { width: 340px; max-height: 420px; overflow: auto; }
.htmx-request.htmx-indicator, .htmx-request .htmx-indicator { opacity: 1; }
#list.htmx-swapping, #list.htmx-request { opacity: .6; transition: opacity .15s; }

.kpi { border-radius: .7rem; background: #fff; border: 1px solid var(--line); padding: 1rem 1.1rem; height: 100%; }
.kpi .v { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.kpi .l { font-size: .78rem; color: #7d7176; }
.kpi i { font-size: 1.3rem; color: var(--wine); }
a.kpi { text-decoration: none; color: inherit; display: block; }
a.kpi:hover { border-color: #d6b6c1; }

.stepper { display: flex; gap: .25rem; margin: 0; padding: 0; list-style: none; overflow-x: auto; }
.stepper li { flex: 1; min-width: 90px; text-align: center; font-size: .7rem; color: #9b9095; position: relative; padding-top: 1.6rem; }
.stepper li::before { content: ''; position: absolute; top: .45rem; left: 50%; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: #e6dfe2; z-index: 1; }
.stepper li::after { content: ''; position: absolute; top: .85rem; left: -50%; width: 100%; height: 2px; background: #e6dfe2; }
.stepper li:first-child::after { display: none; }
.stepper li.done { color: #4a4044; }
.stepper li.done::before, .stepper li.done::after { background: var(--wine); }
.stepper li.current { color: var(--wine); font-weight: 700; }
.stepper li.current::before { background: #fff; border: 3px solid var(--wine); }

.ficha-cata .range-val { width: 3.2rem; text-align: center; font-weight: 700; }
.ficha-cata input[type=range] { accent-color: var(--wine); }
.total-cata { font-size: 2.5rem; font-weight: 700; color: var(--wine); }
.codigo-ciego { font-family: ui-monospace, monospace; font-size: 1.6rem; letter-spacing: .15em; font-weight: 700; }

/* Login */
.bare { background: radial-gradient(circle at 20% 10%, #f3e7ea, transparent 50%), var(--cream); }
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 1rem; padding: 2.2rem; box-shadow: 0 10px 40px rgba(90, 20, 44, .08); }

.ts-wrapper.form-select { padding: 0; }
.ts-control { border-radius: .375rem; }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0, 0, 0, .15); }
  body.sidebar-open .sidebar { transform: none; }
  .main { margin-left: 0; }
  .content { padding: 1rem; }
}
@media print {
  .sidebar, .topbar, .footer, .btn, form.filters { display: none !important; }
  .main { margin: 0; }
}

.form-range::-webkit-slider-thumb { background: var(--wine); }
.form-range::-moz-range-thumb { background: var(--wine); }
.form-range:focus::-webkit-slider-thumb { box-shadow: 0 0 0 .25rem rgba(122, 31, 61, .25); }
.card > .table-responsive > .table > :not(caption) > * > *:first-child { padding-left: 1rem; }
.card > .table-responsive > .table > :not(caption) > * > *:last-child { padding-right: 1rem; }
