:root {
  --bg: #0f1116;
  --panel: #151920;
  --card: #1b2029;
  --text: #f2f3f7;
  --muted: #9aa0ad;
  --line: rgba(255,255,255,0.08);
  --accent: #f39c4c;
  --shadow: 0 16px 40px rgba(0,0,0,0.45);
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Manrope", system-ui, -apple-system, sans-serif;
  background: radial-gradient(800px 500px at 10% 0%, rgba(243,156,76,0.15), transparent 50%),
    radial-gradient(700px 500px at 90% 10%, rgba(80,90,120,0.2), transparent 50%),
    var(--bg);
  color: var(--text);
}

.auth-screen {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 24px;
  background: var(--bg);
  z-index: 50;
}
.auth-screen.show {
  display: grid;
}
.auth-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 28px;
  box-shadow: var(--shadow);
  width: min(420px, 92vw);
  display: grid;
  gap: 12px;
}
.auth-title {
  font-size: 20px;
  font-weight: 600;
}
.auth-sub {
  font-size: 13px;
  color: var(--muted);
}
.auth-row {
  display: grid;
  gap: 10px;
}
.auth-row input {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-size: 14px;
  background: #0f1116;
  color: var(--text);
}
.auth-note {
  font-size: 12px;
  color: var(--muted);
}

.mg-preloader {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, 0.86);
  display: grid;
  place-items: center;
  z-index: 40;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.mg-preloader.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.mg-preloader-card {
  display: grid;
  gap: 10px;
  align-items: center;
  justify-items: center;
  padding: 22px 26px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(18, 20, 28, 0.9);
  box-shadow: var(--shadow);
}

.mg-preloader-mark {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.06);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.12em;
  animation: mgPulse 1.8s ease-in-out infinite;
}

.mg-preloader-text {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.mg-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.mg-sidebar {
  background: #0b0d12;
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.mg-brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.mg-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #ffb36b, #f39c4c);
  font-weight: 700;
  color: #1a1a1a;
}

.mg-name {
  font-size: 16px;
  font-weight: 600;
}

.mg-sub {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
}

.mg-nav {
  display: grid;
  gap: 8px;
}

.mg-item {
  background: transparent;
  border: 1px solid transparent;
  color: rgba(255,255,255,0.7);
  text-align: left;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mg-item.is-active,
.mg-item:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.12);
  color: #fff;
}

.mg-item:focus-visible {
  outline: none;
  border-color: rgba(243,156,76,0.8);
  box-shadow: 0 0 0 2px rgba(243,156,76,0.3);
}

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

.mg-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  font-size: 12px;
  text-align: center;
}

.mg-content {
  padding: 32px 36px 60px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.mg-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.mg-title {
  font-size: 26px;
  font-weight: 600;
}

.mg-subtitle {
  color: var(--muted);
  font-size: 13px;
}

.mg-actions {
  display: flex;
  gap: 10px;
}

.auth-lang {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 2;
}

.lang-select {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
}

.lang-select:focus {
  outline: none;
  border-color: rgba(243,156,76,0.6);
  box-shadow: 0 0 0 2px rgba(243,156,76,0.18);
}

.mg-row-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.mg-primary {
  background: var(--accent);
  border: none;
  color: #1a1a1a;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.mg-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.mg-primary:hover,
.mg-ghost:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 18px rgba(0,0,0,0.25);
}

.mg-danger {
  border-color: rgba(255, 120, 120, 0.35);
  color: #ffaaaa;
}

.mg-danger:hover {
  box-shadow: 0 12px 18px rgba(120, 20, 20, 0.35);
}

.mg-primary:focus-visible,
.mg-ghost:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(243,156,76,0.28);
}

.mg-input,
.mg-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0f1218;
  color: var(--text);
  font-size: 13px;
}

.mg-textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0f1218;
  color: var(--text);
  font-size: 13px;
  resize: vertical;
  min-height: 90px;
}

.mg-billing-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.mg-billing-badge {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.mg-billing-badge.good {
  background: rgba(47, 197, 130, 0.15);
  color: #44d28a;
}

.mg-billing-badge.due {
  background: rgba(243,156,76,0.2);
  color: #f5b678;
}

.mg-billing-badge.overdue {
  background: rgba(231,71,71,0.2);
  color: #ff8686;
}

.mg-billing-badge.paused {
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.7);
}

.mg-billing-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mg-bill-btn {
  padding: 6px 12px;
  font-size: 12px;
}

.mg-note-meta {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  margin-top: -6px;
}

.mg-plan-cell {
  display: grid;
  gap: 6px;
}

.mg-billing-badge.is-compact {
  font-size: 10px;
  padding: 4px 8px;
  letter-spacing: 0.06em;
}

.mg-input:focus,
.mg-select:focus {
  outline: none;
  border-color: rgba(243,156,76,0.6);
  box-shadow: 0 0 0 2px rgba(243,156,76,0.18);
}

.mg-input:focus-visible,
.mg-select:focus-visible {
  outline: none;
}

.mg-inline-field {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}

.mg-inline-suffix {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.mg-input-compact {
  padding: 8px 12px;
}

.mg-form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mg-form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mg-form-grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.mg-field {
  display: grid;
  gap: 8px;
}

.mg-field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(255,255,255,0.7);
}

.mg-span-2 {
  grid-column: span 2;
}

.mg-actions-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.mg-actions-row-wide {
  margin-top: 8px;
  padding-bottom: 4px;
  justify-content: flex-end;
}

.mg-status {
  font-size: 12px;
  color: var(--muted);
}

.mg-drawer {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, 0.72);
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  z-index: 40;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.mg-drawer.is-open {
  opacity: 1;
  pointer-events: auto;
}

.mg-drawer-panel {
  width: min(880px, 92vw);
  height: 100%;
  background: #0f1116;
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 40px rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  transform: translateX(24px);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.mg-drawer.is-open .mg-drawer-panel {
  transform: translateX(0);
  opacity: 1;
}

.mg-drawer-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mg-drawer-title {
  font-size: 20px;
  font-weight: 600;
}

.mg-drawer-sub {
  font-size: 12px;
  color: var(--muted);
}

.mg-drawer-body {
  padding: 24px;
  overflow-y: auto;
  display: grid;
  gap: 20px;
  opacity: 0;
  transform: translateY(6px);
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.mg-drawer .mg-card {
  margin-top: 0;
}

.mg-drawer.is-open .mg-drawer-body {
  opacity: 1;
  transform: translateY(0);
}

.mg-table .mg-row.head {
  position: sticky;
  top: 0;
  z-index: 1;
}

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

.mg-grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.mg-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mg-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.mg-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 34px rgba(10, 10, 18, 0.35);
}

.mg-panel .mg-card + .mg-card {
  margin-top: 16px;
}

.mg-panel .mg-grid + .mg-card {
  margin-top: 16px;
}

.mg-wide {
  grid-column: 1 / -1;
}

.mg-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.mg-label {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.mg-value {
  font-size: 22px;
  font-weight: 700;
}

.mg-hint {
  font-size: 12px;
  color: var(--muted);
}

.mg-list {
  display: grid;
  gap: 10px;
}

.mg-list-item {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
}

.mg-log-item {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.mg-log-item:hover {
  border-color: rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.06);
}

.mg-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mg-log-left {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
}

.mg-log-restaurant {
  font-weight: 600;
  color: #f2f3f7;
}

.mg-log-action {
  color: rgba(255,255,255,0.7);
  font-size: 13px;
}

.mg-log-time {
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  white-space: nowrap;
}

.mg-log-details {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-4px);
  margin-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 10px;
  gap: 8px;
  transition: max-height 0.35s ease, opacity 0.2s ease, transform 0.25s ease;
}

.mg-log-item.is-open .mg-log-details {
  max-height: 260px;
  opacity: 1;
  transform: translateY(0);
  display: grid;
}

.mg-log-detail {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px;
  font-size: 12px;
}

.mg-log-key {
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.mg-log-val {
  color: #e9ecf2;
}

.mg-log-filters {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 0;
}

.mg-log-filters .mg-field {
  margin: 0;
}

.mg-log-filter-panel {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-6px);
  transition: max-height 0.25s ease, opacity 0.2s ease, transform 0.25s ease, margin-bottom 0.2s ease;
}

.mg-log-filter-panel.is-open {
  max-height: 420px;
  opacity: 1;
  margin-bottom: 16px;
  transform: translateY(0);
}

.mg-collapsible {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-6px);
  transition: max-height 0.3s ease, opacity 0.2s ease, transform 0.25s ease;
}

.mg-collapsible.is-open {
  max-height: 1200px;
  opacity: 1;
  transform: translateY(0);
}

.mg-disclosure {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.mg-disclosure:hover {
  border-color: rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  transform: translateY(-1px);
}

.mg-disclosure:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(243,156,76,0.28);
}

.mg-disclosure-icon {
  width: 9px;
  height: 9px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

.mg-disclosure.is-open .mg-disclosure-icon {
  transform: rotate(135deg);
}

@media (max-width: 1100px) {
  .mg-log-filters {
    grid-template-columns: 1fr;
  }
}

.mg-table {
  display: grid;
  gap: 10px;
}

.mg-row {
  display: grid;
  grid-template-columns: 1.4fr 0.6fr 0.6fr 0.9fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px dashed rgba(255,255,255,0.1);
}

.mg-row:not(.head):hover {
  background: rgba(255,255,255,0.03);
  border-radius: 10px;
}

.mg-row.rest-row {
  grid-template-columns: 1.6fr 0.6fr 0.7fr 0.8fr auto;
}

.mg-row.domain-row {
  grid-template-columns: 1.6fr 0.6fr 0.9fr 0.7fr auto;
}

.mg-row.user-row {
  grid-template-columns: 1.1fr 1.3fr 0.6fr 0.6fr auto;
}

.mg-row.payment-row {
  grid-template-columns: 0.9fr 0.9fr 0.7fr 0.9fr 1fr auto;
}

.mg-row.expired-row {
  grid-template-columns: 1.4fr 0.7fr 0.6fr;
}

.mg-row.head {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.mg-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(47, 197, 130, 0.15);
  color: #44d28a;
  font-size: 11px;
  font-weight: 600;
}

.mg-badge.warn {
  background: rgba(243,156,76,0.18);
  color: #f5b678;
}

.mg-badge.off {
  background: rgba(231,71,71,0.18);
  color: #ff8686;
}

.mg-name {
  font-weight: 600;
}

.mg-subtext {
  font-size: 12px;
  color: var(--muted);
}

.mg-panel {
  display: none;
}

.mg-panel.is-active {
  display: block;
  animation: mgFadeUp 0.28s ease;
}

@keyframes mgFadeUp {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes mgPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(243,156,76,0.0);
  }
  50% {
    transform: scale(1.03);
    box-shadow: 0 0 18px rgba(243,156,76,0.35);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(243,156,76,0.0);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 1100px) {
  .mg-shell { grid-template-columns: 1fr; }
  .mg-sidebar { flex-direction: row; overflow-x: auto; align-items: center; }
  .mg-nav { display: flex; flex-wrap: nowrap; }
  .mg-content { padding: 24px; }
  .mg-grid-4, .mg-grid-2 { grid-template-columns: 1fr; }
  .mg-form-grid,
  .mg-form-grid-3,
  .mg-form-grid-4 { grid-template-columns: 1fr; }
  .mg-row { grid-template-columns: 1fr; gap: 6px; }
  .mg-topbar { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 640px) {
  .auth-lang {
    top: 12px;
    right: 12px;
  }
}
