@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  --ink: #12131c;
  --ink-2: #3b3d4d;
  --muted: #74768a;
  --line: #e6e4de;
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --accent: #ff5a36;
  --accent-ink: #ffffff;
  --accent-soft: #fff0eb;
  --ok: #15925a;
  --ok-soft: #e5f6ee;
  --warn: #b7791f;
  --warn-soft: #fdf3e1;
  --danger: #d03b3b;
  --danger-soft: #fdeaea;
  --side: #12131c;
  --side-ink: #c9cad6;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(18, 19, 28, .05), 0 6px 24px rgba(18, 19, 28, .06);
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 28px; font-weight: 800; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- Botones y formularios ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); padding: 9px 16px; border-radius: 999px; font-weight: 600; cursor: pointer; text-decoration: none; transition: transform .12s ease, background .15s ease, border-color .15s ease; white-space: nowrap; }
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover { background: #000; }
.btn-accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-accent:hover { filter: brightness(.95); border-color: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(18, 19, 28, .05); border-color: transparent; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-danger { color: var(--danger); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; justify-content: center; padding: 12px; }
.forgot { margin-top: 18px; }
.setup-page { min-height: 100vh; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stack { display: grid; gap: 6px; }
.mt { margin-top: 16px; }
.mt-sm { margin-top: 8px; }

label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.req { color: var(--accent); }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=date], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(18, 19, 28, .08); }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check-pill { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); padding: 8px 12px; border-radius: 999px; cursor: pointer; font-weight: 500; margin: 0; }
.check-pill:has(input:checked) { border-color: var(--ink); background: var(--ink); color: #fff; }
.check-pill input { accent-color: var(--accent); }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-brand { background: var(--side); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-brand::after { content: ''; position: absolute; width: 520px; height: 520px; right: -160px; bottom: -160px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 90, 54, .55), rgba(255, 90, 54, 0) 70%); }
.auth-brand h1 { font-size: 44px; max-width: 12ch; line-height: 1.05; position: relative; z-index: 1; }
.auth-brand p { color: var(--side-ink); max-width: 42ch; margin-top: 16px; position: relative; z-index: 1; }
.auth-brand ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 10px; color: var(--side-ink); position: relative; z-index: 1; }
.auth-brand li::before { content: '→ '; color: var(--accent); font-weight: 700; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: 26px; margin-bottom: 6px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; background: #ebe9e3; padding: 4px; border-radius: 999px; margin: 24px 0; }
.segmented button { border: 0; background: transparent; padding: 9px; border-radius: 999px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.segmented button[aria-selected=true] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.02em; position: relative; z-index: 1; }
.logo-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; color: #fff; font-weight: 800; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 22px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.side .logo { color: #fff; padding: 0 8px; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; border-radius: 10px; text-decoration: none; font-weight: 600; color: var(--side-ink); }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a[aria-current=page] { background: rgba(255, 255, 255, .1); color: #fff; }
.nav .count { background: var(--accent); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 999px; }
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 13px; }
.side-foot strong { color: #fff; display: block; }
.side-foot span { display: block; }
.side-foot button { display: flex; margin-top: 10px; color: var(--side-ink); border-color: rgba(255, 255, 255, .15); background: transparent; }
.main { padding: 32px clamp(16px, 4vw, 44px) 64px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { margin-top: 6px; }
.topbar-mobile { display: none; }

/* ---------- Tarjetas y grids ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.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)); }
.stat { padding: 18px 20px; }
.stat .value { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 600; }

.progress { height: 8px; background: #eeece6; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .4s ease; }
.progress.ok > span { background: var(--ok); }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: #eeece6; color: var(--ink-2); white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

.hero-card { background: var(--ink); color: #fff; border: 0; position: relative; overflow: hidden; }
.hero-card::after { content: ''; position: absolute; width: 300px; height: 300px; right: -90px; top: -120px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 90, 54, .5), transparent 70%); pointer-events: none; }
.hero-card .muted { color: var(--side-ink); }
.hero-card .progress { background: rgba(255, 255, 255, .15); }

/* ---------- Listas ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.step-check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; flex: none; color: transparent; font-weight: 800; font-size: 14px; }
.step-check:hover { border-color: var(--ink); }
.step-check.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.step-check[disabled] { cursor: default; }
li.is-done .step-title { text-decoration: line-through; color: var(--muted); }
.step-title { font-weight: 700; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--line); position: relative; font-size: 14px; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 14px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
.mini-list { margin: 4px 0 0; padding-left: 16px; font-size: 13px; color: var(--ink-2); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button[aria-selected=true] { color: var(--ink); border-color: var(--accent); }

/* ---------- Archivos ---------- */
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 28px; text-align: center; background: var(--surface-2); transition: border-color .15s, background .15s; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.file-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 800; font-size: 11px; text-transform: uppercase; flex: none; }

/* ---------- Kanban ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.column { background: #ecebe5; border-radius: var(--radius); padding: 12px; min-height: 140px; display: flex; flex-direction: column; gap: 8px; }
.column.over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.column-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 6px; font-weight: 700; font-size: 14px; }
.column-head .n { font-size: 12px; color: var(--muted); font-weight: 700; }
.step-name { display: inline-flex; align-items: center; gap: 8px; line-height: 1.25; }
.step-n { flex: none; width: 22px; height: 22px; border-radius: 7px; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 800; }
.column-desc { font-size: 12px; color: var(--muted); padding: 0 4px 4px; line-height: 1.4; }
.task { background: var(--surface); border-radius: 10px; padding: 12px; box-shadow: var(--shadow); cursor: grab; border: 1px solid transparent; }
.task:hover { border-color: var(--line); }
.task.dragging { opacity: .4; }
.task-title { font-weight: 700; font-size: 14px; }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.drop-marker { height: 3px; background: var(--accent); border-radius: 3px; }
.board.readonly .task { cursor: default; }
.add-task { border: 1px dashed #cfccc3; background: transparent; border-radius: 10px; padding: 8px; color: var(--muted); font-weight: 600; cursor: pointer; }
.add-task:hover { color: var(--ink); border-color: var(--ink-2); }
.service-switch { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

/* ---------- Modal y toast ---------- */
dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(18, 19, 28, .45); }
.modal-body { padding: 24px; max-height: 80vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--line); background: var(--surface-2); }
.toast-host { position: fixed; bottom: 20px; right: 20px; display: grid; gap: 8px; z-index: 100; }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 600; font-size: 14px; animation: toast-in .2s ease; max-width: 360px; }
.toast.error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.secret-box { font-family: ui-monospace, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; user-select: all; word-break: break-all; }
.empty { text-align: center; padding: 32px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; word-break: break-word; }
.answer { padding: 12px 0; border-bottom: 1px solid var(--line); }
.answer:last-child { border-bottom: 0; }
.answer .q { font-weight: 700; font-size: 14px; }
.answer .a { white-space: pre-wrap; margin-top: 4px; color: var(--ink-2); }
.answer .a.missing { color: var(--danger); font-style: italic; }
.loading { padding: 48px; text-align: center; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { padding: 28px 20px; }
  .auth-brand h1 { font-size: 30px; }
  .auth-brand ul { display: none; }
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .2s ease; z-index: 50; }
  .side.open { transform: none; }
  .topbar-mobile { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--side); color: #fff; position: sticky; top: 0; z-index: 40; }
  .topbar-mobile .btn { color: #fff; border-color: rgba(255, 255, 255, .2); background: transparent; }
  .main { padding: 20px 16px 48px; }
  .kv { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
