/* ===== DESIGN TOKENS ===== */
:root {
  --bg:        #FAFAF7;
  --bg-2:      #F6F6F2;
  --surface:   #EFEFEA;
  --surface-2: #F3F2EC;
  --accent:    #E6E1D6;
  --olive:     #A9AD9B;
  --text:      #121212;
  --text-2:    #4A4A4A;
  --text-3:    #7A7A72;
  --border:    rgba(18,18,18,0.07);
  --border-2:  rgba(18,18,18,0.04);
  --shadow-card:  0 1px 2px rgba(20,20,18,0.04), 0 6px 24px -8px rgba(20,20,18,0.10);
  --shadow-hover: 0 2px 4px rgba(20,20,18,0.05), 0 14px 36px -10px rgba(20,20,18,0.18);
  --shadow-nav:   0 1px 0 rgba(18,18,18,0.04);

  --ok:        #6B8F71;
  --ok-soft:   #E2EBE0;
  --fail:      #A05C52;
  --fail-soft: #EFDFDB;
  --wait:      #B8935A;
  --wait-soft: #F1E6D2;
  --idle:      #A9AD9B;
  --idle-soft: #E5E6DD;
  --alert:     #8B3A3A;

  --col-idle:    #ECEBE3;
  --col-contact:  #E6E8EC;
  --col-wait:     #EFE9DC;
  --col-ok:       #E5ECE2;
  --col-fail:     #ECDDD9;
  --contact:      #7A8696;
  --contact-soft: #E2E5EA;

  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;

  --font: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

[data-theme="dark"] {
  --bg:        #121212;
  --bg-2:      #161614;
  --surface:   #1C1C1A;
  --surface-2: #242420;
  --accent:    #C8C3B5;
  --olive:     #8A8A82;
  --text:      #F0EFE9;
  --text-2:    #B5B5AD;
  --text-3:    #8A8A82;
  --border:    rgba(240,239,233,0.07);
  --border-2:  rgba(240,239,233,0.04);
  --shadow-card:  0 1px 2px rgba(0,0,0,0.4), 0 8px 28px -10px rgba(0,0,0,0.5);
  --shadow-hover: 0 2px 6px rgba(0,0,0,0.5), 0 16px 40px -10px rgba(0,0,0,0.6);
  --shadow-nav:   0 1px 0 rgba(240,239,233,0.05);

  --ok-soft:   #233028;
  --fail-soft: #3a2624;
  --wait-soft: #322a1f;
  --idle-soft: #26261f;

  --col-idle:    #1F1F1C;
  --col-contact:  #1B1E22;
  --col-wait:     #221F1A;
  --contact:      #7A8696;
  --contact-soft: #22272E;
  --col-ok:      #1C2220;
  --col-fail:    #221C1B;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease;
  overflow-x: hidden;
}
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ===== UTILITIES ===== */
.hidden { display: none !important; }
.drawer-open { overflow: hidden; }
.spacer { flex: 1; }

/* ===== LOGIN ===== */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 10%, rgba(230,225,214,0.6), transparent 50%),
    radial-gradient(circle at 80% 100%, rgba(169,173,155,0.18), transparent 50%),
    var(--bg);
  padding: 24px;
}
[data-theme="dark"] .login-page {
  background:
    radial-gradient(circle at 20% 10%, rgba(200,195,181,0.06), transparent 50%),
    radial-gradient(circle at 80% 100%, rgba(138,138,130,0.10), transparent 50%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 36px 32px 28px;
  box-shadow: 0 1px 2px rgba(20,20,18,.04), 0 24px 60px -20px rgba(20,20,18,.18);
}
.login-brand {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 26px;
}
.brand-mark {
  display: grid; place-items: center;
  background: var(--text); color: var(--bg);
  font-weight: 800; letter-spacing: -0.04em;
  border-radius: 9px;
}
.login-brand .brand-mark { width: 40px; height: 40px; font-size: 18px; }
.login-brand-name { font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.login-brand-name span { color: var(--text-3); font-weight: 500; margin-left: 4px; }
.login-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 6px; }
.login-sub { color: var(--text-2); font-size: 13.5px; margin-bottom: 24px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 0; }
.field label {
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-3);
}
.field input {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  outline: none;
  font-size: 13px;
  transition: border-color .15s ease, box-shadow .15s ease;
  width: 100%;
}
.field input:focus {
  border-color: var(--olive);
  box-shadow: 0 0 0 3px rgba(169,173,155,0.15);
}
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; color: var(--text-2);
}
.login-row a {
  color: var(--text); font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid var(--olive);
  padding-bottom: 1px;
}
.login-row a:hover { color: var(--olive); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 14px; height: 14px; accent-color: var(--olive); flex-shrink: 0; }
.login-foot {
  margin-top: 22px; padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-3);
  text-align: center;
}
.error-msg {
  color: var(--fail); font-size: 13px; padding: 10px 12px;
  background: var(--fail-soft); border-radius: 8px;
}
.reset-success {
  color: var(--ok); font-size: 13px; padding: 10px 12px;
  background: var(--ok-soft); border-radius: 8px;
}
.reset-btns { display: flex; gap: 8px; }

/* ===== BUTTONS ===== */
.btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .15s ease, border-color .15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface); }
.btn svg { width: 14px; height: 14px; }
.btn-primary {
  background: var(--text); color: var(--bg); border-color: var(--text);
}
.btn-primary:hover { opacity: .9; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-full { width: 100%; justify-content: center; padding: 12px; font-size: 14px; }

/* ===== NAVBAR ===== */
.navbar {
  height: 64px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 28px; gap: 24px;
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-nav);
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand .brand-mark { width: 30px; height: 30px; font-size: 14px; border-radius: 9px; }
.brand-name span { color: var(--text-3); font-weight: 500; margin-left: 4px; }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: transparent;
  border: 1px solid transparent;
  display: grid; place-items: center;
  color: var(--text-2);
  position: relative;
  transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

.notif-dot {
  position: absolute; top: 8px; right: 9px;
  min-width: 14px; height: 14px; padding: 0 4px;
  background: var(--alert); color: #fff;
  border-radius: 999px;
  font-size: 9px; font-weight: 700;
  display: grid; place-items: center;
  border: 2px solid var(--bg);
  line-height: 1;
}

.theme-toggle {
  display: inline-flex;
  background: var(--surface);
  border-radius: 999px;
  padding: 3px;
  border: 1px solid var(--border);
}
.theme-toggle button {
  border: 0; background: transparent;
  width: 30px; height: 30px; border-radius: 999px;
  color: var(--text-3); cursor: pointer;
  display: grid; place-items: center;
  transition: background .2s ease, color .2s ease;
}
.theme-toggle button.active {
  background: var(--bg); color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
[data-theme="dark"] .theme-toggle button.active { box-shadow: 0 0 0 1px var(--border); }
.theme-toggle svg { width: 15px; height: 15px; }

.divider-v { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 14px 5px 6px;
  background: var(--surface);
  border-radius: 999px;
  border: 1px solid var(--border);
}
.avatar {
  width: 28px; height: 28px; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--olive));
  color: var(--text);
  display: grid; place-items: center;
  font-weight: 700; font-size: 11px;
  letter-spacing: 0.02em; flex-shrink: 0;
}
.user-chip .name { font-weight: 600; font-size: 13px; }
.user-chip .role {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--text);
  background: var(--accent);
  padding: 2px 7px; border-radius: 5px;
}
[data-theme="dark"] .user-chip .role { color: var(--bg); }
.user-chip .role.vendor {
  background: transparent; color: var(--ok);
  border: 1px solid var(--ok);
}

.btn-ghost {
  background: transparent; border: 0;
  padding: 8px 12px;
  font: inherit; color: var(--text-2);
  border-radius: 10px; font-weight: 500;
}
.btn-ghost:hover { background: var(--surface); color: var(--text); }

/* ===== LOADING ===== */
.app-loading {
  flex: 1; display: flex; align-items: center; justify-content: center;
}
.spinner {
  width: 36px; height: 36px;
  border: 2.5px solid var(--border); border-top-color: var(--olive);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== APP LAYOUT ===== */
.app-page {
  min-height: 100vh;
  display: flex; flex-direction: column;
}
.page {
  padding: 24px 28px 60px;
  flex: 1;
}
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 22px; gap: 24px;
}
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 4px; }
.page-sub { color: var(--text-2); font-size: 13.5px; }
.page-actions { display: flex; gap: 10px; align-items: center; }

/* ===== METRICS ===== */
.metrics {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px; margin-bottom: 22px;
}
@media (max-width: 1400px) { .metrics { grid-template-columns: repeat(3, 1fr); } }
.metric {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px 14px;
  box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; gap: 10px;
  min-height: 116px;
  transition: box-shadow .2s ease;
}
.metric:hover { box-shadow: var(--shadow-hover); }
.metric-head {
  display: flex; align-items: center; justify-content: space-between;
  color: var(--text-3); font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.metric-icon {
  width: 24px; height: 24px; border-radius: 7px;
  background: var(--surface);
  display: grid; place-items: center;
  color: var(--text-2);
}
.metric-icon svg { width: 13px; height: 13px; }
.metric-value {
  font-size: 32px; font-weight: 700;
  letter-spacing: -0.025em; line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.metric-value .unit { font-size: 14px; color: var(--text-3); font-weight: 600; margin-left: 4px; }
.metric.ok  .metric-value { color: var(--ok); }
.metric.fail .metric-value { color: var(--fail); }
.metric.wait .metric-value { color: var(--wait); }
.metric-foot {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--text-2); gap: 8px;
}
.trend { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: 11.5px; }
.trend.up   { color: var(--ok); }
.trend.down { color: var(--fail); }
.trend.flat { color: var(--text-3); }
.progress { height: 4px; background: var(--surface); border-radius: 999px; overflow: hidden; flex: 1; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--text); }
.metric.ok   .progress > span { background: var(--ok); }
.metric.fail .progress > span { background: var(--fail); }
.metric.wait .progress > span { background: var(--wait); }
.metric--clickable { cursor: pointer; }

.monto-item { display: flex; flex-direction: column; gap: 3px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.monto-item:last-of-type { border-bottom: none; }
.monto-item-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.monto-item-vendor { font-size: 11.5px; color: var(--text-3); font-weight: 500; }
.monto-item-client { font-size: 14px; font-weight: 600; color: var(--text); }
.monto-item-product { font-size: 12.5px; color: var(--text-2); }
.monto-item-bottom { display: flex; align-items: center; gap: 10px; margin-top: 2px; }
.monto-item-amount { font-size: 15px; font-weight: 700; color: var(--ok); font-variant-numeric: tabular-nums; }
.monto-item-date { font-size: 11.5px; color: var(--text-3); }

.monto-total { margin-top: 24px; padding: 20px; background: var(--surface); border-radius: var(--radius-md); text-align: center; }
.monto-total-label { font-size: 12px; color: var(--text-3); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.monto-total-value { font-size: 36px; font-weight: 800; color: var(--ok); font-variant-numeric: tabular-nums; }

.source-rows { display: flex; flex-direction: column; gap: 4px; }
.source-row { display: flex; align-items: center; justify-content: space-between; font-size: 12px; }
.source-row .lbl { color: var(--text-2); }
.source-row .val { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

.metric-head-label { display: flex; align-items: center; gap: 6px; }
.mini-switch {
  width: 22px; height: 13px;
  background: var(--border);
  border-radius: 7px;
  border: none; padding: 0; margin: 0;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .2s;
}
.mini-switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
  transition: transform .2s;
}
.mini-switch.active { background: var(--olive); }
.mini-switch.active::after { transform: translateX(9px); }

/* ===== FILTERBAR ===== */
.filterbar {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-card);
  flex-wrap: wrap;
}
.search {
  flex: 1; min-width: 200px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px; height: 36px;
  background: var(--surface); border-radius: 9px;
  color: var(--text-2);
}
.search svg { width: 15px; height: 15px; flex-shrink: 0; }
.search input {
  border: 0; background: transparent; outline: none;
  font: inherit; flex: 1; color: var(--text); font-size: 13px;
}
.search input::placeholder { color: var(--text-3); }
.filter-select {
  height: 36px; padding: 0 32px 0 12px;
  background: var(--surface);
  border: 0; border-radius: 9px;
  font: inherit; font-size: 13px; font-weight: 500;
  color: var(--text); cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%237A7A72' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
[data-theme="dark"] .filter-select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%238A8A82' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
  background-color: var(--surface);
}
.filter-count { color: var(--text-3); font-size: 12.5px; font-weight: 600; margin-left: 4px; }
.seg {
  display: inline-flex;
  background: var(--surface);
  border-radius: 9px; padding: 3px;
}
.seg button {
  border: 0; background: transparent;
  padding: 6px 12px; border-radius: 7px;
  font: inherit; font-size: 12.5px; font-weight: 600;
  color: var(--text-3); cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
}
.seg button.active {
  background: var(--bg); color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
[data-theme="dark"] .seg button.active { box-shadow: 0 0 0 1px var(--border); }
.seg svg { width: 13px; height: 13px; }

/* ===== KANBAN ===== */
.kanban {
  display: grid;
  grid-template-columns: repeat(5, minmax(260px, 1fr));
  gap: 14px; align-items: start;
  overflow-x: auto;
  padding-bottom: 8px;
}
.kanban.four-col { grid-template-columns: repeat(4, minmax(260px, 1fr)); }
.col {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 6px;
  display: flex; flex-direction: column;
  min-height: 500px;
  border: 1px solid var(--border-2);
}
.col[data-col="idle"]    { background: var(--col-idle); }
.col[data-col="contact"] { background: var(--col-contact); }
.col[data-col="wait"]    { background: var(--col-wait); }
.col[data-col="ok"]      { background: var(--col-ok); }
.col[data-col="fail"]    { background: var(--col-fail); }
.col-head {
  padding: 12px 10px 10px;
  display: flex; align-items: center; gap: 10px;
}
.col-dot { width: 8px; height: 8px; border-radius: 999px; flex-shrink: 0; }
.col[data-col="idle"]    .col-dot { background: var(--idle); }
.col[data-col="contact"] .col-dot { background: var(--contact); }
.col[data-col="wait"]    .col-dot { background: var(--wait); }
.col[data-col="ok"]      .col-dot { background: var(--ok); }
.col[data-col="fail"]    .col-dot { background: var(--fail); }
.col[data-col="arch"]    .col-dot { background: var(--text-3); }
.col-title { font-weight: 700; font-size: 13.5px; letter-spacing: -0.01em; }
.col-count {
  margin-left: auto; font-weight: 700; font-size: 11.5px;
  color: var(--text-2); background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.col-body {
  display: flex; flex-direction: column; gap: 8px;
  padding: 2px 6px 10px; min-height: 60px;
}

/* card */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px 14px 12px;
  box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; gap: 10px;
  cursor: pointer;
  position: relative;
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.card.draggable { cursor: grab; }
.card.draggable:active { cursor: grabbing; }
.card.dragging { opacity: 0.4; }
.col.drag-over { background: var(--accent); }
[data-theme="dark"] .col.drag-over { background: #2c2a23; }

.card-top { display: flex; align-items: flex-start; gap: 10px; }
.card-client { flex: 1; min-width: 0; }
.card-name {
  font-weight: 700; font-size: 13.5px; color: var(--text);
  letter-spacing: -0.01em; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-sub {
  font-size: 11.5px; color: var(--text-3); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-product { font-weight: 600; font-size: 13px; color: var(--text); line-height: 1.3; }
.card-qty { font-size: 11.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface); color: var(--text-2);
  border-radius: 6px; padding: 3px 7px;
  font-size: 11px; font-weight: 600;
  border: 1px solid var(--border-2);
}
.pill svg { width: 11px; height: 11px; opacity: .7; }
.pill.money { color: var(--text); font-variant-numeric: tabular-nums; }
.days {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 6px; padding: 3px 8px 3px 6px;
  font-size: 11px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  border: 1px solid transparent;
}
.days .dot { width: 6px; height: 6px; border-radius: 999px; }
.days.ok   { background: var(--ok-soft);   color: var(--ok); }
.days.wait { background: var(--wait-soft); color: var(--wait); }
.days.fail { background: var(--fail-soft); color: var(--fail); }
.days.idle { background: var(--idle-soft); color: var(--text-3); }
.days.ok   .dot { background: var(--ok); }
.days.wait .dot { background: var(--wait); }
.days.fail .dot { background: var(--fail); }
.days.idle .dot { background: var(--idle); }
.card-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.seller {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; color: var(--text-2);
}
.seller .avatar { width: 20px; height: 20px; font-size: 9px; }
.seller.unassigned { color: var(--text-3); }
.seller.unassigned .avatar { background: transparent; border: 1px dashed var(--border); color: var(--text-3); }
.card-status {
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 3px 8px; border-radius: 5px;
}
.status-Pendiente  { background: var(--wait-soft); color: var(--wait); }
.status-Contactado { background: var(--idle-soft); color: var(--text-2); }
.status-Cerrado    { background: var(--ok-soft);   color: var(--ok); }

/* empty col */
.col-empty {
  padding: 32px 16px 28px; text-align: center;
  color: var(--text-3);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  margin: 4px;
  border: 1px dashed var(--border); border-radius: 12px;
}
.col-empty .empty-ic {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--border);
  display: grid; place-items: center; color: var(--text-3); margin-bottom: 2px;
}
.col-empty .empty-ic svg { width: 16px; height: 16px; }
.col-empty .empty-t { font-weight: 600; color: var(--text-2); font-size: 12.5px; }
.col-empty .empty-d { font-size: 11.5px; color: var(--text-3); line-height: 1.4; }

/* ===== KANBAN GROUPS (admin) ===== */
#adminKanban {
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.kanban-group { width: 100%; }
.group-header {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 2px 10px;
}
.group-avatar {
  width: 28px; height: 28px;
  font-size: 10.5px; font-weight: 800;
  flex-shrink: 0;
}
.group-name {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.group-badge {
  font-size: 9.5px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-3);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1px 6px; border-radius: 999px;
}
.group-count {
  margin-left: auto;
  font-size: 12px; font-weight: 600;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.group-cols {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.kanban-loose {
  border-top: 1px solid var(--border);
  padding-top: 24px;
}
.loose-label {
  font-size: 10.5px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-3);
  padding: 0 2px 10px;
}
.loose-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(230px, 1fr));
  gap: 10px;
}

/* ===== TABLE VIEW ===== */
.table-view { overflow: auto; }
.data-table {
  width: 100%; border-collapse: collapse; font-size: 14px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-md);
  overflow: hidden;
}
.data-table thead { position: sticky; top: 0; z-index: 10; }
.data-table th {
  background: var(--surface); padding: 10px 16px; text-align: left;
  font-size: 11px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table-row { cursor: pointer; transition: background .1s; }
.table-row:hover { background: var(--surface); }
.table-row:last-child td { border-bottom: none; }
.table-empty td { text-align: center; color: var(--text-3); padding: 48px; }
.cell-main { font-weight: 600; }
.cell-sub  { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ===== BADGES (table/drawer) ===== */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px; border-radius: 5px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
  white-space: nowrap;
}
.badge-ok      { background: var(--ok-soft);   color: var(--ok); }
.badge-fail    { background: var(--fail-soft);  color: var(--fail); }
.badge-wait    { background: var(--wait-soft);  color: var(--wait); }
.badge-idle    { background: var(--idle-soft);  color: var(--text-2); }
.badge-neutral { background: var(--surface);    color: var(--text-2); }
.badge-info    { background: var(--idle-soft);  color: var(--text-2); }

/* semaforo in table */
.semaforo {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 6px; padding: 3px 8px 3px 6px;
  font-size: 11px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.semaforo .dot { width: 6px; height: 6px; border-radius: 999px; }
.semaforo.ok   { background: var(--ok-soft);   color: var(--ok); }
.semaforo.wait { background: var(--wait-soft); color: var(--wait); }
.semaforo.fail { background: var(--fail-soft); color: var(--fail); }
.semaforo.idle { background: var(--idle-soft); color: var(--text-3); }
.semaforo.ok   .dot { background: var(--ok); }
.semaforo.wait .dot { background: var(--wait); }
.semaforo.fail .dot { background: var(--fail); }
.semaforo.idle .dot { background: var(--idle); }

/* origen chip */
.origen-chip {
  display: inline-flex; padding: 3px 8px;
  background: var(--surface); color: var(--text-2);
  border-radius: 6px; font-size: 11px; font-weight: 600;
  border: 1px solid var(--border-2);
}

/* ===== DRAWER ===== */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(20,20,18,0.32);
  backdrop-filter: blur(2px);
  z-index: 80;
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(520px, 96vw);
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  box-shadow: -20px 0 60px -20px rgba(0,0,0,.18);
  z-index: 90;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.22,.61,.36,1);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--bg-2); flex-shrink: 0;
}
.drawer-head .title { flex: 1; min-width: 0; }
.drawer-head h2 {
  margin: 0 0 4px;
  font-size: 16px; font-weight: 700; letter-spacing: -0.01em;
  color: var(--text); line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.drawer-head .sub {
  color: var(--text-2); font-size: 12.5px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.drawer-head .sub .dot { width: 4px; height: 4px; border-radius: 999px; background: var(--text-3); }
.drawer-body {
  flex: 1; overflow-y: auto;
  padding: 16px 20px 28px;
  display: flex; flex-direction: column; gap: 14px;
}

/* drawer panels */
.panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
}
.panel-title {
  font-size: 11px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-3);
  margin: 0 0 12px;
  display: flex; align-items: center; gap: 8px;
}
.panel-title svg { width: 14px; height: 14px; color: var(--text-3); }
.kv {
  display: grid;
  grid-template-columns: 110px 1fr;
  row-gap: 9px; column-gap: 14px;
  font-size: 13px; align-items: start;
}
.kv dt { color: var(--text-3); font-weight: 500; margin: 0; }
.kv dd { color: var(--text); margin: 0; font-weight: 600; word-break: break-word; }
.kv dd.muted { color: var(--text-2); font-weight: 500; }
.message-block {
  background: var(--surface); border-radius: 12px;
  padding: 12px 14px; color: var(--text-2);
  font-size: 13px; font-weight: 500; line-height: 1.55; margin-top: 10px;
}
.message-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text); margin-bottom: 6px;
}
.field-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field-row:last-child { margin-bottom: 0; }
.field-row label {
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3);
}
.field-input, .field-select, .field-textarea {
  border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
  border-radius: 10px; padding: 10px 12px;
  font: inherit; font-size: 13px; width: 100%; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field-input:focus, .field-select:focus, .field-textarea:focus {
  border-color: var(--olive);
  box-shadow: 0 0 0 3px rgba(169,173,155,0.15);
}
.field-textarea { resize: vertical; min-height: 78px; font-family: inherit; }
.field-select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%237A7A72' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}
[data-theme="dark"] .field-select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%238A8A82' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
}
.input-prefix-wrap { position: relative; }
.input-prefix {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); font-size: 13px; font-weight: 600; pointer-events: none;
}
.field-input.with-prefix { padding-left: 24px; font-variant-numeric: tabular-nums; }

.notes-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.note {
  background: var(--surface); border-left: 2px solid var(--olive);
  border-radius: 8px; padding: 9px 12px;
  font-size: 12.5px; color: var(--text); line-height: 1.45;
}
.note .meta {
  display: flex; gap: 6px; align-items: center;
  font-size: 10.5px; color: var(--text-3); margin-bottom: 4px; font-weight: 600;
}
.note .meta .by { color: var(--text-2); font-weight: 700; }

.timeline { display: flex; flex-direction: column; gap: 10px; }
.tl-item {
  display: grid; grid-template-columns: 24px 1fr auto;
  gap: 10px; align-items: flex-start; font-size: 12.5px;
}
.tl-ic {
  width: 24px; height: 24px; border-radius: 7px;
  background: var(--surface); border: 1px solid var(--border);
  display: grid; place-items: center; color: var(--text-2);
}
.tl-ic svg { width: 12px; height: 12px; }
.tl-ic.ok   { color: var(--ok); }
.tl-ic.fail { color: var(--fail); }
.tl-ic.wait { color: var(--wait); }
.tl-content .who { font-weight: 700; color: var(--text); }
.tl-content .what { color: var(--text-2); margin-top: 2px; }
.tl-time { font-size: 11px; color: var(--text-3); white-space: nowrap; }

.drawer-actions { display: flex; gap: 8px; align-items: center; }
.save-status { font-size: 13px; color: var(--ok); }
.save-status.error { color: var(--fail); }

/* ===== NOTIFICATIONS ===== */
.notif-wrap { position: relative; }
.notif-panel {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 380px; background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 2px rgba(20,20,18,.05), 0 24px 60px -16px rgba(20,20,18,.22);
  z-index: 70; overflow: hidden;
  transform-origin: top right;
  transform: scale(.96) translateY(-4px); opacity: 0; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.notif-panel.open {
  opacity: 1; transform: scale(1) translateY(0); pointer-events: auto;
}
.notif-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 10px; border-bottom: 1px solid var(--border);
}
.notif-head h3 { margin: 0; font-size: 14px; font-weight: 700; letter-spacing: -0.01em; flex: 1; }
.notif-mark {
  background: transparent; border: 0;
  color: var(--text-2); font: inherit; font-size: 11.5px; font-weight: 600;
  cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.notif-mark:hover { background: var(--surface); color: var(--text); }
.notif-mark:disabled { color: var(--text-3); cursor: not-allowed; }
.notif-tabs {
  display: flex; gap: 2px;
  padding: 10px 12px 8px; border-bottom: 1px solid var(--border);
}
.notif-tab {
  border: 0; background: transparent;
  padding: 5px 10px; border-radius: 999px;
  font: inherit; font-size: 12px; font-weight: 600;
  color: var(--text-2); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.notif-tab:hover { background: var(--surface); color: var(--text); }
.notif-tab.active { background: var(--accent); color: var(--text); }
[data-theme="dark"] .notif-tab.active { background: var(--surface-2); }
.notif-tab .badge {
  background: var(--text); color: var(--bg);
  font-size: 9.5px; font-weight: 800;
  padding: 1px 5px; border-radius: 999px;
  min-width: 16px; text-align: center; line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
.notif-list { max-height: 360px; overflow-y: auto; padding: 4px 0; }
.notif-list::-webkit-scrollbar { width: 10px; }
.notif-list::-webkit-scrollbar-track { background: transparent; }
.notif-list::-webkit-scrollbar-thumb {
  background: var(--surface); border-radius: 999px; border: 3px solid var(--bg);
}
.notif-item {
  display: grid; grid-template-columns: 32px 1fr auto;
  gap: 12px; padding: 12px 16px; cursor: pointer;
  border-bottom: 1px solid var(--border-2);
  align-items: flex-start; background: var(--bg);
  transition: background .15s ease; position: relative;
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--bg-2); }
.notif-item.unread { background: var(--surface-2); }
[data-theme="dark"] .notif-item.unread { background: var(--surface); }
.notif-item.unread::before {
  content: ''; position: absolute; left: 6px; top: 22px;
  width: 4px; height: 4px; border-radius: 999px; background: var(--olive);
}
.notif-item.unread .notif-text-main { color: var(--text); font-weight: 600; }
.notif-ic {
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--surface); display: grid; place-items: center;
  color: var(--text-2); flex-shrink: 0;
}
.notif-ic svg { width: 14px; height: 14px; }
.notif-content { min-width: 0; }
.notif-text-main { font-size: 13px; color: var(--text-2); line-height: 1.35; margin: 0 0 4px; }
.notif-time { font-size: 10.5px; color: var(--text-3); white-space: nowrap; font-weight: 600; padding-top: 2px; }
.notif-empty {
  padding: 40px 24px; text-align: center; color: var(--text-3); font-size: 13px;
}
.notif-empty .empty-ic {
  width: 44px; height: 44px; border-radius: 12px; background: var(--surface);
  display: grid; place-items: center; color: var(--text-3); margin: 0 auto 10px;
}
.notif-empty .empty-ic svg { width: 18px; height: 18px; }
.notif-empty .t { font-weight: 600; color: var(--text-2); margin-bottom: 2px; }
.notif-foot {
  padding: 10px 12px; border-top: 1px solid var(--border);
  text-align: center; background: var(--bg-2);
}
.notif-foot button {
  color: var(--text); font: inherit; font-size: 12px; font-weight: 600;
  padding: 4px 8px; border-radius: 6px;
}
.notif-foot button:hover { background: var(--surface); }

/* ===== GESTIÓN VIEW ===== */
.gestion-view {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  align-items: start;
  padding-bottom: 8px;
}
.gestion-col {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 6px;
  min-width: 180px;
  flex: 1;
  border: 1px solid var(--border-2);
}
.gestion-col[data-gestion-col="idle"] { background: var(--col-idle); }
.gestion-col.drag-over { background: var(--accent); }
[data-theme="dark"] .gestion-col.drag-over { background: #2c2a23; }
.gestion-col-head {
  padding: 10px 10px 8px;
  display: flex; align-items: center; gap: 8px;
}
.gestion-col[data-gestion-col="idle"]   .col-dot { background: var(--idle); }
.gestion-col[data-gestion-col="vendor"] .col-dot { background: var(--olive); }
.gestion-col-title { font-weight: 700; font-size: 12.5px; letter-spacing: -0.01em; }
.gestion-col-count {
  margin-left: auto; font-weight: 700; font-size: 11px;
  color: var(--text-2); background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px 7px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.gestion-col-body {
  display: flex; flex-direction: column; gap: 6px;
  padding: 2px 4px 8px; min-height: 60px;
}
.gestion-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.gestion-card.draggable { cursor: grab; }
.gestion-card.draggable:active { cursor: grabbing; }
.gestion-card.dragging { opacity: 0.4; }
.gestion-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.gestion-card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
}
.gestion-card-name {
  font-weight: 700; font-size: 12.5px; color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.gestion-star {
  width: 13px; height: 13px; flex-shrink: 0;
  color: var(--wait);
}
.gestion-card-qty { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ===== LOCKED STATE (vendedor) ===== */
.field-select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.field-lock-msg {
  font-size: 11.5px; color: var(--text-3);
  background: var(--surface);
  border-radius: 8px; padding: 8px 12px;
  margin-top: -4px; line-height: 1.4;
}

/* ===== CONFIRM DIALOG ===== */
.confirm-overlay {
  position: fixed; inset: 0;
  background: rgba(20,20,18,0.40);
  backdrop-filter: blur(3px);
  z-index: 200;
  display: grid; place-items: center;
  padding: 24px;
}
.confirm-modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px 24px 20px;
  box-shadow: 0 2px 6px rgba(0,0,0,.08), 0 24px 60px -16px rgba(0,0,0,.24);
  max-width: 400px; width: 100%;
}
.confirm-msg {
  font-size: 14px; color: var(--text); line-height: 1.5;
  margin: 0 0 18px;
}
.confirm-actions {
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ===== FOCUS ===== */
:focus-visible { outline: 2px solid var(--olive); outline-offset: 2px; border-radius: 6px; }

/* ===== SETTINGS PAGE ===== */
.settings-page {
  display: none;
  padding: 24px 28px 72px;
  max-width: 1080px;
}
body.settings-open .settings-page { display: block; }
body.settings-open .app-page-content { display: none; }

.settings-back {
  display: inline-flex; align-items: center; gap: 7px;
  border: 0; background: transparent;
  color: var(--text-3); font: inherit; font-size: 12.5px; font-weight: 600;
  cursor: pointer; padding: 4px 0; margin-bottom: 14px;
  transition: color .15s ease;
}
.settings-back:hover { color: var(--text); }
.settings-back svg { width: 15px; height: 15px; }

.settings-layout {
  display: grid;
  grid-template-columns: 212px 1fr;
  gap: 32px;
  align-items: start;
}
.settings-nav {
  position: sticky; top: 88px;
  display: flex; flex-direction: column; gap: 2px;
}
.settings-nav-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%; text-align: left;
  border: 0; background: transparent;
  padding: 10px 12px; border-radius: 10px;
  font: inherit; font-size: 13.5px; font-weight: 500;
  color: var(--text-2); cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.settings-nav-item:hover { background: var(--surface); color: var(--text); }
.settings-nav-item.active { background: var(--surface); color: var(--text); font-weight: 700; }
.settings-nav-item svg { width: 17px; height: 17px; color: var(--text-3); flex-shrink: 0; }
.settings-nav-item.active svg { color: var(--text); }

.settings-section { display: none; }
.settings-section.active { display: block; }

.sec-head { margin-bottom: 16px; }
.sec-head h2 { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 3px; }
.sec-head p { color: var(--text-2); font-size: 13px; margin: 0; }

.settings-page .panel { padding: 20px; margin-bottom: 16px; }
.panel-h {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.panel-h h3 { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.panel-h p { font-size: 12px; color: var(--text-3); margin: 2px 0 0; }

.avatar-row { display: flex; align-items: center; gap: 18px; margin-bottom: 22px; }
.avatar-xl {
  width: 72px; height: 72px; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--olive));
  color: var(--text);
  display: grid; place-items: center;
  font-weight: 800; font-size: 25px; letter-spacing: 0.01em;
  flex-shrink: 0;
}
[data-theme="dark"] .avatar-xl { color: var(--bg); }
.avatar-row .ar-meta .t { font-weight: 700; font-size: 14px; }
.avatar-row .ar-meta .d { font-size: 12px; color: var(--text-3); margin: 2px 0 0; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field-grid .full { grid-column: 1 / -1; }

.pass-hint { font-size: 11.5px; color: var(--fail); margin: 4px 0 0; }
.pass-hint.hidden { display: none; }
.pass-error { font-size: 12px; color: var(--fail); margin: 0 auto 0 0; }
.pass-error.hidden { display: none; }

.toggle-row {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--border-2);
}
.toggle-row:first-of-type { border-top: 0; }
.toggle-row .tr-text { flex: 1; min-width: 0; }
.toggle-row .tr-text .t { font-weight: 600; font-size: 13.5px; color: var(--text); }
.toggle-row .tr-text .d { font-size: 12px; color: var(--text-3); margin-top: 2px; line-height: 1.4; }

.danger-row {
  display: flex; align-items: center; gap: 16px;
  border: 1px solid var(--fail-soft); background: var(--fail-soft);
  border-radius: var(--radius-sm); padding: 14px 16px;
}
[data-theme="dark"] .danger-row { background: transparent; border-color: var(--fail); }
.danger-row .dr-text { flex: 1; }
.danger-row .dr-text .t { font-weight: 700; font-size: 13px; color: var(--fail); }
.danger-row .dr-text .d { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.btn-danger {
  border: 1px solid var(--fail); background: transparent; color: var(--fail);
  padding: 8px 13px; border-radius: 9px; font: inherit; font-weight: 600; font-size: 12.5px;
  cursor: pointer; white-space: nowrap;
  transition: background .12s ease, color .12s ease;
}
.btn-danger:hover { background: var(--fail); color: #fff; }

.settings-foot {
  display: flex; justify-content: flex-end; align-items: center; gap: 10px;
  margin-top: 20px; padding-top: 18px;
  border-top: 1px solid var(--border);
}
.settings-foot .saved-note {
  margin-right: auto; font-size: 12.5px; color: var(--ok); font-weight: 600;
  display: none; align-items: center; gap: 6px;
}
.settings-foot .saved-note.show { display: flex; }
.settings-foot .saved-note svg { width: 14px; height: 14px; }

.seg-pref { display: inline-flex; background: var(--surface); border-radius: 10px; padding: 3px; }
.seg-pref button {
  border: 0; background: transparent; font: inherit; font-size: 12.5px; font-weight: 600;
  color: var(--text-3); padding: 7px 14px; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .15s ease, color .15s ease;
}
.seg-pref button.active { background: var(--bg); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
[data-theme="dark"] .seg-pref button.active { box-shadow: 0 0 0 1px var(--border); }
.seg-pref svg { width: 14px; height: 14px; }

.user-chip { cursor: pointer; color: var(--text); transition: border-color .15s ease, background .15s ease; }
.user-chip:hover { border-color: var(--olive); background: var(--accent); }
[data-theme="dark"] .user-chip:hover { background: var(--surface-2); }

@media (max-width: 820px) {
  .settings-layout { grid-template-columns: 1fr; gap: 18px; }
  .settings-nav { position: static; flex-direction: row; flex-wrap: wrap; }
  .settings-nav-item { width: auto; }
  .field-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════
   REPORTS MODULE
   ═══════════════════════════════════════════════════════════ */

/* Reportes tab button — subtle olive accent */
.rpt-tab-btn { color: var(--olive) !important; }
.rpt-tab-btn.active { color: var(--text) !important; }

/* When reports view is active, hide filterbar children except #viewToggle and metrics */
#adminPanel.rpt-active .filterbar > *:not(#viewToggle) { display: none !important; }
#adminPanel.rpt-active .metrics { display: none; }

/* ── reports-view ── */
.reports-view { padding: 0 0 20px; max-width: 1320px; margin: 0 auto; }

/* ── Toolbar ── */
.rpt-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 0 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.rpt-tool-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rpt-tool-group.is-b { padding-left: 6px; border-left: 1px solid var(--border); }
.tg-label { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.rpt-spacer { flex: 1; }

/* Compare toggle switch */
.rpt-compare-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.rpt-compare-toggle:hover { border-color: var(--olive); color: var(--text); }
.rpt-compare-toggle.active { border-color: var(--olive); background: var(--accent); color: var(--text); }
.rpt-compare-toggle .sw {
  width: 28px; height: 16px;
  background: var(--border);
  border-radius: 8px;
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
}
.rpt-compare-toggle .sw::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .2s;
}
.rpt-compare-toggle.active .sw { background: var(--olive); }
.rpt-compare-toggle.active .sw::after { transform: translateX(12px); }

/* ── Period selector ── */
.period-wrap { position: relative; }
.period-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  white-space: nowrap;
}
.period-btn:hover { border-color: var(--olive); }
.period-btn[aria-expanded="true"] { border-color: var(--olive); box-shadow: 0 0 0 2px var(--accent); }
.period-btn .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--olive);
  flex-shrink: 0;
}
.slot-b .dot { background: var(--wait); }
.pb-meta { display: flex; flex-direction: column; line-height: 1.2; }
.pb-label { font-size: 13px; font-weight: 500; }
.pb-range { font-size: 11px; color: var(--text-3); }
.chev { width: 14px; height: 14px; color: var(--text-3); transition: transform .2s; }
.period-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }

/* Period popup */
.period-pop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 200;
  display: none;
  overflow: hidden;
}
.period-pop.open { display: block; }
.pp-section { padding: 8px 0; }
.pp-label {
  padding: 4px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-3);
}
.pp-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 14px;
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background .12s, color .12s;
}
.pp-item:hover { background: var(--accent); color: var(--text); }
.pp-item.active { color: var(--text); }
.pp-item .tick { width: 14px; height: 14px; opacity: 0; color: var(--olive); flex-shrink: 0; }
.pp-item.active .tick { opacity: 1; }
.pi-range { margin-left: auto; font-size: 11px; color: var(--text-3); }

/* Custom date range — range picker inline */
.pp-custom { border-top: 1px solid var(--border); }
.pp-rp { padding: 10px 12px 8px; }
.period-pop.has-rp { min-width: 530px; }

/* Small label showing selected range inside popup */
.rp-range-label {
  font-size: 11.5px; color: var(--text-3); text-align: center;
  padding: 6px 0 2px; min-height: 22px; transition: color .15s;
}
.rp-range-label.has-range { color: var(--ok); font-weight: 600; }

/* Popup footer */
.pp-foot {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
}
.pp-foot button {
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.pp-foot button:hover { background: var(--accent); color: var(--text); }
.pp-foot button.apply {
  background: var(--olive);
  border-color: var(--olive);
  color: #fff;
}
.pp-foot button.apply:hover { opacity: .9; }

/* ── Grid ── */
.rpt-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 10px;
}
.rpt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.rpt-card.span-2 { grid-column: span 2; }

/* Card header */
.rpt-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.rpt-card-head h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.rpt-card-head p {
  font-size: 11px;
  color: var(--text-3);
  margin: 2px 0 0;
}
.kpi { text-align: right; }
.kpi .v { font-size: 18px; font-weight: 700; color: var(--text); line-height: 1; }
.kpi .l { font-size: 10px; color: var(--text-3); margin-top: 2px; }

/* Chart containers */
.rpt-chart { width: 100%; overflow: visible; }
.rpt-chart svg { width: 100%; display: block; overflow: visible; }

/* Legend */
.rpt-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
}
.rpt-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-2);
}
.rpt-legend-dot {
  width: 8px; height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* SVG chart elements */
.rpt-grid-line { stroke: var(--border); stroke-width: 1; }
.rpt-axis-label { font-size: 11px; fill: var(--text-3); font-family: inherit; }
.rpt-val-label { font-size: 11px; fill: var(--text-2); font-family: inherit; font-weight: 600; }
.rpt-cat-label { font-size: 11px; fill: var(--text-2); font-family: inherit; }
.rpt-no-data { font-size: 13px; fill: var(--text-3); font-family: inherit; }

/* ── Donut ── */
.donut-layout {
  display: flex;
  align-items: center;
  gap: 14px;
}
.donut-svg { flex: 0 0 120px; }
.donut-legend { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.dl-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-2);
}
.dl-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.dl-name { flex: 1; }
.dl-count { font-weight: 600; color: var(--text); }
.donut-center-v { font-size: 16px; font-weight: 700; fill: var(--text); font-family: inherit; }
.donut-center-l { font-size: 9px; fill: var(--text-3); font-family: inherit; }

/* ── Stacked bars ── */
.stack-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}
.stack-name {
  width: 90px;
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}
.stack-bars { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.stack-bar { width: 100%; height: 12px; display: flex; border-radius: 3px; overflow: hidden; }
.stack-bar.is-b { opacity: 0.45; }
.stack-seg { height: 100%; }
.row-total { font-size: 12px; color: var(--text-3); width: 28px; text-align: right; flex-shrink: 0; }

/* ── Ranking table ── */
.rank-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rank-table th {
  text-align: left;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
}
.rank-table td { padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.rank-table tr:last-child td { border-bottom: none; }
.rank-table tr:hover td { background: var(--surface-2); }
.rank-pos { font-size: 12px; color: var(--text-3); font-weight: 600; width: 28px; }
.rank-pos.gold   { color: #B8935A; }
.rank-pos.silver { color: #7A8696; }
.rank-pos.bronze { color: #A05C52; }
.rank-seller { display: flex; align-items: center; gap: 9px; }
.rank-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--olive);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.rank-name { font-weight: 500; color: var(--text); }
.rank-money { font-weight: 600; color: var(--ok); }
.conv-cell { min-width: 90px; }
.conv-bar-wrap { display: flex; align-items: center; gap: 6px; }
.conv-bar-bg { flex: 1; height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.conv-bar-fill { height: 100%; background: var(--olive); border-radius: 3px; }
.conv-pct { font-size: 11px; color: var(--text-2); width: 32px; text-align: right; }
.rank-delta { font-size: 11px; color: var(--text-3); }
.rank-delta.up   { color: var(--ok); }
.rank-delta.down { color: var(--fail); }

@media (max-width: 900px) {
  .rpt-grid { grid-template-columns: 1fr; }
  .rpt-card.span-2 { grid-column: span 1; }
  .donut-layout { flex-direction: column; align-items: flex-start; }
  .donut-svg { flex: none; width: 140px; }
}

/* Legend swatch (.sw used in rpt-legend / donut-legend contexts) */
.rpt-legend .sw, .dl-row .sw, .donut-legend .sw {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 2px;
  flex-shrink: 0;
}
.lg { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-2); }
.dl-row .nm { flex: 1; color: var(--text-2); font-size: 11px; }
.dl-row .vl { font-weight: 600; color: var(--text); font-size: 11px; }
.dl-row .pct { font-size: 10px; color: var(--text-3); width: 30px; text-align: right; }

/* Conversion bar in ranking table */
.conv-bar { width: 60px; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin-top: 3px; }
.conv-bar span { display: block; height: 100%; background: var(--olive); border-radius: 2px; }

/* Monto progress bar in ranking table */
.rank-monto-bar { width: 100%; height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; margin-top: 4px; min-width: 60px; }
.rank-monto-bar span { display: block; height: 100%; background: var(--ok); border-radius: 2px; }

/* Table number column alignment */
.rank-table th.num, .rank-table td.num { text-align: right; }

/* ===== RANGE PICKER — Iniciar nuevo período ===== */
.rp-modal { max-width: 700px !important; width: 95% !important; }

.rp-calendar { display: flex; gap: 28px; margin-bottom: 4px; }
.rp-month { flex: 1; min-width: 0; }

.rp-month-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.rp-month-name { font-size: 13px; font-weight: 700; color: var(--text); }
.rp-nav {
  width: 28px; height: 28px; display: flex; align-items: center;
  justify-content: center; border: none; background: none; border-radius: 6px;
  cursor: pointer; color: var(--text-2); padding: 0; font-family: inherit;
}
.rp-nav:hover { background: var(--surface); color: var(--text); }
.rp-nav--hidden { visibility: hidden; pointer-events: none; }

.rp-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.rp-dow {
  font-size: 10px; font-weight: 600; color: var(--text-3);
  text-align: center; padding: 3px 0 7px; user-select: none;
}

.rp-day {
  position: relative; aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; cursor: pointer; color: var(--text); user-select: none;
}
.rp-day--other { color: var(--text-3); opacity: .3; pointer-events: none; }
.rp-day--today > span { color: var(--ok); font-weight: 700; }

/* Fondo del rango — capa stretchy */
.rp-day::before {
  content: ''; position: absolute; inset: 2px 0;
  background: transparent; z-index: 0; pointer-events: none;
}
/* Número del día — encima de la capa */
.rp-day > span {
  position: relative; z-index: 1;
  width: 26px; height: 26px; display: flex; align-items: center;
  justify-content: center; border-radius: 50%;
}
.rp-day:not(.rp-day--start):not(.rp-day--end):not(.rp-day--other):hover > span {
  background: var(--surface);
}

/* Días dentro del rango */
.rp-day--in-range::before { background: var(--ok-soft); }

/* Start y end: pastilla sólida */
.rp-day--start > span,
.rp-day--end > span { background: var(--ok); color: #fff; font-weight: 600; }
/* Hoy dentro de start/end ya tiene el verde del ok */
.rp-day--start.rp-day--today > span,
.rp-day--end.rp-day--today > span { color: #fff; }

/* Extensión horizontal de la banda desde start / hacia end */
.rp-day--start::before { background: var(--ok-soft); left: 50%; }
.rp-day--end::before   { background: var(--ok-soft); right: 50%; }
/* Cuando start === end no hay banda */
.rp-day--start.rp-day--end::before { background: transparent; }

/* Info bar */
.rp-info {
  font-size: 12.5px; color: var(--text-2); line-height: 1.6;
  padding: 10px 0; min-height: 38px;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

/* Separador entre meses */
.rp-divider { width: 1px; background: var(--border); flex-shrink: 0; margin: 0 -8px; }
