/* Fonai Services — hoja de estilos del portal (sin dependencias externas) */

:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --ink: #15171c;
  --ink-2: #3a3e47;
  --muted: #6c707a;
  --border: #e5e5df;
  --border-strong: #d6d6ce;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e6f2f0;
  --ok: #15803d;
  --ok-soft: #e8f5ec;
  --warn: #b45309;
  --warn-soft: #fdf3e4;
  --bad: #b91c1c;
  --bad-soft: #fdecec;
  --idle: #71717a;
  --idle-soft: #f0f0ee;
  --focus: 0 0 0 3px rgba(15, 118, 110, .28);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 22, 28, .04), 0 1px 1px rgba(20, 22, 28, .03);
  --shadow-hover: 0 10px 30px -12px rgba(20, 22, 28, .18), 0 2px 6px rgba(20, 22, 28, .05);
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1013;
    --surface: #15181d;
    --surface-2: #1a1d23;
    --ink: #eceef1;
    --ink-2: #c5c9d0;
    --muted: #8d939d;
    --border: #252931;
    --border-strong: #323741;
    --accent: #2dd4bf;
    --accent-ink: #062b27;
    --accent-soft: #0f2a27;
    --ok: #4ade80;
    --ok-soft: #10261a;
    --warn: #fbbf24;
    --warn-soft: #2a2010;
    --bad: #f87171;
    --bad-soft: #2c1414;
    --idle: #9ca3af;
    --idle-soft: #1f2329;
    --focus: 0 0 0 3px rgba(45, 212, 191, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-hover: 0 12px 30px -12px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
a { color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.015em; }
p { margin: 0; }
svg { flex-shrink: 0; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------------ Cabecera */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1160px; margin: 0 auto; padding: 0 24px;
  height: 60px; display: flex; align-items: center; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 650; letter-spacing: -0.01em; }
.brand-mark { width: 28px; height: 28px; }
.brand-name { font-size: 15px; }
.nav { display: flex; gap: 2px; flex: 1; }
.nav a {
  text-decoration: none; color: var(--muted); font-weight: 500; font-size: 14px;
  padding: 7px 12px; border-radius: 8px; transition: color .15s, background .15s;
}
.nav a:hover { color: var(--ink); background: var(--idle-soft); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); }
.userbox { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 650; letter-spacing: .02em;
}
.userbox form { margin: 0; }

/* ------------------------------------------------------------------ Estructura */
.page { max-width: 1160px; margin: 0 auto; padding: 40px 24px 72px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.eyebrow { font-size: 12.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.page-title { font-size: 28px; font-weight: 680; line-height: 1.2; }
.page-sub { color: var(--muted); margin-top: 6px; }
.section-title { font-size: 15px; font-weight: 650; margin-bottom: 4px; }
.section-sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.stack > * + * { margin-top: 20px; }
.status-note { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }

/* ------------------------------------------------------------------ Tarjetas de apps */
.apps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.app-card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
  transition: box-shadow .2s ease, border-color .2s ease, transform .2s ease;
}
.app-card.is-active:hover { box-shadow: var(--shadow-hover); border-color: var(--border-strong); transform: translateY(-1px); }
.app-card.is-soon { background: var(--surface-2); }
.app-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.app-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.is-soon .app-icon { background: var(--idle-soft); color: var(--idle); }
.app-company { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.app-name { font-size: 17px; font-weight: 650; line-height: 1.3; }
.app-desc { color: var(--ink-2); font-size: 14px; margin-top: 8px; flex: 1; }
.is-soon .app-desc { color: var(--muted); }
.app-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border);
}
.app-guard { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }

/* Indicador de estado */
.status {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  font-size: 12.5px; font-weight: 550; padding: 4px 10px 4px 9px; border-radius: 999px;
  background: var(--idle-soft); color: var(--idle);
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status[data-state="up"] { background: var(--ok-soft); color: var(--ok); }
.status[data-state="up"]::before { box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 22%, transparent); }
.status[data-state="degraded"] { background: var(--warn-soft); color: var(--warn); }
.status[data-state="down"] { background: var(--bad-soft); color: var(--bad); }

/* ------------------------------------------------------------------ Botones */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-size: 14px; font-weight: 600; line-height: 1;
  padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--bg)); }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--border-strong); background: var(--surface-2); }
.btn-quiet { background: transparent; color: var(--muted); padding: 8px 10px; }
.btn-quiet:hover { color: var(--ink); background: var(--idle-soft); }
.btn-danger { background: transparent; color: var(--bad); border-color: var(--border); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-sm { font-size: 13px; padding: 7px 11px; }
.btn-block { width: 100%; padding: 12px 16px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; pointer-events: none; }

/* ------------------------------------------------------------------ Paneles y formularios */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-body { padding: 24px; }
.panel + .panel { margin-top: 20px; }
.panel-head { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; align-items: start; }

.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; color: var(--ink-2); }
.field-hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.input, .select {
  width: 100%; font: inherit; font-size: 15px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 10px 12px; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.input-code { font-family: var(--mono); font-size: 22px; letter-spacing: .35em; text-align: center; padding: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; margin: 0 16px 8px 0; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.alert { border-radius: var(--radius-sm); padding: 11px 14px; font-size: 14px; margin-bottom: 18px; border: 1px solid; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-error { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert-info { background: var(--accent-soft); color: var(--ink-2); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }

/* ------------------------------------------------------------------ Tablas */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 24px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 14px 24px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .muted, .muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--idle-soft); color: var(--idle); margin-left: 6px; }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.inline-form { display: inline; margin: 0; }

/* ------------------------------------------------------------------ Autenticación */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 28px; font-weight: 650; font-size: 16px; }
.auth-brand .brand-mark { width: 34px; height: 34px; }
.auth-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 32px; box-shadow: 0 24px 60px -30px rgba(20, 22, 28, .22), var(--shadow); }
.auth-title { font-size: 21px; font-weight: 680; margin-bottom: 6px; }
.auth-sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 22px; display: flex; gap: 6px; align-items: center; justify-content: center; }

.qr { display: grid; place-items: center; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 10px; width: max-content; margin: 4px 0 14px; }
.qr svg { display: block; }
.secret { font-family: var(--mono); font-size: 13.5px; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 8px; padding: 8px 10px; word-break: break-all; }
.steps { margin: 0 0 18px; padding-left: 20px; color: var(--ink-2); font-size: 14px; }
.steps li + li { margin-top: 6px; }

.empty { text-align: center; padding: 56px 24px; color: var(--muted); }

/* ------------------------------------------------------------------ Responsive */
@media (max-width: 760px) {
  .topbar-inner { height: auto; flex-wrap: wrap; gap: 10px 16px; padding: 12px 16px 0; }
  .brand { order: 1; }
  .userbox { order: 2; margin-left: auto; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .user-name { display: none; }
  .page { padding: 28px 16px 56px; }
  .page-title { font-size: 24px; }
  .apps-grid { grid-template-columns: 1fr; gap: 14px; }
  .app-card { padding: 18px; }
  .auth-panel { padding: 24px; }
  .table th, .table td { padding: 12px 16px; }
  .panel-body, .panel-head { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
.error-actions { margin-top: 20px; }
.eyebrow a { text-decoration: none; } .eyebrow a:hover { color: var(--ink); }
