/* MyCuadraOK CEO — tablet-first */
:root {
  --bg: #0a0f14;
  --bg2: #0d1117;
  --card: #161b22;
  --border: rgba(255,255,255,0.08);
  --text: #e6edf3;
  --muted: #8b949e;
  --gold: #d4af37;
  --gold-soft: rgba(212,175,55,0.14);
  --accent: #58a6ff;
  --ok: #3fb950;
  --warn: #d29922;
  --err: #f85149;
  --nav-w: 240px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: 'Outfit', system-ui, sans-serif;
  background: radial-gradient(ellipse 100% 60% at 50% -10%, rgba(212,175,55,0.07), transparent 45%), var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-top: var(--safe-t);
}

.login-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
}

.login-card h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.login-card .sub { color: var(--muted); margin: 0 0 1.5rem; font-size: 0.95rem; }
.login-card label { display: block; margin-bottom: 1rem; font-size: 0.9rem; color: var(--muted); }
.login-card input {
  display: block; width: 100%; margin-top: 0.35rem;
  padding: 0.85rem 1rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg2); color: var(--text);
  font-size: 1rem;
}
.login-card button {
  width: 100%; padding: 0.95rem; border: none; border-radius: 10px;
  background: linear-gradient(135deg, var(--gold), #b8962e);
  color: #111; font-weight: 700; font-size: 1rem; cursor: pointer;
}
.login-card .err { color: var(--err); font-size: 0.9rem; min-height: 1.2rem; }
.server-status { font-size: 0.78rem; margin-top: 0.65rem; line-height: 1.4; padding: 0.5rem 0.6rem; border-radius: 8px; }
.server-status.checking { color: var(--muted); }
.server-status.ok { color: #3fb950; background: rgba(63,185,80,0.08); }
.server-status.err { color: var(--err); background: rgba(248,81,73,0.08); }
.login-card .brand { font-size: 0.8rem; color: var(--muted); margin-top: 1rem; text-align: center; }

#app {
  display: none;
  min-height: 100vh;
}

.sidebar {
  width: var(--nav-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.sidebar-head h1 { margin: 0; font-size: 1.15rem; }
.badge-ceo {
  display: inline-block; font-size: 0.65rem; font-weight: 700;
  background: var(--gold-soft); color: var(--gold);
  border: 1px solid rgba(212,175,55,0.35);
  padding: 0.15rem 0.45rem; border-radius: 6px; vertical-align: middle;
}
.sidebar-head p { margin: 0.35rem 0 0; font-size: 0.82rem; color: var(--muted); }

.nav { flex: 1; margin-top: 1.5rem; display: flex; flex-direction: column; gap: 0.25rem; }
.nav-item {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.75rem 0.85rem; border-radius: 10px;
  color: var(--muted); text-decoration: none; cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
  font: inherit; font-size: 0.95rem;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item.active { background: var(--gold-soft); color: var(--gold); font-weight: 600; }
.nav-item .icon { font-size: 1.15rem; width: 1.4rem; text-align: center; }

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding-top: 1rem; font-size: 0.85rem; color: var(--muted);
}
.sidebar-foot button {
  margin-top: 0.5rem; width: 100%; padding: 0.55rem;
  border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--text); cursor: pointer;
}

.main {
  margin-left: var(--nav-w);
  padding: 1.25rem 1.5rem 5rem;
  min-height: 100vh;
}

.topbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}
.topbar h2 { margin: 0; font-size: 1.35rem; }
.topbar .meta { margin: 0.25rem 0 0; font-size: 0.82rem; color: var(--muted); }
.topbar .meta code { font-size: 0.78rem; }

.btn {
  padding: 0.65rem 1.1rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card);
  color: var(--text); cursor: pointer; font: inherit; font-size: 0.9rem;
}
.btn-gold {
  background: linear-gradient(135deg, var(--gold), #b8962e);
  color: #111; border: none; font-weight: 600;
}
.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.8rem; border-radius: 8px; border: 1px solid var(--border); background: var(--bg2); color: var(--text); cursor: pointer; }

.view { display: none; }
.view.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.kpi.gold { border-color: rgba(212,175,55,0.35); }
.kpi.warn { border-color: rgba(210,153,34,0.35); }
.kpi .num { display: block; font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.kpi .lbl { font-size: 0.78rem; color: var(--muted); margin-top: 0.35rem; }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
  margin-bottom: 1rem;
}
.panel h3 { margin: 0 0 0.75rem; font-size: 1rem; }

.mov-list { list-style: none; margin: 0; padding: 0; }
.mov-item {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}
.mov-item:last-child { border-bottom: none; }
.mov-head { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.9rem; }
.mov-head span { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.mov-body { color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; }
.empty { color: var(--muted); font-style: italic; padding: 1rem 0; }

.inv-summary {
  display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.inv-summary .pill {
  background: var(--gold-soft); border: 1px solid rgba(212,175,55,0.3);
  padding: 0.6rem 1rem; border-radius: 10px; font-size: 0.9rem;
}
.inv-summary strong { color: var(--gold); font-size: 1.2rem; margin-right: 0.35rem; }

.inv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.85rem;
}
.inv-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.inv-card.low { border-color: rgba(248,81,73,0.45); }
.inv-name { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.5rem; }
.inv-qty { font-size: 1.75rem; font-weight: 700; }
.inv-qty span { font-size: 0.85rem; color: var(--muted); font-weight: 400; }
.inv-min { font-size: 0.78rem; color: var(--muted); margin: 0.25rem 0 0.65rem; }

.form-panel label {
  display: block; margin-bottom: 0.85rem; font-size: 0.88rem; color: var(--muted);
}
.form-panel input, .form-panel select, .form-panel textarea {
  display: block; width: 100%; margin-top: 0.3rem;
  padding: 0.75rem 0.85rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg2); color: var(--text);
  font: inherit; font-size: 1rem;
}
.form-panel textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; }

.modal {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.65); align-items: center; justify-content: center; padding: 1rem;
}
.modal.open { display: flex; }
.modal-box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; width: 100%; max-width: 400px;
}
.modal-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }

.fab {
  position: fixed; right: 1.25rem; bottom: calc(1.25rem + var(--safe-b));
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), #b8962e);
  color: #111; border: none; font-size: 1.5rem; font-weight: 700;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4); cursor: pointer; z-index: 50;
}

.toast {
  position: fixed; bottom: calc(5rem + var(--safe-b)); left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--card); border: 1px solid var(--gold);
  padding: 0.75rem 1.25rem; border-radius: 10px; opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s; z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Tablet portrait / móvil */
@media (max-width: 900px) {
  .sidebar {
    width: 100%; height: auto; position: fixed; bottom: 0; top: auto;
    flex-direction: row; padding: 0.5rem; border-right: none;
    border-top: 1px solid var(--border); padding-bottom: calc(0.5rem + var(--safe-b));
  }
  .sidebar-head, .sidebar-foot { display: none; }
  .nav { flex-direction: row; margin: 0; overflow-x: auto; flex: 1; }
  .nav-item { flex-direction: column; font-size: 0.72rem; padding: 0.5rem 0.65rem; min-width: 72px; text-align: center; }
  .nav-item .icon { font-size: 1.25rem; }
  .main { margin-left: 0; margin-bottom: 72px; padding: 1rem; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
}

.modal-box label { display: block; margin: 0.75rem 0; font-size: 0.88rem; color: var(--muted); }
.modal-box input, .modal-box textarea, .modal-box select {
  display: block; width: 100%; margin-top: 0.3rem; padding: 0.7rem;
  border-radius: 8px; border: 1px solid var(--border); background: var(--bg2); color: var(--text); font: inherit;
}
.modal-box.wide { max-width: 480px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.action-list { list-style: none; margin: 0; padding: 0; }
.action-item {
  padding: 0.75rem 0; border-bottom: 1px solid var(--border); cursor: pointer;
  display: flex; flex-direction: column; gap: 0.2rem;
}
.action-item:last-child { border-bottom: none; }
.action-item strong { font-size: 0.9rem; }
.action-item span { font-size: 0.82rem; color: var(--muted); }
.action-item.pri-high strong { color: var(--err); }
.action-item.pri-medium strong { color: var(--warn); }
.count-badge {
  display: inline-block; font-size: 0.75rem; background: var(--err);
  color: #fff; padding: 0.1rem 0.45rem; border-radius: 8px; margin-left: 0.35rem;
}
.nav-badge {
  background: var(--err); color: #fff; font-size: 0.65rem;
  padding: 0.1rem 0.35rem; border-radius: 6px; margin-left: auto;
}

.pipeline-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pipe-pill {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.5rem 0.75rem; text-align: center; min-width: 80px;
}
.pipe-n { display: block; font-size: 1.25rem; font-weight: 700; color: var(--gold); }
.pipe-l { font-size: 0.72rem; color: var(--muted); }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th, .data-table td { padding: 0.65rem 0.5rem; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--muted); font-weight: 500; font-size: 0.78rem; }
.data-table code { font-size: 0.82rem; color: var(--gold); }
.dir-access-table code.dir-pwd { font-family: 'JetBrains Mono', monospace; letter-spacing: 0.02em; }
.dir-pwd-input { max-width: 140px; padding: 0.35rem 0.5rem; font-size: 0.82rem; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; color: var(--text); }
.btn-copy { margin-left: 0.25rem; padding: 0.15rem 0.4rem; font-size: 0.75rem; opacity: 0.85; }

.tag {
  display: inline-block; font-size: 0.72rem; padding: 0.15rem 0.45rem;
  border-radius: 6px; background: rgba(255,255,255,0.06); color: var(--muted);
}
.tag.ok { background: rgba(63,185,80,0.15); color: var(--ok); }
.tag.err { background: rgba(248,81,73,0.15); color: var(--err); }
.tag.warn { background: rgba(210,153,34,0.15); color: var(--warn); }

.list-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.85rem; margin-bottom: 0.5rem;
}
.list-card.warn { border-color: rgba(210,153,34,0.35); }
.list-card strong { display: block; margin-bottom: 0.25rem; }
.list-card span, .list-card small { font-size: 0.82rem; color: var(--muted); }
.list-card small { display: block; margin-top: 0.25rem; }

.pro-card { cursor: pointer; transition: border-color 0.15s; }
.pro-card:hover { border-color: rgba(212,175,55,0.4); }
.pro-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.pro-meta { font-size: 0.82rem; color: var(--muted); margin-top: 0.25rem; }
.pro-notes { font-size: 0.85rem; margin-top: 0.35rem; font-style: italic; }

.compact-form { margin-bottom: 1rem; }
.pay-info p { margin: 0; line-height: 1.6; font-size: 0.92rem; }
.inv-summary .pill.gold { border-color: rgba(212,175,55,0.35); }
.inv-summary .pill.warn { border-color: rgba(248,81,73,0.35); }

.sub-tabs { display: flex; gap: 0.35rem; margin-bottom: 1rem; flex-wrap: wrap; }
.sub-tab {
  padding: 0.55rem 1rem; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg2); color: var(--muted); cursor: pointer; font: inherit; font-size: 0.88rem;
}
.sub-tab.active { background: var(--gold-soft); color: var(--gold); border-color: rgba(212,175,55,0.35); font-weight: 600; }
.ptab { display: none; }
.ptab.active { display: block; }
.toolbar-row { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.toolbar-row h3 { margin: 0; }
.list-card.muted { opacity: 0.55; }
.modal-box label { display: block; margin: 0.75rem 0; font-size: 0.88rem; color: var(--muted); }

@media (min-width: 901px) and (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
}
