﻿/* ============================================================
   Kiwi & Coco — Notification Admin UI
   ============================================================ */
:root {
  --cream: #f4f7fb;
  --paper: #ffffff;
  --ink: #172033;
  --sub: #334155;
  --muted: #64748b;
  --border: #d9e2ef;
  --brand: #2563eb;
  --brand-dk: #1d4ed8;
  --brand-lt: rgba(37, 99, 235, 0.10);
  --gold: #7fb0ff;
  --wa: #25D366;
  --wa-dk: #128C7E;
  --ok: #059669;
  --ok-bg: rgba(5, 150, 105, 0.12);
  --warn: #d97706;
  --warn-bg: rgba(217, 119, 6, 0.12);
  --err: #dc2626;
  --err-bg: rgba(220, 38, 38, 0.12);
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .04);
  --shadow-md: 0 12px 28px rgba(15, 23, 42, .08);
  --shadow-lg: 0 24px 56px rgba(15, 23, 42, .12);
  --r: 12px;
  --r-lg: 18px;
  --r-xl: 24px;
  --radius: var(--r);
  --green: var(--wa);
  --green-dark: var(--wa-dk);
  --text: var(--ink);
  --surface: var(--paper);
  --success: var(--ok);
  --error: var(--err);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Manrope", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background:
    radial-gradient(1200px 520px at 8% -14%, rgba(37, 99, 235, 0.08), transparent 55%),
    radial-gradient(1000px 440px at 92% 118%, rgba(96, 165, 250, 0.10), transparent 54%),
    var(--cream);
  min-height: 100vh;
}

h1, h2, h3 { margin: 0; font-family: "Fraunces", Georgia, serif; font-weight: 700; line-height: 1.15; }
p { margin: 0; }
a { color: var(--brand); }

/* ── AUTH PAGE ─────────────────────────────────────────── */
.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 12% -8%, rgba(37,99,235,.13) 0%, transparent 52%),
    radial-gradient(ellipse at 86% 116%, rgba(96,165,250,.15) 0%, transparent 54%),
    var(--cream);
}

.auth-box {
  width: min(420px, 100%);
  display: grid;
  gap: 20px;
  text-align: center;
}

.auth-logo {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--gold));
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
  box-shadow: var(--shadow-md);
}

.auth-logo svg {
  width: 30px;
  height: 30px;
  display: block;
}

.auth-brand h1 { font-size: 2rem; }
.auth-brand p { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }

.auth-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 36px;
  box-shadow: var(--shadow-lg);
  text-align: left;
}

.auth-card h2 { font-size: 1.45rem; margin-bottom: 4px; }
.auth-sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 24px; }
.auth-form { display: grid; gap: 16px; margin-top: 24px; }
.auth-footer { font-size: 0.78rem; color: var(--muted); }

/* ── APP BAR ────────────────────────────────────────────── */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 24px;
  min-height: 64px;
  background: rgba(244, 247, 251, .90);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

.brand-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  flex: 0 1 auto;
  flex-wrap: wrap;
}

.brand-logo-box {
  min-width: 38px;
  min-height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  display: grid;
  place-items: center;
  color: var(--ink);
  flex-shrink: 0;
  border: 1px solid var(--border);
  box-shadow: 0 10px 22px rgba(37, 99, 235, .12);
  overflow: hidden;
}

.brand-logo-img {
  display: block;
  flex-shrink: 1;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 56px;
  object-fit: contain;
}

.brand-logo-box svg {
  width: 100%;
  height: 100%;
  max-width: 34px;
  max-height: 34px;
  display: block;
}

.brand-logo-box img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.brand-wrap > div:last-child {
  min-width: 0;
  max-width: min(42vw, 420px);
}

.brand-name {
  font-family: "Fraunces", serif;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-font-fraunces { font-family: "Fraunces", Georgia, serif; }
.brand-font-manrope { font-family: "Manrope", system-ui, sans-serif; }
.brand-font-inter { font-family: "Inter", system-ui, sans-serif; }
.brand-font-montserrat { font-family: "Montserrat", system-ui, sans-serif; }
.brand-font-helvetica { font-family: Helvetica, Arial, sans-serif; }
.brand-font-arial { font-family: Arial, sans-serif; }
.brand-font-georgia { font-family: Georgia, serif; }
.brand-font-verdana { font-family: Verdana, sans-serif; }
.brand-font-tahoma { font-family: Tahoma, sans-serif; }
.brand-font-times_new_roman { font-family: "Times New Roman", Times, serif; }

.tab-nav {
  display: flex;
  gap: 2px;
  flex: 0 1 auto;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
  min-width: 0;
  padding: 4px 0;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 10px;
  font: 600 0.84rem "Manrope", sans-serif;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.tab-btn:hover { background: #ffffff; color: var(--ink); border-color: var(--border); box-shadow: var(--shadow); }
.tab-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18); }
.tab-ico {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 14px;
}

.tab-ico svg {
  width: 14px;
  height: 14px;
  display: block;
}
.app-bar-end {
  min-width: max-content;
  display: flex;
  justify-content: flex-end;
  width: 100%;
}

/* ── LAYOUT ─────────────────────────────────────────────── */
.app-main {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 60px;
  display: grid;
  gap: 20px;
}

/* ── BANNERS ─────────────────────────────────────────────── */
.flash-band { padding: 14px 24px; font-size: 0.9rem; border-bottom: 1px solid transparent; }
.flash-success { background: var(--ok-bg); color: var(--ok); border-color: rgba(5, 150, 105, 0.22); }
.flash-error { background: var(--err-bg); color: var(--err); border-color: rgba(220, 38, 38, 0.22); }
.warn-band { padding: 14px 24px; background: var(--warn-bg); color: var(--warn); border-bottom: 1px solid rgba(217, 119, 6, 0.22); font-size: 0.9rem; }

/* ── TAB PANES ───────────────────────────────────────────── */
.tab-pane { display: contents; }
.tab-pane[hidden] { display: none !important; }

/* ── PANE HEADER ─────────────────────────────────────────── */
.pane-header h1 { font-size: clamp(1.5rem, 3vw, 2rem); }
.pane-header p { color: var(--muted); margin-top: 6px; font-size: 0.92rem; }

/* ── CARDS ───────────────────────────────────────────────── */
.card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
}

.card-inner { padding: 20px 24px; }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.card-head h2 { font-size: 1.05rem; }
.card-head p { color: var(--muted); font-size: 0.82rem; margin-top: 3px; }

/* ── STATUS GRID ─────────────────────────────────────────── */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.stat-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.stat-icon-green { background: rgba(5, 150, 105, 0.12); color: var(--ok); }
.stat-icon-ok { background: var(--ok-bg); color: var(--ok); }
.stat-icon-warn { background: var(--warn-bg); color: var(--warn); }
.stat-icon-blue { background: rgba(37, 99, 235, 0.12); color: var(--brand); }
.stat-icon-neutral { background: var(--cream); color: var(--sub); }

.stat-body { min-width: 0; }
.stat-label { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 2px; }
.stat-value { font-family: "Fraunces", serif; font-size: 1.2rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-hint { font-size: 0.77rem; color: var(--muted); margin-top: 2px; }

/* ── ACTION CARD ─────────────────────────────────────────── */
.action-card {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.10), rgba(255, 255, 255, 0.96));
  border: 1px solid rgba(37, 99, 235, 0.20);
  border-radius: var(--r-lg);
  padding: 22px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.action-card h2 { font-size: 1.05rem; color: var(--ink); }
.action-card p { font-size: 0.85rem; color: var(--sub); margin-top: 3px; }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  border: none;
  font: 600 0.88rem "Manrope", sans-serif;
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s, box-shadow .15s, transform .1s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-dk)); color: #fff; box-shadow: 0 2px 8px rgba(46, 91, 255, 0.34); }
.btn-primary:hover { box-shadow: 0 8px 18px rgba(37, 99, 235, 0.28); }
.btn-wa { background: linear-gradient(135deg, #22c55e, var(--wa-dk)); color: #fff; box-shadow: 0 2px 8px rgba(37,211,102,.28); }
.btn-wa:hover { box-shadow: 0 4px 14px rgba(37,211,102,.4); }
.btn-ghost { background: var(--paper); color: var(--ink); border: 1px solid var(--border); box-shadow: var(--shadow); }
.btn-ghost:hover { background: #eef4fb; }
.btn-outline { background: transparent; color: var(--ink); border: 1px solid var(--border); box-shadow: none; }
.btn-outline:hover { background: rgba(255, 255, 255, 0.72); }
.btn-sm { min-height: 34px; padding: 0 14px; font-size: 0.82rem; }
.btn-block { width: 100%; }
.btn-link {
  background: transparent;
  border: none;
  color: var(--brand);
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.btn-link:hover { color: var(--brand-dk); text-decoration: underline; }

/* ── ENDPOINT LIST ───────────────────────────────────────── */
.endpoint-list { padding: 0 24px 20px; display: grid; gap: 10px; }
.endpoint-item { border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.endpoint-label { padding: 7px 14px; font-size: 0.73rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); background: var(--cream); border-bottom: 1px solid var(--border); }
.endpoint-row { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--paper); }
.endpoint-code { font: 13px/1.4 ui-monospace,"Courier New",monospace; color: var(--brand-dk); flex: 1; word-break: break-all; }

/* ── COURIER SELECTOR ───────────────────────────────────── */
.courier-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.courier-card {
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  background: var(--paper);
  padding: 14px;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}

/* ── ORDER SEARCH ───────────────────────────────────────── */
.order-search-toolbar {
  display: flex;
  gap: 8px;
}

.order-search-input-wrap {
  position: relative;
  flex: 1;
}

.order-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px 10px 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  background: var(--paper);
  color: var(--ink);
}

.order-search-banner {
  margin-top: 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.07), rgba(255, 255, 255, 0.92));
}

.order-search-banner-icon {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.14);
  color: var(--brand);
  display: grid;
  place-items: center;
  flex: 0 0 28px;
  font-size: 14px;
}

.order-search-banner strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
}

.order-search-banner p {
  color: var(--sub);
  font-size: 0.84rem;
}

.order-search-quicklist {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.order-search-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.82);
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s, box-shadow .15s;
}

.order-search-chip:hover {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.22);
  color: var(--brand-dk);
  box-shadow: var(--shadow);
}

.order-search-chip code {
  font-size: 11px;
  color: var(--muted);
}

.order-search-summary {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.order-search-metric {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.order-search-metric-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
}

.order-search-metric-value {
  margin-top: 6px;
  font-size: 24px;
  line-height: 1;
  font-weight: 800;
  color: var(--ink);
}

.order-search-metric-copy {
  margin-top: 6px;
  font-size: 12px;
  color: var(--sub);
}

.order-search-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
}

.order-search-empty-icon {
  font-size: 38px;
  margin-bottom: 10px;
}

.order-search-empty-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.order-search-empty-copy {
  font-size: 13px;
  margin-top: 6px;
}

.os-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  padding: 12px;
  background: #f9fafb;
  border-radius: 10px;
  margin-bottom: 14px;
}

.os-summary-card {
  min-height: 68px;
}

.os-summary-label {
  font-size: 10px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.os-summary-value {
  margin-top: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--sub);
}

.os-summary-value-strong {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.os-shipment-callout {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.os-shipment-callout-pending {
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.08), rgba(255, 255, 255, 0.96));
  border-color: rgba(217, 119, 6, 0.18);
}

.os-shipment-callout-live {
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.08), rgba(255, 255, 255, 0.96));
  border-color: rgba(5, 150, 105, 0.18);
}

.os-shipment-callout-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.os-shipment-callout-copy {
  margin-top: 4px;
  font-size: 12px;
  color: var(--sub);
  line-height: 1.45;
}

.os-callout-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.os-callout-chip-pending {
  color: #b45309;
  background: rgba(217, 119, 6, 0.12);
}

.os-callout-chip-live {
  color: #047857;
  background: rgba(5, 150, 105, 0.12);
}

.os-action-chip-muted {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: rgba(148, 163, 184, 0.08);
  border: 1px dashed rgba(148, 163, 184, 0.35);
}

.os-inline-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--paper);
  color: var(--sub);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.os-inline-action:hover {
  border-color: rgba(37, 99, 235, 0.24);
  color: var(--brand-dk);
  background: rgba(37, 99, 235, 0.06);
}

.os-card-footer-note {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

@media (max-width: 720px) {
  .order-search-toolbar {
    flex-direction: column;
  }

  .os-shipment-callout {
    flex-direction: column;
  }
}

.courier-card:hover {
  border-color: rgba(37, 99, 235, 0.32);
  box-shadow: var(--shadow);
}

.courier-card:active {
  transform: translateY(1px);
}

.courier-card.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px rgba(46, 91, 255, 0.16);
  background: rgba(46, 91, 255, 0.1);
}

.courier-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.courier-card-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f97316, #fb7185);
  position: relative;
  color: transparent;
  font-size: 0;
  box-shadow: 0 3px 8px rgba(251, 113, 133, .28);
}

.courier-card-icon::before {
  content: "";
  width: 18px;
  height: 18px;
  display: block;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 18px 18px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7h18v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'/%3E%3Cpath d='M8 7a4 4 0 0 1 8 0'/%3E%3C/svg%3E");
}

[data-integration-card="shopify"] .courier-card-icon {
  background: linear-gradient(135deg, #10b981, #22c55e);
  box-shadow: 0 3px 8px rgba(16, 185, 129, .3);
}

[data-integration-card="shopify"] .courier-card-icon::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7h16v12a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1z'/%3E%3Cpath d='M8 10h8M8 14h8'/%3E%3C/svg%3E");
}

[data-integration-card="whatsapp"] .courier-card-icon {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  box-shadow: 0 3px 8px rgba(34, 197, 94, .3);
}

[data-integration-card="whatsapp"] .courier-card-icon::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 11.5a8.5 8.5 0 0 1-12.8 7.3L3 20l1.3-4.9A8.5 8.5 0 1 1 21 11.5z'/%3E%3Cpath d='M9.6 9.8c.4 1.4 1.5 2.4 2.9 2.9l1.2-1.2c.2-.2.4-.2.7-.1l1.8.7c.3.1.5.5.4.8-.3 1.8-2 3-3.8 2.7-3.1-.6-5.7-3.2-6.3-6.3-.3-1.8.9-3.5 2.7-3.8.3-.1.7.1.8.4l.7 1.8c.1.3.1.5-.1.7z'/%3E%3C/svg%3E");
}

[data-integration-card="nimbuspost"] .courier-card-icon {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 3px 8px rgba(37, 99, 235, .28);
}

[data-integration-card="nimbuspost"] .courier-card-icon::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 18h10a4 4 0 0 0 .3-8A5 5 0 0 0 7.4 8.6 3.5 3.5 0 0 0 7 18z'/%3E%3C/svg%3E");
}

[data-integration-card="delhivery"] .courier-card-icon {
  background: linear-gradient(135deg, #f59e0b, #f97316);
  box-shadow: 0 3px 8px rgba(249, 115, 22, .28);
}

[data-integration-card="delhivery"] .courier-card-icon::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7h11v8H3zM14 10h4l3 3v2h-7z'/%3E%3Ccircle cx='8' cy='18' r='2'/%3E%3Ccircle cx='18' cy='18' r='2'/%3E%3C/svg%3E");
}

[data-integration-card="instagram"] .courier-card-icon {
  background: linear-gradient(135deg, #f43f5e, #8b5cf6);
  box-shadow: 0 3px 8px rgba(244, 63, 94, .3);
}

[data-integration-card="instagram"] .courier-card-icon::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='5'/%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Ccircle cx='17' cy='7' r='1' fill='%23ffffff' stroke='none'/%3E%3C/svg%3E");
}

.courier-card-title {
  font-weight: 700;
  font-size: 0.93rem;
}

.courier-card-sub {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

.courier-card-meta {
  margin-top: 10px;
  color: var(--sub);
  font-size: 0.78rem;
}

/* ── PROVIDER TOGGLE SWITCH ──────────────────────── */
.provider-toggle {
  margin-left: auto;
  cursor: pointer;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.provider-toggle input { display: none; }
.provider-toggle-track {
  width: 36px;
  height: 20px;
  background: var(--border, #d1d5db);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
  display: block;
}
.provider-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform 0.2s;
}
.provider-toggle input:checked + .provider-toggle-track {
  background: #22c55e;
}
.provider-toggle input:checked + .provider-toggle-track::after {
  transform: translateX(16px);
}

.courier-config-panel[hidden] {
  display: none !important;
}

/* ── SETTINGS FORM ───────────────────────────────────────── */
.settings-form { display: grid; gap: 16px; }

.form-section {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.section-hd {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 24px;
  background: var(--cream);
  border-bottom: 1px solid var(--border);
}

.section-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.section-title { font-family: "Fraunces", serif; font-weight: 700; font-size: 0.97rem; }
.section-desc { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.section-body { padding: 20px 24px; display: grid; gap: 16px; }

/* ── FIELDS ─────────────────────────────────────────────── */
.field { display: grid; gap: 5px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; }
.field-label { font-size: 0.87rem; font-weight: 700; color: var(--ink); }
.field-hint { font-size: 0.77rem; color: var(--muted); line-height: 1.4; }

.campaign-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--cream);
  border: 1px solid var(--border);
  color: var(--sub);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.campaign-pill-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.campaign-pill {
  border: 1px solid var(--border);
  background: var(--paper);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  font: 600 0.8rem "Manrope", sans-serif;
  cursor: pointer;
}

.campaign-pill:hover {
  background: var(--brand-lt);
  border-color: var(--brand);
  color: var(--brand);
}

.campaign-mapping-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.campaign-param-builder {
  display: grid;
  gap: 10px;
}

.campaign-param-row {
  display: grid;
  grid-template-columns: 90px 160px minmax(160px, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.campaign-param-index {
  font-size: 0.85rem;
  color: var(--muted);
}

.campaign-preview-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: linear-gradient(180deg, rgba(46, 91, 255, 0.08), var(--paper));
  padding: 14px;
}

.campaign-preview-meta {
  font-size: 0.82rem;
  color: var(--muted);
}

.campaign-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.campaign-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--paper);
}

.campaign-list-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.campaign-error-cell {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--sub);
  font-size: 0.82rem;
}

input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--paper);
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(46, 91, 255, 0.16);
}

textarea { resize: vertical; min-height: 80px; }

.input-reveal { display: flex; gap: 8px; }
.input-reveal input { flex: 1; min-width: 0; }

/* ── TOGGLE SWITCH CARDS ─────────────────────────────────── */
.toggle-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.toggle-card:has(input:checked) {
  border-color: var(--brand);
  background: linear-gradient(to right, rgba(46, 91, 255, 0.14), var(--paper));
}

.toggle-info { flex: 1; min-width: 0; }
.toggle-title { font-size: 0.92rem; font-weight: 700; }
.toggle-desc { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }

.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }

.switch-track {
  position: absolute;
  inset: 0;
  background: #d1d5db;
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s;
}

.switch-track::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: var(--ink);
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}

.switch input:checked + .switch-track { background: var(--brand); }
.switch input:checked + .switch-track::before { transform: translateX(20px); }
.toggle-warn .toggle-title { color: var(--warn); }
.toggle-warn:has(input:checked) { border-color: var(--warn); background: var(--warn-bg); }
.toggle-warn input:checked + .switch-track { background: var(--warn); }

/* ── FORM ACTIONS ─────────────────────────────────────────── */
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ── ADVANCED DETAILS ─────────────────────────────────────── */
details { border-top: 1px solid var(--border); }

summary {
  padding: 10px 0;
  cursor: pointer;
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--muted);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 7px;
  user-select: none;
}

summary::-webkit-details-marker { display: none; }
summary::before { content: '▶'; font-size: 0.6rem; transition: transform .15s; }
details[open] summary::before { transform: rotate(90deg); }
details .inner { padding-top: 16px; display: grid; gap: 16px; }

/* ── MINI ACTIVITY LOG (overview) ────────────────────────── */
.mini-log { display: grid; }

.mini-row {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  padding: 13px 24px;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.mini-row:last-child { border-bottom: none; }
.mini-icon {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f97316, #ef4444);
  border: 1px solid rgba(255,255,255,.5);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: transparent;
  font-size: 0;
  position: relative;
  box-shadow: 0 3px 8px rgba(239, 68, 68, .26);
}

.mini-icon::before {
  content: "";
  width: 14px;
  height: 14px;
  display: block;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 8a6 6 0 0 0-12 0c0 7-3 9-3 9h18s-3-2-3-9'/%3E%3Cpath d='M13.73 21a2 2 0 0 1-3.46 0'/%3E%3C/svg%3E");
}

.mini-icon-alert {
  background: linear-gradient(135deg, #ef4444, #f97316);
}

.mini-icon-shopify {
  background: linear-gradient(135deg, #10b981, #22c55e);
}

.mini-icon-shopify::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7h16v12a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1z'/%3E%3Cpath d='M8 10h8M8 14h8'/%3E%3C/svg%3E");
}

.mini-icon-whatsapp {
  background: linear-gradient(135deg, #22c55e, #16a34a);
}

.mini-icon-whatsapp::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 11.5a8.5 8.5 0 0 1-12.8 7.3L3 20l1.3-4.9A8.5 8.5 0 1 1 21 11.5z'/%3E%3C/svg%3E");
}

.mini-icon-nimbuspost {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.mini-icon-nimbuspost::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 18h10a4 4 0 0 0 .3-8A5 5 0 0 0 7.4 8.6 3.5 3.5 0 0 0 7 18z'/%3E%3C/svg%3E");
}

.mini-icon-delhivery {
  background: linear-gradient(135deg, #f59e0b, #f97316);
}

.mini-icon-delhivery::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7h11v8H3zM14 10h4l3 3v2h-7z'/%3E%3Ccircle cx='8' cy='18' r='2'/%3E%3Ccircle cx='18' cy='18' r='2'/%3E%3C/svg%3E");
}

.mini-icon-instagram {
  background: linear-gradient(135deg, #f43f5e, #8b5cf6);
}

.mini-icon-instagram::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='5'/%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Ccircle cx='17' cy='7' r='1' fill='%23ffffff' stroke='none'/%3E%3C/svg%3E");
}

.mini-icon-admin {
  background: linear-gradient(135deg, #64748b, #475569);
}

.mini-icon-admin::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3l7 4v5c0 5-3.4 8-7 9-3.6-1-7-4-7-9V7z'/%3E%3C/svg%3E");
}
.mini-body { flex: 1; min-width: 0; }
.mini-row form { margin-left: auto; }
.mini-title { font-weight: 600; }
.mini-meta { font-size: 0.78rem; color: var(--muted); margin-top: 1px; }

/* ── ACTIVITY TABLE ──────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  max-height: 450px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--paper);
}

.table-wrap-header {
  padding: 10px 16px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--paper);
  z-index: 10;
}

.activity-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.activity-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  background: var(--cream);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 9;
}

.table-wrap-header + .activity-table thead th {
  top: 44px;
}

.activity-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  vertical-align: middle;
}

.activity-table tr:last-child td { border-bottom: none; }
.activity-table tr:hover td { background: rgba(37, 99, 235, 0.06); }
.event-name { font-weight: 600; display: flex; align-items: center; gap: 7px; }

.activity-note-full {
  font-size: .82rem;
  color: var(--muted);
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.activity-cell-wrap {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
}

.activity-cell-mono-wrap {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-all;
  line-height: 1.35;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
}

.ordersdb-wrap {
  max-height: 70vh;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: auto;
}

.ordersdb-table {
  min-width: 3200px;
}

.ordersdb-table th {
  text-transform: none;
  letter-spacing: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.73rem;
}

/* Keep Orders DB column header + filter row pinned while scrolling. */
.ordersdb-table thead tr:first-child th {
  position: sticky;
  top: 0;
  z-index: 12;
}

.ordersdb-table thead tr.ordersdb-filter-row th {
  position: sticky;
  top: 38px;
  z-index: 11;
  background: var(--paper);
}

.ordersdb-table td {
  white-space: nowrap;
}

.ordersdb-url-cell {
  max-width: 220px;
  white-space: normal;
}

.ordersdb-url-cell a {
  display: block;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-all;
  line-height: 1.35;
}

/* ── BADGES ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-sent { background: var(--ok-bg); color: var(--ok); }
.badge-failed { background: var(--err-bg); color: var(--err); }
.badge-skipped { background: rgba(148, 163, 184, 0.16); color: var(--muted); }
.badge-rejected { background: var(--warn-bg); color: var(--warn); }

/* ── EMPTY STATE ──────────────────────────────────────────── */
.empty-state { text-align: center; padding: 56px 24px; color: var(--muted); }
.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  border: 1px solid rgba(255,255,255,.5);
  color: transparent;
  font-size: 0;
  position: relative;
  box-shadow: 0 8px 18px rgba(249, 115, 22, .22);
}

.empty-icon::before {
  content: "";
  width: 28px;
  height: 28px;
  display: block;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 28px 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='7 10 12 15 17 10'/%3E%3Cline x1='12' y1='15' x2='12' y2='3'/%3E%3C/svg%3E");
}
.empty-state h3 { font-size: 1rem; color: var(--sub); margin-bottom: 8px; }
.empty-state p { font-size: 0.87rem; max-width: 340px; margin: 0 auto; }

/* ── ALERTS ───────────────────────────────────────────────── */
.alerts { display: grid; gap: 8px; margin: 14px 0; }
.alert { padding: 12px 16px; border-radius: var(--r); font-size: 0.88rem; }
.alert-success { background: var(--ok-bg); color: #86efac; border: 1px solid rgba(134, 239, 172, 0.4); }
.alert-error { background: var(--err-bg); color: #fca5a5; border: 1px solid rgba(252, 165, 165, 0.4); }
.alert-warn { background: var(--warn-bg); color: #fcd34d; border: 1px solid rgba(252, 211, 77, 0.4); }

/* ── INFO BANNER ──────────────────────────────────────────── */
.info-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(46, 91, 255, 0.12);
  border: 1px solid rgba(46, 91, 255, 0.28);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 0.9rem;
  color: var(--ink);
}
.info-banner-icon {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: transparent;
  font-size: 0;
  position: relative;
  box-shadow: 0 2px 6px rgba(37, 99, 235, .28);
}

.info-banner-icon::before {
  content: "";
  width: 16px;
  height: 16px;
  display: block;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 16px 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cline x1='12' y1='10' x2='12' y2='16'/%3E%3Ccircle cx='12' cy='7' r='1' fill='%23ffffff' stroke='none'/%3E%3C/svg%3E");
}
.info-banner-body { flex: 1; line-height: 1.5; }

/* ── TOOLBAR ROW ──────────────────────────────────────────── */
.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.muted-sm { font-size: 0.82rem; color: var(--muted); margin-top: 2px; }

/* ── LOADING ──────────────────────────────────────────────── */
.loading-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 32px 20px;
  color: var(--muted);
  font-size: 0.9rem;
}
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(224, 224, 224, 0.18);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── API ERROR ────────────────────────────────────────────── */
.api-error {
  background: var(--err-bg);
  border: 1px solid #fca5a5;
  color: #fecaca;
  border-radius: var(--radius);
  padding: 16px 20px;
  font-size: 0.9rem;
}

/* ── WHATSAPP INBOX ──────────────────────────────────────── */
/* ═══════════════════════════ WHATSAPP-STYLE INBOX ═══════════════════════════ */

.inbox-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  height: clamp(520px, calc(100vh - 260px), 960px);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--paper);
}

/* ────────────────── SIDEBAR ────────────────── */
.inbox-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--paper);
  min-height: 0;
  overflow: hidden;
}

.inbox-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.inbox-sidebar-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

.btn-icon {
  appearance: none;
  background: none;
  border: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  color: var(--sub);
  transition: background .15s, color .15s;
}

.btn-icon:hover {
  background: var(--brand-lt);
  color: var(--brand);
}

.btn-icon:active {
  background: rgba(37, 99, 235, 0.18);
}

.btn-icon.btn-ghost {
  opacity: 0.6;
}

.inbox-search {
  padding: 8px 12px;
  flex-shrink: 0;
}

.inbox-search input {
  width: 100%;
  padding: 8px 12px;
  background: #1E1E1E;
  border: none;
  border-radius: 20px;
  font-size: 0.9rem;
  color: var(--ink);
}

.inbox-search input::placeholder {
  color: var(--muted);
}

.inbox-search input:focus {
  outline: none;
  background: #242424;
}

.inbox-conversations {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding: 8px 8px;
  display: grid;
  gap: 2px;
  align-content: start;
}

.inbox-conversations::-webkit-scrollbar {
  width: 8px;
}

.inbox-conversations::-webkit-scrollbar-track {
  background: transparent;
}

.inbox-conversations::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

.inbox-conversations::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}

.inbox-conversation-item {
  appearance: none;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  display: flex;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  transition: background .15s;
  color: inherit;
}

.inbox-conversation-item:hover {
  background: rgba(224, 224, 224, 0.06);
}

.inbox-conversation-item.active {
  background: rgba(46, 91, 255, 0.14);
}

.inbox-conversation-avatar {
  width: 48px;
  height: 48px;
  min-width: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
}

.inbox-conversation-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.inbox-conversation-name {
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.95rem;
}

.inbox-conversation-preview {
  font-size: 0.85rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inbox-conversation-time {
  font-size: 0.8rem;
  color: var(--muted);
  flex-shrink: 0;
  white-space: nowrap;
}

.inbox-conversation-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.inbox-summary {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
  flex-shrink: 0;
}

/* ────────────────── MAIN VIEW ────────────────── */
.inbox-mainview {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--paper);
}

.inbox-mainheader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--paper);
}

.inbox-mainheader-info {
  flex: 1;
  min-width: 0;
}

.inbox-mainheader-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inbox-mainheader-status {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}

.inbox-mainheader-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.inbox-thread {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.inbox-thread::-webkit-scrollbar {
  width: 8px;
}

.inbox-thread::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

.chat-message {
  display: flex;
  margin-bottom: 4px;
}

.chat-message.incoming {
  justify-content: flex-start;
}

.chat-message.outgoing {
  justify-content: flex-end;
}

.chat-bubble {
  max-width: 65%;
  padding: 10px 12px;
  border-radius: 12px;
  word-break: break-word;
  line-height: 1.4;
  font-size: 0.9rem;
}

.chat-bubble.incoming {
  background: #1D1D1D;
  color: var(--ink);
}

.chat-bubble.outgoing {
  background: var(--brand);
  color: #fff;
}

.chat-time {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
  padding: 0 4px;
}

.chat-media-img,
.chat-media-video {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  display: block;
  margin-bottom: 4px;
}

/* ────────────────── COMPOSER ────────────────── */
.inbox-composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--paper);
  flex-shrink: 0;
}

.inbox-composer-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.inbox-input {
  flex: 1;
  padding: 10px 12px;
  background: #1D1D1D;
  border: none;
  border-radius: 20px;
  font-size: 0.9rem;
  color: var(--ink);
  transition: background .15s;
}

.inbox-input::placeholder {
  color: var(--muted);
}

.inbox-input:focus {
  outline: none;
  background: #242424;
}

.inbox-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.inbox-media-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

.inbox-media-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.inbox-media-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  position: relative;
}

.inbox-media-action:hover {
  background: rgba(224, 224, 224, 0.06);
  border-color: var(--brand);
}

.inbox-media-icon {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #10b981, #14b8a6);
  color: transparent;
  font-size: 0;
  position: relative;
  box-shadow: 0 2px 6px rgba(20, 184, 166, .25);
}

.inbox-media-icon::before {
  content: "";
  width: 18px;
  height: 18px;
  display: block;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 18px 18px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'/%3E%3Cpath d='M21 15l-5-5L5 21'/%3E%3C/svg%3E");
}

.inbox-media-action:nth-child(2) .inbox-media-icon {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 2px 6px rgba(37, 99, 235, .25);
}

.inbox-media-action:nth-child(3) .inbox-media-icon {
  background: linear-gradient(135deg, #a855f7, #7c3aed);
  box-shadow: 0 2px 6px rgba(124, 58, 237, .25);
}

.inbox-media-action span:last-child {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}

.inbox-upload-status {
  font-size: 0.8rem;
  color: var(--brand);
  padding: 4px 0;
}

@media (max-width: 900px) {
  .inbox-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
    height: clamp(560px, calc(100vh - 180px), 960px);
  }

  .inbox-sidebar {
    display: none;
  }

  .inbox-sidebar.mobile-show {
    display: flex;
  }

  .inbox-mainview {
    display: none;
  }

  .inbox-mainview.mobile-show {
    display: flex;
  }

  .inbox-mainheader {
    padding: 10px 12px;
  }

  .inbox-mainheader-name {
    font-size: 0.9rem;
  }

  .inbox-mainheader-status {
    font-size: 0.7rem;
  }

  #inbox-back-btn {
    display: flex !important;
  }

  .chat-bubble {
    max-width: 85%;
  }

  .inbox-input {
    font-size: 1rem;
  }
}

/* ── TEMPLATE GRID ────────────────────────────────────────── */
.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.tpl-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow .15s, border-color .15s;
}
.tpl-card:hover { box-shadow: 0 4px 18px rgba(0,0,0,.22); border-color: rgba(46, 91, 255, 0.4); }
.tpl-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.tpl-card-name { font-weight: 700; font-size: 0.92rem; font-family: 'Courier New', monospace; color: var(--text); word-break: break-all; }
.tpl-card-lang { font-size: 0.78rem; color: var(--muted); }
.tpl-header-preview {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  border-left: 3px solid var(--green);
  padding-left: 10px;
  white-space: pre-wrap;
  word-break: break-word;
}
.tpl-body-preview {
  font-size: 0.85rem;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
}
.tpl-reject-reason {
  font-size: 0.8rem;
  background: var(--err-bg);
  color: var(--err);
  padding: 6px 10px;
  border-radius: 6px;
}
.tpl-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.tpl-use-label { font-size: 0.78rem; color: var(--muted); font-weight: 600; margin-right: 2px; }

.tpl-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  align-items: end;
}

.tpl-filter-actions {
  display: flex;
  align-items: end;
}

.tpl-buttons-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tpl-button-row {
  display: grid;
  grid-template-columns: 160px 1fr 1.2fr;
  gap: 10px;
}

.media-upload-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
}

.media-upload-row input[type="file"] {
  flex: 1;
  min-width: 220px;
}

.auth-options {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 12px;
  background: var(--cream);
}

.auth-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.toggle-inline {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-size: 0.88rem;
  color: var(--ink);
  margin-top: 8px;
}

  /* ============================================================
     Instagram module
     ============================================================ */

  /* Webhook URL display */
  .ig-webhook-url-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 8px 12px;
    margin-top: 4px;
  }
  .ig-webhook-url-box code {
    font-family: 'Fira Mono', 'Courier New', monospace;
    font-size: 0.83rem;
    color: var(--ink);
    word-break: break-all;
    flex: 1;
  }

  /* Connection test status bar */
  .ig-status-box {
    padding: 10px 14px;
    border-radius: var(--r);
    font-size: 0.88rem;
    margin-top: 10px;
    border: 1px solid transparent;
  }
  .ig-status-ok {
    background: var(--ok-bg);
    color: var(--ok);
    border-color: #86EFAC;
  }
  .ig-status-err {
    background: var(--err-bg);
    color: var(--err);
    border-color: #FCA5A5;
  }

  /* Post → Product mapping table */
  .ig-map-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--r);
    margin-top: 4px;
  }
  .ig-map-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
  }
  .ig-map-table th {
    background: var(--cream);
    color: var(--sub);
    font-weight: 600;
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
  }
  .ig-map-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
  }
  .ig-map-table tr:last-child td { border-bottom: none; }
  .ig-map-cell {
    width: 100%;
    min-width: 120px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.83rem;
    background: var(--paper);
    color: var(--ink);
    box-sizing: border-box;
  }
  .ig-map-cell:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 2px var(--brand-lt);
  }

  /* Setup guide */
  .ig-guide-card {
    background: linear-gradient(135deg, rgba(46, 91, 255, 0.14) 0%, #171717 100%);
    border-color: rgba(46, 91, 255, 0.28);
  }
  .ig-guide-steps {
    padding-left: 20px;
    margin: 10px 0 0;
    line-height: 1.8;
    font-size: 0.9rem;
    color: var(--sub);
  }
  .ig-guide-steps li { margin-bottom: 6px; }
  .ig-guide-steps code {
    background: rgba(46, 91, 255, 0.14);
    color: #b9c9ff;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.82rem;
  }

  /* Badge */
  .badge-required {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--brand);
    background: var(--brand-lt);
    padding: 1px 6px;
    border-radius: 20px;
    vertical-align: middle;
    margin-left: 4px;
  }

.toggle-inline input {
  width: 15px;
  height: 15px;
}

/* ── CATEGORY CHIPS ───────────────────────────────────────── */
.cat-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
}
.chip-utility     { background: rgba(46, 91, 255, 0.10); color: var(--brand-dk); }
.chip-marketing   { background: rgba(168, 85, 247, 0.10); color: #7c3aed; }
.chip-auth        { background: rgba(245, 158, 11, 0.12); color: var(--warn); }

/* ── TEMPLATE STATUS BADGES ───────────────────────────────── */
.badge-tpl-approved,
.badge-tpl-pending,
.badge-tpl-rejected,
.badge-tpl-paused {
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 0.74rem;
  font-weight: 700;
}
.badge-tpl-approved { background: var(--ok-bg); color: var(--ok); }
.badge-tpl-pending  { background: var(--warn-bg); color: var(--warn); }
.badge-tpl-rejected { background: var(--err-bg); color: var(--err); }
.badge-tpl-paused   { background: rgba(148, 163, 184, 0.16); color: var(--muted); }

/* ── PHONE NUMBER GRID ────────────────────────────────────── */
.num-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.num-card {
  background: var(--paper);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow .15s, border-color .15s;
}
.num-card:hover { box-shadow: 0 4px 18px rgba(0,0,0,.22); }
.num-card-active { border-color: var(--green); background: rgba(34, 197, 94, 0.12); }
.num-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.num-display { font-weight: 800; font-size: 1.05rem; color: var(--text); }
.num-verified-name { font-size: 0.85rem; color: var(--ink); font-weight: 500; }
.num-meta { display: flex; gap: 14px; font-size: 0.82rem; color: var(--muted); flex-wrap: wrap; }
.num-id-row { font-size: 0.78rem; color: var(--muted); word-break: break-all; }
.quality-green { color: #16a34a; font-weight: 600; }
.quality-yellow { color: #ca8a04; font-weight: 600; }
.quality-red { color: #dc2626; font-weight: 600; }

/* ── CREATE TEMPLATE FORM ─────────────────────────────────── */
.var-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.var-hint { font-size: 0.8rem; color: var(--muted); }
.var-hint code { background: rgba(224, 224, 224, 0.08); padding: 1px 5px; border-radius: 4px; font-family: monospace; }
.field-optional { font-size: 0.78rem; color: var(--muted); font-weight: 400; margin-left: 4px; }
.required { color: #dc2626; margin-left: 2px; }
.text-link {
  background: none;
  border: none;
  color: var(--green);
  font: inherit;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  font-size: inherit;
}
.text-link:hover { color: var(--green-dark); }

/* ── WABA SWITCHER ────────────────────────────────────────── */
.waba-list { display: flex; flex-direction: column; gap: 8px; padding: 4px 0 8px; }
.waba-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper);
  flex-wrap: wrap;
}
.waba-row-active { border-color: var(--green); background: rgba(34, 197, 94, 0.12); }
.waba-info { flex: 1; min-width: 0; }
.waba-name { font-weight: 700; font-size: 0.92rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.waba-id { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 1180px) {
  .app-bar {
    padding: 8px 20px;
  }

  .brand-wrap > div:last-child {
    max-width: min(34vw, 220px);
  }

  .tab-nav { width: 100%; }

  .tab-btn {
    flex: 0 0 auto;
  }
}

@media (max-width: 760px) {
  .app-bar { padding: 12px 16px; }
  .brand-wrap {
    flex: 1 1 100%;
    max-width: 100%;
  }
  .brand-wrap > div:last-child {
    max-width: calc(100% - 172px);
  }
  .tab-nav {
    width: 100%;
    justify-content: center;
    overflow-x: auto;
    flex-wrap: nowrap;
  }
  .tab-btn { flex: 0 0 auto; justify-content: center; padding: 7px 10px; font-size: 0.79rem; }
  .app-main { width: calc(100% - 24px); padding: 20px 0 48px; }
  .action-card { flex-direction: column; align-items: flex-start; }
  .field-row { grid-template-columns: 1fr; }
  .tpl-filter-grid { grid-template-columns: 1fr; }
  .tpl-button-row { grid-template-columns: 1fr; }
  .auth-options-grid { grid-template-columns: 1fr; }
  .media-upload-row { align-items: stretch; }
  .card-head { flex-direction: column; gap: 10px; }
}

@media (max-width: 480px) {
  .brand-wrap > div:last-child {
    max-width: calc(100% - 152px);
  }
  .status-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 22px; }
}
