@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
  --cafe: #4a3728;
  --oliva: #6b7654;
  --dorado: #b8925a;
  --crema: #f7f2ea;
  --crema-dark: #ece3d3;
  --text: #2e241c;
  --danger: #a44a3f;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Inter', sans-serif; background: var(--crema); color: var(--text); }
h1, h2, h3 { font-family: 'Cormorant Garamond', serif; margin: 0; }

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, var(--cafe), var(--oliva)); }
.login-card { background: var(--crema); padding: 40px 36px; border-radius: 10px; width: 320px; box-shadow: 0 20px 50px rgba(0,0,0,0.25); text-align: center; }
.login-card h1 { font-size: 32px; color: var(--cafe); }
.login-card .subtitle { color: var(--oliva); margin-bottom: 24px; font-size: 14px; }
.login-card form { display: flex; flex-direction: column; text-align: left; }
.login-card label { font-size: 12px; margin: 10px 0 4px; color: var(--cafe); font-weight: 600; }
.login-card input { padding: 10px 12px; border: 1px solid var(--crema-dark); border-radius: 6px; font-size: 14px; }
.login-card button { margin-top: 20px; padding: 11px; background: var(--dorado); color: white; border: none; border-radius: 6px; font-weight: 600; cursor: pointer; font-size: 15px; }
.login-card button:hover { background: var(--cafe); }
.error { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 16px; }

/* Dashboard */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 28px; background: var(--cafe); color: var(--crema); }
.topbar .brand { font-family: 'Cormorant Garamond', serif; font-size: 24px; letter-spacing: 0.5px; }
.user-box { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.role-badge { background: rgba(255,255,255,0.15); padding: 3px 10px; border-radius: 10px; font-size: 11px; }
.user-box button { background: transparent; border: 1px solid var(--crema); color: var(--crema); padding: 6px 14px; border-radius: 6px; cursor: pointer; }
.user-box button:hover { background: var(--crema); color: var(--cafe); }

.tabs { display: flex; gap: 4px; padding: 16px 28px 0; flex-wrap: wrap; }
.tab-btn { padding: 9px 16px; border: none; background: var(--crema-dark); color: var(--cafe); border-radius: 8px 8px 0 0; cursor: pointer; font-weight: 600; font-size: 13px; }
.tab-btn.active { background: var(--oliva); color: white; }

main { padding: 0 28px 40px; }
.tab-panel { display: none; background: white; border-radius: 0 8px 8px 8px; padding: 24px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.tab-panel.active { display: block; }

.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.panel-header h2 { color: var(--cafe); }
.panel-header button, .btn-secondary { background: var(--dorado); color: white; border: none; padding: 9px 16px; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 13px; }
.panel-header button:hover, .btn-secondary:hover { background: var(--cafe); }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; padding: 10px 12px; background: var(--crema-dark); color: var(--cafe); font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--crema-dark); vertical-align: top; }
.data-table tr:hover td { background: #fbf8f2; }
.data-table button { border: none; background: none; cursor: pointer; color: var(--oliva); font-size: 12px; margin-right: 8px; }
.data-table button.delete { color: var(--danger); }
.data-table .empty { text-align: center; color: #999; padding: 20px; }
.restricted-row td { background: #fdf3f1 !important; }

.status-badge { padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; background: var(--crema-dark); color: var(--cafe); }

/* View switch (actores) */
.view-switch { display: flex; gap: 2px; background: var(--crema-dark); border-radius: 6px; padding: 2px; }
.view-btn { border: none; background: transparent; padding: 6px 12px; font-size: 12px; border-radius: 4px; cursor: pointer; color: var(--cafe); }
.view-btn.active { background: var(--dorado); color: white; }

/* Lanes */
.lanes { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 10px; }
.lane { min-width: 220px; flex-shrink: 0; }
.lane-title { color: white; padding: 8px 12px; border-radius: 6px 6px 0 0; font-size: 13px; font-weight: 600; }
.lane-body { background: #fbf8f2; border: 1px solid var(--crema-dark); border-top: none; border-radius: 0 0 6px 6px; padding: 10px; min-height: 200px; }
.actor-card { background: white; border: 1px solid var(--crema-dark); border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 2px; }
.actor-card small { color: #777; font-size: 11px; }
.actor-card small.org { font-style: italic; }
.restricted-card { border-color: var(--danger); background: #fdf3f1; }

/* Network */
.network-wrap { text-align: center; }
.network-wrap .hint { font-size: 11px; color: #999; margin-top: 6px; }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); align-items: center; justify-content: center; z-index: 100; overflow-y: auto; padding: 30px 0; }
.modal-overlay.active { display: flex; }
.modal { background: white; padding: 24px; border-radius: 10px; width: 460px; max-width: 90vw; max-height: 85vh; overflow-y: auto; }
.modal h3 { color: var(--cafe); margin-bottom: 14px; }
.modal label { display: block; font-size: 12px; font-weight: 600; color: var(--cafe); margin: 10px 0 4px; }
.modal input, .modal select, .modal textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--crema-dark); border-radius: 6px; font-size: 13px; font-family: inherit; }
.modal textarea { min-height: 60px; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-actions button { padding: 9px 18px; border-radius: 6px; border: none; cursor: pointer; font-weight: 600; font-size: 13px; }
.modal-actions button#modalSave { background: var(--dorado); color: white; }
.modal-actions button.secondary { background: var(--crema-dark); color: var(--cafe); }

/* Admin */
.new-user-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.new-user-form input, .new-user-form select { padding: 8px 10px; border: 1px solid var(--crema-dark); border-radius: 6px; font-size: 13px; }
.new-user-form button { background: var(--dorado); color: white; border: none; padding: 9px 16px; border-radius: 6px; cursor: pointer; font-weight: 600; }

.loading, .error-inline { padding: 30px; text-align: center; color: #999; }

/* Filtros */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filter-bar select, .filter-bar input.filter-search { padding: 7px 10px; border: 1px solid var(--crema-dark); border-radius: 6px; font-size: 12px; background: white; }
.filter-bar input.filter-search { min-width: 220px; }
.filter-clear { background: none; border: 1px solid var(--danger); color: var(--danger); padding: 6px 12px; border-radius: 6px; font-size: 12px; cursor: pointer; }
.filter-clear:hover { background: var(--danger); color: white; }
.result-count { font-size: 12px; color: #999; margin: 0 0 8px; }

/* Filas y tarjetas clicables (abren ficha de actor) */
.clickable-row { cursor: pointer; }
.clickable-row td:first-child { color: var(--dorado); font-weight: 600; }
.actor-card { cursor: pointer; transition: box-shadow 0.15s; }
.actor-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.data-table a { color: var(--dorado); text-decoration: none; font-weight: 600; }
.data-table a:hover { text-decoration: underline; }

.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { background: #ddd0b8; }

/* Módulo de Costos */
.resumen-strip { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.resumen-card { background: var(--crema-dark); border-radius: 8px; padding: 10px 16px; min-width: 150px; }
.resumen-card.ref { background: #f0ebe0; opacity: 0.85; }
.resumen-card .resumen-label { display: block; font-size: 11px; color: var(--cafe); font-weight: 600; margin-bottom: 4px; }
.resumen-card .resumen-value { display: block; font-size: 15px; font-weight: 700; color: var(--cafe); font-family: 'Cormorant Garamond', serif; }

.cf-settings { display: flex; gap: 18px; flex-wrap: wrap; background: #fbf8f2; padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; font-size: 12px; }
.cf-settings label { display: flex; align-items: center; gap: 6px; color: var(--cafe); font-weight: 600; }
.cf-settings input { padding: 4px 6px; border: 1px solid var(--crema-dark); border-radius: 4px; font-size: 12px; }

.matrix-scroll { overflow-x: auto; max-width: 100%; }
.matrix-table { font-size: 11px; white-space: nowrap; }
.matrix-table th, .matrix-table td { padding: 5px 8px; }
.matrix-table .sticky-col { position: sticky; left: 0; background: white; z-index: 2; text-align: left; min-width: 220px; white-space: normal; }
.matrix-table thead th.sticky-col { background: var(--crema-dark); z-index: 3; }
.matrix-table td.num, .matrix-table th { text-align: right; }
.matrix-table .category-row td { background: var(--oliva); color: white; font-weight: 700; text-align: left; padding-top: 8px; padding-bottom: 8px; }
.matrix-table .subtotal-row td { background: #ede5d3; font-weight: 700; }
.matrix-table .total-row td { background: var(--cafe); color: white; font-weight: 700; }
.cell-input { width: 90px; text-align: right; padding: 3px 4px; border: 1px solid var(--crema-dark); border-radius: 4px; font-size: 11px; }
.add-line-btn, .edit-label-btn { background: none; border: 1px solid white; color: white; border-radius: 4px; font-size: 10px; padding: 1px 6px; cursor: pointer; margin-left: 6px; }
.matrix-table .edit-label-btn { border-color: var(--dorado); color: var(--dorado); background: none; }

.budget-summary { margin-bottom: 8px; }
.note-cell { font-size: 11px; color: #777; max-width: 260px; }
.sub-h { color: var(--cafe); font-size: 16px; margin: 0 0 10px; }
.network-node { cursor: pointer; transition: r 0.15s; }
.network-node:hover { r: 10; }
.network-tooltip {
  display: none; position: absolute; background: var(--cafe); color: white; padding: 6px 12px;
  border-radius: 5px; font-size: 12px; pointer-events: none; white-space: normal; z-index: 10;
  max-width: 220px; line-height: 1.5;
}
