/* ============================================================
   Grupo Zolar — Minimalist light design system
   Pure white · confident typography · zero decoration
   ============================================================ */
:root {
  --bg: #ffffff;
  --bg-elevated: #ffffff;
  --bg-subtle: #fafafa;
  --bg-muted: #f4f4f5;

  --text: #0a0a0a;
  --text-secondary: #52525b;
  --text-tertiary: #a1a1aa;

  --hairline: #e4e4e7;
  --hairline-strong: #d4d4d8;

  --accent: #0a0a0a;
  --accent-hover: #27272a;
  --accent-pressed: #000000;
  --accent-ring: rgba(10, 10, 10, 0.12);

  --link: #2563eb;
  --link-hover: #1d4ed8;

  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --success: #16a34a;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.06);

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --t-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --t: 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --font-display: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  letter-spacing: -0.011em;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

h1, h2, h3, h4 { color: var(--text); margin: 0; font-family: var(--font-display); font-weight: 600; letter-spacing: -0.022em; }
h1 { font-size: 48px; font-weight: 600; letter-spacing: -0.035em; line-height: 1.05; }
h2 { font-size: 20px; font-weight: 600; letter-spacing: -0.018em; }
h3 { font-size: 16px; font-weight: 600; letter-spacing: -0.014em; }
p { margin: 0; }
a { color: var(--link); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--link-hover); }

.muted { color: var(--text-secondary); }
.tertiary { color: var(--text-tertiary); }
.hide { display: none !important; }

/* ============================================================
   LOGIN — pure white, floating composition (no card, no blobs)
   ============================================================ */
#login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #ffffff;
  animation: fadeIn 0.4s ease-out;
}

.login-card {
  width: 100%;
  max-width: 360px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  animation: slideUp 0.5s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.login-logo {
  width: 36px;
  height: 36px;
  margin: 0 auto 32px;
  border-radius: 8px;
  background: #0a0a0a;
  display: grid; place-items: center;
}
.login-logo svg { width: 20px; height: 20px; color: #fff; }

.login-card h1 {
  font-size: 28px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: -0.025em;
  color: var(--text);
}
.login-card .subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 32px;
  font-weight: 400;
  letter-spacing: -0.008em;
}

#login-form { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.005em;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  letter-spacing: -0.008em;
}
input::placeholder, textarea::placeholder { color: var(--text-tertiary); }
input:hover:not(:focus), select:hover:not(:focus), textarea:hover:not(:focus) {
  border-color: var(--hairline-strong);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

button {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  padding: 8px 14px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: #ffffff;
  color: var(--text);
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
button:hover { background: var(--bg-muted); }
button:active { transform: scale(0.985); }
button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

button.primary, button[type="submit"] {
  background: #0a0a0a;
  color: #ffffff;
  border: 1px solid #0a0a0a;
  font-weight: 500;
  padding: 10px 18px;
  margin-top: 10px;
  font-size: 14px;
  border-radius: var(--radius-sm);
}
button.primary:hover, button[type="submit"]:hover {
  background: #27272a;
  border-color: #27272a;
}
button.primary:active, button[type="submit"]:active {
  background: #000000;
  border-color: #000000;
  transform: scale(0.99);
}
button.primary:focus-visible, button[type="submit"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring);
}

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--hairline);
  padding: 6px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}
button.ghost:hover { background: var(--bg-muted); }

button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--hairline);
}
button.danger:hover {
  background: var(--danger-soft);
  border-color: rgba(220, 38, 38, 0.3);
}

.error {
  color: var(--danger);
  font-size: 13px;
  font-weight: 500;
  margin: 8px 0 0;
  text-align: center;
  min-height: 18px;
  letter-spacing: -0.005em;
}

/* ============================================================
   HEADER — flat, hairline-only
   ============================================================ */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: #ffffff;
  border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0; z-index: 50;
  height: 56px;
}
header .brand-mini {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 14px;
  letter-spacing: -0.014em;
  color: var(--text);
}
header .brand-mini .dot {
  width: 20px; height: 20px;
  border-radius: 5px;
  background: #0a0a0a;
}
header .right { display: flex; gap: 6px; align-items: center; font-size: 13px; }
header a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--t-fast), color var(--t-fast);
}
header a:hover { color: var(--text); background: var(--bg-muted); }
header .muted { font-size: 13px; color: var(--text-secondary); padding-right: 6px; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 64px 32px 96px;
  animation: fadeIn 0.3s ease-out;
}

/* ============================================================
   LAUNCHER
   ============================================================ */
.launcher-header { margin-bottom: 48px; }
.launcher-header .greeting {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  font-weight: 500;
  letter-spacing: -0.008em;
}
.launcher-header h1 {
  font-size: 48px;
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.05;
  color: var(--text);
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 16px;
}

.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.app-card {
  position: relative;
  background: #ffffff;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 22px;
  cursor: pointer;
  transition: border-color var(--t), transform var(--t), box-shadow var(--t);
  display: flex; flex-direction: column; gap: 12px;
  animation: slideUp 0.4s ease-out both;
  min-height: 156px;
}
.app-card:hover {
  border-color: var(--hairline-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.app-card:active { transform: translateY(0); transition-duration: 0.08s; }

.app-card .icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--bg-muted);
  display: grid; place-items: center;
  font-size: 20px;
}
.app-card .nombre {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.014em;
  color: var(--text);
}
.app-card .desc {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-top: -4px;
  letter-spacing: -0.008em;
}
.app-card .rol {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-muted);
  color: var(--text-secondary);
  align-self: flex-start;
  margin-top: auto;
  text-transform: capitalize;
}
.app-card .rol.admin {
  background: #0a0a0a;
  color: #ffffff;
}

#apps-empty {
  background: #ffffff;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 56px 28px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14.5px;
  line-height: 1.6;
}

/* ============================================================
   ADMIN
   ============================================================ */
.admin-page-header { margin-bottom: 36px; }
.admin-page-header h1 {
  font-size: 36px;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text);
}
.admin-page-header .subtitle {
  color: var(--text-secondary);
  margin-top: 8px;
  font-size: 15px;
  letter-spacing: -0.012em;
}

.tabs {
  display: inline-flex;
  gap: 0;
  background: transparent;
  padding: 0;
  border-bottom: 1px solid var(--hairline);
  border-radius: 0;
  margin-bottom: 28px;
  width: fit-content;
}
.tabs button {
  background: transparent;
  color: var(--text-secondary);
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 500;
  border: 0;
  border-radius: 0;
  letter-spacing: -0.005em;
  border-bottom: 1.5px solid transparent;
  margin-bottom: -1px;
}
.tabs button:hover { color: var(--text); background: transparent; }
.tabs button.active {
  background: transparent;
  color: var(--text);
  box-shadow: none;
  border-bottom-color: var(--text);
}

.card {
  background: #ffffff;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  margin-bottom: 16px;
}
.card h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.014em;
  margin-bottom: 16px;
}

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > input, .row > select { flex: 1; min-width: 140px; }
.row label.checkbox-inline {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 0 8px; font-size: 13.5px; color: var(--text-secondary);
  white-space: nowrap;
}
.row label.checkbox-inline input[type=checkbox] {
  width: auto; min-height: 0;
  accent-color: var(--text);
  cursor: pointer;
}
.row button { flex: 0 0 auto; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--hairline);
}
tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--hairline);
  vertical-align: middle;
  color: var(--text);
  letter-spacing: -0.006em;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--t-fast); }
tbody tr:hover { background: var(--bg-subtle); }

.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions button { padding: 5px 10px; font-size: 12.5px; border-radius: 6px; }

code {
  font-family: var(--font-mono);
  background: var(--bg-muted);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12.5px;
  color: var(--text);
}

.badge {
  display: inline-flex; align-items: center;
  font-size: 11.5px; font-weight: 500;
  padding: 2px 8px; border-radius: 999px;
  background: var(--bg-muted); color: var(--text-secondary);
}

#permisos-matrix table { font-size: 13px; }
#permisos-matrix select { padding: 6px 10px; font-size: 13px; min-height: 0; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(10, 10, 10, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid; place-items: center;
  z-index: 100;
  animation: fadeIn 0.18s ease-out;
}
.modal {
  background: #ffffff;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 28px;
  min-width: 380px; max-width: 90vw; max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.modal h3 { font-size: 18px; font-weight: 600; letter-spacing: -0.018em; margin-bottom: 18px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  header { padding: 0 16px; }
  .container { padding: 40px 20px 64px; }
  .login-card { padding: 0; max-width: 100%; }
  .grid { grid-template-columns: 1fr; }
  .launcher-header h1 { font-size: 36px; }
  .admin-page-header h1 { font-size: 28px; }
  h1 { font-size: 32px; }
}
