:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --card: #ffffff;
  --ink: #0f172a;
  --ink-soft: #64748b;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(2, 6, 23, .12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: #f1f5f9;
  -webkit-font-smoothing: antialiased;
}

/* ─── Brand ─── */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: #fff; font-weight: 800; letter-spacing: .5px;
}
.brand.small .brand-mark { width: 32px; height: 32px; border-radius: 9px; font-size: 13px; }
.brand-name { font-weight: 700; font-size: 18px; }
.brand-sub { color: var(--ink-soft); font-size: 13px; }

/* ─── Auth ─── */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #1e3a8a 0%, #0f172a 60%);
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--card);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px;
}
.auth-card .brand { margin-bottom: 24px; }
.auth-card form { display: flex; flex-direction: column; gap: 16px; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: #334155; }
.auth-card input {
  padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.auth-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.auth-card button {
  margin-top: 4px; padding: 12px; border: 0; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font-size: 15px; font-weight: 700;
  cursor: pointer; transition: filter .15s;
}
.auth-card button:hover { filter: brightness(1.05); }
.foot { margin: 20px 0 0; text-align: center; color: var(--ink-soft); font-size: 13px; }
.alert {
  background: #fef2f2; color: var(--danger); border: 1px solid #fecaca;
  padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-bottom: 18px;
}

/* ─── Topbar ─── */
.topbar { background: #fff; border-bottom: 1px solid var(--line); }
.topbar-inner {
  max-width: 1040px; margin: 0 auto; padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-chip { font-size: 14px; color: #334155; font-weight: 600; }
.btn-ghost {
  text-decoration: none; color: var(--ink-soft); font-size: 14px; font-weight: 600;
  padding: 7px 12px; border-radius: 9px; border: 1px solid var(--line);
}
.btn-ghost:hover { background: #f8fafc; color: var(--ink); }

/* ─── Lobby ─── */
.lobby { max-width: 1040px; margin: 0 auto; padding: 48px 24px; }
.lobby h1 { margin: 0 0 6px; font-size: 28px; }
.lead { margin: 0 0 32px; color: var(--ink-soft); }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.app-tile {
  display: flex; flex-direction: column; gap: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; text-decoration: none; color: var(--ink);
  transition: transform .15s, box-shadow .15s, border-color .15s;
  border-top: 3px solid var(--accent);
}
.app-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--accent); }
.app-icon { font-size: 30px; }
.app-name { font-weight: 700; font-size: 18px; }
.app-desc { color: var(--ink-soft); font-size: 14px; line-height: 1.4; }

/* ─── Administration ─── */
.admin { max-width: 980px; margin: 0 auto; padding: 32px 24px 64px; }
.admin.narrow { max-width: 680px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 24px; }
.back { display: inline-block; font-size: 13px; color: var(--ink-soft); text-decoration: none; margin-bottom: 4px; }
.back:hover { color: var(--accent); }
.btn { display: inline-block; text-decoration: none; cursor: pointer; font-size: 14px; font-weight: 700; padding: 10px 16px; border-radius: 10px; border: 0; background: var(--accent); color: #fff; }
.btn:hover { background: #1e40af; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px; }
.card h2 { margin: 0 0 14px; font-size: 16px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--ink-soft); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; padding: 0 12px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.right { text-align: right; }
.strong { font-weight: 700; }
.muted { color: var(--ink-soft); font-size: 13px; }
.link { color: var(--accent); text-decoration: none; font-weight: 600; }
.link:hover { text-decoration: underline; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.b-admin { background: #eef2ff; color: #4338ca; }
.b-user { background: #f1f5f9; color: #475569; }
.chip { display: inline-block; background: #eff6ff; color: #1d4ed8; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; margin: 2px 4px 2px 0; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.dot.ok { background: #16a34a; }
.dot.off { background: #cbd5e1; }
.form { display: flex; flex-direction: column; gap: 16px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: #334155; }
.form input:not([type=checkbox]) { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; background: #fff; outline: none; }
.form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.form input:disabled { background: #f8fafc; color: #94a3b8; }
.hint { color: var(--ink-soft); font-size: 12px; font-weight: 400; }
small.hint { margin-top: 2px; }
.switches, .apps-block { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.apps-block { border-top: 1px solid var(--line); padding-top: 16px; }
.apps-title { font-weight: 700; font-size: 14px; color: #334155; }
.switch { flex-direction: row !important; align-items: flex-start; gap: 10px !important; font-weight: 500 !important; cursor: pointer; }
.switch input { margin-top: 3px; width: 16px; height: 16px; }
.switch span { font-weight: 600; color: #334155; }
.switch small { display: block; font-weight: 400; color: var(--ink-soft); font-size: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 4px; }
.row-form { flex-direction: row; align-items: center; }
.row-form input { flex: 1; }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid #fecaca; padding: 10px 16px; border-radius: 10px; font-weight: 700; cursor: pointer; }
.btn-danger:hover { background: #fef2f2; }
.danger-card { border-color: #fecaca; }
.empty { color: var(--ink-soft); }
.alert { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-bottom: 18px; }
