:root {
  --bg: #0f0f0f;
  --panel: #1a1a1a;
  --border: #2e2e2e;
  --text: #f2f0ed;
  --text-dim: #afa69d;
  --accent: #ccff00;
  --accent-fg: #0f0f0f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
}

.page-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.wrap {
  width: 100%;
  max-width: 900px;
  text-align: center;
}

.logo {
  display: block;
  width: 180px;
  max-width: 60%;
  height: auto;
  margin: 0 auto 6px;
}

.subtitle {
  color: var(--text-dim);
  font-size: 14px;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 48px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 22px;
  text-decoration: none;
  color: var(--text);
  text-align: left;
  transition: border-color .15s, transform .15s;
}

.tile:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.tile-icon { margin-bottom: 12px; color: #fc8215; }
.tile-icon svg { display: block; width: 30px; height: 30px; }
.tile-name { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.tile-desc { font-size: 13px; color: var(--text-dim); line-height: 1.4; }

@media (prefers-color-scheme: light) {
  /* el portal es siempre oscuro, coherente con el resto de apps internas */
}

/* ── Cabecera comun de las apps Playroom ───────────────────────────── */
.ph-header {
  position: sticky; top: 0; z-index: 100; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; height: 64px; padding: 0 28px;
  background: rgba(15,15,15,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.ph-header-left { display: flex; align-items: center; gap: 16px; min-width: 0; }
.ph-brand { display: flex; align-items: center; gap: 16px; text-decoration: none; color: inherit; flex-shrink: 0; }
.ph-logo { height: 34px; width: auto; display: block; }
.ph-divider { width: 1px; height: 24px; background: var(--border); flex-shrink: 0; }
.ph-appname { font-size: 13px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--text-dim); white-space: nowrap; }
.ph-nav { display: flex; align-items: center; gap: 4px; margin-left: 8px; }
.ph-nav a { color: var(--text-dim); text-decoration: none; font-size: 13px; padding: 6px 12px; border-radius: 8px; }
.ph-nav a:hover, .ph-nav a.active { color: var(--text); background: var(--panel); }
.ph-header-right { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.ph-portal-link {
  color: var(--text-dim); text-decoration: none; font-size: 12.5px;
  border: 1px solid var(--border); border-radius: 20px; padding: 5px 14px; white-space: nowrap;
}
.ph-portal-link:hover { border-color: var(--accent); color: var(--text); }
.ph-user { text-align: right; line-height: 1.3; }
.ph-user-name { display: block; font-size: 12.5px; color: var(--text); }
.ph-user-role { display: block; font-size: 11px; color: var(--text-dim); }
.ph-icon-btn {
  background: none; border: 1px solid var(--border); color: var(--text-dim); border-radius: 6px;
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; text-decoration: none; font-size: 14px; flex-shrink: 0; padding: 0;
}
.ph-icon-btn:hover { border-color: #ef4444; color: #ef4444; }
.ph-icon-btn.admin:hover { border-color: var(--accent); color: var(--accent); }

/* ── Login ──────────────────────────────────────────────────────────── */
.login-box {
  width: 320px; margin: 0 auto; background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 28px; text-align: center;
}
.login-box img { width: 150px; max-width: 60%; height: auto; margin-bottom: 24px; }
.login-box input {
  width: 100%; box-sizing: border-box; background: #222222; border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; color: var(--text); font-size: 14px; margin-bottom: 10px;
}
.login-box button {
  width: 100%; background: var(--accent); border: none; border-radius: 8px; color: var(--accent-fg);
  font-weight: 600; padding: 10px 12px; font-size: 14px; cursor: pointer; margin-top: 4px;
}
.login-box button:hover { filter: brightness(1.08); }
.login-error { color: #ef4444; font-size: 13px; margin-bottom: 10px; }

/* ── Admin ──────────────────────────────────────────────────────────── */
.admin-wrap { max-width: 760px; margin: 0 auto; text-align: left; }
.admin-wrap .back-link { display: inline-block; margin-bottom: 20px; color: var(--text-dim); text-decoration: none; font-size: 13px; }
.admin-wrap .back-link:hover { color: var(--text); }
.admin-wrap h1 { font-size: 18px; margin: 0 0 20px; }
table.users-table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 10px; overflow: hidden; margin-bottom: 28px; }
table.users-table th, table.users-table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
table.users-table th { color: var(--text-dim); font-weight: 600; font-size: 11px; text-transform: uppercase; }
table.users-table tr:last-child td { border-bottom: none; }
.app-badge { display: inline-block; font-size: 11px; background: rgba(204,255,0,.14); color: var(--accent); border-radius: 5px; padding: 2px 8px; margin: 2px 3px 2px 0; }
.admin-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 20px; }
.admin-card h2 { font-size: 14px; margin: 0 0 14px; }
.admin-card input[type=text], .admin-card input[type=password] {
  width: 100%; box-sizing: border-box; background: #222222; border: 1px solid var(--border); color: var(--text);
  padding: 9px 12px; border-radius: 7px; font-size: 13px; margin-bottom: 10px;
}
.perm-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.perm-grid label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim); }
.admin-card button.submit { background: var(--accent); border: none; color: var(--accent-fg); font-weight: 600; border-radius: 6px; padding: 8px 16px; font-size: 13px; cursor: pointer; }
.admin-row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-row-actions button {
  background: #222222; border: 1px solid var(--border); color: var(--text); border-radius: 6px;
  padding: 4px 9px; font-size: 11.5px; cursor: pointer;
}
.admin-row-actions button:hover { border-color: var(--accent); }
.admin-row-actions button.danger:hover { background: rgba(239,68,68,.15); border-color: #ef4444; color: #ef4444; }
#admin-status { font-size: 12px; color: var(--text-dim); margin-left: 8px; }

/* ── 403 ────────────────────────────────────────────────────────────── */
.error-box { max-width: 420px; margin: 0 auto; text-align: center; }
.error-box .code { font-size: 44px; margin-bottom: 8px; }
.error-box a { color: var(--accent); }

/* ── Responsive (móvil / tablet) ───────────────────────────────────── */
@media (max-width: 860px) {
  .ph-header { padding: 0 14px; gap: 10px; height: 56px; }
  .ph-logo { height: 26px; }
  .ph-appname, .ph-divider, .ph-user { display: none; }
  .ph-portal-link { padding: 5px 10px; font-size: 11.5px; }
  .page-content { padding: 20px 14px; }
  .login-box { width: 100%; max-width: 320px; }
}
