:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --text: #162033;
  --muted: #6c7890;
  --primary: #2457e6;
  --primary-strong: #153db3;
  --danger: #d14638;
  --success: #178a49;
  --border: #e6ebf4;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.05);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --sidebar-width: 240px;
  --topbar-height: 40px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  font-family: Inter, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(36, 87, 230, 0.08), transparent 24%),
    linear-gradient(180deg, #f6f9ff 0%, #f2f6fb 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

/* ---------- AUTH ---------- */

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
}

.auth-panel {
  background: linear-gradient(180deg, #0f172a 0%, #16284f 100%);
  color: #fff;
  padding: 48px;
  display: flex;
  align-items: flex-end;
}

.auth-panel-copy {
  max-width: 320px;
}

.auth-panel h1 {
  margin: 8px 0 12px;
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1.08;
}

.auth-panel p {
  margin: 0;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.7;
}

.auth-main {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.auth-card,
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(100%, 460px);
  padding: 28px;
}

.auth-card.wide {
  width: min(100%, 1020px);
}
.logo-img { width: 46px; height: 46px; background-color: white; border-radius: 50%;}
.card-head h2,
.page-head h1 {
  margin: 0 0 8px;
}

.card-head.compact h2 {
  margin-bottom: 6px;
}

.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
}

.muted {
  color: var(--muted);
  line-height: 1.6;
}

.form-grid {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}

input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  padding: 14px 15px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus {
  border-color: rgba(36, 87, 230, 0.5);
  box-shadow: 0 0 0 4px rgba(36, 87, 230, 0.1);
}

code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
  background: #eef3ff;
  border-radius: 12px;
  padding: 10px 12px;
  display: inline-block;
  word-break: break-all;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  padding: 12px 15px;
  font-weight: 700;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.2s ease, opacity 0.2s ease;
}

.btn-danger:hover {
  transform: translateY(-1px);
  background: #b9382b;
}

/* ---------- BUTTONS ---------- */

.btn-primary,
.btn-secondary,
.btn-danger,
.icon-btn,
.menu-btn,
.menu-toggle {
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.2s ease, opacity 0.2s ease;
}

.btn-primary:hover,
.btn-secondary:hover,
.btn-danger:hover,
.icon-btn:hover,
.menu-btn:hover,
.menu-toggle:hover {
  transform: translateY(-1px);
}
.menu-toggle {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  font-size: 20px;
  line-height: 1;
  padding: 0;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  padding: 14px 18px;
  font-weight: 700;
}

.btn-primary:hover {
  background: var(--primary-strong);
}

.btn-secondary {
  background: #eff3ff;
  color: var(--primary-strong);
  padding: 12px 15px;
  font-weight: 700;
}

.icon-btn,
.menu-btn {
  width: 42px;
  height: 42px;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.mobile-only {
  display: none;
}

/* ---------- FLASH ---------- */

.flash-wrap {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.flash {
  padding: 14px 16px;
  border-radius: 16px;
  font-size: 14px;
  background: #eef4ff;
  border: 1px solid #d7e4ff;
}

.flash.error {
  background: #fff2f0;
  border-color: #ffd3ce;
}

.flash.success {
  background: #eefcf2;
  border-color: #c8f0d4;
}

.flash.info {
  background: #f4f7fb;
  border-color: #e0e7f0;
}

/* ---------- APP LAYOUT ---------- */

.app-shell {
  min-height: 100vh;
  display: flex;
  background: var(--bg);
}

.sidebar-overlay {
  display: none;
}

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: linear-gradient(180deg, #0f172a 0%, #13264c 100%);
  color: #fff;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.sidebar-brand,
.brand-title {
  font-size: 18px;
  font-weight: 800;
}

.brand-subtitle {
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.12);
  font-weight: 800;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 14px;
  color: #d8e1f0;
  background: transparent;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-link.danger {
  color: #ffe0dc;
}

.nav-icon {
  width: 18px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 14px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.07);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.14);
  font-weight: 700;
}

.user-name {
  font-size: 14px;
  font-weight: 700;
}

.user-role {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
}

.main-shell {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar {
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 18px;
  background: rgba(244, 247, 251, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(230, 235, 244, 0.9);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-title {
  font-weight: 800;
  font-size: 18px;
}

.content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 16px;
  overflow: auto;
}

/* ---------- GENERAL CONTENT ---------- */

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-head.compact {
  margin-bottom: 12px;
}

.card-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(280px, 400px) minmax(0, 1fr);
}

.card {
  padding: 24px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 14px;
}

th {
  background: #f8faff;
  font-weight: 700;
}

.badge {
  display: inline-block;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: #eef3ff;
  color: var(--primary-strong);
  font-weight: 700;
}

.badge.success {
  background: #eefcf2;
  color: var(--success);
}

.badge.danger {
  background: #fff2f0;
  color: var(--danger);
}

.badge.muted-badge {
  background: #f4f7fb;
  color: var(--muted);
}

.invite-link-box {
  margin-top: 20px;
  padding: 18px;
  border-radius: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.copy-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

/* ---------- 2FA ---------- */

.twofa-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.qr-box {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  text-align: center;
}

.qr-box img {
  display: block;
  width: 100%;
  max-width: 240px;
  margin: 0 auto;
  border-radius: 16px;
  background: #fff;
  padding: 12px;
}

.secret-box {
  margin-top: 14px;
}

.secret-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

/* ---------- DASHBOARD ---------- */

.dashboard-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  gap: 10px;
}

.dashboard-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 2px 0;
}

.dashboard-topbar h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: #0f172a;
}

.dashboard-topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.dashboard-error,
.error-text {
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
  min-height: 20px;
}

.dashboard-frame-wrap {
  flex: 1;
  min-height: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
}

.dashboard-host,
.loading-box {
  width: 100%;
  height: calc(100vh - var(--topbar-height) - 70px);
  min-height: 620px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 15px;
  background: #fff;
}

.dashboard-host metabase-dashboard,
metabase-dashboard {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 620px;
}

/* ---------- MOBILE ---------- */

@media (max-width: 991px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-panel {
    display: none;
  }

  .auth-main {
    padding: 20px;
  }

  .auth-card,
  .auth-card.wide {
    width: 100%;
    padding: 22px;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1001;
    width: min(88vw, 300px);
    min-width: min(88vw, 300px);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  }

  .sidebar.open,
  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-overlay,
  .mobile-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    display: block;
    border: 0;
  }

  .sidebar-overlay.show,
  .mobile-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-only {
    display: inline-grid;
    margin-left: auto;
  }

  .topbar {
    padding: 0 14px;
  }

  .content {
    padding: 12px;
  }

  .card-grid,
  .twofa-layout,
  .copy-row {
    grid-template-columns: 1fr;
  }

  .dashboard-topbar h1 {
    font-size: 20px;
  }

  .dashboard-host,
  .loading-box {
    height: calc(100vh - var(--topbar-height) - 56px);
    min-height: 480px;
  }

  .dashboard-host metabase-dashboard,
  metabase-dashboard {
    min-height: 480px;
  }
}