/* MINOT — estilo inspirado en Notion */
:root {
  --bg: #ffffff;
  --bg-side: #f7f7f5;
  --bg-hover: rgba(55, 53, 47, .06);
  --bg-soft: #fbfbfa;
  --text: #37352f;
  --text-2: rgba(55, 53, 47, .65);
  --text-3: rgba(55, 53, 47, .45);
  --border: rgba(55, 53, 47, .12);
  --accent: #2383e2;
  --accent-text: #ffffff;
  --danger: #e03e3e;
  --ok: #0f7b6c;
  --shadow: 0 1px 2px rgba(15, 15, 15, .06), 0 4px 12px rgba(15, 15, 15, .06);
  --radius: 6px;

  --tag-gray: #e3e2e0;    --tag-gray-t: #32302c;
  --tag-orange: #fadec9;  --tag-orange-t: #49290e;
  --tag-yellow: #fdecc8;  --tag-yellow-t: #402c1b;
  --tag-green: #dbeddb;   --tag-green-t: #1c3829;
  --tag-blue: #d3e5ef;    --tag-blue-t: #183347;
  --tag-purple: #e8deee;  --tag-purple-t: #412454;
  --tag-red: #ffe2dd;     --tag-red-t: #5d1715;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191919; --bg-side: #202020; --bg-hover: rgba(255,255,255,.055); --bg-soft: #202020;
    --text: rgba(255,255,255,.88); --text-2: rgba(255,255,255,.6); --text-3: rgba(255,255,255,.4);
    --border: rgba(255,255,255,.1); --shadow: 0 4px 16px rgba(0,0,0,.4);
    --tag-gray: #373737; --tag-gray-t: rgba(255,255,255,.85);
    --tag-orange: #5c3b23; --tag-orange-t: #fff;
    --tag-yellow: #564328; --tag-yellow-t: #fff;
    --tag-green: #2b4632; --tag-green-t: #fff;
    --tag-blue: #28456c; --tag-blue-t: #fff;
    --tag-purple: #492f64; --tag-purple-t: #fff;
    --tag-red: #6e3630; --tag-red-t: #fff;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.5 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Helvetica, Arial, sans-serif;
  color: var(--text); background: var(--bg);
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-color: var(--text-3); }

/* ── Layout ── */
.app { display: flex; min-height: 100vh; }
.side {
  width: 240px; flex-shrink: 0; background: var(--bg-side); border-right: 1px solid var(--border);
  padding: 12px 8px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
}
.side .ws { display: flex; align-items: center; gap: 8px; padding: 6px 10px 14px; font-weight: 600; }
.side .ws .logo { width: 22px; height: 22px; border-radius: 4px; background: #e8590c; color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.side .sec { font-size: 11px; color: var(--text-3); font-weight: 600; padding: 14px 10px 4px; text-transform: uppercase; letter-spacing: .04em; }
.side a.item { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: var(--radius); color: var(--text-2); }
.side a.item:hover { background: var(--bg-hover); text-decoration: none; }
.side a.item.on { background: var(--bg-hover); color: var(--text); font-weight: 600; }
.side .ico { width: 20px; text-align: center; }
.side .me { margin-top: auto; padding: 10px; font-size: 12px; color: var(--text-2); border-top: 1px solid var(--border); }
.side .me form { margin: 6px 0 0; }
.side form.search input { width: 100%; }

.main { flex: 1; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 24px; font-size: 13px; color: var(--text-2);
  position: sticky; top: 0; background: var(--bg); z-index: 5; }
.page { max-width: 1180px; margin: 0 auto; padding: 24px 48px 80px; }
.page.wide { max-width: none; padding: 24px 32px 80px; }
.page-icon { font-size: 52px; line-height: 1; margin: 16px 0 8px; }
h1.title { font-size: 34px; font-weight: 700; margin: 0 0 6px; letter-spacing: -.01em; }
.subtitle { color: var(--text-2); margin-bottom: 20px; }
h2 { font-size: 18px; margin: 32px 0 10px; }

/* ── Controles ── */
input, select, textarea {
  font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 5px 8px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(35,131,226,.35); border-color: var(--accent); }
textarea { width: 100%; resize: vertical; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; font: inherit; white-space: nowrap; }
.btn:hover { background: var(--bg-hover); text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(.95); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; }
.btn.sm { padding: 2px 8px; font-size: 12px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.toolbar .grow { flex: 1; }
.tabs { display: flex; gap: 2px; margin-bottom: 6px; }
.tabs a { padding: 4px 10px; border-radius: var(--radius); color: var(--text-2); font-size: 13px; }
.tabs a.on { background: var(--bg-hover); color: var(--text); font-weight: 600; }

/* ── Tags ── */
.tag { display: inline-block; padding: 0 6px; border-radius: 3px; font-size: 12px; line-height: 20px; white-space: nowrap;
  background: var(--tag-gray); color: var(--tag-gray-t); margin: 1px 2px 1px 0; }
.tag.orange { background: var(--tag-orange); color: var(--tag-orange-t); }
.tag.yellow { background: var(--tag-yellow); color: var(--tag-yellow-t); }
.tag.green  { background: var(--tag-green);  color: var(--tag-green-t); }
.tag.blue   { background: var(--tag-blue);   color: var(--tag-blue-t); }
.tag.purple { background: var(--tag-purple); color: var(--tag-purple-t); }
.tag.red    { background: var(--tag-red);    color: var(--tag-red-t); }

/* ── Tablas ── */
.table-wrap { overflow-x: auto; }
table.db { width: 100%; border-collapse: collapse; font-size: 14px; }
table.db th { text-align: left; font-weight: 500; color: var(--text-2); font-size: 13px; padding: 6px 8px;
  border-bottom: 1px solid var(--border); white-space: nowrap; }
table.db th a { color: inherit; }
table.db td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.db tr:hover td { background: var(--bg-soft); }
table.db td.num, table.db th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.db td.t a { font-weight: 500; }
.count { color: var(--text-3); font-size: 12px; padding: 8px; }
.empty { color: var(--text-3); padding: 24px 8px; }

/* ── Dashboard ── */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin: 10px 0 8px; }
.kpi { border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; background: var(--bg); }
.kpi .l { font-size: 12px; color: var(--text-2); }
.kpi .v { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.funnel .row { display: grid; grid-template-columns: 150px 1fr 110px; align-items: center; gap: 10px; padding: 4px 0; font-size: 13px; }
.funnel .bar { height: 18px; border-radius: 3px; background: var(--accent); opacity: .75; min-width: 2px; }
.funnel .n { text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ── Kanban ── */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 20px; align-items: flex-start; }
.col { width: 260px; flex-shrink: 0; border-radius: 8px; background: var(--bg-soft); padding: 8px; }
.col .head { display: flex; align-items: center; gap: 6px; padding: 2px 4px 8px; font-size: 13px; }
.col .head .n { color: var(--text-3); }
.col .head .sum { margin-left: auto; color: var(--text-3); font-size: 12px; }
.col.over { outline: 2px dashed var(--accent); }
.card { background: var(--bg); border-radius: 6px; box-shadow: var(--shadow); padding: 8px 10px; margin-bottom: 8px; cursor: grab; border: 1px solid var(--border); }
.card .t { font-weight: 500; margin-bottom: 4px; }
.card .m { font-size: 12px; color: var(--text-2); }
.card.dragging { opacity: .5; }
.col .add { display: block; color: var(--text-3); padding: 4px; font-size: 13px; }

/* ── Página de registro ── */
.props { display: grid; grid-template-columns: 180px 1fr; gap: 2px 8px; margin: 12px 0 20px; align-items: center; }
.props label { color: var(--text-2); font-size: 14px; padding: 5px 0; display: flex; gap: 6px; align-items: center; }
.props .v input:not([type=checkbox]), .props .v select { width: 100%; max-width: 480px; border-color: transparent; background: transparent; }
.props .v input:hover, .props .v select:hover { background: var(--bg-hover); }
.props .v input:focus, .props .v select:focus { background: var(--bg); border-color: var(--accent); }
.props .v textarea { max-width: 720px; border-color: var(--border); }
.title-input { font-size: 34px; font-weight: 700; border: none; width: 100%; padding: 0; background: transparent; letter-spacing: -.01em; }
.title-input:focus { outline: none; }
.ms { display: flex; flex-wrap: wrap; gap: 4px 10px; padding: 4px 0; }
.ms label { font-size: 13px; color: var(--text); padding: 0; }
.editor { width: 100%; min-height: 260px; border: none; border-top: 1px solid var(--border); padding: 16px 0; font-size: 15px; line-height: 1.7; border-radius: 0; }
.editor:focus { outline: none; border-color: var(--border); }
.actions { display: flex; gap: 8px; align-items: center; margin: 16px 0; position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; border-top: 1px solid var(--border); }
.meta { font-size: 12px; color: var(--text-3); }

/* ── Ítems de cotización ── */
table.items input, table.items select { width: 100%; }
table.items td { padding: 4px; }
.totales { margin-left: auto; width: 320px; margin-top: 12px; }
.totales div { display: flex; justify-content: space-between; padding: 4px 8px; font-variant-numeric: tabular-nums; }
.totales .big { font-weight: 700; font-size: 16px; border-top: 1px solid var(--border); padding-top: 8px; }

/* ── Mensajes ── */
.flash { padding: 8px 12px; border-radius: var(--radius); margin-bottom: 12px; font-size: 13px; }
.flash.ok { background: var(--tag-green); color: var(--tag-green-t); }
.flash.error { background: var(--tag-red); color: var(--tag-red-t); }

/* ── Login ── */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--bg-side); padding: 16px; }
.login .box { width: 100%; max-width: 380px; background: var(--bg); border-radius: 12px; box-shadow: var(--shadow); padding: 36px 32px; text-align: center; }
.login .box .logo { width: 48px; height: 48px; border-radius: 10px; background: #e8590c; color: #fff; display: grid; place-items: center; margin: 0 auto 14px; font-weight: 700; font-size: 20px; }
.login .box .btn { width: 100%; justify-content: center; padding: 9px; margin-top: 18px; }

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; gap: 2px; }
  .side .sec, .side .me, .side form.search { display: none; }
  .page, .page.wide { padding: 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .props { grid-template-columns: 1fr; }
  h1.title, .title-input { font-size: 26px; }
}

@media print {
  .side, .topbar, .actions, .no-print { display: none !important; }
}
