/* ============================================================
   Órbita — hoja de estilos (port de Tailwind v4 a CSS plano)
   Paleta y radios tomados de app/globals.css del proyecto original.
   ============================================================ */

:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --ink: #14141a;
  --muted: #6b6b76;
  --line: #e6e6e2;
  --accent: #1b1a23;
  --positive: #16a34a;
  --negative: #dc2626;
  --warning: #d97706;
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 248px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --shadow: 0 1px 2px rgba(20, 20, 26, .04), 0 4px 16px rgba(20, 20, 26, .04);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ───────── estructura ───────── */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 4px; }
.sidebar__brand b { font-size: 17px; letter-spacing: -.02em; }
.sidebar__logo {
  width: 30px; height: 30px; border-radius: 9px; background: var(--accent);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: 0 0 auto;
}
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group__title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); padding: 4px 10px; font-weight: 600;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500; font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--bg); color: var(--ink); }
.nav-link.is-active { background: var(--accent); color: #fff; }
.nav-link .ico { width: 17px; height: 17px; flex: 0 0 auto; stroke-width: 1.8; }
.nav-badge {
  margin-left: auto; background: var(--negative); color: #fff;
  font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 6px; min-width: 18px; text-align: center;
}
.nav-link.is-active .nav-badge { background: #fff; color: var(--accent); }

.sidebar__foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
.userbox { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.userbox__name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.userbox__role { font-size: 11px; color: var(--muted); }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700;
}
.avatar--sm { width: 24px; height: 24px; font-size: 10px; }
.avatar--lg { width: 44px; height: 44px; font-size: 15px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: none; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.content { padding: 26px 30px 60px; max-width: 1500px; width: 100%; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.page-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }

/* ───────── tarjetas ───────── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card__head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card__title { font-size: 15px; font-weight: 650; }
.card__body { padding: 18px; }
.card--pad { padding: 18px; }

.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

.stat { padding: 16px 18px; }
.stat__label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat__value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; }
.stat__hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.is-positive { color: var(--positive); }
.is-negative { color: var(--negative); }
.is-warning { color: var(--warning); }

/* ───────── botones ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 14px; font-weight: 600; white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: var(--bg); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { opacity: .88; background: var(--accent); }
.btn--danger { background: var(--negative); border-color: var(--negative); color: #fff; }
.btn--danger:hover { opacity: .88; background: var(--negative); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn--ghost:hover { background: var(--bg); color: var(--ink); }
.btn--sm { height: 32px; padding: 0 11px; font-size: 13px; }
.btn--icon { width: 34px; padding: 0; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ───────── formularios ───────── */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.label { font-size: 13px; font-weight: 600; color: var(--ink); }
.hint { font-size: 12px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--ink);
  transition: border-color .15s;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); }
.textarea { min-height: 96px; resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-row--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ───────── tablas ───────── */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--bg); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; }

/* ───────── etiquetas de estado ───────── */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 650;
  background: var(--bg); color: var(--muted); white-space: nowrap;
}
.tag--green  { background: #dcfce7; color: #15803d; }
.tag--red    { background: #fee2e2; color: #b91c1c; }
.tag--amber  { background: #fef3c7; color: #b45309; }
.tag--blue   { background: #dbeafe; color: #1d4ed8; }
.tag--gray   { background: #ececeb; color: #52525b; }
.tag--purple { background: #ede9fe; color: #6d28d9; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }

/* ───────── varios ───────── */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty__title { font-weight: 650; color: var(--ink); margin-bottom: 4px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.bold { font-weight: 650; }
.row { display: flex; align-items: center; gap: 10px; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.mt-0{margin-top:0}.mt-1{margin-top:6px}.mt-2{margin-top:12px}.mt-3{margin-top:18px}.mt-4{margin-top:24px}
.mb-0{margin-bottom:0}.mb-1{margin-bottom:6px}.mb-2{margin-bottom:12px}.mb-3{margin-bottom:18px}
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ───────── avisos flash ───────── */
.flash-stack { position: fixed; right: 18px; bottom: 18px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.flash {
  background: var(--accent); color: #fff; padding: 11px 15px; border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(20,20,26,.18); font-size: 14px; font-weight: 550; max-width: 380px;
  animation: flash-in .25s ease;
}
.flash--error { background: var(--negative); }
@keyframes flash-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ───────── modales (sustituyen a los diálogos de React) ───────── */
.modal { position: fixed; inset: 0; z-index: 80; display: none; }
.modal:target, .modal.is-open { display: block; }
.modal__bg { position: absolute; inset: 0; background: rgba(20,20,26,.45); }
.modal__panel {
  position: relative; margin: 5vh auto; max-width: 620px; width: calc(100% - 32px);
  background: var(--surface); border-radius: var(--radius); box-shadow: 0 24px 60px rgba(0,0,0,.25);
  max-height: 90vh; overflow-y: auto;
}
.modal__head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal__title { font-size: 16px; font-weight: 650; }
.modal__body { padding: 20px; }
.modal__foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

/* ───────── responsive ───────── */
@media (max-width: 1100px) {
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--sidebar { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 60;
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.18);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(20,20,26,.4); z-index: 50; }
  .topbar { display: flex; }
  .content { padding: 18px 16px 80px; }
  .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
  .form-row, .form-row--3 { grid-template-columns: 1fr; }
  .page-title { font-size: 20px; }
}

/* ───────── Tablero kanban (arrastrar y soltar) ───────── */
.kanban {
  display: flex; gap: 16px; align-items: flex-start;
  overflow-x: auto; overflow-y: hidden;
  padding-bottom: 12px;
  /* altura acotada al viewport para que la barra de scroll horizontal quede siempre visible */
  height: calc(100vh - 230px); min-height: 360px;
  scroll-behavior: smooth;
}
.kanban__col {
  flex: 0 0 300px; width: 300px; align-self: stretch;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 0;
}
.kanban__col--new { background: transparent; border: 0; padding: 0; }
.kanban__head { flex: 0 0 auto; }
.kanban__list {
  display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto; overflow-x: hidden; flex: 1 1 auto; min-height: 40px;
  padding: 2px; margin: -2px; border-radius: var(--radius-sm);
  transition: background .12s, box-shadow .12s;
}
.kanban__list.is-over { background: color-mix(in srgb, var(--accent) 6%, transparent); box-shadow: inset 0 0 0 2px var(--accent); }
.kanban__card { cursor: default; }
.kanban[data-can-edit="1"] .kanban__card { cursor: grab; }
.kanban__card.dragging { opacity: .4; cursor: grabbing; }
.kanban.is-panning { cursor: grabbing; scroll-behavior: auto; }
.kanban.is-panning .kanban__card { cursor: grabbing; }
@media (max-width: 900px) {
  .kanban { height: auto; overflow-x: auto; }
  .kanban__list { overflow-y: visible; max-height: none; }
}
