:root {
  --bg: #191919;
  --panel: #202225;
  --panel-2: #26292d;
  --border: #33373c;
  --text: #e7e6e3;
  --muted: #9b9a97;
  --accent: #4a9eff;
  --danger: #e5534b;
  --ok: #57ab5a;
  --warn: #d29922;
  --radius: 8px;
  --font: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; }
input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.muted { color: var(--muted); }
.spacer { flex: 1; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky; top: 0; z-index: 10;
}
.brand { color: var(--text); font-weight: 700; font-size: 15px; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  color: var(--muted); padding: 5px 10px; border-radius: 6px; font-weight: 500;
}
.topbar nav a:hover { background: var(--panel-2); color: var(--text); }
.topbar nav a.active { background: var(--panel-2); color: var(--text); }
.whoami { color: var(--muted); }
.inline-form { display: inline-flex; gap: 8px; align-items: center; margin: 0; }

/* ---------- botones ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #0b1520; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: rgba(229, 83, 75, .12); }

/* ---------- layout paginas ---------- */
main { padding: 24px; }
.page { max-width: 860px; margin: 0 auto; }
.page-wide { max-width: 1280px; }
.page-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; flex: 1; }
.empty { color: var(--muted); }

/* ---------- lista de proyectos ---------- */
.project-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.project-item {
  display: flex; align-items: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
}
.project-item:hover { border-color: var(--muted); }
.project-link { flex: 1; display: flex; align-items: center; gap: 10px; padding: 13px 16px; color: var(--text); font-weight: 500; }
.project-icon { color: var(--accent); }
.btn-del { margin-right: 8px; visibility: hidden; }
.project-item:hover .btn-del, tr:hover .btn-del { visibility: visible; }

/* ---------- kanban ---------- */
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
.col {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px; min-height: 200px; display: flex; flex-direction: column;
}
.col header {
  font-weight: 600; padding: 4px 6px 10px; display: flex; align-items: center; gap: 8px;
}
.col .count { color: var(--muted); font-weight: 400; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-todo { background: var(--muted); }
.dot-doing { background: var(--accent); }
.dot-done { background: var(--ok); }
.cards { display: flex; flex-direction: column; gap: 8px; min-height: 30px; flex: 1; }
.card {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; cursor: grab; word-break: break-word;
}
.card:hover { border-color: var(--muted); }
.card.dragging { opacity: .4; }
.card .card-meta { color: var(--muted); font-size: 11.5px; margin-top: 6px; display: flex; gap: 8px; align-items: center; }
/* Icono de contenido: como en Notion, delante del titulo y en la primera linea. */
.card .note-icon { color: var(--muted); vertical-align: -2px; margin-right: 6px; }
.drop-placeholder {
  height: 6px; border-radius: 3px; background: var(--accent); opacity: .7; margin: 0;
}
.add-task { margin-top: 10px; }
.add-task input { width: 100%; background: transparent; border-color: transparent; color: var(--muted); }
.add-task input:hover { background: var(--panel-2); }
.add-task input:focus { background: var(--panel-2); border-color: var(--accent); color: var(--text); }

/* ---------- modal ---------- */
.modal-backdrop[hidden] { display: none; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .55);
  display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50;
}
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  width: 720px; max-width: 100%; max-height: 86vh; display: flex; flex-direction: column;
  padding: 18px;
}
.modal-head { display: flex; gap: 8px; align-items: center; }
.modal-title {
  flex: 1; font-size: 18px; font-weight: 600; background: transparent; border-color: transparent;
}
.modal-title:hover { background: var(--panel-2); }
.modal-title:focus { background: var(--panel-2); border-color: var(--accent); }
.modal-meta { color: var(--muted); font-size: 12px; padding: 6px 10px 2px; }
/* Editor unico: se ve como quedara y se escribe encima (contenteditable). */
.notes-editor {
  margin-top: 10px;
  min-height: 300px; max-height: 56vh; overflow: auto;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--panel-2); color: var(--text);
  padding: 12px 14px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
  outline: none;
}
.notes-editor:focus { border-color: var(--accent); }
.notes-editor.is-empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  pointer-events: none;
}
.notes-editor img {
  max-width: 100%; border-radius: 6px; display: block; margin: 8px 0;
  border: 1px solid var(--border);
}
.notes-editor img.uploading { opacity: .45; }
.notes-editor a { word-break: break-all; cursor: pointer; }
.notes-editor a:hover { text-decoration: underline; }
.modal-foot { display: flex; align-items: center; gap: 10px; margin-top: 12px; }

/* ---------- contabilidad ---------- */
.conta-table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.conta-table th, .conta-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.conta-table th { color: var(--muted); font-weight: 500; font-size: 12.5px; background: var(--panel); }
.conta-table tbody tr:hover { background: var(--panel-2); }
.conta-table .amount { text-align: right; font-variant-numeric: tabular-nums; }
.th-amount { text-align: right !important; }
.conta-table td[data-edit] { cursor: text; }
.conta-table td input, .conta-table td select { width: 100%; }
.new-row td { background: var(--panel); }
.new-row input, .new-row select { width: 100%; }
.total-row td { font-weight: 700; border-bottom: none; background: var(--panel); }

/* ---------- login ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 32px; width: 340px;
}
.login-card h1 { margin: 0 0 18px; font-size: 20px; text-align: center; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.login-error {
  background: rgba(229, 83, 75, .12); border: 1px solid var(--danger); color: var(--danger);
  border-radius: 6px; padding: 8px 10px; margin: 0 0 14px;
}

@media (max-width: 900px) {
  .board { grid-template-columns: 1fr; }
}
