/* God Mode - Dark Theme */

:root {
  --bg-primary: #0a0e0c;
  --bg-secondary: #101714;
  --bg-card: #161e1a;
  --bg-card-hover: #1c2622;
  --bg-sidebar: #0c110f;
  --bg-input: #131b17;

  --text-primary: #e4e7e5;
  --text-secondary: #a1aaa5;
  --text-muted: #525b56;

  --border-color: #243029;
  --border-light: #1c261f;

  /* Primary — Payfrit green MD palette */
  --accent: #00d974;
  --accent-hover: #00b862;
  --accent-subtle: #00a357;
  --accent-muted: rgba(0, 217, 116, 0.12);
  --accent-light: #33ff9f;

  /* Success — emerald (distinct from accent) */
  --green: #34d399;
  --green-muted: rgba(52, 211, 153, 0.15);

  /* Error — coral rose (warmer than pure red) */
  --red: #f87171;
  --red-muted: rgba(248, 113, 113, 0.12);

  /* Warning — warm amber */
  --orange: #fbbf24;
  --orange-muted: rgba(251, 191, 36, 0.12);

  /* Info — slate blue */
  --blue: #60a5fa;
  --blue-muted: rgba(96, 165, 250, 0.12);

  /* Teal — analogous accent for secondary interactive */
  --teal: #2dd4bf;
  --teal-muted: rgba(45, 212, 191, 0.12);

  /* Violet — triadic pop for disputes, special states */
  --violet: #a78bfa;
  --violet-muted: rgba(167, 139, 250, 0.12);

  --radius: 8px;
  --radius-lg: 12px;
  --sidebar-width: 240px;
  --topbar-height: 56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- Layout ---- */

.god-layout {
  display: flex;
  min-height: 100vh;
}

.god-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.god-sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-color);
}

.god-sidebar-brand h1 {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.god-sidebar-brand .subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.god-sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.god-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.god-nav-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.god-nav-item.active {
  background: var(--accent-muted);
  color: var(--accent);
}

.god-nav-item .nav-icon {
  width: 18px;
  text-align: center;
  font-size: 15px;
  opacity: 0.7;
}

.god-nav-item.active .nav-icon {
  opacity: 1;
}

.god-sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-color);
}

.god-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius);
}

.god-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-muted);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}

.god-user-name {
  font-size: 13px;
  font-weight: 500;
}

.god-user-role {
  font-size: 11px;
  color: var(--text-muted);
}

.god-logout-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  width: 100%;
  margin-top: 8px;
  transition: all 0.15s;
}

.god-logout-btn:hover {
  border-color: var(--red);
  color: var(--red);
}

/* ---- Main Content ---- */

.god-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
}

.god-topbar {
  height: var(--topbar-height);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 50;
}

.god-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.god-search input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.god-search input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px var(--teal-muted);
}

.god-search input::placeholder {
  color: var(--text-muted);
}

.god-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
}

.god-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  max-height: 400px;
  overflow-y: auto;
  display: none;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.god-search-results.open { display: block; }

.god-search-group-label {
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.god-search-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.1s;
}

.god-search-item:hover {
  background: var(--bg-card-hover);
}

.god-search-item .item-type {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.god-search-item .item-type.user { background: var(--teal-muted); color: var(--teal); }
.god-search-item .item-type.business { background: var(--accent-muted); color: var(--accent); }
.god-search-item .item-type.beacon { background: var(--violet-muted); color: var(--violet); }

.god-page-title {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.god-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* ---- Stat Cards ---- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 8px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-card .stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.orange .stat-value { color: var(--orange); }
.stat-card.red .stat-value { color: var(--red); }
.stat-card.blue .stat-value { color: var(--blue); }
.stat-card.teal .stat-value { color: var(--teal); }
.stat-card.violet .stat-value { color: var(--violet); }

/* ---- Tables ---- */

.god-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
}

.god-table-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.god-table-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.god-table {
  width: 100%;
  border-collapse: collapse;
}

.god-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.god-table td {
  padding: 10px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-light);
}

.god-table tr:last-child td {
  border-bottom: none;
}

.god-table tr:hover td {
  background: var(--bg-card-hover);
}

.god-table .clickable {
  cursor: pointer;
  color: var(--teal);
}

.god-table .clickable:hover {
  text-decoration: underline;
}

/* ---- Badges / Pills ---- */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.badge-green { background: var(--green-muted); color: var(--green); }
.badge-red { background: var(--red-muted); color: var(--red); }
.badge-orange { background: var(--orange-muted); color: var(--orange); }
.badge-blue { background: var(--blue-muted); color: var(--blue); }
.badge-teal { background: var(--teal-muted); color: var(--teal); }
.badge-violet { background: var(--violet-muted); color: var(--violet); }
.badge-muted { background: var(--border-color); color: var(--text-muted); }
.badge-accent { background: var(--accent-muted); color: var(--accent); }

/* ---- Entity Detail Panel ---- */

.entity-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
}

.entity-list {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.entity-list-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 10;
}

.entity-list-header input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}

.entity-list-header input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px var(--teal-muted);
}

.entity-list-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.1s;
}

.entity-list-item:hover {
  background: var(--bg-card-hover);
}

.entity-list-item.active {
  background: var(--accent-muted);
  border-left: 3px solid var(--accent);
}

.entity-list-item .item-name {
  font-weight: 500;
  font-size: 13px;
}

.entity-list-item .item-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.entity-detail {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.detail-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.detail-card h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
}

.detail-row .label {
  color: var(--text-muted);
}

.detail-row .value {
  font-weight: 500;
  text-align: right;
}

/* ---- Timeline ---- */

.timeline-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 500;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
}

.timeline-overlay.open {
  display: flex;
}

.timeline-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 720px;
  padding: 24px;
}

.timeline-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.timeline-panel-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.timeline-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}

.timeline-close:hover {
  color: var(--text-primary);
}

.timeline {
  position: relative;
  padding-left: 28px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-color);
}

.timeline-event {
  position: relative;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
}

.timeline-event::before {
  content: '';
  position: absolute;
  left: -24px;
  top: 16px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-color);
  border: 2px solid var(--bg-secondary);
}

.timeline-event.event-progress::before { background: var(--accent); }
.timeline-event.event-payment::before { background: var(--teal); }
.timeline-event.event-task::before { background: var(--orange); }
.timeline-event.event-error::before { background: var(--red); }

.timeline-event .event-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.timeline-event .event-title {
  font-size: 13px;
  font-weight: 600;
}

.timeline-event .event-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ---- Pagination ---- */

.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  padding: 16px;
}

.pagination button {
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
}

.pagination button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.pagination button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.pagination .page-info {
  font-size: 12px;
  color: var(--text-muted);
}

/* ---- Beacon Health Grid ---- */

.beacon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.beacon-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.beacon-card:hover {
  border-color: var(--accent);
}

.beacon-card .beacon-name {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
}

.beacon-card .beacon-uuid {
  font-size: 10px;
  color: var(--text-muted);
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.beacon-card .beacon-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 11px;
}

.beacon-card .beacon-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.beacon-dot.active { background: var(--green); }
.beacon-dot.inactive { background: var(--red); }
.beacon-dot.orphan { background: var(--orange); }

/* ---- Payment Breakdown Bar ---- */

.payment-bar {
  display: flex;
  height: 28px;
  border-radius: 4px;
  overflow: hidden;
  margin: 8px 0;
}

.payment-bar > div {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  min-width: 2px;
}

.payment-bar .bar-paid { background: var(--accent); }
.payment-bar .bar-pending { background: var(--orange); }
.payment-bar .bar-failed { background: var(--red); }
.payment-bar .bar-refunded { background: var(--teal); }
.payment-bar .bar-disputed { background: var(--violet); }

/* ---- Misc ---- */

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.loading {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
}

a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--accent-light); text-decoration: underline; }

/* ---- Filters bar ---- */

.filters-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filters-bar select,
.filters-bar input[type="date"] {
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 12px;
}

/* ---- CRUD Buttons ---- */

.god-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.god-btn-primary {
  background: var(--accent);
  color: #0a0e0c;
  border-color: var(--accent);
  font-weight: 600;
}

.god-btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 12px rgba(0, 217, 116, 0.25);
}

.god-btn-danger {
  background: transparent;
  color: var(--red);
  border-color: var(--border-color);
}

.god-btn-danger:hover {
  background: var(--red-muted);
  border-color: var(--red);
}

.god-btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-color);
}

.god-btn-ghost:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.god-btn-sm {
  padding: 4px 8px;
  font-size: 11px;
}

.god-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---- Inline Search (for link business) ---- */

.god-inline-search {
  position: relative;
  margin-top: 12px;
}

.god-inline-search input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}

.god-inline-search input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px var(--teal-muted);
}

.god-inline-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  max-height: 200px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  display: none;
}

.god-inline-search-results.open {
  display: block;
}

.god-inline-search-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  transition: background 0.1s;
}

.god-inline-search-item:hover {
  background: var(--bg-card-hover);
}

/* ---- Expandable SP Section ---- */

.god-biz-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}

.god-biz-row:last-child {
  border-bottom: none;
}

.god-biz-row .biz-name {
  cursor: pointer;
  color: var(--teal);
  font-weight: 500;
}

.god-biz-row .biz-name:hover {
  text-decoration: underline;
}

.god-biz-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.god-sp-panel {
  padding: 8px 0 8px 16px;
  border-bottom: 1px solid var(--border-light);
}

.god-sp-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
}

.god-sp-item label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex: 1;
}

.god-sp-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.god-sp-type {
  font-size: 11px;
  color: var(--text-muted);
}

.god-sp-inactive {
  opacity: 0.5;
}

/* ---- Modal ---- */

.god-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 600;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px;
  overflow-y: auto;
  opacity: 0;
  transition: opacity 0.15s;
}

.god-modal.open {
  opacity: 1;
}

.god-modal-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: 0 16px 64px rgba(0,0,0,0.5);
}

.god-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.god-modal-header h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  border: none;
  padding: 0;
}

.god-modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.god-modal-close:hover {
  color: var(--text-primary);
}

.god-modal-body {
  padding: 20px;
}

.god-modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---- Form Groups ---- */

.god-form-group {
  margin-bottom: 14px;
}

.god-form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.god-form-group input,
.god-form-group select,
.god-form-group textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.god-form-group input:focus,
.god-form-group select:focus,
.god-form-group textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px var(--teal-muted);
}

.god-form-group textarea {
  resize: vertical;
  min-height: 60px;
}

.god-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.god-form-group .god-form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---- Edit Button (inline) ---- */

.god-edit-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s;
  margin-left: 6px;
}

.god-edit-btn:hover {
  color: var(--accent);
  background: var(--accent-muted);
}

/* ---- Scrollbar ---- */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
