/* ============ RESET ============ */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f4f6f8;
  color: #222;
}

/* ============ LAYOUT ============ */

.admin-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: #111;
  color: #fff;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
}

.sidebar h2 {
  margin: 0 0 24px 0;
  font-size: 18px;
  font-weight: 600;
}

.sidebar a {
  color: #bbb;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 6px;
  transition: background 0.2s, color 0.2s;
}

.sidebar a:hover {
  background: #1e1e1e;
  color: #fff;
}

.sidebar a.active {
  background: #2d2d2d;
  color: #fff;
}

.admin-main {
  flex: 1;
  padding: 32px;
}

/* ============ CARDS ============ */

.cards {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.card {
  background: #fff;
  padding: 20px;
  border-radius: 10px;
  min-width: 200px;
  flex: 1;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.card h3 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 16px;
}

/* ============ TABLE ============ */

.table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
}

.table th,
.table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #eee;
  font-size: 14px;
}

.table th {
  background: #fafafa;
  font-weight: 600;
}

.table tr:hover {
  background: #f9f9f9;
}

.toolbar {
  margin-bottom: 15px;
}

.toolbar button {
  margin-right: 10px;
}

.toolbar .active {
  font-weight: 700;
}

/* ============ UTILITIES ============ */

.btn {
  padding: 8px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
}

.btn-danger {
  background: #c0392b;
  color: white;
}

.text-muted {
  color: #777;
  font-size: 14px;
}

/* === Layout === */

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f4f6f9;
  color: #222;
}

.layout {
  display: flex;
  min-height: 100vh;
}

/* === Sidebar === */

.sidebar {
  width: 240px;
  background: #111827;
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.sidebar-top {
  margin-bottom: 30px;
}

.app-name {
  font-size: 18px;
  font-weight: 600;
}

.app-env {
  font-size: 12px;
  opacity: 0.6;
  margin-top: 4px;
}

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

.nav-link {
  display: block;
  padding: 10px 12px;
  border-radius: 6px;
  color: #d1d5db;
  text-decoration: none;
  font-size: 14px;
  transition: background 0.2s ease;
}

.nav-link:hover {
  background: #1f2937;
  color: #fff;
}

.nav-link.small {
  font-size: 13px;
  opacity: 0.8;
}

.sidebar-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* === Content === */

.content {
  flex: 1;
  padding: 40px;
}

h1 {
  margin-top: 0;
}

/* === Button === */

.btn {
  display: inline-block;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
}

/* ============ DASHBOARD GRID ============ */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

/* ============ COMPACT TABLE ============ */

.table-compact td {
  padding: 6px 10px;
  font-size: 13px;
}

.muted {
  color: #777;
  font-size: 13px;
}

/* ============ KPI ============ */

.kpi {
  font-size: 20px;
  font-weight: 600;
}

.row {
  display: flex;
  gap: 20px;
}

/* ============ BUTTON REFINEMENT ============ */

.btn-primary {
  background: #2563eb;   /* modern blue */
  color: #fff;
  border: none;
}

.btn-primary:hover {
  background: #1d4ed8;
}

/* ============ STATUS BADGES (for outbox) ============ */

.badge {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.badge-pending {
  background: #fef3c7;
  color: #92400e;
}

.badge-sent {
  background: #d1fae5;
  color: #065f46;
}

.badge-failed {
  background: #fee2e2;
  color: #7f1d1d;
}

/* ============ FORM ============ */

.form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row label { font-size: 13px; color: #444; }
.form-row input, .form-row textarea {
  padding: 10px 12px;
  border: 1px solid #e3e6ea;
  border-radius: 10px;
  font: inherit;
  background: #fff;
}
.form-row textarea { resize: vertical; }

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

.hr { border: none; border-top: 1px solid #eee; margin: 16px 0; }

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 14px;
}

.kv { display: flex; flex-direction: column; gap: 14px; }
.kv-row { display: grid; grid-template-columns: 120px 1fr; gap: 12px; }
.kv-k { font-size: 13px; color: #666; }
.kv-v { font-size: 14px; }

.note-pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  background: #f7f7f7;
  border: 1px solid #eee;
  padding: 12px;
  border-radius: 10px;
}

@media (max-width: 720px) {
  .kv-row { grid-template-columns: 1fr; }
  .content { padding: 18px; }
  .sidebar { width: 210px; }
}

/* ===== Detail top bar (shared) ===== */

.detail-top { 
  margin-bottom: 16px; 
}

.detail-head { 
  display:flex; 
  align-items:baseline; 
  gap:10px; 
  flex-wrap:wrap; 
}

.detail-page {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: 0.2px;
}

.detail-sub {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  text-decoration: none;
  background: #fff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  color: #111;
  font-size: 16px;
  line-height: 1;
}

.icon-btn:hover {
  background: #f9fafb;
}

.detail-product {
  font-size: 14px;
  color: #374151;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  padding: 6px 10px;
  max-width: min(640px, 75vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.back-btn {
  width: 40px;
  height: 40px;
}

.detail-title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  text-decoration: none;
  color: #111;
  background: #fff;
}

.icon-btn:hover {
  background: #f3f4f6;
}

/* ===== Clickable rows ===== */
tr.row-link {
  cursor: pointer;
}

tr.row-link:hover {
  background: #f3f4f6;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
}

.event-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 10px;
}

.event-title {
  font-weight: 600;
}

.event-meta summary {
  cursor: pointer;
  user-select: none;
  margin-top: 10px;
}

.event-meta pre {
  margin-top: 10px;
}