/* ========================================
   SCJE Área Jurídica — stylesheet
   Aesthetic: refined editorial / law office
   ======================================== */

:root {
  --ink: #1a1f2e;
  --ink-soft: #4a4f5e;
  --ink-mute: #6b7080;
  --paper: #faf6ee;
  --paper-edge: #f0e9d6;
  --paper-shadow: rgba(0,0,0,0.12);

  --panel: #1f2433;
  --panel-bg: #181c28;
  --panel-soft: #2a3042;
  --panel-line: #353c50;
  --panel-line-soft: #2a3042;

  --accent: #b89456;
  --accent-soft: #d4b87a;
  --accent-dim: #8a6c3e;

  --text-light: #e8e3d6;
  --text-mid: #b8b5a8;
  --text-mute: #8a8f9e;

  --danger: #c4654a;
  --success: #6a9f7a;
  --warn: #c79a3a;

  --radius: 6px;
  --radius-sm: 4px;
  --radius-lg: 10px;

  --nav-w: 240px;
  --topbar-h: 60px;

  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'DM Sans', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--panel-bg);
  color: var(--text-light);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ========================================
   App shell
   ======================================== */
.app {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  height: 100vh;
}

/* Top bar */
.topbar {
  grid-column: 1 / -1;
  background: var(--panel);
  border-bottom: 1px solid var(--panel-line);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 18px;
  z-index: 5;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.brand-mark {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  color: var(--accent-soft);
  letter-spacing: 0.02em;
}
.brand-sub {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-mute);
}
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.install-btn {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent-soft);
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  display: none;
}
.install-btn.show { display: inline-flex; }
.install-btn:hover { background: rgba(184, 148, 86, 0.1); }

/* Sidenav */
.sidenav {
  background: var(--panel);
  border-right: 1px solid var(--panel-line);
  padding: 18px 12px;
  overflow-y: auto;
}
.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-mute);
  padding: 14px 12px 6px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--text-mid);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: rgba(255,255,255,0.03); color: var(--text-light); }
.nav-item.active {
  background: var(--panel-soft);
  color: var(--accent-soft);
}
.nav-item .ic {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-item .ic svg { width: 18px; height: 18px; }

/* Main content */
.main {
  overflow-y: auto;
  background: var(--panel-bg);
  position: relative;
}
.view { display: none; padding: 32px 40px 80px; }
.view.active { display: block; }
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 18px;
  flex-wrap: wrap;
}
.view-title {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 600;
  color: var(--text-light);
  letter-spacing: 0.005em;
}
.view-subtitle {
  font-size: 13px;
  color: var(--text-mute);
  margin-top: 4px;
  font-style: italic;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 600;
  transition: background 0.15s, transform 0.1s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn:hover { background: var(--accent-soft); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--panel-line);
  color: var(--text-light);
}
.btn-ghost:hover { background: rgba(255,255,255,0.04); border-color: var(--accent); }
.btn-danger {
  background: transparent;
  border: 1px solid rgba(196, 101, 74, 0.4);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(196, 101, 74, 0.1); border-color: var(--danger); }
.btn-sm { padding: 7px 14px; font-size: 11px; }

/* ========================================
   Cards & lists
   ======================================== */
.card {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 18px;
}
.card-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  color: var(--accent-soft);
  margin-bottom: 4px;
}
.card-sub {
  font-size: 12px;
  color: var(--text-mute);
  margin-bottom: 18px;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* Template cards on home */
.tpl-card {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-lg);
  padding: 26px 24px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  position: relative;
  overflow: hidden;
}
.tpl-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s;
}
.tpl-card:hover { border-color: var(--accent-dim); transform: translateY(-2px); }
.tpl-card:hover::before { transform: scaleX(1); }
.tpl-card .tpl-num {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 14px;
  color: var(--text-mute);
}
.tpl-card .tpl-name {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 600;
  color: var(--text-light);
}
.tpl-card .tpl-desc {
  font-size: 13px;
  color: var(--text-mute);
  line-height: 1.55;
}

/* List rows */
.list { display: flex; flex-direction: column; }
.list-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  margin-bottom: 8px;
  gap: 14px;
  transition: border-color 0.12s;
}
.list-row:hover { border-color: var(--accent-dim); }
.list-row .lr-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.list-row .lr-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-row .lr-meta {
  font-size: 12px;
  color: var(--text-mute);
}
.list-row .lr-meta .pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  background: rgba(184, 148, 86, 0.15);
  color: var(--accent-soft);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-right: 6px;
}
.list-row .lr-actions { display: flex; gap: 6px; }

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-mute);
}
.empty-mark {
  font-family: var(--font-serif);
  font-size: 56px;
  font-style: italic;
  color: var(--accent-dim);
  margin-bottom: 14px;
}
.empty-text { font-size: 14px; margin-bottom: 18px; }

/* ========================================
   Forms
   ======================================== */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-mute);
  font-weight: 500;
}
.field input,
.field textarea,
.field select {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-sm);
  color: var(--text-light);
  padding: 10px 12px;
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(0,0,0,0.35);
}
.field textarea { resize: vertical; min-height: 70px; line-height: 1.55; }
.field .hint { font-size: 11px; color: var(--text-mute); font-style: italic; }
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-light);
  cursor: pointer;
  margin-bottom: 12px;
}
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--accent); }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .row-2, .row-3 { grid-template-columns: 1fr; } }

/* Form sections (collapsible) */
.fs {
  margin-bottom: 18px;
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}
.fs-head {
  padding: 14px 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}
.fs-head:hover { background: rgba(255,255,255,0.02); }
.fs-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent-soft);
  font-weight: 600;
}
.fs-num {
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--text-mute);
  margin-right: 12px;
  font-style: italic;
}
.fs-toggle { color: var(--text-mute); transition: transform 0.2s; }
.fs.collapsed .fs-toggle { transform: rotate(-90deg); }
.fs.collapsed .fs-body { display: none; }
.fs-body { padding: 6px 18px 20px; }

/* ========================================
   Editor (two-pane layout)
   ======================================== */
.editor {
  display: grid;
  grid-template-columns: minmax(340px, 420px) 1fr;
  gap: 0;
  height: calc(100vh - var(--topbar-h));
  margin: -32px -40px 0;
}
.editor-form {
  background: var(--panel);
  border-right: 1px solid var(--panel-line);
  padding: 24px 22px 80px;
  overflow-y: auto;
}
.editor-preview {
  background: linear-gradient(135deg, #2a3042 0%, #1f2433 100%);
  padding: 28px 32px 80px;
  overflow-y: auto;
}
.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--panel-line);
}
.editor-back {
  background: transparent;
  border: none;
  color: var(--text-mute);
  font-size: 12px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.editor-back:hover { color: var(--accent-soft); }
.editor-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  color: var(--accent-soft);
}
.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.toolbar-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-mute);
}
.toolbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }

@media (max-width: 1024px) {
  .editor { grid-template-columns: 1fr; height: auto; }
  .editor-form { max-height: none; border-right: none; border-bottom: 1px solid var(--panel-line); }
}

/* Client picker chips */
.client-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}
.client-picker.has-client {
  border-color: var(--accent-dim);
  background: rgba(184, 148, 86, 0.06);
}
.client-picker .cp-info { flex: 1; min-width: 0; }
.client-picker .cp-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.client-picker .cp-meta { font-size: 11px; color: var(--text-mute); }
.client-picker .cp-empty { color: var(--text-mute); font-style: italic; font-size: 13px; }

/* ========================================
   Document preview (cream paper)
   ======================================== */
.doc-wrap {
  display: flex;
  justify-content: center;
  padding-bottom: 40px;
}
.document {
  width: 210mm;
  max-width: 100%;
  min-height: 297mm;
  background: var(--paper);
  color: var(--ink);
  padding: 22mm 24mm;
  font-family: var(--font-serif);
  font-size: 12.5pt;
  line-height: 1.65;
  box-shadow:
    0 1px 2px rgba(0,0,0,0.4),
    0 20px 50px rgba(0,0,0,0.35);
  position: relative;
}
.document::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid var(--paper-edge);
  pointer-events: none;
}

.doc-header-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--paper-edge);
}
.doc-header-logo img {
  max-height: 60px;
  max-width: 140px;
  object-fit: contain;
}
.doc-header-info {
  flex: 1;
  text-align: right;
  font-size: 10pt;
  line-height: 1.4;
  color: var(--ink-soft);
  font-family: var(--font-sans);
}
.doc-header-info strong {
  display: block;
  color: var(--ink);
  font-size: 11pt;
  margin-bottom: 2px;
}
.doc-header-info.no-logo { text-align: left; }

.doc-title {
  text-align: center;
  font-size: 20pt;
  font-weight: 600;
  letter-spacing: 0.16em;
  margin-bottom: 6px;
  text-transform: uppercase;
}
.doc-rule {
  width: 60px;
  height: 1px;
  background: var(--accent);
  margin: 0 auto 28px;
}
.doc-place {
  text-align: right;
  font-style: italic;
  margin-bottom: 22px;
  color: var(--ink-soft);
}
.doc-h2 {
  text-align: center;
  font-size: 13pt;
  font-weight: 600;
  letter-spacing: 0.18em;
  margin: 22px 0 14px;
  text-transform: uppercase;
}
.doc p { margin-bottom: 12px; text-align: justify; hyphens: auto; }
.doc strong { font-weight: 600; }
.stip { margin-bottom: 14px; }
.stip-title { font-weight: 600; display: inline; }

.signatures {
  margin-top: 50px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}
.sig-block { text-align: center; }
.sig-canvas-wrap {
  height: 110px;
  border-bottom: 1px solid var(--ink);
  margin-bottom: 8px;
  position: relative;
}
.sig-canvas-wrap canvas {
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  display: block;
}
.sig-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b8a989;
  font-style: italic;
  font-size: 11pt;
  pointer-events: none;
}
.sig-clear {
  position: absolute;
  top: 4px;
  right: 4px;
  background: transparent;
  border: none;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 6px;
  font-family: var(--font-sans);
  opacity: 0.5;
}
.sig-clear:hover { opacity: 1; color: var(--danger); }
.sig-label { font-size: 11pt; font-weight: 500; margin-top: 4px; }
.sig-name { font-size: 10pt; color: var(--ink-soft); margin-top: 2px; }

/* Table inside docs (e.g. presupuesto) */
.doc table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 11pt;
}
.doc table th, .doc table td {
  border-bottom: 1px solid var(--paper-edge);
  padding: 8px 6px;
  text-align: left;
}
.doc table th {
  font-weight: 600;
  border-bottom-color: var(--ink);
  font-size: 10pt;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.doc table td.num, .doc table th.num { text-align: right; }
.doc table tfoot td { font-weight: 600; border-bottom: none; padding-top: 12px; }

/* ========================================
   Modal
   ======================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-lg);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--panel-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  color: var(--accent-soft);
}
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-mute);
  font-size: 22px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { color: var(--text-light); }
.modal-body { padding: 22px 24px; }
.modal-foot {
  padding: 16px 24px;
  border-top: 1px solid var(--panel-line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ========================================
   Search bar
   ======================================== */
.searchbar {
  position: relative;
  margin-bottom: 18px;
}
.searchbar input {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  padding: 12px 14px 12px 40px;
  font-size: 14px;
  color: var(--text-light);
}
.searchbar input:focus { outline: none; border-color: var(--accent); }
.searchbar .si {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-mute);
}

/* ========================================
   Logo upload preview
   ======================================== */
.logo-uploader {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px;
  background: rgba(0,0,0,0.2);
  border: 1px dashed var(--panel-line);
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.logo-preview {
  width: 80px;
  height: 80px;
  background: var(--paper);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-preview .lp-empty {
  color: var(--ink-mute);
  font-size: 22px;
  font-family: var(--font-serif);
  font-style: italic;
}
.logo-actions { display: flex; flex-direction: column; gap: 8px; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--panel);
  border: 1px solid var(--accent-dim);
  color: var(--text-light);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 200;
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ========================================
   Responsive (mobile)
   ======================================== */
@media (max-width: 760px) {
  body { overflow: auto; }
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) 1fr auto;
    height: auto;
    min-height: 100vh;
  }
  .topbar { padding: 0 16px; }
  .brand-sub { display: none; }
  .sidenav {
    grid-row: 3;
    border-right: none;
    border-top: 1px solid var(--panel-line);
    padding: 6px;
    display: flex;
    justify-content: space-around;
    position: sticky;
    bottom: 0;
    z-index: 10;
  }
  .nav-section-label { display: none; }
  .nav-item {
    flex-direction: column;
    gap: 3px;
    padding: 8px 4px;
    font-size: 10px;
    flex: 1;
    text-align: center;
  }
  .main { overflow: visible; }
  .view { padding: 22px 18px 40px; }
  .view-title { font-size: 24px; }
  .editor {
    margin: -22px -18px 0;
    grid-template-columns: 1fr;
  }
  .editor-form { padding: 20px 16px 40px; }
  .editor-preview { padding: 20px 12px 40px; }
  .document { padding: 14mm 12mm; font-size: 11.5pt; }
  .signatures { grid-template-columns: 1fr; gap: 18px; }
}

/* Print */
@media print {
  body { overflow: visible; background: white; }
  .topbar, .sidenav, .editor-form, .preview-toolbar, .editor-header { display: none !important; }
  .app { display: block; height: auto; }
  .main { overflow: visible; }
  .view { padding: 0; }
  .editor { display: block; margin: 0; height: auto; }
  .editor-preview { background: white; padding: 0; }
  .document {
    box-shadow: none;
    width: 100%;
    min-height: auto;
    padding: 18mm;
  }
  .sig-clear, .sig-placeholder { display: none !important; }
}

/* ============================================================
   USER CHIP (topbar — usuario actual + logout)
   ============================================================ */
.user-chip {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 4px;
  border: 1px solid var(--line, #2a3142);
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
}
.user-chip.show { display: inline-flex; }
.uc-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent, #c9a96e);
  color: #1a1a1a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.5px;
}
.uc-name {
  color: var(--text, #e8ebf0);
  font-weight: 500;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.uc-role {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent, #c9a96e);
  padding: 2px 6px;
  border: 1px solid var(--accent, #c9a96e);
  border-radius: 100px;
  opacity: 0.85;
}
.uc-logout {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-mute, #8e95a3);
  font-size: 14px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.uc-logout:hover { background: rgba(236, 124, 124, 0.15); color: #ec7c7c; }

@media (max-width: 768px) {
  .uc-name { max-width: 80px; }
  .uc-role { display: none; }
}

/* ============================================================
   LOGIN OVERLAY
   ============================================================ */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(at 30% 20%, rgba(201, 169, 110, 0.08), transparent 60%),
    radial-gradient(at 70% 80%, rgba(26, 31, 46, 0.4), transparent 60%),
    #0f1115;
  padding: 24px;
  overflow-y: auto;
}
.login-overlay.show { display: flex; }
body.logged-out { overflow: hidden; }
body.logged-out .app { filter: blur(6px); pointer-events: none; user-select: none; }

.login-card {
  width: 100%;
  max-width: 380px;
  background: rgba(26, 31, 46, 0.95);
  border: 1px solid #2a3142;
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  animation: loginFadeIn 0.35s ease-out;
}
@keyframes loginFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-brand {
  text-align: center;
  margin-bottom: 26px;
  padding-bottom: 22px;
  border-bottom: 1px solid #2a3142;
}
.lb-mark {
  font-family: var(--font-serif, 'Cormorant Garamond', serif);
  font-size: 26px;
  font-weight: 600;
  color: #c9a96e;
  letter-spacing: 0.5px;
}
.lb-sub {
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #8e95a3;
  margin-top: 4px;
}

.login-form { display: flex; flex-direction: column; gap: 14px; }

.login-field { display: flex; flex-direction: column; gap: 6px; }
.login-field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #8e95a3;
  font-weight: 500;
}
.login-field input {
  background: #0f131c;
  border: 1px solid #2a3142;
  border-radius: 8px;
  padding: 11px 14px;
  color: #e8ebf0;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-field input:focus {
  outline: none;
  border-color: #c9a96e;
  box-shadow: 0 0 0 3px rgba(201, 169, 110, 0.12);
}

.login-message {
  display: none;
  font-size: 12px;
  padding: 9px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid #2a3142;
  color: #c9a96e;
  text-align: center;
  margin-top: 4px;
}
.login-message.show { display: block; }
.login-message.error {
  background: rgba(236, 124, 124, 0.1);
  border-color: rgba(236, 124, 124, 0.4);
  color: #ec7c7c;
}

.login-submit {
  margin-top: 8px;
  padding: 12px;
  background: #c9a96e;
  color: #1a1a1a;
  border: 0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.login-submit:hover:not(:disabled) { background: #d4b681; }
.login-submit:active:not(:disabled) { transform: scale(0.99); }
.login-submit:disabled { opacity: 0.5; cursor: not-allowed; }

.login-footer {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid #2a3142;
  font-size: 11px;
  text-align: center;
  color: #8e95a3;
  line-height: 1.5;
}

/* ============================================================
   USUARIOS — pills extra
   ============================================================ */
.pill-accent {
  background: rgba(201, 169, 110, 0.15) !important;
  color: var(--accent, #c9a96e) !important;
  border: 1px solid rgba(201, 169, 110, 0.4);
}
.pill-muted {
  background: rgba(255, 255, 255, 0.05) !important;
  color: var(--text-mute, #8e95a3) !important;
  border: 1px solid var(--line, #2a3142);
}
.list-row-muted { opacity: 0.55; }
.list-row-muted .lr-title { color: var(--text-mute, #8e95a3); }

/* Hint debajo de un campo */
.field .hint, .field > .hint {
  font-size: 11px;
  color: var(--text-mute, #8e95a3);
  margin-top: 4px;
  font-style: italic;
}

/* select disabled visual */
select:disabled { opacity: 0.6; cursor: not-allowed; }

/* ============================================================
   EDITOR DE PLANTILLAS — tabs, form designer, WYSIWYG, modal ancho
   ============================================================ */
.modal-card.modal-wide {
  max-width: min(960px, 96vw) !important;
  width: 96vw !important;
}
.modal-wide .modal-body {
  max-height: 78vh; overflow-y: auto;
}

.tpl-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--panel-line, #2a3142);
  margin-bottom: 16px;
}
.tpl-tab {
  background: transparent;
  border: 0;
  color: var(--text-mute, #8e95a3);
  padding: 10px 16px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.tpl-tab:hover { color: var(--text-light, #e6e9f0); }
.tpl-tab.active {
  color: var(--accent, #c9a96e);
  border-bottom-color: var(--accent, #c9a96e);
}
.tpl-tab-body { padding: 4px 2px; }

/* form designer */
.fd-section {
  background: rgba(0,0,0,0.18);
  border: 1px solid var(--panel-line, #2a3142);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 14px;
}
.fd-section-head {
  display: flex; gap: 8px; align-items: center; margin-bottom: 10px;
}
.fd-section-title {
  flex: 1;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--panel-line, #2a3142);
  color: var(--text-light, #e6e9f0);
  padding: 6px 10px;
  border-radius: 4px;
  font-weight: 600;
}
.fd-field {
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--panel-line, #2a3142);
  border-radius: 4px;
  padding: 10px;
  margin-bottom: 8px;
}

/* WYSIWYG */
.wy-toolbar {
  display: flex; gap: 4px; flex-wrap: wrap; align-items: center;
  padding: 6px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--panel-line, #2a3142);
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
}
.wy-toolbar button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-light, #e6e9f0);
  padding: 4px 10px;
  cursor: pointer;
  font-size: 13px;
  border-radius: 3px;
}
.wy-toolbar button:hover {
  background: rgba(255,255,255,0.07);
  border-color: var(--panel-line, #2a3142);
}
.wy-toolbar select {
  background: rgba(0,0,0,0.25);
  color: var(--text-light, #e6e9f0);
  border: 1px solid var(--panel-line, #2a3142);
  padding: 4px 6px;
  border-radius: 3px;
  font-size: 12px;
}
.wy-sep {
  width: 1px; height: 18px;
  background: var(--panel-line, #2a3142);
  margin: 0 4px;
}
.wy-editor {
  min-height: 320px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 14px;
  background: #fff;
  color: #111;
  border: 1px solid var(--panel-line, #2a3142);
  border-radius: 0 0 4px 4px;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 14px;
  line-height: 1.55;
}
.wy-editor:focus { outline: 2px solid var(--accent, #c9a96e); outline-offset: -2px; }
.wy-editor .stip {
  margin: 8px 0;
  padding-left: 0;
}
.wy-editor .stip-title { font-weight: 700; }
.wy-editor h2 { font-size: 16px; margin: 14px 0 8px; }
.wy-editor p  { margin: 6px 0; }
.wy-editor ul, .wy-editor ol { margin: 6px 0 6px 26px; }
.wy-editor table { border-collapse: collapse; width: 100%; margin: 8px 0; }
.wy-editor td, .wy-editor th { border: 1px solid #ccc; padding: 6px 8px; }

/* code inline (para mostrar marcadores en hints) */
code {
  background: rgba(0,0,0,0.3);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--accent, #c9a96e);
}

/* ============================================================
   LOGO DEL LOGIN
   ============================================================ */
.lb-logo {
  background: #ffffff;
  border-radius: 10px;
  padding: 16px 20px;
  margin: 0 auto 14px;
  max-width: 280px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.lb-logo img {
  display: block;
  width: 100%;
  height: auto;
}
/* En pantallas pequeñas, un pelín menos de padding para no comerse el espacio */
@media (max-width: 420px) {
  .lb-logo {
    max-width: 240px;
    padding: 12px 16px;
  }
}

/* ============================================================
   MEMBRETE — logo SCJE como fallback corporativo
   ============================================================ */
/* Cuando se usa el logo corporativo (firm-default) en lugar de uno personal,
   un poquito más grande porque es apaisado, y conserva la proporción.
   Si el letrado/a tiene logo personal, mantiene el tamaño compacto original. */
.doc-header-img.firm-default {
  max-height: 70px;
  max-width: 200px;
  object-fit: contain;
}

/* ============================================================
   BANNER DE ORIGEN EXTERNO — datos importados desde otra app
   ============================================================ */
.source-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
  padding: 10px 14px;
  background: linear-gradient(90deg, rgba(201,169,110,0.10), rgba(201,169,110,0.04));
  border: 1px solid rgba(201,169,110,0.35);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-light, #e6e9f0);
}
.sb-icon {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(201,169,110,0.20);
  color: var(--accent, #c9a96e);
  border-radius: 50%;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.sb-body { flex: 1; line-height: 1.4; }
.sb-title { font-weight: 500; }
.sb-meta { font-size: 11px; color: var(--text-mute, #8e95a3); margin-top: 2px; }
.sb-close {
  background: transparent;
  border: 0;
  color: var(--text-mute, #8e95a3);
  font-size: 18px;
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
}
.sb-close:hover { color: var(--text-light, #e6e9f0); }

/* ============================================================
   EXPEDIENTES (casos)
   ============================================================ */
.filters-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filters-bar .searchbar { flex: 1 1 280px; min-width: 220px; }
.filters-bar select {
  padding: 8px 12px;
  background: var(--surface, #1c1f26);
  border: 1px solid var(--border, #2a2e36);
  border-radius: 6px;
  color: var(--text-light, #e6e9f0);
  font-size: 13px;
  font-family: var(--font-sans);
}
.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-mute, #8e95a3);
  cursor: pointer;
  user-select: none;
}
.filter-toggle input { cursor: pointer; }

.caso-num {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  padding: 2px 6px;
  background: rgba(201,169,110,0.10);
  border: 1px solid rgba(201,169,110,0.25);
  border-radius: 4px;
  color: var(--accent, #c9a96e);
  letter-spacing: 0.04em;
}
.caso-prox { color: var(--accent, #c9a96e); font-weight: 500; }
.caso-row { transition: background 0.12s; }
.caso-row:hover { background: rgba(255,255,255,0.03); }

.caso-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 720px) {
  .caso-grid { grid-template-columns: 1fr; }
}

/* Pills por área jurídica */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 500;
  margin-left: 6px;
  border: 1px solid transparent;
  letter-spacing: 0.02em;
}
.pill-area-penal       { background: rgba(220,87,87,0.12);  color: #e08585; border-color: rgba(220,87,87,0.30); }
.pill-area-civil       { background: rgba(86,156,214,0.12); color: #82bcec; border-color: rgba(86,156,214,0.30); }
.pill-area-laboral     { background: rgba(220,150,50,0.12); color: #e0a96e; border-color: rgba(220,150,50,0.30); }
.pill-area-extranjeria { background: rgba(155,89,182,0.12); color: #b481cc; border-color: rgba(155,89,182,0.30); }
.pill-area-familia     { background: rgba(231,100,170,0.12);color: #e895c3; border-color: rgba(231,100,170,0.30); }
.pill-area-mercantil   { background: rgba(86,200,150,0.12); color: #7fd2af; border-color: rgba(86,200,150,0.30); }
.pill-area-contencioso { background: rgba(180,140,90,0.12); color: #c3a37c; border-color: rgba(180,140,90,0.30); }
.pill-area-otro        { background: rgba(140,140,140,0.10);color: #9da3ad; border-color: rgba(140,140,140,0.30); }

/* ============================================================
   DETALLE DE EXPEDIENTE — header + tabs + stepper
   ============================================================ */

/* --- Header --- */
.caso-head {
  background: var(--surface, #1c1f26);
  border: 1px solid var(--border, #2a2e36);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 14px;
}
.caso-head-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.caso-head-body {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.caso-head-title-wrap { flex: 1; min-width: 240px; }
.caso-head-title {
  margin: 0 0 4px;
  font-family: var(--font-serif, 'Cormorant Garamond', serif);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-light, #e6e9f0);
}
.caso-head-sub {
  font-size: 13px;
  color: var(--text-mute, #8e95a3);
  margin-bottom: 8px;
}
.caso-head-fase {
  font-size: 12px;
  color: var(--text-mute, #8e95a3);
}
.caso-head-fase strong {
  color: var(--text-light, #e6e9f0);
  font-weight: 500;
}
.caso-head-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* --- Estado badge (interno) --- */
.estado-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(150,150,150,0.10);
  border: 1px solid rgba(150,150,150,0.20);
  color: var(--text-light, #e6e9f0);
}
.estado-consulta_inicial,
.estado-encargo_aceptado          { background: rgba(86,156,214,0.10); border-color: rgba(86,156,214,0.25); color: #82bcec; }
.estado-en_estudio,
.estado-estrategia_definida       { background: rgba(155,89,182,0.10); border-color: rgba(155,89,182,0.25); color: #b481cc; }
.estado-denuncia_presentada,
.estado-denuncia_en_preparacion,
.estado-personado,
.estado-personacion_pendiente,
.estado-diligencias_previas_abiertas { background: rgba(220,150,50,0.10); border-color: rgba(220,150,50,0.25); color: #e0a96e; }
.estado-pendiente_provision_documental,
.estado-pendiente_declaraciones,
.estado-pendiente_prueba,
.estado-pendiente_senalamiento,
.estado-pendiente_sentencia       { background: rgba(245,200,80,0.10); border-color: rgba(245,200,80,0.25); color: #e8c878; }
.estado-juicio_senalado,
.estado-juicio_celebrado          { background: rgba(220,87,87,0.10); border-color: rgba(220,87,87,0.30); color: #e08585; }
.estado-sentencia_dictada,
.estado-en_ejecucion              { background: rgba(86,200,150,0.10); border-color: rgba(86,200,150,0.30); color: #7fd2af; }
.estado-valorando_recurso,
.estado-recurso_en_preparacion,
.estado-recurso_presentado        { background: rgba(86,156,214,0.10); border-color: rgba(86,156,214,0.25); color: #82bcec; }
.estado-archivo_sobreseimiento,
.estado-asunto_cerrado,
.estado-suspendido                { background: rgba(140,140,140,0.10); border-color: rgba(140,140,140,0.20); color: #9da3ad; }

/* --- Tabs --- */
.caso-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border, #2a2e36);
  margin-bottom: 14px;
  overflow-x: auto;
  scrollbar-width: none;
}
.caso-tabs::-webkit-scrollbar { display: none; }
.caso-tab {
  background: transparent;
  border: 0;
  padding: 10px 14px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-mute, #8e95a3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.caso-tab:hover { color: var(--text-light, #e6e9f0); }
.caso-tab.active {
  color: var(--accent, #c9a96e);
  border-bottom-color: var(--accent, #c9a96e);
  font-weight: 500;
}

/* --- Resumen layout 2 columnas --- */
.caso-resumen-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
@media (max-width: 880px) {
  .caso-resumen-grid { grid-template-columns: 1fr; }
}

/* --- Key/Value list --- */
.kv { display: flex; flex-direction: column; }
.kv-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border, #2a2e36);
  font-size: 13px;
}
.kv-row:last-child { border-bottom: 0; }
.kv-k {
  color: var(--text-mute, #8e95a3);
  font-size: 12px;
}
.kv-v { color: var(--text-light, #e6e9f0); word-break: break-word; }
@media (max-width: 480px) {
  .kv-row { grid-template-columns: 1fr; gap: 2px; }
}

/* --- Stepper vertical (fase procesal) --- */
.stepper { display: flex; flex-direction: column; }
.stepper-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
}
.stepper-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  grid-row: 1;
  grid-column: 1;
}
.stepper-bullet {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  border: 2px solid var(--border, #2a2e36);
  background: var(--surface, #1c1f26);
  color: var(--text-mute, #8e95a3);
  flex-shrink: 0;
  transition: all 0.2s;
}
.stepper-line {
  width: 2px;
  flex: 1;
  min-height: 22px;
  background: var(--border, #2a2e36);
  margin-top: 2px;
  margin-bottom: 2px;
}
.stepper-content {
  padding-top: 4px;
  padding-bottom: 16px;
  min-width: 0;
}
.stepper-label {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-light, #e6e9f0);
}
.stepper-desc {
  font-size: 11px;
  color: var(--text-mute, #8e95a3);
  margin-top: 4px;
  line-height: 1.45;
}

/* Estados */
.stepper-item.done .stepper-bullet {
  background: var(--accent, #c9a96e);
  border-color: var(--accent, #c9a96e);
  color: #fff;
}
.stepper-item.done .stepper-line.done { background: var(--accent, #c9a96e); }
.stepper-item.current .stepper-bullet {
  background: rgba(201,169,110,0.15);
  border-color: var(--accent, #c9a96e);
  color: var(--accent, #c9a96e);
}
.stepper-item.current .stepper-label {
  color: var(--accent, #c9a96e);
  font-weight: 600;
}
.stepper-item.pending .stepper-label { opacity: 0.5; }
.stepper-item.pending .stepper-bullet { opacity: 0.7; }

/* ============================================================
   HITOS / CALENDARIO
   ============================================================ */
.hito-row {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border, #2a2e36);
  border-radius: 6px;
  background: var(--surface, #1c1f26);
  align-items: start;
  margin-bottom: 6px;
}
.hito-row.is-done { opacity: 0.55; }
.hito-row.is-done .hito-title { text-decoration: line-through; }
.hito-row.is-late { border-color: rgba(220,87,87,0.45); background: rgba(220,87,87,0.04); }
.hito-row.is-soon { border-color: rgba(245,200,80,0.40); background: rgba(245,200,80,0.04); }

.hito-date {
  text-align: center;
  padding: 4px;
  border-right: 1px solid var(--border, #2a2e36);
  padding-right: 10px;
}
.hito-date-d { font-size: 22px; font-weight: 600; line-height: 1; color: var(--text-light, #e6e9f0); font-family: var(--font-serif, serif); }
.hito-date-m { font-size: 11px; color: var(--text-mute, #8e95a3); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }
.hito-date-h { font-size: 11px; color: var(--accent, #c9a96e); margin-top: 4px; font-family: ui-monospace, monospace; }

.hito-body { min-width: 0; }
.hito-title { font-size: 14px; font-weight: 500; color: var(--text-light, #e6e9f0); line-height: 1.3; margin-bottom: 4px; }
.hito-meta { font-size: 11px; color: var(--text-mute, #8e95a3); }
.hito-meta a { color: var(--accent, #c9a96e); text-decoration: none; }
.hito-meta a:hover { text-decoration: underline; }
.hito-vis { color: var(--accent, #c9a96e); }
.hito-late-lbl { color: #e08585; font-weight: 500; }
.hito-soon-lbl { color: #e8c878; font-weight: 500; }
.hito-desc { font-size: 12px; color: var(--text-mute, #8e95a3); margin-top: 6px; line-height: 1.4; white-space: pre-wrap; }

.hito-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

/* Agenda agrupada por fecha */
.agenda-group {
  margin-bottom: 18px;
}
.agenda-date {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-mute, #8e95a3);
  margin-bottom: 6px;
  padding: 4px 0;
  text-transform: capitalize;
  border-bottom: 1px solid var(--border, #2a2e36);
}
.agenda-group.is-today .agenda-date {
  color: var(--accent, #c9a96e);
  border-bottom-color: var(--accent, #c9a96e);
  font-weight: 600;
}
.agenda-today {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  background: var(--accent, #c9a96e);
  color: #fff;
  font-size: 10px;
  border-radius: 999px;
  letter-spacing: 0.05em;
}

@media (max-width: 540px) {
  .hito-row { grid-template-columns: 50px 1fr; }
  .hito-actions { grid-column: 2; justify-content: flex-end; margin-top: 4px; }
}

/* ============================================================
   GESTIÓN ECONÓMICA
   ============================================================ */
.econ-summary-card { margin-bottom: 12px; }
.econ-summary-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 8px;
  flex-wrap: wrap;
}

.econ-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 10px;
  margin-bottom: 14px;
}
@media (max-width: 640px) {
  .econ-summary-grid { grid-template-columns: 1fr; }
}

.econ-stat {
  padding: 12px 14px;
  background: var(--surface-soft, rgba(255,255,255,0.02));
  border: 1px solid var(--border, #2a2e36);
  border-radius: 8px;
}
.econ-stat-label {
  font-size: 11px;
  color: var(--text-mute, #8e95a3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.econ-stat-value {
  font-family: var(--font-serif, serif);
  font-size: 22px;
  font-weight: 600;
  color: var(--text-light, #e6e9f0);
  line-height: 1.1;
}
.econ-stat-sub {
  font-size: 11px;
  color: var(--text-mute, #8e95a3);
  margin-top: 4px;
}
.econ-stat.is-paid    .econ-stat-value { color: #7fd2af; }
.econ-stat.is-pending .econ-stat-value { color: #e8c878; }
.econ-stat.is-ok      .econ-stat-value { color: #7fd2af; }

.econ-progress {
  height: 6px;
  background: var(--border, #2a2e36);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}
.econ-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent, #c9a96e), #7fd2af);
  transition: width 0.3s ease;
}

.econ-suplidos {
  font-size: 12px;
  padding: 8px 10px;
  background: rgba(220,150,50,0.08);
  border: 1px solid rgba(220,150,50,0.25);
  border-radius: 6px;
  color: var(--text-light, #e6e9f0);
  margin-bottom: 10px;
}
.econ-suplidos .hint { color: var(--text-mute, #8e95a3); font-style: italic; }

.econ-forma-pago {
  padding: 10px 12px;
  background: rgba(255,255,255,0.02);
  border-left: 3px solid var(--accent, #c9a96e);
  border-radius: 4px;
  margin-bottom: 8px;
}
.econ-forma-pago-label {
  font-size: 11px;
  color: var(--text-mute, #8e95a3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.econ-forma-pago-text {
  font-size: 13px;
  color: var(--text-light, #e6e9f0);
  white-space: pre-wrap;
  line-height: 1.5;
}

.econ-budget-ok {
  display: inline-block;
  font-size: 12px;
  padding: 4px 10px;
  background: rgba(127,210,175,0.10);
  border: 1px solid rgba(127,210,175,0.30);
  color: #7fd2af;
  border-radius: 999px;
  font-weight: 500;
}

/* Filas de movimientos */
.pago-row {
  display: grid;
  grid-template-columns: 56px 1fr auto auto;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border, #2a2e36);
  border-radius: 6px;
  background: var(--surface, #1c1f26);
  margin-bottom: 6px;
  align-items: center;
}
.pago-date {
  text-align: center;
  padding-right: 8px;
  border-right: 1px solid var(--border, #2a2e36);
}
.pago-date-d { font-size: 20px; font-weight: 600; line-height: 1; color: var(--text-light, #e6e9f0); font-family: var(--font-serif, serif); }
.pago-date-m { font-size: 10px; color: var(--text-mute, #8e95a3); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }

.pago-body { min-width: 0; }
.pago-tipo {
  font-size: 11px;
  color: var(--accent, #c9a96e);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.pago-concepto {
  font-size: 13px;
  color: var(--text-light, #e6e9f0);
  font-weight: 500;
  line-height: 1.3;
}
.pago-meta {
  font-size: 11px;
  color: var(--text-mute, #8e95a3);
  margin-top: 3px;
}

.pago-amount {
  text-align: right;
  white-space: nowrap;
  padding-right: 4px;
}
.pago-amount-num {
  font-family: var(--font-serif, serif);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.pago-row.pago-in  .pago-amount-num { color: #7fd2af; }
.pago-row.pago-out .pago-amount-num { color: #e08585; }
.pago-row.pago-tipo-suplido .pago-amount-num { color: #e0a96e; }

.pago-actions {
  display: flex;
  gap: 2px;
}

@media (max-width: 540px) {
  .pago-row {
    grid-template-columns: 48px 1fr;
    gap: 10px;
  }
  .pago-amount { grid-column: 2; text-align: left; padding-right: 0; padding-top: 4px; }
  .pago-actions { grid-column: 2; justify-content: flex-end; }
}

/* ============================================================
   PORTAL CLIENTE
   ============================================================ */

/* Tarjetas de stats en el panel del cliente */
.cli-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.cli-stat-card {
  padding: 18px 20px;
  background: var(--surface, #1c1f26);
  border: 1px solid var(--border, #2a2e36);
  border-radius: 10px;
}
.cli-stat-num {
  font-family: var(--font-serif, serif);
  font-size: 36px;
  font-weight: 600;
  color: var(--accent, #c9a96e);
  line-height: 1;
  margin-bottom: 4px;
}
.cli-stat-label {
  font-size: 12px;
  color: var(--text-mute, #8e95a3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Tarjeta resumen del estado del asunto */
.cli-summary-card {
  border-left: 3px solid var(--accent, #c9a96e);
}

/* Fila de expediente del cliente (clic en toda la fila) */
.cli-exp-row { cursor: pointer; transition: background 0.15s; }
.cli-exp-row:hover { background: rgba(201,169,110,0.05); }

/* Cuenta del cliente (en panel) */
.cli-account-card { background: rgba(255,255,255,0.02); }

/* Avatar role pill para cliente */
.uc-role-cliente { background: rgba(201,169,110,0.20) !important; color: var(--accent, #c9a96e) !important; }

/* ============================================================
   TIEMPOS (time tracking)
   ============================================================ */
.tiempo-row {
  display: grid;
  grid-template-columns: 56px 1fr auto auto;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border, #2a2e36);
  border-radius: 6px;
  background: var(--surface, #1c1f26);
  margin-bottom: 6px;
  align-items: start;
}
.tiempo-row.no-fact { opacity: 0.72; }
.tiempo-date { text-align: center; padding-right: 8px; border-right: 1px solid var(--border, #2a2e36); }
.tiempo-date-d { font-size: 20px; font-weight: 600; line-height: 1; color: var(--text-light, #e6e9f0); font-family: var(--font-serif, serif); }
.tiempo-date-m { font-size: 10px; color: var(--text-mute, #8e95a3); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }
.tiempo-body { min-width: 0; }
.tiempo-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.tiempo-cat {
  font-size: 11px; color: var(--accent, #c9a96e);
  text-transform: uppercase; letter-spacing: 0.04em; font-weight: 500;
}
.tiempo-fac {
  font-size: 10px; padding: 1px 6px; border-radius: 999px;
}
.tiempo-fac.is-fac { background: rgba(127,210,175,0.12); color: #7fd2af; border: 1px solid rgba(127,210,175,0.3); }
.tiempo-fac.is-nofac { background: rgba(140,140,140,0.10); color: #9da3ad; border: 1px solid rgba(140,140,140,0.20); }
.tiempo-desc { font-size: 13px; color: var(--text-light, #e6e9f0); line-height: 1.4; }
.tiempo-meta { font-size: 11px; color: var(--text-mute, #8e95a3); margin-top: 4px; }
.tiempo-dur { text-align: right; white-space: nowrap; padding-right: 4px; }
.tiempo-dur-num { font-family: var(--font-serif, serif); font-size: 16px; font-weight: 600; color: var(--text-light, #e6e9f0); }
.tiempo-importe { font-size: 11px; color: #7fd2af; margin-top: 2px; font-family: ui-monospace, monospace; }
.tiempo-actions { display: flex; gap: 2px; }
@media (max-width: 540px) {
  .tiempo-row { grid-template-columns: 48px 1fr; gap: 10px; }
  .tiempo-dur { grid-column: 2; text-align: left; padding-right: 0; }
  .tiempo-actions { grid-column: 2; justify-content: flex-end; }
}

/* ============================================================
   REPORTES
   ============================================================ */
.rep-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.rep-kpi {
  padding: 14px 16px;
  background: var(--surface, #1c1f26);
  border: 1px solid var(--border, #2a2e36);
  border-radius: 8px;
}
.rep-kpi-lbl {
  font-size: 11px;
  color: var(--text-mute, #8e95a3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.rep-kpi-num {
  font-family: var(--font-serif, serif);
  font-size: 24px;
  font-weight: 600;
  color: var(--text-light, #e6e9f0);
  line-height: 1.1;
}
.rep-kpi-money { color: #7fd2af; }
.rep-kpi-warn  { color: #e8c878; }
.rep-kpi-sub {
  font-size: 11px;
  color: var(--text-mute, #8e95a3);
  margin-top: 4px;
}

.rep-bars { display: flex; flex-direction: column; gap: 8px; }
.rep-bar-row {
  display: grid;
  grid-template-columns: 100px 1fr 80px;
  gap: 10px;
  align-items: center;
}
.rep-bar-lbl { font-size: 12px; color: var(--text-light, #e6e9f0); }
.rep-bar-track {
  height: 8px;
  background: rgba(255,255,255,0.05);
  border-radius: 999px;
  overflow: hidden;
}
.rep-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent, #c9a96e), #7fd2af);
}
.rep-bar-val { font-size: 12px; color: var(--text-mute, #8e95a3); text-align: right; font-family: ui-monospace, monospace; }
@media (max-width: 540px) {
  .rep-bar-row { grid-template-columns: 80px 1fr 70px; gap: 6px; }
  .rep-bar-lbl { font-size: 11px; }
}

.rep-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
@media (max-width: 880px) { .rep-2col { grid-template-columns: 1fr; } }

.rep-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.rep-table thead th {
  text-align: left;
  font-size: 11px;
  color: var(--text-mute, #8e95a3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border, #2a2e36);
  padding: 6px 8px;
  font-weight: 500;
}
.rep-table tbody td {
  padding: 8px;
  border-bottom: 1px solid var(--border, #2a2e36);
  color: var(--text-light, #e6e9f0);
}
.rep-table tbody tr:last-child td { border-bottom: 0; }
.rep-table .rep-num { text-align: right; font-family: ui-monospace, monospace; }
.rep-table .rep-mute { color: var(--text-mute, #8e95a3); }
.rep-table .rep-warn { color: #e8c878; }

/* Caso picker en el editor */
.caso-picker {
  border: 1px solid var(--border, #2a2e36);
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--surface, #1c1f26);
  margin-bottom: 8px;
}
.caso-picker.is-empty { background: rgba(255,255,255,0.02); border-style: dashed; }
.caso-pick-row { cursor: pointer; }
.caso-pick-row:hover { background: rgba(201,169,110,0.06); }
.caso-pick-row.is-recommended { border-left: 3px solid var(--accent, #c9a96e); }

/* ============================================================
   DROPZONE & UPLOADS
   ============================================================ */
.dropzone {
  border: 2px dashed var(--border, #2a2e36);
  border-radius: 10px;
  padding: 28px 18px;
  text-align: center;
  cursor: pointer;
  background: rgba(255,255,255,0.02);
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 12px;
}
.dropzone:hover { background: rgba(255,255,255,0.04); border-color: var(--accent, #c9a96e); }
.dropzone.is-dragover {
  background: rgba(201,169,110,0.10);
  border-color: var(--accent, #c9a96e);
  border-style: solid;
}
.dz-icon { font-size: 32px; opacity: 0.7; margin-bottom: 4px; }
.dz-text { font-size: 14px; color: var(--text-light, #e6e9f0); margin-bottom: 2px; }
.dz-sub { font-size: 11px; color: var(--text-mute, #8e95a3); }
.dz-options { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border, #2a2e36); display: inline-block; }
.dz-options label { cursor: pointer; }
.dz-options input { cursor: pointer; margin-right: 4px; }

.dz-progress {
  margin-top: 8px;
  padding: 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.03);
  font-size: 12px;
}
.dz-progress-row {
  display: flex; justify-content: space-between;
  padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,0.05);
}
.dz-progress-row:last-child { border-bottom: 0; }
.dzp-name { color: var(--text-light, #e6e9f0); }
.dzp-status { color: var(--text-mute, #8e95a3); }

.upload-list {
  display: flex; flex-direction: column; gap: 6px;
}
.upload-row {
  display: grid;
  grid-template-columns: 36px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: var(--surface, #1c1f26);
  border: 1px solid var(--border, #2a2e36);
  border-radius: 6px;
}
.upl-ic { font-size: 22px; text-align: center; }
.upl-body { min-width: 0; }
.upl-name {
  font-size: 13px; font-weight: 500;
  color: var(--accent, #c9a96e);
  cursor: pointer; text-decoration: underline;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.upl-name:hover { color: var(--text-light, #e6e9f0); }
.upl-meta {
  font-size: 11px; color: var(--text-mute, #8e95a3); margin-top: 2px;
}
.upl-badges { display: flex; flex-direction: column; gap: 2px; align-items: flex-end; }
.upl-badge {
  font-size: 9px; padding: 1px 6px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.04em;
  white-space: nowrap;
}
.upl-badge.is-cliente { background: rgba(127,210,175,0.12); color: #7fd2af; border: 1px solid rgba(127,210,175,0.3); }
.upl-badge.is-interno { background: rgba(140,140,140,0.10); color: #9da3ad; border: 1px solid rgba(140,140,140,0.20); }
.upl-badge.is-by-client { background: rgba(82,148,214,0.12); color: #6aa5d6; border: 1px solid rgba(82,148,214,0.3); }
.upl-actions { display: flex; gap: 2px; }
@media (max-width: 540px) {
  .upload-row { grid-template-columns: 32px 1fr auto; }
  .upl-badges { grid-column: 2 / span 2; flex-direction: row; align-items: flex-start; margin-top: 4px; }
  .upl-actions { grid-row: 1; }
}

/* Fila de documento generado por plantilla (vs archivo subido) */
.upload-row.doc-row {
  background: rgba(201,169,110,0.04);
  border-left: 3px solid var(--accent, #c9a96e);
}
.doc-tplbadge {
  background: rgba(201,169,110,0.12);
  color: var(--accent, #c9a96e);
  padding: 1px 6px; border-radius: 3px;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
}
.upl-badge.is-generated {
  background: rgba(201,169,110,0.12);
  color: var(--accent, #c9a96e);
  border: 1px solid rgba(201,169,110,0.3);
}

/* ============================================================
   AUDITORÍA
   ============================================================ */
.audit-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  align-items: end;
}
.audit-summary {
  display: grid;
  grid-template-columns: 160px 1fr 1fr;
  gap: 16px;
  margin-top: 8px;
}
@media (max-width: 720px) {
  .audit-summary { grid-template-columns: 1fr; }
}
.audit-stat-big {
  background: rgba(201,169,110,0.06);
  border: 1px solid rgba(201,169,110,0.2);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}
.audit-stat-num {
  font-family: var(--font-serif, serif);
  font-size: 36px;
  font-weight: 600;
  color: var(--accent, #c9a96e);
  line-height: 1;
}
.audit-stat-lbl {
  font-size: 11px;
  color: var(--text-mute, #8e95a3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 6px;
}
.audit-col-h {
  font-size: 11px;
  color: var(--text-mute, #8e95a3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.audit-day {
  margin-bottom: 14px;
}
.audit-day-head {
  font-size: 12px;
  color: var(--text-mute, #8e95a3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 0;
  border-bottom: 1px solid var(--border, #2a2e36);
  margin-bottom: 4px;
}
.audit-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 10px;
  padding: 6px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  align-items: start;
}
.audit-row:last-child { border-bottom: 0; }
.audit-time {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--text-mute, #8e95a3);
  padding-top: 2px;
}
.audit-body { min-width: 0; }
.audit-line { font-size: 13px; line-height: 1.4; color: var(--text-light, #e6e9f0); }
.audit-action { color: var(--text-mute, #aab); }
.audit-target { color: var(--accent, #c9a96e); }
.audit-link { cursor: pointer; text-decoration: underline; }
.audit-extra { font-size: 11px; color: var(--text-mute, #888); margin-top: 2px; }
.audit-rol {
  font-size: 9px; padding: 1px 5px; border-radius: 999px;
  background: rgba(140,140,140,0.10); color: #9da3ad;
  border: 1px solid rgba(140,140,140,0.20);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-left: 4px;
}
.audit-ip {
  font-family: ui-monospace, monospace;
  font-size: 10px;
  color: var(--text-mute, #6a7282);
  align-self: center;
}

/* ============================================================
   ONEDRIVE
   ============================================================ */
.sp-pill {
  font-size: 11px; padding: 3px 10px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.04em; font-weight: 500;
  white-space: nowrap;
}
.sp-pill-ok   { background: rgba(127,210,175,0.15); color:#7fd2af; border:1px solid rgba(127,210,175,0.3); }
.sp-pill-warn { background: rgba(232,200,120,0.15); color:#e8c878; border:1px solid rgba(232,200,120,0.3); }
.sp-pill-off  { background: rgba(140,140,140,0.10); color:#9da3ad; border:1px solid rgba(140,140,140,0.20); }

.sp-steps {
  margin: 8px 0 0 20px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-light, #e6e9f0);
}
.sp-steps li { margin-bottom: 6px; }
.sp-steps code {
  background: rgba(255,255,255,0.05);
  padding: 1px 6px; border-radius: 3px;
  font-size: 90%;
  color: var(--accent, #c9a96e);
}
.sp-steps a { color: var(--accent, #c9a96e); }

/* === Texto justificado en la vista previa de documentos === */
.document.preview-justify .doc-body { text-align: justify; hyphens: auto; }
.document.preview-justify .doc-body p,
.document.preview-justify .doc-body .stip {
  text-align: justify;
  hyphens: auto;
  margin-bottom: 12px;
}
.document.preview-justify .doc-body .stip-title { font-weight: 600; }

/* Tamaño de letra de los documentos: más legible y ocupa toda la página */
.document.preview-justify { font-size: 11pt; line-height: 1.55; padding: 22mm 24mm; }
.document.preview-justify .doc-body { text-align: justify; hyphens: auto; }
.document.preview-justify .doc-body p,
.document.preview-justify .doc-body .stip {
  text-align: justify;
  hyphens: auto;
  margin-bottom: 10px;
}
.document.preview-justify .doc-body .stip-title { font-weight: 600; }

/* Botones que no se imprimen ni se ven en PDF */
.no-pdf { } /* placeholder; el JS los oculta */
@media print { .no-pdf { display:none !important; } }

/* === Vista previa expandida (sin formulario a la izquierda) === */
.editor.preview-fullwidth { grid-template-columns: 1fr !important; }
.editor.preview-fullwidth .editor-preview { padding-left: 40px; padding-right: 40px; }

/* Botón "Editar texto" cuando está activo */
.btn.editing { background: #c9a96e; color: #1a1a1a; }

/* Indicador visual de edición en línea */
[contenteditable="true"] { caret-color: #c9a96e; }
[contenteditable="true"]:focus { outline-color: #c9a96e !important; }

/* === Marcadores de salto de página automáticos (líneas en la vista previa) === */
.page-boundary-marker {
  position: absolute;
  left: -8px;
  right: -8px;
  height: 0;
  border-top: 1px dashed rgba(201, 169, 110, 0.7);
  pointer-events: none;
  z-index: 50;
}
.page-boundary-marker::after {
  content: '— corte de página —';
  position: absolute;
  top: -7px;
  right: 4px;
  background: #c9a96e;
  color: #1a1a1a;
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 2px;
  font-family: sans-serif;
}

/* === Salto manual (visible en la previa, oculto al imprimir/PDF) === */
.page-break {
  border-top: 2px dashed #c9a96e;
  color: #c9a96e;
  text-align: center;
  padding: 4px 0;
  margin: 12px 0;
  font-size: 10px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  font-family: sans-serif;
  user-select: none;
  page-break-after: always;
}

/* === Dropdown del botón Descargar === */
.dropdown-wrap { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: #1f2433;
  border: 1px solid #2a3042;
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  z-index: 100;
  min-width: 220px;
  overflow: hidden;
}
.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 10px 14px;
  color: #e6e9f0;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.dropdown-item:hover { background: #2a3042; color: #c9a96e; }
