/* ===========================================================
   Morivo Team Dashboard — SPA frontend
   Design systém převzat 1:1 z Morivo Call asistent / banner-app
   (:root tokeny velínu). Vanilla CSS, žádný build.
   =========================================================== */
:root {
  color-scheme: light;
  --bg: #F6F4FE; --panel: #ffffff; --panel-2: #F9F7FF;
  --ink: #0D0D0D; --ink-soft: #6B6B7B; --ink-faint: #9890b0;
  --line: #E8E4F5; --accent: #655DEC; --accent-soft: #EDE9FE; --accent-d: #4f47c9;
  --alert: #e8443b; --alert-soft: #fdeceb; --ok: #2ea66f; --ok-soft: #e8f6ef;
  --radius: 14px; --radius-inner: 10px; --radius-chip: 8px;
  --control-h: 40px; --control-radius: 11px;
  --fs-cap: 11px; --fs-sm: 12px; --fs-base: 13px; --fs-stat: 22px;
  --body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --display: 'Nunito', 'Inter', -apple-system, sans-serif;
  --shadow: 0 1px 2px rgba(60,40,120,.04), 0 4px 16px rgba(80,60,160,.07);
  --shadow-lg: 0 8px 40px rgba(80,60,160,.18);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  font-family: var(--body); font-size: var(--fs-base); background: var(--bg);
  color: var(--ink); line-height: 1.45; -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- topbar + brand ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 24px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand:hover { text-decoration: none; }
.brand-logo { display: block; flex-shrink: 0; }
.brand-word {
  font-family: var(--display); font-weight: 900; font-size: 19px;
  color: var(--accent); letter-spacing: -.02em;
}
.brand-word span { color: var(--ink); font-weight: 800; margin-left: 5px; }
.userbox { display: flex; align-items: center; gap: 13px; font-size: var(--fs-sm); color: var(--ink-soft); }
.user-name { font-weight: 600; color: var(--ink); }
.user-role { font-size: var(--fs-cap); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent-d); background: var(--accent-soft); padding: 2px 7px; border-radius: 999px; }
.ubadge {
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff;
  font-weight: 800; font-size: 13px; display: inline-flex; align-items: center;
  justify-content: center; text-transform: uppercase; flex-shrink: 0;
}

/* ---------- container ---------- */
#app { max-width: 1180px; margin: 30px auto 64px; padding: 0 22px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 26px;
}
.narrow { max-width: 432px; margin: 7vh auto; }

/* ---------- typografie ---------- */
h1 { font-family: var(--display); font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 18px; }
h2 { font-family: var(--display); font-size: 16px; font-weight: 800; letter-spacing: -.01em; margin: 0 0 12px; }
.muted { color: var(--ink-soft); font-size: var(--fs-base); line-height: 1.55; }
.muted.sm { font-size: var(--fs-sm); }
.lede { color: var(--ink-soft); font-size: var(--fs-base); margin: -8px 0 20px; }

/* ---------- form prvky ---------- */
label { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft); margin-bottom: 14px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px; height: var(--control-h); padding: 0 13px;
  border: 1px solid var(--line); border-radius: var(--control-radius);
  font: inherit; font-weight: 500; color: var(--ink); background: var(--panel);
}
textarea { height: auto; min-height: 78px; padding: 10px 13px; line-height: 1.5; resize: vertical; }
select {
  cursor: pointer; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 16px) center, calc(100% - 11px) center;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 32%, transparent); border-color: var(--accent);
}

/* ---------- tlačítka ---------- */
.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
  height: var(--control-h); padding: 0 18px; border-radius: var(--control-radius);
  font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; transition: .14s;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); color: #fff; border: none; box-shadow: 0 4px 14px rgba(101,93,236,.28); }
.btn.primary:hover { background: var(--accent-d); }
.btn.primary:disabled, .btn:disabled { opacity: .55; cursor: wait; box-shadow: none; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { color: var(--accent); }
.btn.sm { height: 32px; padding: 0 13px; font-size: var(--fs-sm); }
.btn.danger { color: var(--alert); border-color: color-mix(in srgb, var(--alert) 30%, var(--line)); background: var(--panel); }
.btn.danger:hover { background: var(--alert-soft); border-color: var(--alert); }
.card.narrow .btn.primary, .btn.primary.full { width: 100%; }

/* ---------- auth ---------- */
.switch { font-size: var(--fs-base); color: var(--ink-soft); margin-top: 16px; text-align: center; }
.switch a { color: var(--accent); font-weight: 700; text-decoration: none; }
.switch a:hover { text-decoration: underline; }
.auth-logo { display: flex; justify-content: center; margin-bottom: 14px; }
.auth-logo svg { width: 56px; height: auto; }
.msg { padding: 10px 13px; border-radius: var(--radius-inner); font-size: var(--fs-base); margin-bottom: 14px; line-height: 1.5; }
.msg.err { background: var(--alert-soft); color: var(--alert); }
.msg.ok { background: var(--ok-soft); color: var(--ok); }

/* ---------- 2FA ---------- */
.secret-box {
  display: flex; align-items: center; gap: 10px; background: var(--accent-soft);
  border: 1px dashed var(--accent); border-radius: var(--radius-inner); padding: 13px; margin: 10px 0 16px;
}
.secret-box code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 16px; font-weight: 700;
  letter-spacing: 1px; word-break: break-all; flex: 1; color: var(--ink);
}
.otpauth-box {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-inner);
  padding: 11px 12px; margin: 0 0 16px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--fs-sm); color: var(--ink-soft); word-break: break-all; line-height: 1.5;
}
.totp-manual summary { cursor: pointer; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft); margin: -4px 0 12px; }
.totp-manual summary:hover { color: var(--accent); }
.code-input { text-align: center; font-size: 26px; letter-spacing: 10px; font-weight: 800; height: 54px; }

/* ---------- DASHBOARD: hero ---------- */
.hero { text-align: center; margin: 24px 0 34px; }
.hero-title {
  font-family: var(--display); font-weight: 900; font-size: 40px; letter-spacing: -.03em;
  margin: 0 0 8px; color: var(--ink); line-height: 1.05;
}
.hero-sub { color: var(--ink-soft); font-size: 16px; margin: 0; font-weight: 500; }

/* ---------- DASHBOARD: grid appek ---------- */
.apps-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px; align-items: stretch;
}
.app-card {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 22px 18px; cursor: pointer;
  transition: transform .16s cubic-bezier(.4,0,.2,1), box-shadow .16s, border-color .16s;
  color: inherit; text-decoration: none; position: relative; overflow: hidden;
}
.app-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent); opacity: 0; transition: opacity .16s;
}
.app-card:hover {
  text-decoration: none; transform: translateY(-4px);
  box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}
.app-card:hover::before { opacity: 1; }
.app-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.app-emoji {
  font-size: 26px; line-height: 1; width: 50px; height: 50px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); border-radius: var(--radius-inner);
  transition: transform .16s, background .16s;
}
.app-card:hover .app-emoji { transform: scale(1.06) rotate(-3deg); }
.app-tag {
  font-size: var(--fs-cap); font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--accent-d); background: var(--accent-soft); padding: 4px 10px; border-radius: 999px;
  white-space: nowrap; line-height: 1.2;
}
.app-name { font-family: var(--display); font-weight: 800; font-size: 18px; letter-spacing: -.01em; color: var(--ink); margin-top: 2px; }
.app-desc { color: var(--ink-soft); font-size: var(--fs-base); line-height: 1.55; flex: 1; }
.app-open {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 6px;
  font-size: var(--fs-sm); font-weight: 700; color: var(--accent-d);
}
.app-arrow { display: inline-flex; transition: transform .16s; }
.app-card:hover .app-arrow { transform: translate(2px, -2px); }

.apps-foot { text-align: center; color: var(--ink-faint); font-size: var(--fs-sm); margin: 28px 0 0; }

/* skeleton dlaždice */
.app-skeleton {
  height: 172px; border-radius: var(--radius); border: 1px solid var(--line);
  background: linear-gradient(100deg, var(--panel-2) 30%, #f0ecfb 50%, var(--panel-2) 70%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- prázdné / loading stavy ---------- */
.empty {
  text-align: center; padding: 56px 24px; color: var(--ink-soft);
  border: 1px dashed var(--line); border-radius: var(--radius); background: var(--panel-2);
}
.empty.span-all { grid-column: 1 / -1; }
.empty .emo { font-size: 30px; margin-bottom: 10px; }
.empty b { display: block; color: var(--ink); font-size: 15px; font-weight: 800; margin-bottom: 4px; }
.loading { text-align: center; padding: 56px 24px; color: var(--ink-soft); }
.spinner {
  width: 26px; height: 26px; margin: 0 auto 14px; border-radius: 50%;
  border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- toasty ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.toast {
  padding: 13px 16px; border-radius: var(--radius-inner); box-shadow: var(--shadow-lg);
  font-size: var(--fs-base); font-weight: 600; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-left: 4px solid var(--accent);
  animation: toast-in .25s cubic-bezier(.4,0,.2,1); display: flex; align-items: flex-start; gap: 9px;
}
.toast.err { border-left-color: var(--alert); }
.toast.err .t-ic { color: var(--alert); }
.toast.ok { border-left-color: var(--ok); }
.toast.ok .t-ic { color: var(--ok); }
.toast .t-ic { flex-shrink: 0; font-weight: 800; }
.toast.fade { animation: toast-out .3s forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  #app { padding: 0 14px; margin-top: 20px; }
  .card { padding: 20px; }
  .user-name { display: none; }
  .hero-title { font-size: 30px; }
  .hero-sub { font-size: 14px; }
  .apps-grid { grid-template-columns: 1fr; gap: 14px; }
}

/* --- Tým (admin správa účtů) --- */
.team-add { max-width: 460px; }
.team-add h3, .team-h { font-family: 'Nunito','Inter',sans-serif; font-weight: 800; margin: 22px 0 10px; }
.team-list { display: flex; flex-direction: column; gap: 10px; }
.team-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; background: #fff; border: 1px solid #E8E4F5; border-radius: 12px; padding: 12px 16px; }
.team-who b { font-weight: 700; }
.team-status { font-size: 12px; margin-top: 2px; }
.team-act { display: flex; gap: 8px; flex-shrink: 0; }
