/* ===========================================================
   ZIRCONNECT SUITE — Sistema de diseño
   Paleta derivada del logo: ámbar (disco), azul (diente), rojo (sonrisa)
   =========================================================== */

:root {
  /* Color */
  --ink: #1C1F26;
  --ink-soft: #4A505C;
  --slate: #7A8290;
  --line: #E2E5EA;
  --surface: #FFFFFF;
  --bg: #F1F3F4;              /* "Zirconia White" — blanco frío, no cálido */
  --bg-sidebar: #14181F;

  --blue: #1D6FA5;            /* Milling Blue — primario */
  --blue-soft: #E7F1F8;
  --amber: #E8A93B;           /* Disc Amber — en curso / aviso */
  --amber-soft: #FCF2E1;
  --red: #D64550;             /* Signal Red — urgente / externalizado */
  --red-soft: #FBEAEC;
  --green: #3E9C6E;           /* completado */
  --green-soft: #E8F5EE;

  /* Tipografía */
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  /* Layout */
  --sidebar-w: 232px;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(28,31,38,0.06), 0 1px 8px rgba(28,31,38,0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

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

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  color: #fff;
  padding: 0 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: relative;
}

.sidebar::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--amber) 0%, var(--amber) 33%, var(--blue) 33%, var(--blue) 66%, var(--red) 66%, var(--red) 100%);
}

.sidebar .brand {
  position: relative;
  padding: 30px 8px 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.sidebar .brand::before {
  content: "";
  position: absolute;
  top: -60px; left: 50%;
  width: 220px; height: 220px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: conic-gradient(from 180deg, var(--amber), var(--blue), var(--red), var(--amber));
  opacity: 0.16;
  filter: blur(2px);
}

.sidebar .brand::after {
  content: "";
  position: absolute;
  bottom: 0; left: 16px; right: 16px;
  height: 1px;
  background: rgba(255,255,255,0.08);
}

.sidebar .brand .disc {
  width: 30px; height: 30px; border-radius: 50%;
  background: conic-gradient(var(--amber) 0deg 120deg, var(--blue) 120deg 240deg, var(--red) 240deg 360deg);
  flex-shrink: 0;
}

.sidebar .brand-text { font-family: var(--font-display); font-weight: 600; font-size: 15.5px; letter-spacing: 0.02em; line-height: 1.1; }
.sidebar .brand-text span { display: block; font-family: var(--font-body); font-weight: 400; font-size: 10.5px; color: #9AA2B0; letter-spacing: 0.08em; text-transform: uppercase; margin-top: 2px; }

.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.09em; color: #6B7280; padding: 6px 12px 4px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #C7CCD6;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.85; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: var(--blue); color: #fff; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer { margin-top: auto; padding: 10px 12px; border-top: 1px solid rgba(255,255,255,0.08); font-size: 12px; color: #7A8296; }
.sidebar-footer strong { color: #C7CCD6; display: block; font-size: 13px; }

/* ---------- Main ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}

.topbar h1 { font-family: var(--font-display); font-size: 19px; font-weight: 600; margin: 0; }
.topbar .sub { font-size: 12.5px; color: var(--slate); margin-top: 1px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: none; border-radius: 8px;
  padding: 9px 16px;
  font-family: var(--font-body); font-weight: 600; font-size: 13.5px;
  cursor: pointer;
  transition: filter 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { filter: brightness(1.25); }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--bg); }

.content { padding: 26px 28px 60px; flex: 1; }

/* ---------- Tarjetas de estadística ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 26px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
}
.stat-card .label { font-size: 12px; color: var(--slate); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat-card .value { font-family: var(--font-display); font-size: 30px; font-weight: 600; margin-top: 6px; }
.stat-card .delta { font-size: 12px; margin-top: 4px; color: var(--slate); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-amber { background: var(--amber); }
.dot-blue { background: var(--blue); }
.dot-red { background: var(--red); }
.dot-green { background: var(--green); }

/* ---------- Tablero kanban ---------- */
.board-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.board-header h2 { font-family: var(--font-display); font-size: 15.5px; font-weight: 600; margin: 0; }

.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

.kanban-col {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 200px;
}
.kanban-col-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 14px 11px;
  border-bottom: 1px solid var(--line);
}
.kanban-col-head .title { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.kanban-col-head .count { font-family: var(--font-mono); font-size: 11.5px; color: var(--slate); background: var(--bg); border-radius: 20px; padding: 1px 8px; }

.ring { width: 9px; height: 9px; border-radius: 50%; border: 2px solid; flex-shrink: 0; }
.ring-amber { border-color: var(--amber); }
.ring-blue { border-color: var(--blue); }
.ring-red { border-color: var(--red); }
.ring-green { border-color: var(--green); }

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

.job-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.job-card:hover { border-color: var(--blue); box-shadow: var(--shadow); }
.job-card .code { font-family: var(--font-mono); font-size: 11px; color: var(--slate); }
.job-card .client { font-size: 13.5px; font-weight: 600; margin-top: 3px; }
.job-card .desc { font-size: 12px; color: var(--ink-soft); margin-top: 3px; line-height: 1.35; }
.job-card .meta { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.material-tag { font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 5px; text-transform: uppercase; letter-spacing: 0.03em; }
.material-tag.zirconio { background: var(--blue-soft); color: var(--blue); }
.material-tag.pmma { background: var(--amber-soft); color: #A87418; }
.job-card .date { font-size: 11px; color: var(--slate); }

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

/* ---------- Formularios (compartido con nuevo-trabajo) ---------- */
.form-shell { max-width: 980px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.panel h3 {
  font-family: var(--font-display); font-size: 14.5px; font-weight: 600;
  margin: 0 0 16px;
  display: flex; align-items: center; gap: 8px;
}
.panel h3 .idx { font-family: var(--font-mono); font-size: 11px; color: #fff; background: var(--ink); border-radius: 5px; padding: 1px 6px; }

.field-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.field-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.field label .opt { font-weight: 400; color: var(--slate); }
.field input, .field select, .field textarea {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--ink);
  background: var(--surface);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
  border-color: var(--blue);
}
.field input[readonly] { background: var(--bg); color: var(--slate); font-family: var(--font-mono); font-size: 12.5px; }

.toggle-pair { display: flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; width: fit-content; }
.toggle-pair button {
  border: none; background: var(--surface); padding: 8px 16px;
  font-size: 13px; font-weight: 600; color: var(--ink-soft); cursor: pointer;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
  position: relative;
}
.toggle-pair button.active {
  background: var(--blue);
  color: #fff;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.35), 0 0 12px rgba(29,111,165,0.55);
}
.toggle-pair button.active.pmma { background: var(--amber); box-shadow: inset 0 0 0 2px rgba(255,255,255,0.35), 0 0 12px rgba(232,169,59,0.55); }
.toggle-pair button:not(:last-child) { border-right: 1px solid var(--line); }

/* Odontograma */
.odontograma { display: flex; flex-direction: column; gap: 6px; align-items: center; padding: 10px 0 4px; }
.arcada { display: flex; gap: 4px; }
.diente {
  width: 30px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer; user-select: none;
}
.diente svg { transition: fill 0.12s, stroke 0.12s; }
.diente .num { font-family: var(--font-mono); font-size: 9.5px; color: var(--slate); }
.diente.sel svg { fill: var(--blue); stroke: var(--blue); }
.diente.sel .num { color: var(--blue); font-weight: 700; }
.diente:hover svg { stroke: var(--blue); }

.diente.estado-ausencia svg { fill: #fff; stroke: var(--red); stroke-dasharray: 2 2; }
.diente.estado-ausencia .num { color: var(--red); font-weight: 700; }
.diente.estado-implante svg { fill: #1D6FA5; stroke: #1D6FA5; }
.diente.estado-implante .num { color: #1D6FA5; font-weight: 700; }
.diente.estado-pilar svg { fill: #7B4FCF; stroke: #7B4FCF; }
.diente.estado-pilar .num { color: #7B4FCF; font-weight: 700; }
.diente.estado-corona svg { fill: var(--amber); stroke: var(--amber); }
.diente.estado-corona .num { color: var(--amber); font-weight: 700; }

.leyenda-odonto { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; justify-content: center; }
.leyenda-odonto .item { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--slate); }
.leyenda-odonto .punto { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.arcada-divider { width: 1px; align-self: stretch; background: var(--line); margin: 0 4px; }

.helper { font-size: 11.5px; color: var(--slate); margin-top: 8px; text-align: center; }

/* ---------- Chips (guía Vita / materiales) ---------- */
.chip-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 7px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.chip:hover { border-color: var(--blue); }
.chip.active { background: var(--blue); border-color: var(--blue); color: #fff; }

.material-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.material-card {
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 12px 12px;
  cursor: pointer;
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  transition: border-color 0.15s, background 0.15s;
  line-height: 1.3;
}
.material-card:hover { border-color: var(--blue); }
.material-card.active { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }

.subfield-box {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px dashed var(--line);
}
.subfield-box .subfield-label { font-size: 11.5px; font-weight: 600; color: var(--slate); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.subfield-box .checkbox-row { display: flex; flex-wrap: wrap; gap: 14px; }
.subfield-box label.check-item { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink); cursor: pointer; }

/* ---------- Adjuntar archivo ---------- */
.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  padding: 26px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover { border-color: var(--blue); background: var(--blue-soft); }
.dropzone svg { color: var(--slate); margin-bottom: 8px; }
.dropzone .dz-title { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.dropzone .dz-sub { font-size: 12px; color: var(--slate); margin-top: 3px; }
.dropzone.has-file { border-style: solid; border-color: var(--green); background: var(--green-soft); }
.file-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--green); }

.dropzone-linea {
  display: flex; align-items: center; gap: 10px;
  border: 1.5px dashed var(--line); border-radius: 8px;
  padding: 11px 14px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: var(--ink);
  transition: border-color 0.15s, background 0.15s;
}
.dropzone-linea:hover { border-color: var(--blue); background: var(--blue-soft); }
.dropzone-linea svg { color: var(--slate); flex-shrink: 0; }
.dropzone-linea.has-file { border-style: solid; border-color: var(--green); background: var(--green-soft); color: var(--green); }
.dropzone-linea.has-file svg { color: var(--green); }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* ---------- Trazabilidad: resumen de solo lectura ---------- */
.resumen-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 20px; }
.resumen-item .k { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--slate); }
.resumen-item .v { font-size: 14px; font-weight: 600; margin-top: 2px; }
.resumen-item .v.mono { font-family: var(--font-mono); font-weight: 500; }

.posproceso-row {
  display: grid;
  grid-template-columns: 1fr 150px 1fr;
  gap: 10px;
  align-items: end;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.posproceso-row:last-child { border-bottom: none; }
.posproceso-row .paso-nombre { font-size: 13.5px; font-weight: 600; align-self: center; }
.posproceso-row .paso-check { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-soft); align-self: center; }

.job-pick-list { display: flex; flex-direction: column; gap: 8px; }
.job-pick {
  display: flex; align-items: center; justify-content: space-between;
  border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px;
  background: var(--surface);
}
.job-pick .info .code { font-family: var(--font-mono); font-size: 11px; color: var(--slate); }
.job-pick .info .client { font-size: 13.5px; font-weight: 600; margin-top: 2px; }
.job-pick .status-tag { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; }
.status-generada { background: var(--green-soft); color: var(--green); }
.status-pendiente { background: var(--amber-soft); color: #A87418; }

/* ---------- Tabla genérica ---------- */
.tabla-app { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabla-app thead th {
  background: var(--bg); text-align: left; padding: 11px 16px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--slate);
}
.tabla-app tbody td { padding: 11px 16px; border-top: 1px solid var(--line); }
.tabla-app tbody tr:hover { background: #FAFBFB; }
.icon-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 6px;
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink-soft); margin-left: 4px;
}
.icon-btn:hover { border-color: var(--blue); color: var(--blue); }
.icon-btn.danger:hover { border-color: var(--red); color: var(--red); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,24,31,0.55);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-box {
  background: var(--surface); border-radius: var(--radius); width: 480px; max-width: 92vw;
  max-height: 88vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-family: var(--font-display); font-size: 15px; font-weight: 600; }
.modal-close { border: none; background: none; cursor: pointer; color: var(--slate); font-size: 18px; line-height: 1; }
.modal-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .kanban { grid-template-columns: repeat(2, 1fr); }
  .field-grid { grid-template-columns: repeat(2, 1fr); }
}
