/* Paleta de Agencia Palmero: naranja del logo + neutros cálidos (misma que el Dashboard de Costos).
   El tema lo fija theme.js en <html data-theme="light|dark">; sin JS queda el claro. */
:root {
  --bg: #f4f4f2;
  --bg-sunken: #efeeeb;
  --column: #ebeae6;
  --bg-neutral: #0b0b0b0d;
  --bg-hover: #0b0b0b12;
  --bg-pressed: #0b0b0b1f;
  --surface: #ffffff;
  --border: #0b0b0b1a;
  --border-strong: #a8a7a2;
  --text: #1a1a19;
  --text-subtle: #52514e;
  --text-subtlest: #6b6a65;
  --brand: #c95f00;
  --brand-hover: #a84f00;
  --brand-weak: #fdeedd;
  --on-brand: #ffffff;
  --accent-grad: linear-gradient(135deg, #f5a02a, #eb8303);
  --focus: #eb8303;
  --success: #047857;
  --success-weak: #d1fae5;
  --on-success: #ffffff;
  --danger: #dc2626;
  --danger-weak: #fee2e2;
  --on-danger: #ffffff;
  --info-weak: #fdeedd;
  --shadow-raised: 0 1px 2px #0b0b0b14, 0 1px 3px #0b0b0b0f;
  --shadow-hover: 0 8px 18px -6px #0b0b0b2e, 0 2px 4px #0b0b0b14;
  --shadow-overlay: 0 10px 24px -6px #0b0b0b30, 0 0 1px #0b0b0b40;
  --shadow-modal: 0 24px 48px -12px #0b0b0b4d, 0 0 1px #0b0b0b40;
  --blanket: #0b0b0b80;
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 14px;

  --lz-default-bg: #e8e7e3;  --lz-default-fg: #52514e;
  --lz-progress-bg: #e3eefb; --lz-progress-fg: #1d5aa8;
  --lz-success-bg: #d1fae5;  --lz-success-fg: #065f46;
  --lz-moved-bg: #fef3c7;    --lz-moved-fg: #92400e;
  --lz-removed-bg: #fee2e2;  --lz-removed-fg: #991b1b;

  --font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
  --mono: "Cascadia Code", Consolas, ui-monospace, monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #121211;
  --bg-sunken: #0e0e0d;
  --column: #171716;
  --bg-neutral: #f0efec1a;
  --bg-hover: #f0efec1f;
  --bg-pressed: #f0efec2e;
  --surface: #1f1f1d;
  --border: #f0efec2b;
  --border-strong: #6c6b66;
  --text: #f0efec;
  --text-subtle: #c3c2b7;
  --text-subtlest: #9a9990;
  --brand: #f0901f;
  --brand-hover: #f5ab55;
  --brand-weak: #f0901f24;
  --on-brand: #1a1a19;
  --accent-grad: linear-gradient(135deg, #f5ab55, #f0901f);
  --focus: #f0901f;
  --success: #34d399;
  --success-weak: #34d3991f;
  --on-success: #04180f;
  --danger: #f87171;
  --danger-weak: #f871711f;
  --on-danger: #1c0707;
  --info-weak: #f0901f1f;
  --shadow-raised: 0 1px 2px #00000066, 0 1px 3px #00000040;
  --shadow-hover: 0 10px 22px -6px #000000a6, 0 2px 4px #00000066;
  --shadow-overlay: 0 12px 28px -6px #000000b3, 0 0 1px #94a3b840;
  --shadow-modal: 0 28px 56px -12px #000000cc, 0 0 1px #94a3b84d;
  --blanket: #050505cc;

  --lz-default-bg: #2b2b28;  --lz-default-fg: #c3c2b7;
  --lz-progress-bg: #12294a; --lz-progress-fg: #8bb8f0;
  --lz-success-bg: #064e3b;  --lz-success-fg: #6ee7b7;
  --lz-moved-bg: #4a3410;    --lz-moved-fg: #fcd34d;
  --lz-removed-bg: #4c1d1d;  --lz-removed-fg: #fca5a5;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 14px/20px var(--font);
  -webkit-font-smoothing: antialiased; transition: background .2s, color .2s;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3 { margin: 0; color: var(--text); }
a { color: var(--brand); text-decoration: none; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.muted { color: var(--text-subtlest); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border: 0; border-radius: var(--radius-sm);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  background: var(--bg-neutral); color: var(--text-subtle);
  transition: background .1s;
}
.btn:hover { background: var(--bg-hover); }
.btn:active { background: var(--bg-pressed); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); color: var(--on-brand); box-shadow: 0 1px 2px #0b0b0b33; }
.btn.primary:hover { background: var(--brand-hover); }
.btn.subtle { background: transparent; }
.btn.subtle:hover { background: var(--bg-hover); }
.btn.danger { background: var(--danger); color: var(--on-danger); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-subtle); cursor: pointer;
}
.icon-btn:hover { background: var(--bg-hover); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* ---------- Layout ---------- */
.app {
  display: grid; height: 100vh;
  grid-template-columns: 240px minmax(0, 1fr);
  grid-template-rows: 56px minmax(0, 1fr);
}
.topnav {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.product { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: var(--radius-sm); color: var(--text); }
.product:hover { background: var(--bg-hover); }
.product-logo, .project-icon {
  display: grid; place-items: center; background: transparent; box-shadow: none;
}
.product-logo img, .project-icon img { display: block; width: 100%; height: 100%; object-fit: contain; }
.product-logo { width: 30px; height: 30px; }
.product-name { font-weight: 650; font-size: 16px; }
.user-btn {
  display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px 0 4px;
  border: 0; border-radius: 16px; background: transparent; color: var(--text); font: inherit; cursor: pointer;
}
.user-btn:hover { background: var(--bg-hover); }

.sidebar {
  display: flex; flex-direction: column; padding: 16px 8px;
  background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto;
}
.project { display: flex; gap: 10px; align-items: center; padding: 4px 8px 16px; }
.project-icon { width: 36px; height: 36px; flex: none; }
.project-name { font-weight: 600; }
.project-sub { font-size: 12px; color: var(--text-subtlest); }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section {
  font-size: 11px; font-weight: 700; color: var(--text-subtlest);
  text-transform: uppercase; letter-spacing: .03em; padding: 12px 12px 6px;
}
.side-nav a {
  display: flex; align-items: center; gap: 12px; height: 36px; padding: 0 12px;
  border-radius: var(--radius-sm); color: var(--text-subtle); font-weight: 500; position: relative;
}
.side-nav a:hover { background: var(--bg-hover); }
.side-nav a.active { background: var(--brand-weak); color: var(--brand); }
.side-nav a.active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 2px 2px 0; background: var(--brand);
}
.side-foot {
  margin-top: auto; display: flex; gap: 8px; align-items: flex-start;
  padding: 12px; font-size: 12px; line-height: 16px; color: var(--text-subtlest);
}
.side-foot svg { flex: none; margin-top: 1px; }

.content { overflow: auto; padding: 24px 32px 32px; display: flex; flex-direction: column; min-width: 0; }

/* ---------- Encabezado de página y toolbar ---------- */
.breadcrumbs { font-size: 14px; color: var(--text-subtlest); margin-bottom: 8px; }
.page-title { font-size: 26px; line-height: 32px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 20px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 20px; }
.search-box {
  display: flex; align-items: center; gap: 6px; width: 220px; height: 32px; padding: 0 8px;
  border: 2px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-subtlest);
}
.search-box:focus-within { border-color: var(--focus); }
.search-box input { border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; width: 100%; }
.avatar-group { display: flex; padding-left: 4px; }
.avatar-group .av-toggle {
  border: 0; padding: 0; background: none; cursor: pointer; margin-left: -4px; border-radius: 50%;
  box-shadow: 0 0 0 2px var(--bg); transition: transform .1s;
}
.avatar-group .av-toggle:hover { transform: translateY(-2px); z-index: 1; }
.avatar-group .av-toggle.on { box-shadow: 0 0 0 2px var(--brand); z-index: 2; }
.select {
  height: 34px; padding: 0 10px; border: 0; border-radius: var(--radius-sm); background: var(--bg-neutral);
  color: var(--text-subtle); font: inherit; font-weight: 500; cursor: pointer;
}
.select:hover { background: var(--bg-hover); }
.chip {
  height: 34px; padding: 0 14px; border: 0; border-radius: var(--radius-sm); cursor: pointer;
  background: transparent; color: var(--text-subtle); font: inherit; font-weight: 500;
}
.chip:hover { background: var(--bg-hover); }
.chip.on { background: var(--brand-weak); color: var(--brand); }

/* ---------- Avatares, íconos, lozenges ---------- */
.avatar {
  display: inline-grid; place-items: center; flex: none; border-radius: 50%;
  color: #fff; font-weight: 600; user-select: none;
}
.avatar.xs { width: 20px; height: 20px; font-size: 9px; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.md { width: 32px; height: 32px; font-size: 12px; }
.avatar.av-empty { background: var(--bg-neutral); color: var(--text-subtlest); }

.type-icon { display: inline-grid; place-items: center; flex: none; border-radius: 3px; }
.type-icon svg { width: 75%; height: 75%; }
.prio-icon { display: inline-grid; place-items: center; flex: none; }

.lozenge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; white-space: nowrap; letter-spacing: .01em;
  background: var(--lz-default-bg); color: var(--lz-default-fg);
}
.lozenge.inprogress { background: var(--lz-progress-bg); color: var(--lz-progress-fg); }
.lozenge.success { background: var(--lz-success-bg); color: var(--lz-success-fg); }
.lozenge.moved { background: var(--lz-moved-bg); color: var(--lz-moved-fg); }
.lozenge.removed { background: var(--lz-removed-bg); color: var(--lz-removed-fg); }

.key { font-size: 12px; font-weight: 600; color: var(--text-subtlest); white-space: nowrap; }
.tag {
  display: inline-block; max-width: 100%; padding: 0 7px; border-radius: 6px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; font-size: 12px; line-height: 20px;
  background: var(--bg-neutral); color: var(--text-subtle);
}

/* ---------- Tablero ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 12px; align-items: start; min-height: 0; }
.column {
  display: flex; flex-direction: column; min-height: 240px; border-radius: var(--radius-lg); border: 1px solid var(--border);
  background: var(--column); transition: background .12s, box-shadow .12s, opacity .12s;
}
.col-head {
  display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px;
  font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--text-subtlest);
}
.col-count { font-weight: 500; }
.col-body { display: flex; flex-direction: column; gap: 8px; padding: 4px 8px 8px; min-height: 60px; }
.col-empty { padding: 16px 8px; text-align: center; font-size: 13px; color: var(--text-subtlest); }
.col-foot { padding: 0 12px 12px; font-size: 12px; color: var(--text-subtlest); }
.column.can-drop { box-shadow: inset 0 0 0 2px var(--border); }
.column.no-drop { opacity: .45; }
.column.drop-hover { background: var(--brand-weak); box-shadow: inset 0 0 0 2px var(--brand); }

.card-issue {
  display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); box-shadow: var(--shadow-raised); cursor: pointer;
  transition: background .1s;
}
.card-issue:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); border-color: var(--border-strong); }
.card-issue { transition: box-shadow .15s, transform .15s, border-color .15s; }
.card-issue.dragging { opacity: .4; }
.ci-title { color: var(--text); overflow-wrap: anywhere; }
.ci-foot { display: flex; align-items: center; gap: 6px; min-height: 24px; }
.ci-foot > * { flex-shrink: 0; }
.ci-foot .key { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ci-foot .spacer { flex: 1 1 0; min-width: 0; }
.card-issue.closed .ci-title { color: var(--text-subtlest); }

/* ---------- Lista ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-raised); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  position: sticky; top: 0; background: var(--surface); text-align: left; white-space: nowrap;
  padding: 8px; font-size: 12px; font-weight: 600; color: var(--text-subtlest);
  border-bottom: 2px solid var(--border); cursor: pointer; user-select: none;
}
.table th:hover { color: var(--text); }
.table th .dir { font-size: 10px; margin-left: 2px; }
.table td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.cell-flex { display: flex; align-items: center; gap: 8px; }
.cell-title { color: var(--text); font-weight: 500; }
.due-date { font-size: 13px; color: var(--text-subtle); white-space: nowrap; }

/* ---------- Indicadores ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  position: relative; overflow: hidden; padding: 16px; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-raised);
}
.kpi::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--accent-grad); }
.kpi-label { font-size: 12px; font-weight: 600; color: var(--text-subtlest); }
.kpi-value { font-size: 28px; line-height: 36px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-hint { font-size: 12px; color: var(--text-subtlest); }
.kpi.good .kpi-value { color: var(--success); }
.kpi.bad .kpi-value { color: var(--danger); }
.panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.panel { padding: 16px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-raised); min-width: 0; }
.panel h3 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 170px 1fr 28px; align-items: center; gap: 10px; font-size: 13px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-subtle); }
.bar-track { height: 8px; border-radius: 4px; background: var(--bg-neutral); overflow: hidden; }
.bar { height: 100%; border-radius: 4px; background: var(--accent-grad); }
.bar-val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.mini { list-style: none; margin: 0; padding: 0; }
.mini li { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 3px; cursor: pointer; }
.mini li:hover { background: var(--bg-hover); }
.mini .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 20px 8px; text-align: center; color: var(--text-subtlest); font-size: 13px; }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: var(--blanket); backdrop-filter: blur(3px);
  display: flex; justify-content: center; align-items: flex-start; padding: 48px 16px 16px; overflow-y: auto;
}
.overlay-top { z-index: 60; }

/* ---------- Ficha del ticket ---------- */
.issue-modal {
  width: min(1160px, 100%); height: calc(100vh - 64px); display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-modal); overflow: hidden;
}
.issue-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px 12px 24px; }
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--text-subtle); font-size: 14px; }
.crumbs .sep { color: var(--text-subtlest); }
.crumbs .key { font-size: 14px; color: var(--text-subtle); }
.head-actions { margin-left: auto; display: flex; gap: 4px; }
.issue-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 360px; }
.issue-main { overflow-y: auto; padding: 4px 32px 32px 24px; }
.issue-side { overflow-y: auto; padding: 4px 24px 24px 8px; }

.inline {
  display: block; width: 100%; padding: 6px 8px; border: 2px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--text); font: inherit; resize: none; overflow: hidden;
  transition: background .1s, border-color .1s;
}
.inline:hover:not([readonly]):not(:disabled) { background: var(--bg-hover); }
.inline:focus { outline: none; border-color: var(--focus); background: var(--surface) !important; }
.inline[readonly], .inline:disabled { cursor: default; opacity: 1; }
.inline::placeholder { color: var(--text-subtlest); }
.inline.boxed { min-height: 64px; border-color: var(--border); }
.inline.boxed:hover:not([readonly]) { border-color: var(--border-strong); background: transparent; }
.inline.saved { border-color: var(--success) !important; }
.inline.title { font-size: 24px; line-height: 30px; font-weight: 600; margin: 0 0 12px -10px; width: calc(100% + 10px); }
select.inline { appearance: none; cursor: pointer; padding-right: 8px; }

.isec { margin-top: 24px; }
.isec > h3 { display: flex; align-items: baseline; gap: 8px; font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.norm { font-size: 12px; font-weight: 500; color: var(--text-subtlest); }
.tfield { margin-bottom: 14px; }
.tfield label { display: flex; gap: 6px; align-items: center; font-size: 12px; font-weight: 600; color: var(--text-subtlest); margin-bottom: 4px; }
.req { color: var(--danger); }
.isec > .inline:not(.boxed) { margin-left: -10px; width: calc(100% + 10px); }

.guide {
  display: flex; gap: 12px; padding: 16px; border-radius: var(--radius); background: var(--info-weak);
}
.guide.done { background: var(--bg-neutral); }
.guide-icon { color: var(--brand); flex: none; margin-top: 1px; }
.guide.done .guide-icon { color: var(--text-subtlest); }
.guide-title { font-weight: 600; margin-bottom: 4px; }
.guide-text { color: var(--text); margin-bottom: 10px; }
.guide-text:last-child { margin-bottom: 0; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-bottom: 12px; }
.check-item {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 0; border-radius: 6px;
  background: var(--surface); color: var(--text-subtle); font: inherit; font-size: 13px; cursor: pointer;
  box-shadow: var(--shadow-raised);
}
.check-item.ok { color: var(--success); }
.check-item:hover { background: var(--bg-sunken); }

.message { display: flex; gap: 12px; padding: 16px; border-radius: var(--radius); margin-top: 24px; }
.message.ok { background: var(--success-weak); }
.message.bad { background: var(--danger-weak); }
.message-title { font-weight: 600; margin-bottom: 4px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }

.seg { display: flex; gap: 4px; margin-bottom: 16px; }
.seg button {
  height: 28px; padding: 0 12px; border: 0; border-radius: var(--radius-sm); background: var(--bg-neutral);
  color: var(--text-subtle); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
}
.seg button:hover { background: var(--bg-hover); }
.seg button.on { background: var(--brand-weak); color: var(--brand); }

.composer { display: flex; gap: 12px; margin-bottom: 20px; }
.composer-box { flex: 1; }
.composer textarea {
  width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; resize: vertical;
}
.composer textarea:focus { outline: none; border: 2px solid var(--focus); padding: 7px 9px; min-height: 80px; }
.composer-actions { display: flex; gap: 6px; margin-top: 8px; }

.activity { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 18px; }
.activity li { display: flex; gap: 12px; }
.act-body { flex: 1; min-width: 0; }
.act-head { color: var(--text-subtle); }
.act-head b { color: var(--text); font-weight: 600; }
.act-time { color: var(--text-subtlest); font-size: 12px; margin-left: 6px; }
.act-detail { margin-top: 6px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; color: var(--text-subtle); overflow-wrap: anywhere; }
.act-detail .old { text-decoration: line-through; color: var(--text-subtlest); }
.act-comment { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }

.status-wrap { position: relative; display: flex; align-items: center; gap: 8px; margin: 2px 0 20px; }
.status-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border: 0; border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; cursor: pointer; background: var(--lz-default-bg); color: var(--lz-default-fg);
}
.status-btn.inprogress { background: var(--lz-progress-fg); color: var(--surface); }
.status-btn.moved { background: var(--lz-moved-bg); color: var(--lz-moved-fg); }
.status-btn.success { background: var(--success); color: var(--on-success); }
.status-btn.removed { background: var(--lz-removed-bg); color: var(--lz-removed-fg); }
.status-btn:disabled { cursor: default; }
.status-btn:not(:disabled):hover { filter: brightness(.95); }
.menu {
  position: absolute; top: 36px; left: 0; z-index: 5; min-width: 280px; padding: 6px 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-overlay);
}
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 16px; border: 0;
  background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--bg-hover); }
.menu-item .arrow { color: var(--text-subtlest); margin-left: auto; }
.menu-sep { height: 1px; background: var(--border); margin: 6px 0; }

.details { border: 1px solid var(--border); border-radius: var(--radius); }
.details-head { padding: 12px 12px; font-weight: 600; border-bottom: 1px solid var(--border); }
.drow { display: grid; grid-template-columns: 130px minmax(0, 1fr); align-items: center; gap: 8px; padding: 4px 12px; min-height: 40px; }
.drow:first-of-type { padding-top: 8px; }
.drow:last-child { padding-bottom: 8px; }
.dlabel { font-size: 13px; font-weight: 600; color: var(--text-subtle); }
.dval { display: flex; align-items: center; gap: 6px; min-width: 0; }
.dval .inline { padding: 4px 6px; }
.dval > span:not(.avatar):not([id]) { padding: 0 8px; overflow-wrap: anywhere; }
.dval > span[id] { display: inline-grid; }
.meta { margin-top: 16px; padding: 0 4px; font-size: 12px; line-height: 20px; color: var(--text-subtlest); }

/* ---------- Diálogos ---------- */
.dialog {
  width: min(600px, 100%); padding: 24px; border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-modal);
}
.dialog.wide { width: min(760px, 100%); }
.dialog-head { display: flex; align-items: center; margin-bottom: 4px; }
.dialog-head h2 { font-size: 20px; line-height: 24px; font-weight: 600; flex: 1; }
.dialog p.lead { color: var(--text-subtle); margin: 8px 0 16px; }
.req-note { font-size: 12px; color: var(--text-subtlest); margin: 4px 0 16px; }
.form { display: flex; flex-direction: column; gap: 16px; }
.fgroup { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.flabel { font-size: 12px; font-weight: 600; color: var(--text-subtle); }
.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field {
  width: 100%; height: 40px; padding: 0 10px; border: 2px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-sunken); color: var(--text); font: inherit;
}
textarea.field { height: auto; padding: 8px; resize: vertical; }
.field:hover { background: var(--bg-hover); }
.field:focus { outline: none; border-color: var(--focus); background: var(--surface); }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.type-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.type-pick input, .choice input { position: absolute; opacity: 0; pointer-events: none; }
.type-pick span {
  display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px; border-radius: var(--radius-sm); cursor: pointer;
  border: 2px solid var(--border); font-weight: 500;
}
.type-pick span:hover { background: var(--bg-hover); }
.type-pick input:checked + span { border-color: var(--brand); background: var(--brand-weak); }
.type-pick input:focus-visible + span { outline: 2px solid var(--focus); }
.type-help { font-size: 13px; color: var(--text-subtle); padding: 6px 2px 0; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice span {
  display: flex; flex-direction: column; gap: 2px; padding: 12px; border: 2px solid var(--border); border-radius: var(--radius);
  cursor: pointer; font-weight: 600;
}
.choice small { font-weight: 400; color: var(--text-subtle); }
.choice input:checked + span { border-color: var(--brand); background: var(--brand-weak); }

/* ---------- Toasts ---------- */
#toasts { position: fixed; left: 24px; bottom: 24px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px; max-width: 480px; padding: 12px 16px; border-radius: var(--radius);
  background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-overlay); animation: pop .15s ease-out;
}
.toast .ti { flex: none; color: var(--success); }
.toast.error .ti { color: var(--danger); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Categorías y tarjetas ---------- */
.cdot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; }
.cat-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; height: 22px; padding: 0 8px; border-radius: 6px;
  background: var(--bg-neutral); color: var(--text); font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden;
}
.col-head .col-name { color: var(--text-subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-lock { margin-left: auto; display: inline-flex; color: var(--text-subtlest); }
.board { padding-bottom: 8px; }
.ci-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag.area { background: var(--brand-weak); color: var(--brand); }
.ci-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-subtlest); }
.since { display: inline-flex; align-items: center; gap: 3px; }
.cell-sub { font-size: 12px; color: var(--text-subtlest); }
.nowrap { white-space: nowrap; }
.center { text-align: center !important; }
.row-muted td { opacity: .6; }
.table.static tbody tr { cursor: default; }
.table.static tbody tr:hover { background: transparent; }
.table.static th { cursor: default; }
code { font-family: var(--mono); font-size: 12px; }

/* Recorrido por categorías */
.journey { list-style: none; margin: 0; padding: 8px 12px 12px; }
.journey li { position: relative; padding: 8px 0 8px 20px; }
.journey li::before { content: ""; position: absolute; left: 4px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.journey li:first-child::before { top: 16px; }
.journey li:last-child::before { bottom: calc(100% - 16px); }
.journey li:only-child::before { display: none; }
.journey li::after {
  content: ""; position: absolute; left: 0; top: 13px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border-strong);
}
.journey li.current::after { border-color: var(--brand); background: var(--brand); }
.j-meta { margin-top: 4px; font-size: 12px; line-height: 18px; color: var(--text-subtle); }

/* Menú de estado y guía */
.menu-title { padding: 6px 16px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-subtlest); }
.menu-empty { padding: 8px 16px; font-size: 13px; color: var(--text-subtlest); }
.menu-item.strong { color: var(--success); font-weight: 600; }
.menu-item.danger .cat-chip { color: var(--danger); }
.guide-note { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 13px; color: var(--text-subtle); }
.ext-link { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; font-size: 13px; }

/* Menú de usuario */
.user-wrap { position: relative; }
.user-menu { right: 0; left: auto; top: 40px; min-width: 260px; }
.um-head { display: flex; align-items: center; gap: 10px; padding: 8px 16px; }
.um-name { font-weight: 600; }
.um-role { padding: 0 16px 8px; font-size: 12px; color: var(--text-subtlest); }
a.menu-item { color: var(--text); }

/* ---------- Administración ---------- */
.page-lead { max-width: 880px; margin: -8px 0 20px; color: var(--text-subtle); }
.hint-text { max-width: 880px; margin-top: 12px; font-size: 13px; color: var(--text-subtlest); }
.select.sm { height: 30px; }
.field.sm { height: 32px; padding: 0 8px; border-width: 1px; background: var(--surface); }
.color-input { width: 36px; height: 28px; padding: 0; border: 1px solid var(--border); border-radius: 3px; background: none; cursor: pointer; }
.icon-btn.sm { width: 26px; height: 26px; }
.icon-btn:disabled { opacity: .3; cursor: default; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; white-space: nowrap; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; }
.toggle span { position: relative; flex: none; width: 32px; height: 18px; border-radius: 9px; background: var(--border-strong); transition: background .15s; }
.toggle span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; transition: transform .15s;
}
.toggle input:checked + span { background: var(--success); }
.toggle input:checked + span::after { transform: translateX(14px); }
.toggle input:focus-visible + span { outline: 2px solid var(--focus); }
.panel.pending { margin-bottom: 16px; border-left: 3px solid var(--brand); }
.pending-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.pending-row + .pending-row { border-top: 1px solid var(--border); }
.grow { flex: 1; min-width: 0; }
.inline-create { margin-top: 16px; }
.frow4 { display: grid; grid-template-columns: 2fr 1.2fr auto auto; gap: 10px; align-items: center; }
.frow4.two { grid-template-columns: 1fr auto; }
.narrow { max-width: 640px; }
.matrix th, .matrix td { white-space: nowrap; }
.matrix input[type=checkbox] { width: 18px; height: 18px; cursor: pointer; accent-color: var(--brand); }
.matrix td:first-child, .matrix th:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
.mail-preview { margin: 0; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--surface); white-space: pre-wrap; font: 13px/19px var(--font); }
.notif-body td { background: var(--bg-sunken); }
.export-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.export-card {
  display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-raised); color: var(--text);
  transition: box-shadow .15s, transform .15s;
}
.export-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.export-card b { color: var(--brand); }
.export-card span { font-size: 13px; color: var(--text-subtle); }
.detail-cell { max-width: 420px; font-size: 12px; color: var(--text-subtle); overflow-wrap: anywhere; }
.steps { display: flex; flex-direction: column; gap: 10px; max-width: 880px; margin: 0 0 20px; padding-left: 20px; }
.steps input[type=file] { margin-left: 8px; }
.import-stats { display: flex; flex-wrap: wrap; gap: 24px; }
.import-stats div { display: flex; flex-direction: column; }
.import-stats b { font-size: 22px; line-height: 28px; }
.import-stats span { font-size: 12px; color: var(--text-subtlest); }

/* ---------- Tema (botón sol/luna) ---------- */
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }

/* ---------- Login: fondo "constelación" (igual que Campañas Masivas) y tarjeta de vidrio ---------- */
.login-body {
  --canvas-bg: #faf9f7; --canvas-node: 15, 23, 42; --canvas-accent: 201, 95, 0;
  --glass-bg: rgba(255, 255, 255, .72); --glass-border: rgba(255, 255, 255, .9); --glass-ring: rgba(15, 23, 42, .06);
  --glass-shadow: 0 18px 50px -12px rgba(15, 23, 42, .18); --field-bg: rgba(255, 255, 255, .78);
  --vignette: radial-gradient(135% 100% at 50% 45%, rgba(250, 249, 247, 0) 0%, rgba(250, 249, 247, .35) 55%, rgba(250, 249, 247, .75) 100%);
  position: relative; display: grid; place-items: center; min-height: 100vh; padding: 16px;
  background: var(--canvas-bg); overflow: hidden;
}
:root[data-theme="dark"] .login-body {
  --canvas-bg: #0a0a09; --canvas-node: 255, 255, 255; --canvas-accent: 240, 144, 31;
  --glass-bg: rgba(31, 31, 29, .66); --glass-border: rgba(255, 255, 255, .1); --glass-ring: rgba(255, 255, 255, .04);
  --glass-shadow: 0 24px 60px -12px rgba(0, 0, 0, .7); --field-bg: rgba(255, 255, 255, .05);
  --vignette: radial-gradient(135% 100% at 50% 45%, rgba(10, 10, 9, 0) 0%, rgba(10, 10, 9, .32) 55%, rgba(10, 10, 9, .72) 100%);
}
#loginCanvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.login-vignette { position: absolute; inset: 0; pointer-events: none; background: var(--vignette); }
.login-theme { position: absolute; top: 16px; right: 16px; z-index: 3; background: var(--glass-bg); border: 1px solid var(--glass-border); }
.login-card {
  position: relative; z-index: 2; display: flex; flex-direction: column; gap: 20px; width: min(400px, 100%); padding: 32px;
  border-radius: 18px; background: var(--glass-bg); border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(18px) saturate(160%); backdrop-filter: blur(18px) saturate(160%);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-ring);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .login-card { background: var(--surface); } }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.login-brand h1 { font-size: 22px; line-height: 28px; font-weight: 800; letter-spacing: -.01em; }
.login-logo { display: block; height: 72px; width: auto; filter: drop-shadow(0 10px 22px rgba(235, 131, 3, .25)); }
.ms-btn { height: 44px; gap: 10px; border: 1px solid var(--border-strong); background: var(--field-bg); color: var(--text); font-weight: 600; }
.ms-btn:hover { background: var(--bg-hover); }
.dev-badge { padding: 6px 10px; border-radius: 6px; background: var(--lz-moved-bg); color: var(--lz-moved-fg); font-size: 12px; font-weight: 600; }
.login-foot { margin: 0; font-size: 12px; text-align: center; color: var(--text-subtlest); }
.login-card .message { margin-top: 0; }
.login-card .field { height: 44px; border-radius: 10px; border-width: 1px; border-color: var(--border-strong); background: var(--field-bg); }
.login-card .field:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.login-card .btn.primary { height: 44px; font-weight: 700; box-shadow: 0 8px 20px -8px var(--brand); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .lead-icon { position: absolute; left: 12px; width: 16px; height: 16px; color: var(--text-subtlest); pointer-events: none; }
.input-wrap .field { padding-left: 36px; }
.input-wrap .field.has-toggle { padding-right: 44px; }
.pw-toggle {
  position: absolute; right: 4px; display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0;
  border-radius: 8px; background: transparent; color: var(--text-subtlest); cursor: pointer;
}
.pw-toggle:hover { color: var(--text); background: var(--bg-hover); }
.message.info { background: var(--info-weak); }

/* ---------- Imágenes adjuntas ---------- */
.gallery, .attach-row, .act-images { display: flex; flex-wrap: wrap; gap: 8px; }
.gallery, .act-images, .attach-row:not(:empty) { margin-top: 8px; }
.thumb {
  position: relative; width: 112px; height: 80px; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--bg-sunken); cursor: zoom-in;
}
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb:hover { border-color: var(--brand); box-shadow: var(--shadow-hover); }
.thumb .x {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%;
  background: #000000b3; color: #fff; font-size: 14px; line-height: 20px; cursor: pointer;
}
.attach-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 6px; }
.attach-bar .muted { font-size: 12px; }
.drop-over { outline: 2px dashed var(--brand); outline-offset: 3px; border-radius: var(--radius-sm); }
.lightbox { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 24px; background: #02060cd9; cursor: zoom-out; }
.lightbox img { max-width: min(96vw, 1600px); max-height: 92vh; border-radius: var(--radius-sm); background: #fff; box-shadow: var(--shadow-modal); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) { .export-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) { .frow4, .export-grid { grid-template-columns: 1fr; } }
.only-mobile { display: none; }
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .issue-grid { grid-template-columns: minmax(0, 1fr) 300px; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .only-mobile { display: inline-grid; }
  .sidebar { position: fixed; top: 56px; bottom: 0; left: 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-overlay); }
  .sidebar.open { transform: none; }
  .content { padding: 16px; }
  .panels, .frow, .type-picker, .choices { grid-template-columns: 1fr; }
  .issue-modal { height: auto; min-height: calc(100vh - 32px); }
  .overlay { padding: 16px; }
  .issue-grid { grid-template-columns: 1fr; }
  .issue-main, .issue-side { overflow: visible; padding: 8px 16px 16px; }
  .issue-side { order: -1; }
  .product-name { display: none; }
}

/* ---------- Varios responsables ---------- */
.av-stack { display: inline-flex; align-items: center; }
.av-stack .avatar + .avatar { margin-left: -7px; }
.av-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.people { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.pchip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px 2px 3px; border-radius: 999px;
  background: var(--bg-neutral); color: var(--text); font-size: 13px;
}
.pchip .x {
  border: 0; background: transparent; color: var(--text-subtle); cursor: pointer; font-size: 15px; line-height: 1;
  width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; padding: 0;
}
.pchip .x:hover { background: var(--bg-hover); color: var(--text); }
.pchip:not(:has(.x)) { padding-right: 10px; }
.inline.pick { width: auto; max-width: 100%; }
.panel-sub { margin: -4px 0 10px; font-size: 12px; color: var(--text-subtle); }

/* ---------- Clasificación automática ---------- */
.chip-auto {
  display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 999px; font-size: 10px; font-weight: 700;
  letter-spacing: .02em; line-height: 16px; background: var(--brand-weak); color: var(--brand); vertical-align: middle;
}
.auto-note { display: flex; gap: 8px; align-items: flex-start; }
.auto-note svg { flex: none; margin-top: 1px; color: var(--brand); }
details.adv { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px 4px; margin: 4px 0 12px; }
details.adv > summary { cursor: pointer; font-weight: 600; margin-bottom: 10px; }
details.adv > summary .muted { font-weight: 400; font-size: 12px; }

/* ---------- Equipo: panel por responsable ---------- */
.page-lead { color: var(--text-subtle); max-width: 820px; margin: -4px 0 14px; }
.team-table tbody tr { cursor: pointer; }
.team-table tbody tr:hover { background: var(--bg-hover); }
.team-table th.num, .team-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.team-table th[data-team-sort] { cursor: pointer; }
.bad-text { color: var(--danger); font-weight: 600; }
.warn-text { color: #b65c02; font-weight: 600; }
.back-link { display: inline-block; margin-bottom: 10px; color: var(--text-subtle); text-decoration: none; font-size: 13px; }
.back-link:hover { color: var(--brand); }
.person-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.person-head .avatar.md { width: 48px; height: 48px; font-size: 17px; }
.person-name { margin: 0; font-size: 22px; line-height: 28px; }
.sec-title { margin: 22px 0 10px; font-size: 14px; }
.sec-title .muted { font-weight: 400; margin-left: 6px; }
.panels + .sec-title { margin-top: 24px; }
.cols { display: flex; gap: 6px; align-items: flex-end; }
.col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.col-bars { height: 110px; width: 100%; display: flex; align-items: flex-end; gap: 2px; }
.cbar { flex: 1; min-height: 2px; border-radius: 2px 2px 0 0; }
.cbar.a { background: var(--brand); }
.cbar.c { background: var(--success); }
.col-label { font-size: 11px; color: var(--text-subtlest); text-transform: capitalize; }
.legend { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--text-subtle); }
.legend i.cbar { display: inline-block; flex: none; width: 10px; height: 10px; min-height: 0; border-radius: 2px; margin-right: 6px; }
.feed { list-style: none; margin: 0; padding: 0; max-height: 330px; overflow-y: auto; }
.feed li { display: flex; gap: 10px; padding: 7px 6px; border-radius: 3px; cursor: pointer; font-size: 13px; }
.feed li:hover { background: var(--bg-hover); }
.feed-when { flex: none; width: 48px; color: var(--text-subtlest); font-size: 12px; padding-top: 1px; }
.feed-note { color: var(--text-subtle); font-size: 12px; margin-top: 2px; }

.class-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
