:root {
  --bg: #0c0c0c;
  --surface: #151515;
  --surface-2: #1d1d1d;
  --border: #282828;
  --text: #eceae4;
  --muted: #9b978e;
  --santifoto: #e08e45;
  --mvdh: #4e9af1;
  --ambos: #a67ce8;
  --ok: #3fb97c;
  --warn: #e2b340;
  --danger: #e05d5d;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.01em;
}

/* LOGIN */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
}

.brand-badge {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--santifoto);
  margin-bottom: 8px;
  font-weight: 600;
}

.login-card h1 {
  font-size: 28px;
  margin-bottom: 6px;
}

.login-sub {
  color: var(--muted);
  margin: 0 0 20px;
  font-size: 13px;
}

label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

input, select, textarea {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--santifoto);
}

/* BOTONES */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  border-color: #444;
}

.btn-primary {
  background: var(--santifoto);
  border-color: var(--santifoto);
  color: #0c0c0c;
  font-weight: 600;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-ok {
  background: rgba(63, 185, 124, 0.16);
  border-color: var(--ok);
  color: #7ee2ae;
}

.btn-warn {
  background: rgba(226, 179, 64, 0.16);
  border-color: var(--warn);
  color: #f3cf72;
}

.btn-danger {
  background: rgba(224, 93, 93, 0.14);
  border-color: var(--danger);
  color: #f08d8d;
}

.btn-ghost {
  background: transparent;
}

.btn-full {
  width: 100%;
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-top: 10px;
}

/* TOPBAR */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}

.app-title {
  font-size: 22px;
  line-height: 1.1;
}

.app-subtitle {
  font-size: 12px;
  color: var(--muted);
}

.topbar-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.filter-btn.active {
  background: var(--surface-2);
  color: var(--text);
  border-color: #555;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

/* TIRA DE AGENTES */
.agents-strip {
  display: flex;
  gap: 8px;
  padding: 10px 18px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: #101010;
}

.agent-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

.agent-pill:hover {
  border-color: #444;
}

.agent-state-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.agent-state-dot.trabajando { background: var(--ok); }
.agent-state-dot.esperando_aprobacion { background: var(--warn); }
.agent-state-dot.error { background: var(--danger); }

/* PESTAÑAS MÓVIL */
.mobile-col-tabs {
  display: none;
  gap: 6px;
  padding: 10px 12px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
}

.col-tab-btn {
  flex: 0 0 auto;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.col-tab-btn.active {
  color: var(--text);
  border-color: var(--santifoto);
  background: var(--surface-2);
}

/* TABLERO KANBAN */
.kanban-board {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(5, minmax(230px, 1fr));
  gap: 12px;
  padding: 16px 18px 28px;
  overflow-x: auto;
}

.kanban-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 380px;
}

.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}

.col-count {
  font-size: 11px;
  color: var(--muted);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 999px;
}

.kanban-col-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-col {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 24px 8px;
}

/* TARJETA */
.task-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--ambos);
  border-radius: 8px;
  padding: 11px 12px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.task-card:hover {
  border-color: #444;
  transform: translateY(-1px);
}

.task-card.proj-santifoto { border-left-color: var(--santifoto); }
.task-card.proj-mvdh { border-left-color: var(--mvdh); }
.task-card.proj-ambos { border-left-color: var(--ambos); }

.task-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}

.tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 500;
}

.tag-santifoto { background: rgba(224, 142, 69, 0.15); color: var(--santifoto); }
.tag-mvdh { background: rgba(78, 154, 241, 0.15); color: var(--mvdh); }
.tag-ambos { background: rgba(166, 124, 232, 0.15); color: var(--ambos); }

.prio-urgente {
  color: var(--danger);
  font-size: 11px;
  font-weight: 600;
}

.task-title {
  font-weight: 600;
  font-size: 13.5px;
  margin-bottom: 6px;
}

.task-desc {
  color: var(--muted);
  font-size: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
}

.task-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}

.quick-actions {
  display: flex;
  gap: 6px;
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.quick-actions .btn {
  flex: 1;
  padding: 6px 8px;
  font-size: 11.5px;
}

/* MODALES */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.modal-wide {
  max-width: 640px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 22px;
  margin-top: 4px;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}

.modal-body {
  padding: 16px 18px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal-footer, .detail-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.detail-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

.detail-desc {
  white-space: pre-wrap;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  word-break: break-word;
}

.detail-desc a {
  color: var(--santifoto);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.detail-desc a.wa-pill {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(63, 185, 124, 0.16);
  border: 1px solid var(--ok);
  color: #7ee2ae;
  font-size: 11px;
  text-decoration: none;
}

.detail-payload {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  overflow-x: auto;
  color: #c8c4bc;
  margin-bottom: 12px;
}

.feedback-box {
  margin-top: 10px;
}

/* SELECTOR DUAL (KANBAN / OFICINA 3D) */
.view-switcher {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 3px;
}

.view-btn {
  padding: 6px 13px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.view-btn.active {
  background: var(--santifoto);
  color: #0c0c0c;
  font-weight: 600;
}

/* OFICINA 3D (THREE.JS) */
.office3d-wrap {
  position: relative;
  flex: 1;
  min-height: 520px;
  height: calc(100vh - 120px);
  background: radial-gradient(circle at 50% 35%, #1a1514 0%, #090909 100%);
  overflow: hidden;
}

.office3d-canvas-host {
  width: 100%;
  height: 100%;
  touch-action: none;
}

.office3d-hud {
  position: absolute;
  bottom: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(15, 15, 15, 0.82);
  border: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text);
}

.hud-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.hud-pill .dot.trabajando { background: var(--ok); }
.hud-pill .dot.esperando_aprobacion { background: var(--warn); }
.hud-pill .dot.pausa { background: var(--muted); }

.hud-hint {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--muted);
  background: rgba(15, 15, 15, 0.78);
  padding: 5px 10px;
  border-radius: 999px;
}

.office3d-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.office3d-label {
  position: absolute;
  transform: translate(-50%, -100%);
  background: rgba(16, 16, 16, 0.88);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
}

.office3d-label.state-trabajando { border-color: var(--ok); }
.office3d-label.state-esperando_aprobacion { border-color: var(--warn); }
.office3d-label.state-error { border-color: var(--danger); }

.agent-tasks-box {
  margin-bottom: 12px;
  font-size: 12px;
}

.agent-task-mini {
  padding: 6px 9px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 5px;
}

.agent-order-box {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: 8px;
}

.agent-order-box label {
  flex: 1;
  margin-bottom: 0;
}

/* RESPONSIVE MÓVIL (Anti-Box Bloat) */
@media (max-width: 900px) {
  .topbar {
    padding: 12px;
  }
  .mobile-col-tabs {
    display: flex;
  }
  .kanban-board {
    grid-template-columns: 1fr;
    padding: 12px;
  }
  .kanban-col {
    display: none;
    min-height: 280px;
  }
  .kanban-col.mobile-active {
    display: flex;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
}
