/* ==========================================================================
   M222HP GLORY — Shell, Navigation, Bento Grid, Console & Responsive Rules
   ========================================================================== */

/* Brand Mark */
.m2-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.m2-brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(145deg, #171a24, #090b10);
  border: 1px solid rgba(var(--accent-rgb), 0.42);
  box-shadow: 0 0 22px -6px rgba(var(--accent-rgb), 0.35);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.m2-brand-mark svg {
  width: 24px;
  height: 24px;
}

.m2-brand-text {
  min-width: 0;
}

.m2-brand-name {
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  white-space: nowrap;
}

.m2-brand-name span {
  color: var(--accent-light);
}

.m2-brand-sub {
  font-size: 0.6875rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==================== APP SHELL (SIDEBAR + MAIN) ==================== */
.m2-shell {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100svh;
  width: 100%;
}

.m2-sidebar {
  position: sticky;
  top: 0;
  height: 100svh;
  width: var(--sidebar-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: rgba(12, 14, 20, 0.92);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(18px);
  z-index: 40;
  transition: width var(--dur-med) var(--ease-out);
}

:root[data-sidebar="collapsed"] .m2-sidebar {
  width: var(--sidebar-collapsed);
}

.m2-sidebar-head {
  height: var(--topbar-height);
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

:root[data-sidebar="collapsed"] .m2-sidebar-head {
  justify-content: center;
  padding: 0 8px;
}

:root[data-sidebar="collapsed"] .m2-sidebar .m2-brand-text,
:root[data-sidebar="collapsed"] .m2-sidebar .m2-nav-label,
:root[data-sidebar="collapsed"] .m2-sidebar .m2-nav-badge,
:root[data-sidebar="collapsed"] .m2-sidebar .m2-sidebar-user-meta,
:root[data-sidebar="collapsed"] .m2-sidebar .m2-sidebar-credit {
  display: none;
}

:root[data-sidebar="collapsed"] .m2-sidebar .m2-collapse-btn {
  position: absolute;
  right: -13px;
  top: 18px;
  width: 26px;
  height: 26px;
  min-height: 26px;
  min-width: 26px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  z-index: 50;
}

:root[data-sidebar="collapsed"] .m2-sidebar .m2-collapse-btn svg {
  transform: rotate(180deg);
}

.m2-sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.m2-nav-section {
  padding: 10px 10px 4px;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

:root[data-sidebar="collapsed"] .m2-sidebar .m2-nav-section {
  display: none;
}

.m2-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 600;
  text-align: left;
  transition: background-color var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}

.m2-nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.m2-nav-item:hover {
  background: rgba(255, 255, 255, 0.045);
  color: var(--text-primary);
}

.m2-nav-item.is-active,
.m2-nav-item[aria-current="page"] {
  background: rgba(var(--accent-rgb), 0.12);
  border-color: rgba(var(--accent-rgb), 0.28);
  color: var(--accent-light);
}

.m2-nav-item.is-active::before,
.m2-nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

:root[data-sidebar="collapsed"] .m2-sidebar .m2-nav-item {
  justify-content: center;
  padding: 9px;
}

.m2-nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.m2-nav-badge {
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(var(--accent-rgb), 0.15);
  color: var(--accent-light);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
}

.m2-sidebar-foot {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.m2-sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}

:root[data-sidebar="collapsed"] .m2-sidebar .m2-sidebar-user {
  justify-content: center;
  padding: 6px;
}

.m2-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  color: var(--accent-ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.875rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.m2-sidebar-user-meta {
  min-width: 0;
  flex: 1;
}

.m2-sidebar-user-name {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.m2-sidebar-user-sub {
  font-size: 0.7rem;
  color: var(--accent-light);
  font-family: var(--font-mono);
}

.m2-sidebar-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

:root[data-sidebar="collapsed"] .m2-sidebar .m2-sidebar-tools {
  flex-direction: column;
}

.m2-sidebar-credit {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-align: center;
  padding-top: 4px;
}

.m2-sidebar-credit a:hover {
  color: var(--accent-light);
}

/* Main Workspace */
.m2-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.m2-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-height);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(8, 9, 13, 0.82);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(18px);
}

.m2-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.m2-mobile-menu-btn {
  display: none;
}

.m2-page-title {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.m2-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.m2-content {
  flex: 1 1 auto;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}

.m2-page-section {
  display: none;
}

.m2-page-section.is-active {
  display: block;
  animation: m2FadeSlide 0.22s var(--ease-out) both;
}

@media (prefers-reduced-motion: reduce) {
  .m2-page-section.is-active {
    animation: none;
  }
}

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

/* Mobile Navigation Drawer (<dialog>) */
dialog.m2-drawer {
  inset: 0;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
  --drawer-width: min(290px, 82vw);
}

dialog.m2-drawer::backdrop {
  background: rgba(4, 5, 9, 0.72);
  backdrop-filter: blur(4px);
}

dialog.m2-drawer[open] {
  display: block;
}

.m2-drawer-panel {
  width: var(--drawer-width);
  height: 100svh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  padding: 14px 12px calc(18px + env(safe-area-inset-bottom));
  overflow-y: auto;
  box-shadow: 24px 0 60px rgba(0, 0, 0, 0.7);
}

.m2-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* Mobile Bottom Nav */
.m2-bottom-nav {
  display: none;
}

@media (max-width: 1023px) {
  .m2-sidebar {
    display: none;
  }
  .m2-mobile-menu-btn {
    display: inline-flex;
  }
  .m2-topbar {
    padding: 0 14px;
  }
  .m2-content {
    padding: 16px 14px calc(86px + env(safe-area-inset-bottom));
  }
  .m2-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: rgba(12, 14, 20, 0.95);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(18px);
  }
  .m2-bnav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 48px;
    padding: 4px 2px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.65rem;
    font-weight: 600;
  }
  .m2-bnav-btn svg {
    width: 18px;
    height: 18px;
  }
  .m2-bnav-btn.is-active {
    color: var(--accent-light);
    background: rgba(var(--accent-rgb), 0.12);
  }
}

/* ==================== BENTO GRID SYSTEM ==================== */
.m2-bento {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
}

.m2-span-12 { grid-column: span 12; }
.m2-span-8  { grid-column: span 8; }
.m2-span-7  { grid-column: span 7; }
.m2-span-6  { grid-column: span 6; }
.m2-span-5  { grid-column: span 5; }
.m2-span-4  { grid-column: span 4; }
.m2-span-3  { grid-column: span 3; }

@media (max-width: 1200px) {
  .m2-span-3 { grid-column: span 6; }
  .m2-span-5, .m2-span-7, .m2-span-8, .m2-span-4 { grid-column: span 12; }
}

@media (max-width: 767px) {
  .m2-bento {
    gap: 12px;
  }
  .m2-span-12, .m2-span-8, .m2-span-7, .m2-span-6, .m2-span-5, .m2-span-4, .m2-span-3 {
    grid-column: span 12;
  }
}

.m2-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 1120px) {
  .m2-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 540px) {
  .m2-kpi-grid { grid-template-columns: 1fr; gap: 10px; }
}

/* Hero Welcome Card */
.m2-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  background:
    radial-gradient(ellipse 65% 110% at 92% 0%, rgba(var(--accent-rgb), 0.14), transparent 60%),
    radial-gradient(ellipse 50% 90% at 15% 100%, rgba(var(--accent-violet-rgb), 0.1), transparent 65%),
    var(--bg-card);
  border-color: rgba(var(--accent-rgb), 0.28);
}

.m2-hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-light);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.m2-hero-title {
  font-size: clamp(1.25rem, 2.4vw, 1.65rem);
  font-weight: 700;
  color: var(--text-primary);
}

.m2-hero-copy {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 5px;
  max-width: 560px;
}

.m2-hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Quick Nav Feature Tiles */
.m2-feature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 540px) {
  .m2-feature-grid { grid-template-columns: 1fr; }
}

.m2-feature-tile {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  text-align: left;
  width: 100%;
  transition: border-color var(--dur-fast), background-color var(--dur-fast), transform var(--dur-fast);
}

.m2-feature-tile:hover {
  border-color: rgba(var(--accent-rgb), 0.42);
  background: rgba(var(--accent-rgb), 0.05);
  transform: translateY(-1px);
}

.m2-feature-tile-ic {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.m2-feature-tile-ic svg {
  width: 17px;
  height: 17px;
}

.m2-feature-tile-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-primary);
}

.m2-feature-tile-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Form Two-Column Row */
.m2-form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 600px) {
  .m2-form-row { grid-template-columns: 1fr; gap: 0; }
}

/* ==================== GUILD DASHBOARD & SQUADS ==================== */
.m2-guild-hero {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.m2-guild-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.m2-guild-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.m2-guild-emblem {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 14px;
  border: 1px solid rgba(var(--accent-rgb), 0.45);
  background: #08090D;
  overflow: hidden;
  flex-shrink: 0;
}

.m2-guild-emblem img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.m2-guild-lv {
  position: absolute;
  bottom: 3px;
  right: 3px;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(8, 9, 13, 0.9);
  border: 1px solid rgba(var(--accent-rgb), 0.45);
  color: var(--accent-light);
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 700;
}

.m2-guild-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.m2-guild-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.m2-guild-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

@media (max-width: 767px) {
  .m2-guild-stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.m2-mini-stat {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(8, 9, 13, 0.52);
  border: 1px solid var(--border);
}

.m2-mini-stat-k {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.m2-mini-stat-v {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 4px;
}

.m2-squads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(330px, 100%), 1fr));
  gap: 14px;
}

.m2-squad-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.m2-bot-chips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

@media (max-width: 480px) {
  .m2-bot-chips { grid-template-columns: 1fr; }
}

.m2-bot-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  min-width: 0;
}

.m2-bot-chip-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.m2-squad-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.m2-squad-actions .m2-btn--full {
  grid-column: 1 / -1;
}

/* ==================== LIVE CONSOLE TERMINAL ==================== */
.m2-console {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: #07080C;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.m2-console--fullscreen,
.m2-console:fullscreen {
  position: fixed;
  inset: 0;
  z-index: 8500;
  border-radius: 0;
  border: 0;
  height: 100svh;
}

.m2-console-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.m2-console-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.m2-console-search {
  width: min(220px, 100%);
  min-height: 32px;
  padding: 5px 10px;
  font-size: 0.75rem;
}

.m2-console-body {
  position: relative;
  flex: 1 1 auto;
  height: 430px;
  overflow-y: auto;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.55;
}

.m2-console--fullscreen .m2-console-body,
.m2-console:fullscreen .m2-console-body {
  height: auto;
  flex: 1 1 auto;
}

.m2-log-row {
  display: grid;
  grid-template-columns: 70px 64px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding: 5px 8px;
  border-radius: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.m2-log-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.m2-log-time {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.m2-log-lvl {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 4px;
  text-align: center;
}

.m2-log-row--info .m2-log-lvl { background: rgba(56, 189, 248, 0.12); color: #7dd3fc; }
.m2-log-row--success .m2-log-lvl { background: rgba(34, 197, 94, 0.14); color: #86efac; }
.m2-log-row--warning .m2-log-lvl { background: rgba(245, 158, 11, 0.14); color: #fcd34d; }
.m2-log-row--error .m2-log-lvl { background: rgba(239, 68, 68, 0.16); color: #fca5a5; }
.m2-log-row--error { background: rgba(239, 68, 68, 0.045); }

.m2-log-msg {
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.m2-log-msg mark {
  background: rgba(var(--accent-rgb), 0.35);
  color: #fff;
  border-radius: 2px;
  padding: 0 2px;
}

@media (max-width: 560px) {
  .m2-log-row {
    grid-template-columns: auto auto;
  }
  .m2-log-msg {
    grid-column: 1 / -1;
  }
}

.m2-console-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 14px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

/* ==================== AUTH PAGE ==================== */
.m2-auth-page {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.m2-auth-toolbar {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
}

.m2-auth-card {
  width: min(440px, 100%);
  padding: 32px 28px 26px;
  border-radius: var(--radius-xl);
  background: linear-gradient(165deg, rgba(23, 26, 36, 0.9), rgba(13, 15, 22, 0.96));
  border: 1px solid rgba(var(--accent-rgb), 0.25);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.72), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(22px);
}

@media (max-width: 440px) {
  .m2-auth-card {
    padding: 24px 18px 20px;
  }
}

.m2-auth-seg {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  margin: 20px 0;
}

.m2-auth-seg-btn {
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 700;
  transition: all var(--dur-fast);
}

.m2-auth-seg-btn[aria-selected="true"] {
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  color: var(--accent-ink);
  box-shadow: 0 4px 14px -2px rgba(var(--accent-rgb), 0.35);
}

.m2-auth-foot {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.m2-auth-foot a:hover {
  color: var(--accent-light);
}

/* ==================== THEME SWATCHES ==================== */
.m2-theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 480px) {
  .m2-theme-grid { grid-template-columns: 1fr; }
}

.m2-theme-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 13px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  text-align: left;
  width: 100%;
  transition: border-color var(--dur-fast), background-color var(--dur-fast);
}

.m2-theme-card:hover {
  border-color: var(--border-strong);
}

.m2-theme-card[aria-pressed="true"] {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
}

.m2-theme-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.m2-theme-dots i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  display: block;
}

/* ==================== TOOLBAR & BULK ACTION BAR ==================== */
.m2-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.m2-toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.m2-bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 12px;
  border-radius: var(--radius-md);
  background: rgba(var(--accent-rgb), 0.1);
  border: 1px solid rgba(var(--accent-rgb), 0.35);
}

.m2-bulk-bar[hidden] {
  display: none;
}

/* ==================== CLAN TOPOLOGY MAP ==================== */
.m2-topo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px minmax(0, 1.3fr);
  align-items: center;
  gap: 8px;
}

@media (max-width: 680px) {
  .m2-topo {
    grid-template-columns: 1fr;
  }
  .m2-topo-wires {
    display: none;
  }
}

.m2-topo-box {
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(8, 9, 13, 0.55);
  border: 1px solid var(--border);
}

.m2-topo-node {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  width: 100%;
  text-align: left;
  transition: border-color var(--dur-fast), transform var(--dur-fast);
}

.m2-topo-node:hover {
  border-color: var(--accent);
  transform: translateX(2px);
}

/* ==================== ADMIN STRICT SAAS OVERRIDES ==================== */
body.m2-admin-mode .m2-card {
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
}

body.m2-admin-mode .m2-card:hover {
  border-color: var(--border-strong);
}

body.m2-admin-mode .m2-sidebar {
  background: rgba(11, 13, 18, 0.96);
}

body.m2-admin-mode .m2-topbar {
  background: rgba(10, 12, 16, 0.92);
}

/* ==================== LAUNCH PROGRESS STEPS ==================== */
.m2-steps {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.m2-step {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.m2-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
}

.m2-step.is-current {
  color: var(--accent-light);
}

.m2-step.is-current .m2-step-num {
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  color: var(--accent-ink);
  border-color: transparent;
}

.m2-step.is-done {
  color: var(--online);
}

.m2-step.is-done .m2-step-num {
  background: rgba(var(--online-rgb), 0.16);
  border-color: rgba(var(--online-rgb), 0.45);
  color: var(--online);
}

.m2-step-line {
  flex: 1;
  height: 1px;
  background: var(--border);
  min-width: 10px;
}

.m2-step-line.is-done {
  background: rgba(var(--online-rgb), 0.5);
}

/* Mobile strict zero-overflow safeguard */
@media (max-width: 440px) {
  .m2-topbar {
    padding: 0 10px;
    gap: 6px;
  }
  .m2-topbar-left {
    gap: 7px;
  }
  .m2-page-title {
    font-size: 0.9375rem;
  }
  .m2-topbar-right {
    gap: 6px;
  }
  .m2-topbar-right .m2-hide-xs {
    display: none;
  }
  .m2-card {
    padding: 15px;
  }
  .m2-dialog-head,
  .m2-dialog-body,
  .m2-dialog-foot {
    padding-left: 15px;
    padding-right: 15px;
  }
}

@media (max-width: 375px) {
  .m2-topbar .m2-badge {
    padding: 2px 7px;
    font-size: 0.625rem;
  }
}
