/* Shared Admin Panel — desktop + mobile (matches licenses page UX) */
:root {
  --admin-green: #10b981;
  --admin-green-dark: #059669;
  --admin-header: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --admin-bg: #f5f7fa;
  --admin-card: #ffffff;
  --admin-text: #2d3748;
  --admin-muted: #718096;
  --admin-border: #e2e8f0;
  --admin-radius: 14px;
  --admin-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
}

* { box-sizing: border-box; }

body.admin-body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--admin-bg);
  min-height: 100vh;
  color: var(--admin-text);
  -webkit-tap-highlight-color: transparent;
}

.admin-header {
  background: var(--admin-header);
  color: #fff;
  padding: 16px 24px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.admin-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.admin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  border: none;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
  white-space: nowrap;
}

.admin-btn:active { transform: scale(0.98); }

.admin-btn-ghost {
  background: rgba(255, 255, 255, 0.18);
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  color: #fff;
}
.admin-btn-ghost:hover { background: #fff; color: var(--admin-green-dark); }

.admin-btn-solid {
  background: #fff;
  color: var(--admin-green-dark);
  border: 1.5px solid #fff;
}

.admin-btn-primary {
  background: var(--admin-header);
  color: #fff;
}
.admin-btn-success { background: #10b981; color: #fff; }
.admin-btn-warning { background: #f59e0b; color: #fff; }
.admin-btn-danger { background: #ef4444; color: #fff; }
.admin-btn-muted { background: #64748b; color: #fff; }
.admin-btn-sm { padding: 7px 12px; font-size: 12px; }

.admin-container {
  max-width: 1200px;
  margin: 22px auto;
  padding: 0 16px 40px;
}

.admin-card {
  background: var(--admin-card);
  border-radius: var(--admin-radius);
  padding: 20px;
  box-shadow: var(--admin-shadow);
  margin-bottom: 18px;
}

.admin-card h2 {
  margin: 0 0 6px;
  font-size: 17px;
  color: var(--admin-text);
}

.admin-card .desc {
  margin: 0 0 14px;
  color: var(--admin-muted);
  font-size: 13px;
  line-height: 1.5;
}

.admin-page-title { margin-bottom: 18px; }
.admin-page-title h2 {
  margin: 0 0 6px;
  font-size: 26px;
  color: var(--admin-text);
}
.admin-page-title p {
  margin: 0;
  color: var(--admin-muted);
  font-size: 14px;
}

.admin-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.admin-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.admin-stat {
  background: #f8fafc;
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  padding: 14px 12px;
  text-align: center;
}
.admin-stat .n {
  font-size: 22px;
  font-weight: 800;
  color: var(--admin-text);
}
.admin-stat .l {
  font-size: 11px;
  color: var(--admin-muted);
  margin-top: 4px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.admin-form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}
.admin-form-group label {
  font-size: 12px;
  font-weight: 700;
  color: #475569;
}
.admin-form-group input,
.admin-form-group select,
.admin-form-group textarea {
  width: 100%;
  padding: 11px 12px;
  border: 2px solid var(--admin-border);
  border-radius: 10px;
  font-size: 16px; /* avoid iOS zoom */
  background: #fff;
  color: var(--admin-text);
}
.admin-form-group input:focus,
.admin-form-group select:focus,
.admin-form-group textarea:focus {
  outline: none;
  border-color: var(--admin-green);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 14px;
}
.admin-toolbar .admin-form-group {
  margin-bottom: 0;
  flex: 1;
  min-width: 140px;
}
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.admin-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.admin-badge-paid,
.admin-badge-active,
.admin-badge-completed,
.badge-paid,
.badge-active,
.badge-completed { background: #d1fae5; color: #065f46; }
.admin-badge-need,
.admin-badge-failed,
.badge-need,
.badge-failed,
.badge-banned { background: #fee2e2; color: #991b1b; }
.admin-badge-exempt,
.badge-exempt { background: #e0e7ff; color: #3730a3; }
.admin-badge-pending,
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-paid-blue,
.badge-paid { }
.badge-paid.admin-order { background: #dbeafe; color: #1e40af; }

.admin-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}

.admin-msg {
  display: none;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
}
.admin-msg.ok,
.admin-msg.success { display: block; background: #d1fae5; color: #065f46; }
.admin-msg.err,
.admin-msg.error { display: block; background: #fee2e2; color: #991b1b; }

.admin-warn {
  display: none;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  color: #92400e;
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
}

.admin-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  max-height: 70vh;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}
.admin-table th {
  background: #f8fafc;
  padding: 11px 12px;
  text-align: left;
  font-size: 11px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 2px solid var(--admin-border);
  position: sticky;
  top: 0;
  z-index: 2;
}
.admin-table td {
  padding: 11px 12px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
  color: #334155;
  vertical-align: middle;
}
.admin-table tr:hover td { background: #f8fafc; }

.admin-menu-wrap { position: relative; display: inline-block; }
.admin-menu-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--admin-border);
  background: #fff;
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.admin-menu-drop {
  display: none;
  position: absolute;
  right: 0;
  top: 40px;
  min-width: 190px;
  background: #fff;
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
  z-index: 30;
  overflow: hidden;
}
.admin-menu-drop.open { display: block; }
.admin-menu-drop button {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  color: #334155;
  font-weight: 600;
}
.admin-menu-drop button:hover { background: #f8fafc; }
.admin-menu-drop button.danger { color: #b91c1c; }

.admin-empty {
  text-align: center;
  padding: 36px 16px;
  color: #94a3b8;
  font-size: 14px;
}

.admin-toggle-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

/* Mobile: stacked card rows for tables with data-label */
@media (max-width: 768px) {
  .admin-header {
    padding: 12px 14px;
    position: sticky;
  }
  .admin-header h1 { font-size: 17px; }
  .admin-header-actions {
    width: 100%;
  }
  .admin-header-actions .admin-btn {
    flex: 1;
    min-width: calc(50% - 4px);
  }

  .admin-container {
    margin: 14px auto;
    padding: 0 12px 32px;
  }
  .admin-card { padding: 16px; border-radius: 12px; }
  .admin-page-title h2 { font-size: 22px; }

  .admin-grid-2,
  .admin-grid-4 { grid-template-columns: 1fr; }
  .admin-stats { grid-template-columns: repeat(2, 1fr); }

  .admin-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .admin-toolbar .admin-form-group { width: 100%; min-width: 0; }
  .admin-toolbar .admin-btn,
  .admin-actions .admin-btn {
    width: 100%;
  }

  .admin-table-wrap {
    border: none;
    max-height: none;
    overflow: visible;
  }

  .admin-table thead { display: none; }
  .admin-table,
  .admin-table tbody {
    display: block;
    width: 100%;
  }
  .admin-table tr {
    display: block;
    background: #fff;
    border: 1px solid var(--admin-border);
    border-radius: 12px;
    margin-bottom: 12px;
    padding: 12px 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  }
  .admin-table tr:hover td { background: transparent; }
  .admin-table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
    text-align: right;
  }
  .admin-table td:last-child { border-bottom: none; }
  .admin-table td::before {
    content: attr(data-label);
    font-weight: 700;
    color: #64748b;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    text-align: left;
    flex-shrink: 0;
    max-width: 42%;
  }
  .admin-table td.admin-td-actions {
    justify-content: flex-end;
  }
  .admin-table td.admin-td-actions::before {
    margin-right: auto;
  }
  .admin-menu-wrap { width: 100%; }
  .admin-menu-btn { width: 100%; height: 42px; }
  .admin-menu-drop {
    left: 0;
    right: 0;
    min-width: 0;
    width: 100%;
  }

  .admin-actions-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }
  .admin-actions-stack .admin-btn { width: 100%; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .admin-grid-4 { grid-template-columns: 1fr 1fr; }
  .admin-stats { grid-template-columns: repeat(3, 1fr); }
}
