:root {
  color-scheme: dark;
  --bg: #080b0f;
  --panel: #10161d;
  --panel-strong: #151c23;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #f4f7f8;
  --muted: #aeb9bf;
  --soft: #d8e0e3;
  --cyan: #69d9e7;
  --amber: #e6b257;
  --green: #8ed3a2;
  --red: #ef8f8f;
  --ink: #080b0f;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, #000, transparent 82%);
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

.ops-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(10, 15, 20, 0.82);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
}

.brand-mark img {
  width: 100%;
  height: 100%;
}

.brand span:last-child {
  display: grid;
  gap: 1px;
}

.brand strong {
  line-height: 1.1;
}

.brand small,
.access-note span,
.metric-card span,
.metric-card small,
.panel small {
  color: var(--muted);
}

.side-nav {
  display: grid;
  gap: 6px;
}

.side-nav a {
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--soft);
  font-size: 0.94rem;
}

.side-nav a:hover,
.side-nav a.is-active {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.access-note {
  display: grid;
  gap: 3px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.main {
  min-width: 0;
  padding: 28px clamp(18px, 3vw, 40px) 52px;
}

.topbar {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--cyan);
  font-size: 0.75rem;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: break-word;
}

h1 {
  margin: 0;
  font-size: clamp(2.3rem, 5vw, 4.8rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: clamp(1.3rem, 2.8vw, 2rem);
  line-height: 1.05;
  letter-spacing: 0;
}

p {
  color: var(--muted);
}

.operator {
  display: inline-flex;
  min-width: 92px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 8px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--soft);
}

.operator strong {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--text);
  color: var(--ink);
  font-size: 0.78rem;
}

.ops-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.ops-status small {
  margin-left: auto;
  color: var(--muted);
}

.status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(230, 178, 87, 0.12);
}

.ops-status[data-state="ready"] .status-dot {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(142, 211, 162, 0.12);
}

.ops-status[data-state="error"] .status-dot {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(239, 143, 143, 0.12);
}

.metric-grid {
  display: grid;
  gap: 14px;
}
.workspace {
  display: block;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.metric-card {
  display: grid;
  min-height: 140px;
  align-content: space-between;
  padding: 20px;
}

.metric-card strong {
  margin: 14px 0 8px;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1;
}

.workspace-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
  align-items: start;
}

.workspace-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.workspace-layout.is-single-tab {
  display: block;
}

.workspace-layout.is-single-tab .workspace-column {
  display: contents;
}

.panel {
  min-height: 260px;
  padding: 22px;
}

body[data-active-tab="dashboard"] .panel {
  min-height: auto;
}

body[data-active-tab="dashboard"] #presupuestos .task-list,
body[data-active-tab="dashboard"] #proyectos .task-list {
  max-height: 260px;
  overflow: auto;
  padding-right: 6px;
}

body[data-active-tab="dashboard"] #documentos .table-wrap,
body[data-active-tab="dashboard"] #enlaces .table-wrap {
  max-height: 380px;
  overflow: auto;
}

.span-2 {
  grid-column: span 2;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}

.panel-action {
  align-self: start;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--soft);
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
}

.panel-action:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

td {
  color: var(--soft);
}

td strong,
.task-list strong {
  display: block;
  color: var(--text);
}

td small,
.task-list small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.8rem;
  white-space: nowrap;
}

.status.warning {
  color: var(--amber);
}

.status.active {
  color: var(--green);
}

.status.neutral {
  color: var(--soft);
}

.status-list,
.task-list {
  display: grid;
  gap: 13px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.status-list li {
  display: flex;
  gap: 12px;
}

.status-list li > div {
  display: grid;
  gap: 3px;
}

.status-list li strong,
.status-list li small {
  display: block;
}

.status-list .inline-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.dot {
  width: 11px;
  height: 11px;
  margin-top: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--line-strong);
}

.dot.done {
  background: var(--green);
}

.dot.pending {
  background: var(--amber);
}

.document-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.document-grid article {
  display: grid;
  min-height: 112px;
  align-content: space-between;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.document-grid span {
  color: var(--muted);
}

.compact-table table {
  min-width: 620px;
}

.task-list {
  color: var(--soft);
  list-style: square;
  padding-left: 18px;
}

/* Scrollbars personalizados */
.table-wrap,
.task-list {
  scrollbar-color: rgba(255, 255, 255, 0.28) rgba(255, 255, 255, 0.04);
  scrollbar-width: thin;
}

.table-wrap::-webkit-scrollbar,
.task-list::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.table-wrap::-webkit-scrollbar-track,
.task-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
}

.table-wrap::-webkit-scrollbar-thumb,
.task-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
}

.table-wrap::-webkit-scrollbar-thumb:hover,
.task-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.42);
}

/* Gestión de tareas y presupuestos */
.task-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.task-item-row > span:first-child {
  min-width: 0;
}

.task-actions {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 6px;
}

.task-section-label {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

/* Modo Dashboard: renderizar como lista compacta sin acciones */
body[data-active-tab="dashboard"] #presupuestos .task-item-row {
  display: list-item;
}

body[data-active-tab="dashboard"] #presupuestos .task-actions {
  display: none;
}

/* Modo pestaña dedicada: estilo premium e interactivo tipo tarjeta/fila */
body[data-active-tab="presupuestos"] #presupuestos .task-list {
  list-style: none;
  padding-left: 0;
}

body[data-active-tab="presupuestos"] #presupuestos .task-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  transition: all 150ms ease;
}

body[data-active-tab="presupuestos"] #presupuestos .task-item-row:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line-strong);
}

body[data-active-tab="presupuestos"] #presupuestos .task-item-row.archived {
  border-style: dashed;
  opacity: 0.84;
}

.client-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 18px;
}

.client-summary span {
  display: grid;
  gap: 4px;
  min-height: 82px;
  align-content: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.client-summary strong {
  color: var(--text);
  font-size: 1.6rem;
  line-height: 1;
}

.client-summary small {
  color: var(--muted);
}

@media (max-width: 1100px) {
  .ops-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .side-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric-grid,
  .document-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace-layout {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 2;
  }
}

@media (max-width: 680px) {
  .main,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .panel-heading,
  .ops-status {
    flex-direction: column;
  }

  .ops-status {
    align-items: flex-start;
  }

  .ops-status small {
    margin-left: 0;
  }

  .side-nav,
  .metric-grid,
  .document-grid,
  .client-summary {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  h1 {
    font-size: clamp(2.2rem, 16vw, 4rem);
  }
}

/* Clases de utilidad y componentes dinámicos para Fase 1.2 */
.hidden {
  display: none !important;
}

.span-3 {
  grid-column: span 3;
}

.action-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.action-btn {
  display: inline-flex;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.04);
  color: var(--soft);
  cursor: pointer;
  transition: all 120ms ease;
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border-color: var(--line-strong);
}

.action-btn.danger {
  color: var(--red);
}

.action-btn.danger:hover {
  background: rgba(239, 143, 143, 0.1);
  border-color: var(--red);
}

.action-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.action-btn.disabled:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--soft);
  border-color: var(--line);
}

/* Modal Premium y campos interactivos para Fase 1.3 */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 11, 15, 0.85);
  backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.modal-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: transform 200ms ease;
}

.modal-overlay.is-open .modal-card {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.3rem;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
}

.form-group {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: minmax(90px, 0.7fr) minmax(0, 1.3fr);
  gap: 12px;
}

.form-group label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 700;
}

.form-control {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.95rem;
  width: 100%;
  outline: none;
  transition: border-color 150ms ease;
}

.form-control:focus {
  border-color: var(--cyan);
}

.form-control[readonly] {
  opacity: 0.6;
  cursor: not-allowed;
}

textarea.form-control {
  min-height: 92px;
  resize: vertical;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.modal-btn {
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 0.92rem;
  cursor: pointer;
  font-weight: 600;
  transition: all 120ms ease;
}

.modal-btn.primary {
  background: var(--cyan);
  color: var(--ink);
  border: none;
}

.modal-btn.primary:hover {
  background: #5ac5d3;
}

.modal-btn.secondary {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--soft);
}

.modal-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.result-box {
  background: rgba(105, 217, 231, 0.04);
  border: 1px dashed var(--cyan);
  border-radius: 6px;
  padding: 14px;
  margin-top: 18px;
  display: grid;
  gap: 8px;
}

.result-url {
  font-family: monospace;
  color: var(--cyan);
  word-break: break-all;
  font-size: 0.9rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Estilos de Presupuestos Comerciales (Fase 1.6) */
.budgets-card-list {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.budget-card {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.2s ease;
}

.budget-card:hover {
  border-color: var(--line-strong);
}

.budget-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.budget-card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.budget-card-project {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
}

.budget-card-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.budget-card-amount {
  font-weight: 700;
  color: var(--cyan);
  font-size: 1rem;
}

.budget-card-notes {
  margin: 0;
  font-size: 0.85rem;
  color: var(--soft);
  background: rgba(0, 0, 0, 0.15);
  padding: 6px 10px;
  border-radius: 4px;
  border-left: 2px solid var(--cyan);
}

.budget-card-notes.internal {
  border-left-color: var(--amber);
}

.budget-card-doc {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  font-size: 0.85rem;
}

.budget-card-doc.no-doc {
  color: var(--muted);
  justify-content: space-between;
}

.budget-card-doc .doc-icon {
  flex-shrink: 0;
}

.budget-card-doc .doc-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  color: var(--soft);
}

.budget-card-doc .doc-views {
  color: var(--muted);
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.budget-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 10px;
  margin-top: 4px;
}

.budget-card-actions .action-btn.primary {
  background: var(--cyan);
  color: var(--ink);
  border-color: var(--cyan);
}

.budget-card-actions .action-btn.primary:hover {
  background: #5ac5d3;
}

.budget-card-actions .action-btn.success {
  color: var(--green);
  border-color: var(--green);
}

.budget-card-actions .action-btn.success:hover {
  background: rgba(142, 211, 162, 0.1);
}

.budget-card-actions .action-btn.danger {
  color: var(--red);
  border-color: var(--red);
}

.budget-card-actions .action-btn.danger:hover {
  background: rgba(239, 143, 143, 0.1);
}

.budget-card-actions .action-btn.neutral {
  color: var(--soft);
  border-color: var(--line);
}

.status.done {
  color: var(--green);
  border-color: rgba(142, 211, 162, 0.3);
  background: rgba(142, 211, 162, 0.05);
}

.status.idle {
  color: var(--muted);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.status.danger {
  color: var(--red);
  border-color: rgba(239, 143, 143, 0.3);
  background: rgba(239, 143, 143, 0.05);
}

.status.pending {
  color: var(--amber);
  border-color: rgba(230, 178, 87, 0.3);
  background: rgba(230, 178, 87, 0.05);
}

.empty-state {
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 0.9rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.01);
  margin: 10px 0;
}
