/* ---------- Theme: metal-wood ---------- */
:root {
  /* Light (default) — wood + dark metal accents */
  --bg:           #f3e7cf;
  --bg-grain:    #ecdcb9;
  --surface:      #fbf3e0;
  --surface-2:    #efe1c1;
  --ink:          #1c1612;
  --ink-soft:     #4a3d2c;
  --muted:        #7a6a52;
  --line:         #c9b48a;
  --metal:        #1f1d1c;
  --metal-soft:   #2e2b29;
  --wood:         #8b5a2b;
  --wood-dark:    #5c3a21;
  --wood-light:   #c89160;
  --burn:         #c2511f;
  --warn:         #b8480f;
  --ok:           #4a6b29;
  --shadow:       0 6px 16px -8px rgba(60, 40, 15, 0.35);
  --radius:       8px;
  --radius-lg:    14px;
  --grain-img:    repeating-linear-gradient(90deg, rgba(92,58,33,0.05) 0 1px, transparent 1px 4px),
                  repeating-linear-gradient(0deg, rgba(92,58,33,0.04) 0 1px, transparent 1px 7px);
}

[data-theme="dark"] {
  --bg:           #15110d;
  --bg-grain:    #1c1812;
  --surface:      #20180f;
  --surface-2:    #2a1e12;
  --ink:          #f3e7cf;
  --ink-soft:     #d6c39a;
  --muted:        #a39074;
  --line:         #4a3a25;
  --metal:        #0c0a09;
  --metal-soft:   #1d1a17;
  --wood:         #c89160;
  --wood-dark:    #8b5a2b;
  --wood-light:   #e8b888;
  --burn:         #e07b3e;
  --warn:         #f0894a;
  --ok:           #9bbf72;
  --shadow:       0 8px 24px -10px rgba(0, 0, 0, 0.7);
  --grain-img:    repeating-linear-gradient(90deg, rgba(200,145,96,0.04) 0 1px, transparent 1px 4px),
                  repeating-linear-gradient(0deg, rgba(200,145,96,0.03) 0 1px, transparent 1px 7px);
}

/* ---------- Reset ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  background-image: var(--grain-img);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 18px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }
.muted { color: var(--muted); font-size: 12px; }

/* ---------- Topbar ---------- */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 24px;
  align-items: center;
  padding: 14px 24px;
  background: var(--metal);
  color: #f3e7cf;
  border-bottom: 3px solid var(--wood-dark);
  position: sticky; top: 0; z-index: 10;
  box-shadow: 0 2px 0 rgba(0,0,0,0.15);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { color: #f3e7cf; font-family: "Georgia", serif; }
.brand-sub { font-size: 11px; color: #c89160; margin-top: 2px; }
.brand-mark {
  width: 36px; height: 36px;
  background:
    radial-gradient(circle at 50% 50%, var(--burn) 0 4px, transparent 5px),
    radial-gradient(circle at 50% 50%, transparent 5px, #f3e7cf 6px 9px, transparent 10px),
    linear-gradient(135deg, #8b5a2b, #5c3a21);
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px #c89160, 0 0 0 2px var(--metal-soft);
}

.tabs { display: flex; gap: 4px; justify-self: center; }
.tab {
  background: transparent;
  border: 0;
  color: #c89160;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.tab:hover { color: #f3e7cf; background: var(--metal-soft); }
.tab.active { color: #f3e7cf; border-bottom-color: var(--burn); }

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

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--wood); }
.btn-primary {
  background: var(--wood-dark); color: #f3e7cf; border-color: var(--wood-dark);
}
.btn-primary:hover { background: var(--wood); border-color: var(--wood); }
.btn-ghost {
  background: transparent; color: #c89160; border-color: #4a3a25;
}
.btn-ghost:hover { background: var(--metal-soft); color: #f3e7cf; }
.btn-danger {
  background: transparent; color: var(--warn); border-color: var(--warn);
}
.btn-danger:hover { background: var(--warn); color: #fff; }
.btn-icon {
  background: transparent; color: #c89160;
  border: 1px solid #4a3a25;
  width: 32px; height: 32px;
  padding: 0;
  font-size: 16px;
  border-radius: 50%;
}
.btn-icon:hover { background: var(--metal-soft); color: #f3e7cf; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ---------- Layout ---------- */
main { padding: 24px; max-width: 1400px; margin: 0 auto; }
.view { display: flex; flex-direction: column; gap: 20px; }
.view-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.view-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Inputs ---------- */
.input, select, textarea, input[type="text"], input[type="number"], input[type="date"], input[type="search"], input[type="email"], input[type="tel"] {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.input:focus, select:focus, textarea:focus,
input[type="text"]:focus, input[type="number"]:focus, input[type="date"]:focus,
input[type="search"]:focus, input[type="email"]:focus, input[type="tel"]:focus {
  border-color: var(--wood);
}
textarea { resize: vertical; min-height: 60px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card.pad-0 { padding: 0; overflow: hidden; }
.card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
}
.cards-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- KPIs ---------- */
.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--wood-dark);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.kpi-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--ink); margin-top: 4px; font-family: "Georgia", serif; }
.kpi-value.warn { color: var(--warn); }

/* ---------- Dashboard list ---------- */
.dashboard-list { display: flex; flex-direction: column; gap: 10px; }
.dash-row {
  display: grid; grid-template-columns: 1fr auto auto;
  align-items: center; gap: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s;
}
.dash-row:hover { border-color: var(--wood); }
.dash-row .pname { font-weight: 600; }
.dash-row .pcli { font-size: 12px; color: var(--muted); }
.dash-bar {
  height: 5px; background: var(--line); border-radius: 99px; overflow: hidden;
  width: 100%; margin-top: 6px;
}
.dash-bar > span { display: block; height: 100%; background: var(--wood); border-radius: 99px; }

.alerts { display: flex; flex-direction: column; gap: 8px; }
.alert {
  padding: 10px 12px;
  border-radius: var(--radius);
  border-left: 3px solid var(--warn);
  background: var(--surface-2);
  font-size: 13px;
}
.alert.ok { border-left-color: var(--ok); }
.alert.info { border-left-color: var(--wood); }
.alert .a-title { font-weight: 600; }
.alert .a-detail { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------- Project cards / roadmap ---------- */
.proyectos-list { display: flex; flex-direction: column; gap: 14px; }
.proyecto {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow);
}
.proyecto-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 14px;
}
.proyecto-title { display: flex; align-items: center; gap: 10px; }
.proyecto-id {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  background: var(--metal); color: #c89160;
  padding: 2px 8px; border-radius: 4px; font-size: 11px;
}
.proyecto-meta { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.proyecto-meta b { color: var(--ink-soft); font-weight: 500; }
.proyecto-actions { display: flex; gap: 6px; flex-shrink: 0; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid;
}
.badge.estado-planificado  { color: #6a5a3c; border-color: #c9b48a; background: #fbf3e0; }
.badge.estado-en_progreso  { color: #4a6b29; border-color: #9bbf72; background: rgba(155,191,114,0.15); }
.badge.estado-en_riesgo    { color: var(--warn); border-color: var(--warn); background: rgba(184,72,15,0.1); }
.badge.estado-pausado      { color: var(--muted); border-color: var(--line); background: var(--surface-2); }
.badge.estado-completado   { color: var(--metal); border-color: var(--metal); background: rgba(31,29,28,0.06); }
.badge.prio-baja    { color: var(--muted); border-color: var(--line); background: transparent; }
.badge.prio-media   { color: var(--wood); border-color: var(--wood); background: transparent; }
.badge.prio-alta    { color: var(--burn); border-color: var(--burn); background: rgba(194,81,31,0.08); }
.badge.prio-urgente { color: #fff; border-color: var(--burn); background: var(--burn); }

.roadmap {
  display: flex; gap: 4px; padding: 4px 0;
  overflow-x: auto;
}
.roadmap-step {
  flex: 1; min-width: 95px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 11px;
  position: relative;
  cursor: pointer;
  transition: all 0.15s;
}
.roadmap-step:hover { border-color: var(--wood); }
.roadmap-step.completada {
  background: rgba(74,107,41,0.12);
  border-color: var(--ok);
  color: var(--ink-soft);
}
.roadmap-step.completada::after {
  content: "✓"; position: absolute; top: 4px; right: 6px;
  color: var(--ok); font-weight: 700;
}
.roadmap-step.actual {
  background: var(--wood-dark); color: #f3e7cf; border-color: var(--wood-dark);
  box-shadow: 0 0 0 2px rgba(139,90,43,0.25);
}
.roadmap-step.actual .rs-fechas { color: rgba(243,231,207,0.75); }
.roadmap-step .rs-nombre { font-weight: 600; font-size: 12px; }
.roadmap-step .rs-fechas { color: var(--muted); margin-top: 3px; font-size: 10px; }

/* ---------- Tables ---------- */
.table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.table th, .table td {
  text-align: left; padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.table th {
  background: var(--surface-2);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); font-weight: 600;
}
.table tr:hover td { background: var(--surface-2); }
.table tr.low-stock td { background: rgba(184,72,15,0.07); }
.stock-cell { font-weight: 600; }
.stock-cell.low { color: var(--warn); }

/* ---------- Provider cards ---------- */
.proveedor-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--wood);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: var(--shadow);
}
.proveedor-card[data-estado="en_revision"] { border-left-color: var(--warn); }
.proveedor-card[data-estado="descartado"]  { border-left-color: var(--muted); opacity: 0.75; }
.proveedor-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.proveedor-name { font-weight: 600; font-size: 14px; }
.proveedor-cat {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px;
}
.chip {
  font-size: 11px; padding: 2px 8px; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-soft);
}
.stars { color: var(--burn); font-size: 13px; letter-spacing: 1px; }
.proveedor-actions { display: flex; gap: 6px; margin-top: 8px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.15s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  border-top: 3px solid var(--wood-dark);
  width: 100%; max-width: 700px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 50px -10px rgba(0,0,0,0.4);
}
.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-body { padding: 20px; }
.modal-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  display: flex; gap: 8px; justify-content: flex-end;
  background: var(--surface-2);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.fases-edit {
  display: grid;
  grid-template-columns: 1fr 130px 130px 1fr 80px;
  gap: 6px; align-items: center;
  font-size: 12px;
}
.fases-edit .fhead {
  font-weight: 600; color: var(--muted);
  text-transform: uppercase; font-size: 10px; letter-spacing: 0.05em;
  padding-bottom: 4px; border-bottom: 1px solid var(--line);
}

/* ---------- Empty / utility ---------- */
.empty {
  text-align: center; padding: 40px 20px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
}

@media (max-width: 720px) {
  .topbar { grid-template-columns: 1fr; gap: 10px; padding: 12px; }
  .tabs { justify-self: stretch; overflow-x: auto; }
  .topbar-actions { flex-wrap: wrap; }
  main { padding: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .fases-edit { grid-template-columns: 1fr; }
  .fases-edit .fhead { display: none; }
}
