*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f3f3f3;
  --surface: #ffffff;
  --surface-2: #f0f0f0;
  --border: #e1e1e1;
  --border-dark: #c8c8c8;
  --text: #242424;
  --text-2: #616161;
  --text-3: #a0a0a0;
  --accent: #0f6cbd;
  --accent-dark: #0c5aa6;
  --accent-light: #dce9f9;
  --danger: #c4314b;
  --danger-light: #fdf0f2;
  --success: #166534;
  --success-light: #dcfce7;
  --warning: #9a3412;
  --warning-light: #ffedd5;
  --radius: 4px;
  --radius-lg: 6px;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.page { max-width: 1400px; margin: 0 auto; }

/* ── Top bar (igual que en plan-rehabilita-2026) ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0f6cbd;
  padding: 14px 24px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-size: 16px; font-weight: 600; }
.brand:hover { opacity: 0.9; }
.brand-divider { width: 1px; height: 18px; background: rgba(255,255,255,0.35); }
.brand-logo { font-size: 15px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.sync-badge {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500;
  padding: 3px 10px; border-radius: 20px;
  color: #fff; background: rgba(255,255,255,0.15);
}
.sync-badge.sync-ok { background: rgba(255,255,255,0.25); }
.sync-badge.sync-error { background: rgba(255,0,0,0.25); }
.btn-new {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 16px;
  background: #fff; color: var(--accent);
  border: none; border-radius: var(--radius);
  font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer;
}
.btn-new:hover { background: #f0f0f0; }

/* ── Layout de dos columnas ── */
.layout { display: flex; min-height: calc(100vh - 53px); }

.sidebar {
  width: 300px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: #f5f5f5; border: 1px solid #e0e0e0; border-radius: var(--radius);
  padding: 0 10px; height: 36px;
}
.search-box:focus-within { background: #fff; border-color: var(--accent); }
.search-box i { color: var(--text-3); font-size: 13px; }
.search-box input { border: none; background: none; outline: none; font-size: 13px; font-family: inherit; flex: 1; color: var(--text); }
.stats { font-size: 12px; color: var(--text-3); padding: 0 2px; }

.expediente-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.expediente-card {
  display: block; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 10px 12px; cursor: pointer; font-family: inherit;
}
.expediente-card:hover { border-color: var(--border-dark); }
.expediente-card.active { background: var(--accent-light); border-color: var(--accent); }
.expediente-card-nombre { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.expediente-card-dir { font-size: 11.5px; color: var(--text-3); margin-bottom: 6px; }

.badge-estado {
  display: inline-block; font-size: 10.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 10px;
}

/* ── Panel de detalle ── */
.detail { flex: 1; padding: 24px 32px; min-width: 0; overflow-y: auto; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 60vh; color: var(--text-3); gap: 10px; }
.empty-state i { font-size: 28px; opacity: 0.5; }
.empty-state p { font-size: 14px; }

.detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.detail-header h1 { font-size: 22px; font-weight: 600; color: var(--text); }
.detail-subtitle { font-size: 13px; color: var(--text-3); margin-top: 3px; }
.detail-header-actions { display: flex; align-items: center; gap: 8px; }

.estado-select {
  font-size: 12px; font-weight: 600; border: none; border-radius: 14px;
  padding: 5px 10px; font-family: inherit; cursor: pointer;
}
.btn-icon { background: none; border: none; color: var(--text-3); cursor: pointer; padding: 6px; border-radius: var(--radius); font-size: 14px; }
.btn-icon:hover { background: var(--surface-2); color: var(--danger); }

/* ── Tabs ── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.tab-btn {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-2); font-size: 13px; font-weight: 500; font-family: inherit;
  padding: 9px 12px; cursor: pointer; margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Tarjetas de resumen ── */
.summary-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; max-width: 680px; position: relative; }
.summary-edit-btn { position: absolute; top: 14px; right: 14px; background: none; border: none; color: var(--text-3); cursor: pointer; padding: 6px; border-radius: var(--radius); }
.summary-edit-btn:hover { background: var(--surface-2); color: var(--accent); }
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; }
.summary-field-label { font-size: 11px; color: var(--text-3); margin-bottom: 2px; }
.summary-field-value { font-size: 14px; font-weight: 500; color: var(--text); }
.summary-notes { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }

/* ── Listas de items (contactos, requisitos, documentos, cronograma, actas) ── */
.toolbar-row { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.item-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 12px 16px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  margin-bottom: 8px;
}
.item-main { flex: 1; min-width: 0; }
.item-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.item-meta { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.item-notes { font-size: 12px; color: var(--text-2); margin-top: 4px; line-height: 1.4; }
.item-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.group-label { font-size: 11.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; margin: 18px 0 8px; }
.group-label:first-child { margin-top: 0; }

.status-select { font-size: 11.5px; font-weight: 600; border: none; border-radius: 6px; padding: 4px 8px; font-family: inherit; cursor: pointer; }

.crono-step { font-size: 11px; font-weight: 700; color: var(--text-3); min-width: 20px; padding-top: 2px; }

/* ── Tabla de presupuesto ── */
.budget-total { background: var(--success-light); border-radius: var(--radius-lg); padding: 10px 16px; display: inline-block; }
.budget-total-label { font-size: 11px; color: var(--success); }
.budget-total-value { font-size: 18px; font-weight: 700; color: var(--success); }
.budget-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.budget-table th { text-align: left; padding: 8px 6px; color: var(--text-3); font-weight: 600; border-bottom: 1px solid var(--border); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.budget-table td { padding: 10px 6px; border-bottom: 1px solid var(--surface-2); }
.budget-table .amount { text-align: right; font-weight: 600; }

/* ── Empty state pequeño dentro de pestañas ── */
.tab-empty { text-align: center; padding: 40px 20px; color: var(--text-3); }
.tab-empty i { font-size: 26px; margin-bottom: 10px; opacity: 0.5; }
.tab-empty p { font-size: 13px; margin-bottom: 14px; }

/* ── Modal (igual que plan-rehabilita-2026) ── */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; overflow-y: auto; }
.modal-overlay.open { display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal { background: var(--surface); border-radius: var(--radius-lg); width: 480px; max-width: calc(100vw - 48px); max-height: calc(100vh - 48px); overflow-y: auto; box-shadow: 0 24px 64px rgba(0,0,0,0.25); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-3); font-size: 15px; padding: 4px 8px; border-radius: 4px; }
.modal-close:hover { background: var(--surface-2); }
.modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12px; font-weight: 500; color: var(--text-2); }
.form-group input, .form-group select, .form-group textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; font-family: inherit; color: var(--text); background: var(--surface);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--accent); }
.form-group textarea { resize: vertical; min-height: 70px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-divider { border-top: 1px solid var(--border); margin: 4px 0; }
.form-check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }

.btn-cancel { padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text-2); font-size: 13px; font-family: inherit; cursor: pointer; }
.btn-cancel:hover { background: var(--surface-2); }
.btn-save {
  display: flex; align-items: center; gap: 7px; padding: 8px 18px;
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; font-family: inherit; cursor: pointer;
}
.btn-save:hover { background: var(--accent-dark); }
.btn-save:disabled { opacity: 0.6; cursor: default; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--text); color: #fff;
  padding: 10px 18px; border-radius: var(--radius); font-size: 13px; font-weight: 500;
  opacity: 0; transform: translateY(8px); transition: all 0.25s; pointer-events: none; z-index: 9999;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
}
