@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  /* Doctor Doom Marvel Theme — Latverian Emerald, Titanium Steel & Antique Gold */
  --font-sans: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 14px;
  --fs-md: 16px;
  --fs-lg: 20px;
  --fs-xl: 24px;

  --radius: 0.5rem;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --primary: #11693a;
  --primary-dark: #0a3f22;
  --primary-hover: #0d542e;
  --primary-foreground: #ffffff;
  --primary-soft: #eaf7ef;
  --primary-border: rgba(17, 105, 58, 0.24);

  --doom-glow: #147a42;
  --doom-steel: #52665c;
  --doom-steel-light: #cbd5cf;
  --doom-gold: #8a6216;
  --doom-gold-soft: #f2ece0;

  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-subtle: #edf3ef;
  --surface-muted: #dce6e0;
  --input-bg: #ffffff;
  --border: #d7e2db;
  --border-hover: #adc4b7;

  --text: #0c1711;
  --text-secondary: #3b4f43;
  --text-muted: #3b4f43;
  --text-dim: #5e7366;

  --accent-green: #148045;
  --success: #148045;
  --accent-green-deep: #0b5a2f;
  --accent-green-soft: #e6f6ec;
  --accent-green-border: rgba(20, 128, 69, 0.28);

  --info: #0f766e;
  --info-soft: #ecfdf5;
  --warn: #a16207;
  --warning: #ca8a04;
  --warn-soft: #fef9e7;
  --warn-border: rgba(202, 138, 4, 0.36);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --danger-border: rgba(220, 38, 38, 0.24);

  --shadow-sm: 0 1px 2px rgba(6, 18, 11, 0.06);
  --shadow-card: 0px 0.6px 2.5px -1.2px rgba(6, 18, 11, 0.08),
    0px 2.5px 10px -2px rgba(6, 18, 11, 0.07),
    0px 10px 30px -4px rgba(17, 105, 58, 0.06);
  --shadow-inset: 0px 0px 0px 1px rgba(255, 255, 255, 0.55) inset;

  --header-glass: rgba(244, 247, 245, 0.92);
  --bnav-glass: rgba(255, 255, 255, 0.96);
  --bubble-them-bg: #ffffff;
  --custom-card-bg: #f6fbf8;
  --code-color: #0a4626;
  --pre-bg: #07110b;
  --pre-border: #172a1f;
  --pre-text: #d9ece0;
  --toast-bg: #0a1710;
  --toast-text: #ecfdf3;
  --scroll-thumb: rgba(12, 23, 17, 0.18);
  --scroll-thumb-hover: rgba(17, 105, 58, 0.36);

  --sidebar-w: 268px;
  --bottom-nav-h: 64px;
}

html[data-theme="dark"] {
  --primary: #16a34a;
  --primary-dark: #15803d;
  --primary-hover: #22c55e;
  --primary-foreground: #ffffff;
  --primary-soft: rgba(34, 197, 94, 0.14);
  --primary-border: rgba(46, 230, 107, 0.34);

  --doom-glow: #1c9c53;
  --doom-steel: #7c9486;
  --doom-steel-light: #d6e2db;
  --doom-gold: #b89128;
  --doom-gold-soft: #262012;

  --bg: #060b08;
  --surface: #0c1510;
  --surface-subtle: #111e16;
  --surface-muted: #192b20;
  --input-bg: #08100b;
  --border: rgba(163, 196, 176, 0.14);
  --border-hover: rgba(46, 230, 107, 0.36);

  --text: #eef6f1;
  --text-secondary: #9bb3a4;
  --text-muted: #9bb3a4;
  --text-dim: #688272;

  --accent-green: #22c55e;
  --success: #22c55e;
  --accent-green-deep: #4ade80;
  --accent-green-soft: rgba(34, 197, 94, 0.15);
  --accent-green-border: rgba(46, 230, 107, 0.34);

  --info: #2dd4bf;
  --info-soft: rgba(45, 212, 191, 0.14);
  --warn: #eab308;
  --warning: #facc15;
  --warn-soft: rgba(212, 175, 55, 0.16);
  --warn-border: rgba(212, 175, 55, 0.36);
  --danger: #f87171;
  --danger-soft: rgba(239, 68, 68, 0.15);
  --danger-border: rgba(239, 68, 68, 0.34);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
  --shadow-card: 0 12px 32px rgba(0, 0, 0, 0.48), 0 0 0 1px rgba(46, 230, 107, 0.04) inset;

  --header-glass: rgba(6, 11, 8, 0.92);
  --bnav-glass: rgba(11, 20, 15, 0.96);
  --bubble-them-bg: #122118;
  --custom-card-bg: #0e1a13;
  --code-color: #4ade80;
  --pre-bg: #040806;
  --pre-border: rgba(46, 230, 107, 0.16);
  --pre-text: #d1e7d9;
  --toast-bg: #112218;
  --toast-text: #ecfdf3;
  --scroll-thumb: rgba(163, 196, 176, 0.18);
  --scroll-thumb-hover: rgba(46, 230, 107, 0.34);
}

html[data-theme="dark"] .bubble.me {
  background: #0d3620;
  border-color: rgba(46, 230, 107, 0.34);
}

html[data-theme="dark"] button.green {
  background: #15803d;
  border-color: #15803d;
  color: #ffffff;
  font-weight: 600;
  box-shadow: none;
}

html[data-theme="dark"] button.green:hover {
  background: #16a34a;
  border-color: #16a34a;
  box-shadow: none;
}

html[data-theme="dark"] .brand-icon {
  border-color: #223b2c;
  box-shadow: none;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

/* Clean flat surface without neon ambient halo */
body::before {
  display: none;
}

/* --- App Shell --- */
.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
}

/* Desktop Sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #050a08;
  border: 1px solid rgba(34, 197, 94, 0.3);
  overflow: hidden;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
}

.brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  letter-spacing: -0.015em;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--text-dim);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  overflow-y: auto;
}

.nav-group-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  padding: 10px 10px 4px;
  margin-top: 2px;
}

.nav-group-label:first-child {
  padding-top: 2px;
  margin-top: 0;
}

.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
  text-align: left;
  box-shadow: none;
}

.nav-btn .nav-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.nav-btn svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  color: var(--text-dim);
}

.nav-btn:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

.nav-btn.active {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
  font-weight: 600;
}

.nav-btn.active svg {
  color: var(--primary);
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* Main Area */
.main-area {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
}

.mobile-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: 30;
  height: calc(56px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 14px 0;
  background: var(--header-glass);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.content {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
}

.page-sub {
  margin: 3px 0 0;
  font-size: 13.5px;
  color: var(--text-secondary);
}

/* KPI Strip */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 15px 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.kpi-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-card);
}

.kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kpi-ic {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.kpi-ic svg {
  width: 15px;
  height: 15px;
}

.kpi-ic.blue {
  background: var(--primary-soft);
  color: var(--primary);
}

.kpi-ic.green {
  background: var(--accent-green-soft);
  color: var(--accent-green-deep);
}

.kpi-ic.amber {
  background: var(--warn-soft);
  color: var(--warn);
}

.kpi-ic.indigo {
  background: rgba(74, 74, 191, 0.12);
  color: #4a4abf;
}

html[data-theme="dark"] .kpi-ic.indigo {
  background: rgba(129, 140, 248, 0.18);
  color: #a5b4fc;
}

.kpi-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.kpi-value {
  font-size: 24px;
  font-weight: 800;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 3px;
}

/* Cards & Grids */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-card);
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.card h2 {
  margin: 0 0 10px;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.01em;
  border: none;
}

.badge.ok {
  background: #11693a;
  color: #ffffff;
}
.badge.warn {
  background: #8a5a10;
  color: #ffffff;
}
.badge.err {
  background: #b91c1c;
  color: #ffffff;
}
.badge.info {
  background: #1f3a2c;
  color: #ffffff;
}
.badge.secondary {
  background: #dfe7e2;
  color: #1f3328;
}

html[data-theme="dark"] .badge.ok {
  background: #15803d;
  color: #ffffff;
}
html[data-theme="dark"] .badge.warn {
  background: #9a6714;
  color: #ffffff;
}
html[data-theme="dark"] .badge.err {
  background: #991b1b;
  color: #ffffff;
}
html[data-theme="dark"] .badge.info {
  background: #1b3427;
  color: #dcf2e5;
}
html[data-theme="dark"] .badge.secondary {
  background: #1b2b22;
  color: #cfe0d6;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  background: currentColor;
}

/* Forms & Controls */
label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin: 10px 0 5px;
}

input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

input::placeholder, textarea::placeholder {
  color: #98a2b3;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(17, 105, 58, 0.18);
}

html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.24);
}

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

select option {
  background: var(--surface);
  color: var(--text);
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.1s ease;
}

button:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

button:active { transform: scale(0.985); }
button:disabled { opacity: 0.48; cursor: not-allowed; }

button.secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

button.secondary:hover {
  background: var(--surface-subtle);
  border-color: var(--border-hover);
}

button.green {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: #ffffff;
}

button.green:hover {
  background: var(--accent-green-deep);
  border-color: var(--accent-green-deep);
}

button.danger {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #ffffff;
  box-shadow: none;
}

button.danger:hover {
  background: #991b1b;
  border-color: #991b1b;
}

html[data-theme="dark"] button.danger {
  background: #991b1b;
  border-color: #991b1b;
  color: #ffffff;
}

html[data-theme="dark"] button.danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

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

.item {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 10px;
  background: var(--bg);
}

.item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.incoming {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  padding: 9px 12px;
  border-radius: 8px;
  margin-bottom: 9px;
  font-size: 13.5px;
  color: var(--text);
  white-space: pre-wrap;
}

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

.draft-regen-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.draft-regen-group button {
  padding: 6px 10px;
  font-size: 12px;
}

.muted {
  color: var(--text-secondary);
  font-size: 13px;
}

.qr-box {
  text-align: center;
  padding: 12px 0 4px;
}

.qr-box svg {
  border-radius: 12px;
  padding: 10px;
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  max-width: 100%;
  height: auto;
}

pre {
  background: var(--pre-bg);
  border: 1px solid var(--pre-border);
  color: var(--pre-text);
  padding: 12px 14px;
  border-radius: 10px;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

code {
  background: var(--surface-subtle);
  color: var(--code-color);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 12px;
  border: 1px solid var(--border);
}

/* Tables (Audit Log) */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg);
}

/* Chat Viewer */
.chat-card {
  padding: 14px;
}

.chat-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 14px;
  align-items: stretch;
}

.chat-list-col,
.chat-thread-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-sidebar {
  height: 520px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.chat-contact {
  padding: 11px 12px;
  border-bottom: 1px solid var(--surface-subtle);
  cursor: pointer;
  transition: background 0.12s ease;
}

.chat-contact:hover { background: var(--bg); }
.chat-contact.active {
  background: var(--primary-soft);
  border-left: 3px solid var(--primary);
}

.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.chat-topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.chat-topbar-title {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-search-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.chat-thread {
  height: 456px;
  overflow-y: auto;
  padding: 14px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bubble {
  max-width: 80%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow-sm);
}

.bubble.them {
  align-self: flex-start;
  background: var(--bubble-them-bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.bubble.me {
  align-self: flex-end;
  background: var(--accent-green-soft);
  border: 1px solid var(--accent-green-border);
  border-bottom-right-radius: 4px;
}

.bubble-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-dim);
}

.del-msg {
  background: transparent;
  border: 0;
  color: var(--danger);
  padding: 1px 4px;
  font-size: 11px;
  min-height: auto;
  box-shadow: none;
}

.del-msg:hover {
  background: var(--danger-soft);
}

/* Chat Media (Sticker, Image, Voice Note) */
.chat-sticker {
  display: block;
  width: 132px;
  height: 132px;
  object-fit: contain;
  margin-bottom: 4px;
}

.chat-image {
  display: block;
  max-width: 240px;
  max-height: 260px;
  width: 100%;
  border-radius: 8px;
  object-fit: cover;
  cursor: pointer;
  margin-bottom: 6px;
}

.chat-audio {
  display: block;
  width: 225px;
  max-width: 100%;
  height: 36px;
  margin-bottom: 4px;
}

.lightbox-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(16, 24, 40, 0.88);
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: zoom-out;
}

.lightbox-backdrop.open { display: flex; }

.lightbox-backdrop img {
  max-width: 94vw;
  max-height: 88vh;
  border-radius: 12px;
  object-fit: contain;
}

.mobile-back-btn {
  display: none;
}

/* Chat Composer */
.chat-composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: 10px;
}

.chat-composer textarea {
  flex: 1;
  min-height: 42px;
  max-height: 110px;
  padding: 9px 12px;
  resize: none;
  line-height: 1.4;
}

.chat-composer button {
  min-height: 42px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Contacts Modern Card List & Filter Pills */
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  width: 100%;
}

button.fpill {
  padding: 5px 11px;
  min-height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: none;
}

button.fpill:hover {
  background: var(--surface-subtle);
  border-color: var(--border-hover);
  color: var(--text);
}

button.fpill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.contacts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.contact-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.contact-card:hover {
  border-color: var(--primary-border);
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.06);
}

.contact-card.is-custom {
  border-color: var(--primary-border);
  background: var(--custom-card-bg);
}

.contact-top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  width: 100%;
}

.contact-top .badge {
  flex-shrink: 0;
}

.contact-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.contact-main {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.contact-name-row {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.contact-name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hp-dot {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: #11693a;
  color: #ffffff;
  flex-shrink: 0;
}

.contact-meta {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
  font-variant-numeric: tabular-nums;
}

.contact-note {
  font-size: 12.5px;
  color: var(--text-secondary);
  background: var(--bg);
  border-left: 2.5px solid var(--primary);
  padding: 6px 9px;
  border-radius: 6px;
  line-height: 1.4;
  word-break: break-word;
}

.contact-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--surface-subtle);
  flex-wrap: wrap;
}

.contact-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.contact-actions button {
  padding: 5px 12px;
  min-height: 32px;
  font-size: 12px;
}

/* Day Checkboxes */
.day-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.day-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  margin: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

.day-pill input {
  width: auto;
  margin: 0;
  accent-color: var(--primary);
}

/* Mobile Bottom Nav & Drawer */
.bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: var(--bnav-glass);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  box-shadow: 0 -4px 16px rgba(16, 24, 40, 0.05);
}

.bnav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 10.5px;
  font-weight: 600;
  position: relative;
  min-height: 46px;
  box-shadow: none;
}

.bnav-btn svg { width: 19px; height: 19px; }
.bnav-btn:hover { background: transparent; color: var(--text); }
.bnav-btn.active {
  color: var(--primary);
  background: var(--primary-soft);
}

.bnav-dot {
  position: absolute;
  top: 4px;
  right: 18%;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
}

.bnav-dot.show { display: inline-flex; }

/* Mobile More Sheet */
.sheet-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(16, 24, 40, 0.45);
  backdrop-filter: blur(4px);
  align-items: flex-end;
  justify-content: center;
}

.sheet-backdrop.open { display: flex; }

.sheet {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 12px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 30px rgba(16, 24, 40, 0.14);
}

.sheet-handle {
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: var(--border-hover);
  margin: 0 auto 14px;
}

.sheet-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.sheet-item {
  padding: 13px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  text-align: left;
  box-shadow: none;
}

.sheet-item:hover {
  background: var(--primary-soft);
  border-color: var(--primary-border);
}

/* Toast Notification */
.toast {
  position: fixed;
  right: 18px;
  bottom: 20px;
  z-index: 60;
  background: var(--toast-bg);
  color: var(--toast-text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.25);
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* Login Page */
.login-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 24px;
  box-shadow: var(--shadow-card);
}

.pw-wrap {
  position: relative;
  margin-bottom: 14px;
}

.pw-wrap input {
  padding-right: 72px;
}

.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  padding: 5px 10px;
  font-size: 12px;
  min-height: 30px;
}

.pwa-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--primary-border);
  background: var(--primary-soft);
  margin-bottom: 14px;
}

.pwa-banner.show { display: flex; }

/* Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); }

.theme-icon-btn {
  width: 34px;
  height: 34px;
  min-height: 34px !important;
  padding: 0 !important;
  border-radius: 9px;
}

.theme-icon-btn svg {
  width: 17px;
  height: 17px;
}

/* --- Polished Mobile View (<= 860px) --- */
@media (max-width: 860px) {
  .sidebar { display: none; }
  .mobile-header { display: flex; }
  .bottom-nav { display: grid; }

  .content {
    padding: 12px 12px calc(var(--bottom-nav-h) + 22px + env(safe-area-inset-bottom));
  }

  .page-head {
    margin-bottom: 12px;
    gap: 8px;
  }
  .page-title { font-size: 18px; }
  .page-sub { font-size: 12.5px; }
  #topStatusPills { display: none; }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
  }
  .kpi-card { padding: 12px 13px; border-radius: 12px; }
  .kpi-value { font-size: 20px; }

  .grid-2 { grid-template-columns: 1fr; gap: 10px; }
  .grid-form { grid-template-columns: 1fr; gap: 6px; }
  .contacts-grid { grid-template-columns: 1fr; gap: 8px; }
  .contact-card { padding: 11px 12px; gap: 7px; }
  .contact-avatar { width: 36px; height: 36px; font-size: 12.5px; }
  .contact-actions button { min-height: 34px; padding: 5px 12px; }

  .card {
    padding: 14px 13px;
    border-radius: 14px;
    margin-bottom: 10px;
  }

  input, select, textarea {
    font-size: 16px;
    min-height: 44px;
  }
  button {
    min-height: 40px;
  }

  .draft-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .draft-actions > .green {
    width: 100%;
  }
  .draft-regen-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
  .draft-regen-group button {
    width: 100%;
    min-height: 36px;
  }

  /* Full-height Native Mobile Chat Experience */
  #tab-chats .page-head { display: none; }
  .chat-card {
    padding: 10px;
    margin-bottom: 0;
  }
  .chat-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .chat-layout:not(.mobile-thread-open) .chat-thread-col { display: none; }
  .chat-layout.mobile-thread-open .chat-list-col { display: none; }
  .mobile-back-btn {
    display: inline-flex;
    padding: 6px 10px;
    min-height: 34px;
    font-size: 12.5px;
  }
  .chat-sidebar {
    height: calc(100dvh - 190px);
  }
  .chat-topbar {
    flex-wrap: nowrap;
    margin-bottom: 8px;
  }
  .chat-topbar-actions button {
    padding: 6px 9px;
    min-height: 34px;
    font-size: 12px;
  }
  .chat-search-bar input {
    min-height: 38px;
    font-size: 14px;
    padding: 6px 10px;
  }
  .chat-search-bar button {
    min-height: 38px;
    padding: 6px 12px;
  }
  .chat-thread {
    height: calc(100dvh - 266px);
    min-height: 260px;
    padding: 10px;
  }
  .bubble {
    max-width: 88%;
    font-size: 14px;
  }
  .chat-composer {
    gap: 6px;
    margin-top: 8px;
  }
  .chat-composer textarea {
    min-height: 42px;
    padding: 9px 10px;
    font-size: 15px;
  }
  .chat-composer button {
    padding: 8px 11px;
    min-height: 42px;
    font-size: 13px;
  }

  /* Responsive Card Tables (Audit Log) */
  .responsive-table thead { display: none; }
  .responsive-table,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td {
    display: block;
    width: 100%;
  }
  .responsive-table tr {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: var(--bg);
  }
  .responsive-table td {
    border-bottom: 0;
    padding: 3px 0;
  }
  .responsive-table td[data-label]::before {
    content: attr(data-label) ': ';
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    font-weight: 600;
  }

  .toast {
    left: 12px;
    right: 12px;
    bottom: calc(var(--bottom-nav-h) + 12px + env(safe-area-inset-bottom));
    text-align: center;
  }
}

/* Analytics 7-Day Chart & Quota Cards (Feature #10) */
.analytics-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.stat-pill-box {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 0;
}

.stat-pill-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-pill-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
}

.stat-pill-sub {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 1px;
}

.bar-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  align-items: stretch;
  height: 146px;
  padding: 14px 8px 8px;
  border-radius: 12px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
}

.bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 6px;
  min-width: 0;
}

.bar-stack {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 4px;
}

.bar-pair {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  width: 100%;
}

.bar-fill {
  width: 12px;
  max-width: 44%;
  border-radius: 4px 4px 1px 1px;
  min-height: 4px;
  transition: height 0.25s ease;
}

.bar-fill.in { background: var(--primary); }
.bar-fill.auto { background: var(--accent-green); }

.bar-lbl {
  font-size: 10.5px;
  color: var(--text-secondary);
  font-weight: 600;
  line-height: 1;
}

.bar-cnt {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-dim);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.legend-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 3px;
  margin-right: 5px;
  vertical-align: middle;
}

.attach-btn {
  width: 42px;
  min-width: 42px;
  padding: 0;
  font-size: 16px;
}

.group-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-subtle);
  margin-bottom: 8px;
}

.group-row-info {
  min-width: 0;
  flex: 1;
}

.group-row-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 820px) {
  .analytics-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Multi-Tenant Plan Banner & Superadmin Panel (Cekat.ai Style) */
.plan-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.plan-banner.is-warn {
  border-color: var(--danger);
  border-top: 3px solid var(--danger);
  background: var(--surface);
}

.plan-banner-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.plan-avatar {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #11693a;
  border: 1px solid #0a4626;
  color: #ffffff;
  font-size: 15px;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
  overflow: hidden;
  box-shadow: none;
}

.plan-avatar img,
.tenant-avatar img,
.profile-avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile-avatar-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
}

.profile-avatar-preview {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  background: #11693a;
  border: 1px solid #0a4626;
  color: #ffffff;
  font-size: 20px;
  font-weight: 800;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: none;
}

/* Modal Dialog (Edit Profil Penyewa oleh Superadmin) */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(10, 18, 34, 0.55);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 580px;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

/* ============================================================
   BEGINNER-FRIENDLY UX COMPONENTS (Onboarding, Quick Switch, Hints)
   ============================================================ */
.onboard-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

html[data-theme="dark"] .onboard-card {
  background: var(--surface);
  border-color: var(--border);
  border-left: 4px solid var(--primary);
}

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

.onboard-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.015em;
}

.onboard-sub {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.onboard-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.onboard-step {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 13px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.onboard-step.done {
  border-color: var(--primary);
  border-left: 3px solid var(--primary);
  background: var(--surface-subtle);
}

.onboard-step-top {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.onboard-num {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: #1f3a2c;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.onboard-step.done .onboard-num {
  background: var(--primary);
  color: #ffffff;
}

.onboard-step strong {
  display: block;
  font-size: 13px;
  color: var(--text);
  line-height: 1.3;
}

.onboard-step-top > div > span {
  display: block;
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 2px;
  line-height: 1.4;
}

.onboard-step button {
  width: 100%;
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

/* Quick Bot Mode Switcher on Dashboard */
.quick-mode-wrap {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.quick-mode-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.quick-mode-pills {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.qmode-btn {
  padding: 7px 8px;
  min-height: 36px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
  transition: all 0.14s ease;
}

.qmode-btn:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.qmode-btn.active.mode-auto {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: #ffffff;
}

.qmode-btn.active.mode-draft {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.qmode-btn.active.mode-off {
  background: var(--text-secondary);
  border-color: var(--text-secondary);
  color: #ffffff;
}

/* Settings Sub-Tabs & Field Hints */
.settings-subpanel {
  display: none;
}

.settings-subpanel.active {
  display: block;
}

.field-hint {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 4px;
  line-height: 1.45;
}

.adv-accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  margin-bottom: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.adv-accordion summary {
  padding: 14px 18px;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.adv-accordion summary::-webkit-details-marker {
  display: none;
}

.adv-accordion summary::after {
  content: 'Tampilkan';
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text);
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
}

.adv-accordion[open] summary::after {
  content: 'Sembunyikan';
}

.adv-accordion-body {
  padding: 0 18px 18px;
  border-top: 1px solid var(--border);
}

@media (max-width: 820px) {
  .onboard-steps {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .onboard-card {
    padding: 14px;
  }
}

/* ============================================================
   PAKET 2: PRODUCT CATALOG, CRM LABELS & HUMAN TAKEOVER
   ============================================================ */
.kb-subpanel {
  display: none;
}
.kb-subpanel.active {
  display: block;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.product-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.product-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-card);
}

.product-card.is-off {
  opacity: 0.65;
}

.product-thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--text-dim);
  font-size: 12px;
  position: relative;
}

.product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
}

.product-body {
  padding: 12px 13px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.product-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.product-price {
  font-size: 15px;
  font-weight: 800;
  color: var(--primary);
}

.product-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-foot {
  padding: 10px 13px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}

.product-foot button {
  padding: 5px 10px;
  min-height: 30px;
  font-size: 12px;
}

/* CRM Badges */
.crm-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  color: #ffffff;
}
.crm-badge.prospek { background: #334155; color: #ffffff; }
.crm-badge.mau_order { background: #8a5a10; color: #ffffff; }
.crm-badge.menunggu_bayar { background: #b45309; color: #ffffff; }
.crm-badge.sudah_order { background: #11693a; color: #ffffff; }
.crm-badge.vip { background: #18181b; color: #e5c158; }
.crm-badge.komplain { background: #b91c1c; color: #ffffff; }

html[data-theme="dark"] .crm-badge.prospek { background: #334155; color: #f1f5f9; }
html[data-theme="dark"] .crm-badge.mau_order { background: #9a6714; color: #ffffff; }
html[data-theme="dark"] .crm-badge.menunggu_bayar { background: #c2410c; color: #ffffff; }
html[data-theme="dark"] .crm-badge.sudah_order { background: #15803d; color: #ffffff; }
html[data-theme="dark"] .crm-badge.vip { background: #272214; color: #e5c158; }
html[data-theme="dark"] .crm-badge.komplain { background: #991b1b; color: #ffffff; }

/* Chat CRM & Human Takeover Bar */
.chat-crm-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
}

.chat-crm-bar.is-takeover {
  background: var(--surface-subtle);
  border-color: #8a5a10;
  border-left: 3px solid #8a5a10;
}

.chat-crm-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chat-crm-select {
  width: auto !important;
  min-width: 140px;
  min-height: 32px !important;
  padding: 4px 10px !important;
  font-size: 12.5px !important;
  border-radius: 8px !important;
}

.takeover-btn {
  padding: 6px 12px;
  min-height: 32px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 8px;
}

.takeover-btn.is-manual {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: #ffffff;
}

.takeover-btn.is-bot {
  background: #8a5a10;
  border: 1px solid #8a5a10;
  color: #ffffff;
}

.takeover-btn.is-bot:hover {
  background: #734a0c;
  border-color: #734a0c;
}

.plan-identity {
  min-width: 0;
  flex: 1;
}

.plan-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.plan-name-row strong {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.015em;
}

.plan-sub-row {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-top: 3px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.plan-banner-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.plan-quota-box {
  min-width: 200px;
}

.plan-quota-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.plan-quota-head strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.quota-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
  margin-top: 6px;
}

.quota-bar-fill {
  height: 100%;
  min-width: 4px;
  border-radius: 4px;
  background: var(--primary);
  box-shadow: none;
  transition: width 0.25s ease;
}

.quota-bar-fill.is-zero {
  min-width: 0;
}

.quota-bar-fill.high { background: var(--warning); }
.quota-bar-fill.full { background: var(--danger); }

.plan-cta {
  padding: 9px 15px;
  min-height: 38px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
  white-space: nowrap;
}

/* Status & AI Card Mini Grid + Onboarding Notice */
.status-kv-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.status-kv {
  padding: 9px 10px;
  border-radius: 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  min-width: 0;
}

.status-kv-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.status-kv-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wa-onboard-box {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.5;
}

.wa-onboard-box strong {
  color: var(--text);
}

.card-title-ic {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #11693a;
  color: #ffffff;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}

.card-title-ic.green {
  background: #14532d;
  color: #ffffff;
}

.card-title-ic svg {
  width: 15px;
  height: 15px;
}

/* Mobile Sheet Icons */
.sheet-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-bottom: 2px;
}

.sheet-ic {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #11693a;
  color: #ffffff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.sheet-ic svg {
  width: 15px;
  height: 15px;
}

/* Superadmin Sub-Tab Console Bar */
.admin-subtabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-subtab {
  flex: 1 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: none;
  transition: background 0.14s ease, color 0.14s ease;
}

.admin-subtab:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

.admin-subtab.active {
  background: var(--primary);
  color: #ffffff;
  border: 1px solid var(--primary);
  box-shadow: none;
}

.admin-subtab svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.admin-subtab .subtab-count {
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  background: #8a5a10;
  color: #ffffff;
}

.admin-subtab.active .subtab-count {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

.admin-subpanel {
  display: none;
}

.admin-subpanel.active {
  display: block;
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.admin-toolbar input {
  flex: 1;
  min-width: 190px;
}

.admin-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 4px;
}

.tenant-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 15px;
  background: var(--surface);
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease;
}

.tenant-card:hover {
  border-color: var(--border-hover);
}

.tenant-card.is-inactive {
  border-color: var(--danger);
  border-left: 4px solid var(--danger);
  background: var(--surface);
}

.tenant-card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.tenant-ident {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.tenant-avatar {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #1f3a2c;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
}

.tenant-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tenant-meta-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.tenant-meta-cell {
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
}

.tenant-meta-cell strong {
  display: block;
  font-size: 13px;
  color: var(--text);
  margin-top: 2px;
}

.tenant-quota-mini {
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
  margin-top: 5px;
}

.tenant-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tenant-actions button {
  padding: 6px 11px;
  min-height: 32px;
  font-size: 12px;
}

@media (max-width: 820px) {
  .plan-banner {
    flex-direction: column;
    align-items: stretch;
    padding: 14px;
    gap: 12px;
  }
  .plan-banner-right {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
  }
  .plan-quota-box {
    min-width: 0;
    width: 100%;
  }
  .plan-cta {
    width: 100%;
  }
  .status-kv-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .status-kv {
    padding: 7px 8px;
  }
  .status-kv-val {
    font-size: 12px;
  }
  .tenant-meta-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .tenant-actions button {
    flex: 1 1 auto;
  }
}

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

@media (max-width: 820px) {
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   CEKAT.AI AUTH LAYOUT (Login & Sign Up Split-Screen + Mobile)
   ============================================================ */
.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  background: var(--surface);
}

.auth-left {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px 36px;
  background: var(--surface);
}

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

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.auth-brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  overflow: hidden;
  background: #050a08;
  border: 1px solid rgba(34, 197, 94, 0.35);
  flex-shrink: 0;
}

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

.auth-brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.auth-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-home-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
}

.auth-home-link:hover {
  color: var(--primary);
  background: var(--surface-subtle);
}

.auth-theme-btn {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 8px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.auth-theme-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.auth-form-wrap {
  width: 100%;
  max-width: 420px;
  margin: 28px auto;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  margin-bottom: 24px;
}

.auth-tab {
  text-align: center;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}

.auth-tab:hover { color: var(--text); }

.auth-tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
}

.auth-heading {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text);
}

.auth-sub {
  margin: 0 0 22px;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.55;
}

.auth-trial-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 6px;
  background: #11693a;
  border: none;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 14px;
}

.auth-field {
  margin-bottom: 14px;
}

.auth-field label {
  display: block;
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.auth-field input,
.auth-field select {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

html[data-theme="dark"] .auth-field input,
html[data-theme="dark"] .auth-field select {
  background: #121e32;
  border-color: #243146;
}

.auth-field input:focus,
.auth-field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.auth-pw-box {
  position: relative;
}

.auth-pw-box input {
  padding-right: 44px;
}

.auth-eye-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: none;
}

.auth-eye-btn:hover {
  color: var(--text);
  background: var(--surface-subtle);
}

.auth-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.auth-submit {
  width: 100%;
  min-height: 46px;
  border-radius: 8px;
  background: #11693a;
  color: #ffffff;
  font-size: 14.5px;
  font-weight: 600;
  border: 1px solid #0d542e;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
  cursor: pointer;
  box-shadow: none;
  transition: background 0.15s, transform 0.12s;
}

.auth-submit:hover {
  background: #0d542e;
}
.auth-submit:active { transform: scale(0.99); }
.auth-submit:disabled { opacity: 0.65; cursor: not-allowed; }

html[data-theme="dark"] .auth-submit {
  background: #15803d;
  border-color: #15803d;
  box-shadow: none;
}
html[data-theme="dark"] .auth-submit:hover {
  background: #16a34a;
  border-color: #16a34a;
  box-shadow: none;
}

.auth-err {
  min-height: 20px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--danger);
  font-weight: 500;
}

.auth-foot-note {
  text-align: center;
  font-size: 12.5px;
  color: var(--text-dim);
  padding-top: 8px;
}

.auth-foot-note a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

/* Right Doctor Doom Latveria Sovereign Showcase Column (Solid Matte Obsidian) */
.auth-right {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 44px;
  background: #0a1710;
  border-left: 1px solid #1a2e22;
  color: #ffffff;
  overflow: hidden;
}

.auth-right::before {
  display: none;
}

.auth-right::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: #11693a;
  pointer-events: none;
}

.auth-right-inner {
  position: relative;
  z-index: 2;
  max-width: 440px;
  margin: 0 auto;
}

.auth-right-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 6px;
  background: #11693a;
  border: none;
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 18px;
}

.auth-right h2 {
  margin: 0 0 12px;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.025em;
  color: #f0fdf4;
}

.auth-right p {
  margin: 0 0 26px;
  font-size: 14.5px;
  line-height: 1.6;
  color: #b4c8bc;
}

.auth-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 26px;
}

.auth-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 10px;
  background: #112218;
  border: 1px solid #20382a;
}

.auth-step-ic {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: #11693a;
  border: none;
  color: #ffffff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.auth-step strong {
  display: block;
  font-size: 13.5px;
  color: #f0fdf4;
  margin-bottom: 2px;
}

.auth-step span {
  display: block;
  font-size: 12.5px;
  color: #9cb5a6;
  line-height: 1.45;
}

.auth-preview-bubble {
  padding: 14px 16px;
  border-radius: 10px;
  background: #112218;
  border: 1px solid #20382a;
  border-left: 3px solid #15803d;
  box-shadow: none;
  font-size: 12.5px;
  color: #e2efe7;
}

.auth-preview-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: #86efac;
  font-weight: 700;
  margin-bottom: 6px;
}

@media (max-width: 920px) {
  .auth-page {
    grid-template-columns: 1fr;
  }
  .auth-right {
    display: none;
  }
  .auth-left {
    padding: 16px 20px 24px;
  }
  .auth-form-wrap {
    margin: 20px auto;
  }
}

@media (max-width: 480px) {
  .auth-grid-2 {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .auth-heading {
    font-size: 22px;
  }
}

/* ============================================================
   MOBILE ANTI-ZOOM (Prevent Pinch, Double-Tap & iOS Input Zoom)
   ============================================================ */
html,
body {
  touch-action: pan-x pan-y;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-x: none;
}

button,
a,
input,
select,
textarea,
label {
  touch-action: manipulation;
}

@media (max-width: 900px), (hover: none) and (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* ============================================================
   DOCTOR DOOM SOLID ARCHITECTURAL ACCENTS (Zero Neon / Zero Slop)
   ============================================================ */
.plan-banner {
  position: relative;
  overflow: hidden;
  border-color: var(--border);
  border-top: 3px solid var(--primary);
}

.nav-btn.active {
  position: relative;
  border-left: 3px solid var(--primary);
}

html[data-theme="dark"] .card {
  border-color: var(--border);
}

html[data-theme="dark"] .kpi-card {
  background: var(--surface);
  border-color: var(--border);
}

.kpi-ic.blue {
  background: #11693a;
  color: #ffffff;
}

.kpi-ic.green {
  background: #14532d;
  color: #ffffff;
}

.kpi-ic.amber {
  background: #8a5a10;
  color: #ffffff;
}

.kpi-ic.indigo {
  background: #1f3329;
  color: #ffffff;
}

html[data-theme="dark"] .kpi-ic.blue {
  background: #15803d;
  color: #ffffff;
}

html[data-theme="dark"] .kpi-ic.green {
  background: #166534;
  color: #ffffff;
}

html[data-theme="dark"] .kpi-ic.amber {
  background: #9a6714;
  color: #ffffff;
}

html[data-theme="dark"] .kpi-ic.indigo {
  background: #22382c;
  color: #e2efe7;
}

.brand-icon,
.auth-brand-logo {
  border: 1px solid #1f3a2c;
  box-shadow: none;
}

/* ============================================================
   GAYA BICARA PRESET (USER-FRIENDLY PERSONA SELECTOR)
   ============================================================ */
.persona-preset-box {
  margin-top: 14px;
  margin-bottom: 12px;
}

.persona-pills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.persona-pill-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 4px;
  box-shadow: var(--shadow-sm);
  color: inherit;
  font-family: inherit;
}

.persona-pill-card:hover {
  border-color: var(--primary);
  background: var(--surface-subtle);
}

.persona-pill-card.active {
  border: 2px solid var(--primary);
  background: rgba(22, 163, 74, 0.08);
  box-shadow: 0 0 0 1px var(--primary);
}

.persona-pill-title {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.persona-pill-card.active .persona-pill-title {
  color: var(--primary);
}

.persona-pill-sub {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

@media (max-width: 640px) {
  .persona-pills-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

/* ============================================================
   HERO STATUS TOKO & QUICK ACTION BAR (NON-IT FRIENDLY)
   ============================================================ */
.shop-hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--primary);
  border-radius: var(--radius-xl);
  padding: 16px 20px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.shop-hero-card.disconnected {
  border-left-color: #d97706;
  background: rgba(217, 119, 6, 0.04);
}

.shop-hero-main {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 260px;
}

.shop-hero-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
}

.shop-hero-icon.ok {
  background: rgba(22, 163, 74, 0.15);
  border-color: rgba(22, 163, 74, 0.4);
  color: #22c55e;
}

.shop-hero-icon.warn {
  background: rgba(217, 119, 6, 0.15);
  border-color: rgba(217, 119, 6, 0.4);
  color: #f59e0b;
}

.shop-hero-icon svg {
  width: 24px;
  height: 24px;
}

.shop-hero-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.shop-hero-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.4;
}

.shop-hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.shop-quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.quick-act-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
  transition: all 0.15s ease-in-out;
  box-shadow: var(--shadow-sm);
}

.quick-act-btn:hover {
  border-color: var(--primary);
  background: var(--surface-subtle);
  transform: translateY(-1px);
}

.quick-act-ic {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.quick-act-ic svg {
  width: 18px;
  height: 18px;
}

.quick-act-ic.green {
  background: rgba(22, 163, 74, 0.15);
  color: #22c55e;
}

.quick-act-ic.indigo {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
}

.quick-act-ic.amber {
  background: rgba(217, 119, 6, 0.15);
  color: #fbbf24;
}

.quick-act-ic.blue {
  background: rgba(14, 165, 233, 0.15);
  color: #38bdf8;
}

.quick-act-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quick-act-text strong {
  font-size: 13.5px;
  color: var(--text);
}

.quick-act-text small {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Panduan Langkah Scan QR */
.qr-onboard-guide {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.qr-guide-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.qr-step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  font-size: 11px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

/* ============================================================
   UNIFIED TYPOGRAPHY SYSTEM (KONSISTENSI FONT & SKALA HURUF)
   ============================================================ */
html, body,
button, input, select, textarea,
code, pre, kbd, samp,
th, td, summary, label,
.nav-btn, .bnav-btn, .sheet-item,
.persona-pill-card, .quick-act-btn, .qmode-btn, .admin-subtab {
  font-family: var(--font-sans) !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

code {
  font-family: var(--font-sans) !important;
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

pre {
  font-family: var(--font-sans) !important;
  font-size: 13px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}

/* Tier 1: Judul Halaman Utama */
.page-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

/* Tier 2: Judul Kartu & Section */
.card h2,
.shop-hero-title,
.onboard-title,
.plan-name,
.modal-card h2,
.auth-title {
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

/* Tier 3: Sub-Judul Item & Elemen Interaktif */
.persona-pill-title,
.quick-act-text strong,
.item-head strong,
.onboard-step strong,
.sheet-item strong,
.group-row-title,
.contact-name,
.prod-title,
.adv-accordion summary {
  font-size: var(--fs-base);
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.4;
}

/* Tier 4: Teks Utama, Navigasi & Kontrol Form */
body,
.nav-btn,
.admin-subtab,
.incoming,
table {
  font-size: var(--fs-base);
  line-height: 1.5;
}

input,
select,
textarea {
  font-size: var(--fs-base);
  font-weight: 400;
  line-height: 1.45;
}

button,
.qmode-btn {
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.35;
}

/* Tier 5: Label Form, Penjelasan & Teks Sekunder */
label,
.quick-mode-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.4;
}

.page-sub,
.shop-hero-subtitle,
.onboard-sub,
.muted,
.field-hint,
.persona-pill-sub,
.quick-act-text small,
.onboard-step-top > div > span,
.sheet-item .muted,
.qr-guide-step,
.wa-onboard-box {
  font-size: var(--fs-sm) !important;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0;
}

/* Tier 6: Metrik, Label Kartu & Badge (Bebas ALL-CAPS Berlebihan) */
.kpi-label,
.status-kv-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-dim);
}

.kpi-sub {
  font-size: var(--fs-xs);
  font-weight: 400;
  letter-spacing: 0;
}

.kpi-value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.status-kv-val {
  font-size: 13.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
}

.badge {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0;
}

.nav-group-label,
th {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

@media (max-width: 820px) {
  .page-title {
    font-size: 18px;
  }
  .card h2,
  .shop-hero-title,
  .onboard-title {
    font-size: 15px;
  }
  .kpi-value {
    font-size: 20px;
  }
  .content {
    padding-bottom: calc(var(--bottom-nav-h) + 52px + env(safe-area-inset-bottom)) !important;
  }
}

/* ============================================================
   SCHEDULE FORM, iOS TIME INPUT & DAY PILLS REFINEMENT
   ============================================================ */
.grid-form > div,
.grid-2 > div,
.grid-time-2 > div,
.schedule-form-stack > div {
  min-width: 0;
  max-width: 100%;
}

.schedule-preset-box {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
}

.schedule-preset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.schedule-preset-grid button {
  width: 100%;
  padding: 9px 10px;
  min-height: 38px;
  text-align: center;
  justify-content: center;
}

.schedule-form-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

/* Fix iOS Safari <input type="time"> / date intrinsic width overflow & center-alignment */
input[type="time"],
input[type="date"],
input[type="datetime-local"] {
  display: block;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  -webkit-appearance: none;
  appearance: none;
  text-align: left;
  margin: 0;
}

input[type="time"]::-webkit-date-and-time-value,
input[type="date"]::-webkit-date-and-time-value,
input[type="datetime-local"]::-webkit-date-and-time-value {
  text-align: left;
  margin: 0;
}

/* Prevent mobile min-height: 44px from stretching checkboxes & radio buttons */
input[type="checkbox"],
input[type="radio"] {
  width: 18px !important;
  height: 18px !important;
  min-height: 18px !important;
  max-height: 18px !important;
  padding: 0 !important;
  margin: 0 !important;
  flex-shrink: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Balanced 7-Day Selector Grid */
.day-pills {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-top: 6px;
}

.day-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 8px;
  min-height: 42px;
  margin: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.day-pill:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.day-pill:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--primary);
}

@media (max-width: 600px) {
  .schedule-preset-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .schedule-preset-grid button:last-child {
    grid-column: 1 / -1;
  }
  .day-pills {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }
  #saveScheduleBtn {
    width: 100%;
    min-height: 44px;
  }
}

/* ============================================================
   REFERRAL PROGRAM CARD (UNIQUE CODE PER TENANT + FULL LINK)
   ============================================================ */
.ref-boxes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.ref-code-box,
.ref-link-box {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.ref-code-box {
  border-left: 4px solid var(--primary);
}

.ref-box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.ref-box-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-dim);
}

.ref-code-display-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.ref-code-text {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--primary);
  background: var(--surface);
  border: 1px dashed var(--primary);
  padding: 7px 14px;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
  user-select: all;
}

html[data-theme="dark"] .ref-code-text {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.45);
}

.ref-code-actions,
.ref-link-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ref-link-url-text {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-secondary);
  word-break: break-all;
  line-height: 1.45;
  user-select: all;
}

.ref-url-highlight {
  color: var(--primary);
  font-weight: 700;
}

html[data-theme="dark"] .ref-url-highlight {
  color: #4ade80;
}

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

@media (max-width: 600px) {
  .ref-boxes-grid {
    grid-template-columns: 1fr;
  }
  .ref-code-display-row {
    flex-direction: column;
    align-items: stretch;
  }
  .ref-code-text {
    text-align: center;
  }
  .ref-code-actions,
  .ref-link-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ref-code-actions button,
  .ref-link-actions button {
    width: 100%;
  }
  .ref-stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .ref-stats-grid .kpi-card {
    padding: 10px;
  }
  .ref-stats-grid .kpi-label {
    font-size: 11px;
    line-height: 1.25;
  }
  .ref-stats-grid .kpi-value {
    font-size: 18px;
    margin-top: 6px;
  }
}

/* ============================================================
   MOBILE BOTTOM NAVIGATION BAR REFINEMENT (CLEAN & PROPORTIONAL)
   ============================================================ */
.bottom-nav {
  padding: 6px 10px calc(8px + env(safe-area-inset-bottom)) !important;
  gap: 4px !important;
  align-items: center;
}

.bnav-btn {
  font-size: 11px !important;
  font-weight: 600 !important;
  line-height: 1.2 !important;
  letter-spacing: -0.01em !important;
  padding: 6px 2px !important;
  min-height: 48px !important;
  border-radius: 12px !important;
  gap: 4px !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bnav-btn svg {
  width: 20px !important;
  height: 20px !important;
  flex-shrink: 0;
}

.bnav-btn.active {
  color: var(--primary) !important;
  background: var(--primary-soft) !important;
  font-weight: 700 !important;
}

/* ============================================================
   GOOGLE SIGN-IN / REGISTER BUTTON & DIVIDER
   ============================================================ */
.google-auth-wrap {
  margin-bottom: 14px;
}

.google-auth-btn {
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-base);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
  text-decoration: none;
}

.google-auth-btn:hover {
  background: var(--surface-subtle);
  border-color: var(--primary);
}

.google-auth-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
  color: var(--text-dim);
  font-size: var(--fs-xs);
  font-weight: 600;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

input::placeholder {
  text-transform: none;
}








.pair-box{margin-top:16px;padding-top:14px;border-top:1px dashed var(--border,#d6dcd8)}
.pair-title{font-weight:700;font-size:14px}
.pair-row{display:flex;gap:8px;flex-wrap:wrap}
.pair-row input{flex:1 1 180px;min-width:0}
.pair-code{margin:14px 0 8px;text-align:center;font-size:30px;font-weight:800;letter-spacing:6px;font-family:ui-monospace,Consolas,monospace;padding:14px;border-radius:12px;background:rgba(22,163,74,.12);color:#16a34a;user-select:all}
.pair-steps{margin:0;padding-left:20px;font-size:12.5px;line-height:1.7}
.pair-err{margin-top:10px;color:#dc2626;font-size:13px}

/* ============================================================
   DESKTOP UI POLISH (min-width: 861px) & ICON GUARDRAILS
   ============================================================ */
button svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.nav-btn svg {
  width: 17px;
  height: 17px;
}

.quick-act-ic svg {
  width: 18px;
  height: 18px;
}

.theme-icon-btn svg {
  width: 17px;
  height: 17px;
}

.google-auth-btn svg {
  width: 18px;
  height: 18px;
}

@media (min-width: 861px) {
  /* Hindari duplikasi banner PWA di desktop karena sudah ada tombol di footer sidebar */
  .pwa-banner {
    display: none !important;
  }

  /* Sidebar Desktop */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    height: 100vh;
    height: 100dvh;
    z-index: 30;
    padding: 18px 14px 16px;
    gap: 12px;
  }

  .main-area {
    margin-left: var(--sidebar-w);
    width: calc(100% - var(--sidebar-w));
  }

  .sidebar .brand {
    padding: 4px 6px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  .sidebar .nav-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 2px;
    scrollbar-width: thin;
  }

  .nav-btn {
    padding: 9px 12px;
    gap: 8px;
  }

  .nav-btn .nav-left {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sidebar-footer {
    flex-shrink: 0;
    gap: 8px;
    padding-top: 14px;
  }

  .sidebar-footer button {
    min-height: 38px;
    padding: 8px 12px;
    gap: 8px;
    border-radius: 10px;
    justify-content: center;
  }

  /* Kanvas Konten Desktop Lebih Lega & Seimbang */
  .content {
    max-width: 1360px;
    padding: 26px 32px 56px;
  }

  .page-head {
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
  }

  .card {
    padding: 22px 24px;
    margin-bottom: 16px;
  }

  .shop-hero-card,
  .plan-banner,
  .onboard-card {
    padding: 18px 22px;
    margin-bottom: 16px;
  }

  /* Grid Seimbang Across Tabs */
  .kpi-grid {
    gap: 14px;
    margin-bottom: 16px;
  }

  .kpi-card {
    padding: 16px 18px;
  }

  .shop-quick-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
  }

  .quick-act-btn {
    padding: 14px 16px;
    height: 100%;
  }

  .grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: stretch;
    margin-bottom: 16px;
  }

  .grid-2 > .card {
    margin-bottom: 0;
    height: 100%;
  }

  .grid-3 {
    gap: 16px;
  }

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

  .persona-pills-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
  }

  .persona-pill-card {
    height: 100%;
  }

  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
  }

  .contacts-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }

  #billingCouponMsg:empty {
    display: none;
  }

  .admin-subtabs {
    padding: 6px;
    gap: 6px;
    margin-bottom: 18px;
  }

  .modal-card {
    max-width: 660px;
    padding: 24px 26px;
  }

  /* Chat Viewer Full-Height Desktop */
  .chat-layout {
    grid-template-columns: 330px minmax(0, 1fr);
    gap: 16px;
  }

  .chat-sidebar {
    height: clamp(540px, calc(100vh - 235px), 760px);
  }

  .chat-thread {
    height: clamp(476px, calc(100vh - 300px), 696px);
  }

  .bubble {
    max-width: 72%;
  }
}

@media (min-width: 1680px) {
  .content {
    max-width: 1480px;
    padding: 28px 40px 56px;
  }
}

/* Payment Method Picker Modal (Tripay) */
.pay-channel-list {
  max-height: 56vh;
  overflow-y: auto;
  padding-right: 4px;
}

.pay-channel-group {
  margin-bottom: 14px;
}

.pay-channel-group:last-child {
  margin-bottom: 0;
}

.pay-channel-group-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.pay-channel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 520px) {
  .pay-channel-grid {
    grid-template-columns: 1fr;
  }
}

.pay-channel-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.pay-channel-card:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--surface-subtle);
}

.pay-channel-card.active {
  border-color: var(--primary);
  background: rgba(17, 105, 58, 0.08);
  box-shadow: 0 0 0 2px rgba(17, 105, 58, 0.18);
}

.pay-channel-card:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pay-channel-logo {
  width: 52px;
  height: 30px;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px 5px;
  flex-shrink: 0;
  overflow: hidden;
}

.pay-channel-logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.pay-channel-meta {
  min-width: 0;
  flex: 1;
}

.pay-channel-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pay-channel-fee {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* =====================================================================
   WHATSAPP-STYLE CHAT VIEWER (DESKTOP & MOBILE, LIGHT & DARK)
   ===================================================================== */
:root {
  --wa-panel-bg: #ffffff;
  --wa-header-bg: #f0f2f5;
  --wa-border: #e2e8ec;
  --wa-hover: #f5f6f6;
  --wa-active: #f0f2f5;
  --wa-search-bg: #f0f2f5;
  --wa-wallpaper-bg: #efeae2;
  --wa-bubble-in: #ffffff;
  --wa-bubble-out: #d9fdd3;
  --wa-bubble-text: #111b21;
  --wa-bubble-meta: #667781;
  --wa-date-bg: rgba(255, 255, 255, 0.92);
  --wa-date-text: #54656f;
  --wa-composer-bg: #f0f2f5;
  --wa-input-bg: #ffffff;
  --wa-accent: #00a884;
  --wa-accent-hover: #008f6f;
  --wa-check: #53bdeb;
  --wa-doc-bg: rgba(11, 20, 26, 0.05);
}

html[data-theme="dark"] {
  --wa-panel-bg: #111b21;
  --wa-header-bg: #202c33;
  --wa-border: #2a3942;
  --wa-hover: #202c33;
  --wa-active: #2a3942;
  --wa-search-bg: #202c33;
  --wa-wallpaper-bg: #0b141a;
  --wa-bubble-in: #202c33;
  --wa-bubble-out: #005c4b;
  --wa-bubble-text: #e9edef;
  --wa-bubble-meta: rgba(233, 237, 239, 0.65);
  --wa-date-bg: #182229;
  --wa-date-text: #8696a0;
  --wa-composer-bg: #202c33;
  --wa-input-bg: #2a3942;
  --wa-accent: #00a884;
  --wa-accent-hover: #06cf9c;
  --wa-check: #53bdeb;
  --wa-doc-bg: rgba(0, 0, 0, 0.22);
}

.wa-chat-card {
  padding: 0 !important;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--wa-border);
  background: var(--wa-panel-bg);
}

.wa-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 0 !important;
  height: clamp(560px, calc(100vh - 185px), 820px);
  min-height: 0;
}

.wa-list-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--wa-panel-bg);
  border-right: 1px solid var(--wa-border);
}

.wa-list-header {
  padding: 12px 14px 10px;
  background: var(--wa-panel-bg);
  border-bottom: 1px solid var(--wa-border);
  flex-shrink: 0;
}

.wa-list-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.wa-list-title-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

@keyframes waSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.wa-icon-btn.is-spinning svg {
  animation: waSpin 0.9s linear infinite;
}

.wa-sync-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--wa-accent);
  background: rgba(0, 168, 132, 0.09);
  border-bottom: 1px solid var(--wa-border);
  flex-shrink: 0;
}

.wa-list-section-label {
  padding: 8px 14px 5px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--wa-accent);
  background: var(--wa-panel-bg);
  border-bottom: 1px solid var(--wa-border);
}

.wa-sync-spinner {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid rgba(0, 168, 132, 0.25);
  border-top-color: var(--wa-accent);
  animation: waSpin 0.8s linear infinite;
  flex-shrink: 0;
}

.bubble.is-pending {
  opacity: 0.78;
}

.wa-list-title {
  font-size: 19px;
  font-weight: 800;
  color: var(--wa-bubble-text);
  letter-spacing: -0.02em;
}

.wa-list-count {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--wa-bubble-meta);
}

.wa-list-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--wa-search-bg);
  border-radius: 20px;
  padding: 0 12px;
  height: 36px;
  color: var(--wa-bubble-meta);
}

.wa-list-search-wrap input {
  flex: 1;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  min-height: 34px !important;
  height: 34px !important;
  font-size: 13.5px;
  color: var(--wa-bubble-text);
  outline: none;
}

.wa-sidebar {
  flex: 1;
  min-height: 0;
  height: auto !important;
  overflow-y: auto;
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--wa-panel-bg) !important;
}

/* Avatar */
.wa-avatar {
  position: relative;
  overflow: hidden;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: #ffffff;
  flex-shrink: 0;
  user-select: none;
  letter-spacing: 0.02em;
  background: #00a884;
}

.wa-avatar-sm {
  width: 38px;
  height: 38px;
  font-size: 13.5px;
}

.contact-avatar {
  position: relative;
  overflow: hidden;
}

.wa-avatar-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}

/* Contact Row */
.wa-sidebar .chat-contact {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--wa-border);
  border-left: 0 !important;
  cursor: pointer;
  background: transparent;
  transition: background 0.12s ease;
}

.wa-sidebar .chat-contact:hover {
  background: var(--wa-hover);
}

.wa-sidebar .chat-contact.active {
  background: var(--wa-active);
  border-left: 0 !important;
}

.wa-contact-body {
  flex: 1;
  min-width: 0;
}

.wa-contact-row1 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.wa-contact-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--wa-bubble-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wa-contact-time {
  font-size: 11px;
  color: var(--wa-bubble-meta);
  flex-shrink: 0;
}

.wa-contact-row2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 3px;
}

.wa-contact-preview {
  font-size: 12.5px;
  color: var(--wa-bubble-meta);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.wa-contact-tags {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.wa-msg-pill {
  background: var(--wa-accent);
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 700;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Thread Column */
.wa-thread-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  height: 100%;
  background: var(--wa-wallpaper-bg);
}

.wa-topbar {
  height: 58px;
  padding: 0 12px;
  margin-bottom: 0 !important;
  background: var(--wa-header-bg);
  border-bottom: 1px solid var(--wa-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: nowrap !important;
  flex-shrink: 0;
}

.wa-topbar .chat-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.wa-topbar-info {
  min-width: 0;
  flex: 1;
  cursor: pointer;
}

.wa-topbar .chat-topbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--wa-bubble-text);
  line-height: 1.25;
}

.wa-topbar-sub {
  font-size: 12px;
  color: var(--wa-bubble-meta);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
  margin-top: 1px;
}

.wa-topbar-sub.is-manual {
  color: #d97706;
  font-weight: 600;
}

.wa-icon-btn {
  width: 36px;
  height: 36px;
  min-height: 36px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  border: 0 !important;
  background: transparent !important;
  color: var(--wa-bubble-meta) !important;
  box-shadow: none !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 18px;
}

.wa-icon-btn:hover:not(:disabled) {
  background: rgba(128, 128, 128, 0.14) !important;
  color: var(--wa-bubble-text) !important;
}

.wa-icon-btn.active {
  background: rgba(0, 168, 132, 0.16) !important;
  color: var(--wa-accent) !important;
}

.wa-icon-btn.wa-icon-danger:hover:not(:disabled) {
  color: var(--danger) !important;
  background: var(--danger-soft) !important;
}

.wa-icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.wa-crm-bar {
  margin: 0 !important;
  border-radius: 0 !important;
  border: 0 !important;
  border-bottom: 1px solid var(--wa-border) !important;
  padding: 8px 14px !important;
  background: var(--wa-panel-bg) !important;
  flex-shrink: 0;
}

.wa-search-bar {
  margin: 0 !important;
  padding: 8px 12px;
  background: var(--wa-panel-bg);
  border-bottom: 1px solid var(--wa-border);
  align-items: center;
  flex-shrink: 0;
}

.wa-search-bar input {
  flex: 1;
  min-height: 34px !important;
  padding: 6px 12px !important;
  border-radius: 18px !important;
  background: var(--wa-search-bg) !important;
  border: 0 !important;
  font-size: 13.5px;
}

.wa-search-bar .secondary {
  min-height: 34px !important;
  padding: 5px 12px !important;
  font-size: 12.5px;
}

/* WhatsApp Wallpaper Thread */
.wa-thread {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: auto !important;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 14px 5% 18px !important;
  gap: 4px !important;
  background-color: var(--wa-wallpaper-bg) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%23000000' stroke-opacity='0.045' stroke-width='1.2'%3E%3Ccircle cx='22' cy='22' r='8'/%3E%3Cpath d='M75 18l10 6-4 10-10-6z'/%3E%3Cpath d='M18 82c0-7 6-12 13-12s13 5 13 12c0 3-1 6-3 8l2 7-7-2c-2 1-3 1-5 1-7 0-13-5-13-14z'/%3E%3Cpath d='M86 78l4 8 9 1-6 6 2 9-9-4-8 4 1-9-6-6 9-1z'/%3E%3Ccircle cx='60' cy='58' r='4'/%3E%3C/g%3E%3C/svg%3E") !important;
  background-repeat: repeat;
}

html[data-theme="dark"] .wa-thread {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='0.04' stroke-width='1.2'%3E%3Ccircle cx='22' cy='22' r='8'/%3E%3Cpath d='M75 18l10 6-4 10-10-6z'/%3E%3Cpath d='M18 82c0-7 6-12 13-12s13 5 13 12c0 3-1 6-3 8l2 7-7-2c-2 1-3 1-5 1-7 0-13-5-13-14z'/%3E%3Cpath d='M86 78l4 8 9 1-6 6 2 9-9-4-8 4 1-9-6-6 9-1z'/%3E%3Ccircle cx='60' cy='58' r='4'/%3E%3C/g%3E%3C/svg%3E") !important;
}

.wa-empty-state {
  margin: auto;
  text-align: center;
  max-width: 320px;
  padding: 24px 16px;
}

.wa-empty-icon {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--wa-date-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.wa-empty-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--wa-bubble-text);
  margin-bottom: 6px;
}

.wa-empty-sub {
  font-size: 13px;
  color: var(--wa-bubble-meta);
  line-height: 1.5;
}

/* Date Divider Pill */
.wa-date-divider {
  align-self: center;
  background: var(--wa-date-bg);
  color: var(--wa-date-text);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 8px;
  margin: 10px 0 8px;
  box-shadow: 0 1px 1.5px rgba(11, 20, 26, 0.12);
  user-select: none;
}

.wa-load-older-btn {
  align-self: center;
  background: var(--wa-date-bg) !important;
  color: var(--wa-accent) !important;
  border: 1px solid var(--wa-border) !important;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px !important;
  min-height: 30px !important;
  border-radius: 999px !important;
  margin: 2px 0 8px;
  box-shadow: 0 1px 3px rgba(11, 20, 26, 0.1) !important;
  cursor: pointer;
}

.wa-load-older-btn:hover:not(:disabled) {
  background: var(--wa-panel-bg) !important;
  border-color: var(--wa-accent) !important;
}

.wa-load-older-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

/* Authentic WhatsApp Bubbles */
.wa-thread .bubble {
  position: relative;
  max-width: 72%;
  min-width: 86px;
  padding: 7px 9px 6px 10px;
  border-radius: 8px;
  border: 0 !important;
  font-size: 14px;
  line-height: 1.42;
  color: var(--wa-bubble-text) !important;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  margin-top: 6px;
}

.wa-thread .bubble.same-sender {
  margin-top: 1px;
}

.wa-thread .bubble.them {
  align-self: flex-start;
  background: var(--wa-bubble-in) !important;
  border-top-left-radius: 0;
}

.wa-thread .bubble.them.same-sender {
  border-top-left-radius: 8px;
}

.wa-thread .bubble.them:not(.same-sender)::before {
  content: '';
  position: absolute;
  top: 0;
  left: -8px;
  width: 8px;
  height: 13px;
  background: var(--wa-bubble-in);
  clip-path: polygon(100% 0, 0 0, 100% 100%);
}

.wa-thread .bubble.me {
  align-self: flex-end;
  background: var(--wa-bubble-out) !important;
  border-top-right-radius: 0;
}

.wa-thread .bubble.me.same-sender {
  border-top-right-radius: 8px;
}

.wa-thread .bubble.me:not(.same-sender)::before {
  content: '';
  position: absolute;
  top: 0;
  right: -8px;
  width: 8px;
  height: 13px;
  background: var(--wa-bubble-out);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

.wa-msg-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.wa-msg-text code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  background: rgba(128, 128, 128, 0.14);
  padding: 1px 5px;
  border-radius: 4px;
}

.wa-msg-text a {
  color: #027eb5;
  text-decoration: underline;
  word-break: break-all;
}

html[data-theme="dark"] .wa-msg-text a {
  color: #53bdeb;
}

/* WhatsApp Document Card inside Bubble */
.wa-doc-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 7px;
  background: var(--wa-doc-bg);
  margin-bottom: 6px;
}

.wa-doc-icon {
  width: 34px;
  height: 38px;
  border-radius: 6px;
  background: var(--wa-accent);
  color: #ffffff;
  font-size: 9.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.wa-doc-info {
  min-width: 0;
  flex: 1;
}

.wa-doc-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--wa-bubble-text);
  word-break: break-all;
  line-height: 1.3;
}

.wa-doc-sub {
  font-size: 11px;
  color: var(--wa-bubble-meta);
  margin-top: 2px;
}

/* Bubble Footer (Time + Double Check + Subtle Delete) */
.wa-thread .bubble-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  font-size: 11px;
  color: var(--wa-bubble-meta);
  line-height: 1;
}

.wa-check-svg {
  color: var(--wa-check);
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

.wa-thread .del-msg {
  opacity: 0;
  margin-right: auto;
  padding: 2px 6px;
  font-size: 10.5px;
  border-radius: 4px;
  transition: opacity 0.15s ease;
}

.wa-thread .bubble:hover .del-msg,
.wa-thread .bubble.show-actions .del-msg {
  opacity: 1;
}

/* WhatsApp Composer */
.wa-composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 10px;
  margin-top: 0 !important;
  background: var(--wa-composer-bg);
  border-top: 1px solid var(--wa-border);
  flex-shrink: 0;
}

.wa-composer-icon {
  width: 40px;
  height: 40px;
  min-height: 40px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  border: 0 !important;
  background: transparent !important;
  color: var(--wa-bubble-meta) !important;
  box-shadow: none !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}

.wa-composer-icon:hover:not(:disabled) {
  background: rgba(128, 128, 128, 0.14) !important;
  color: var(--wa-bubble-text) !important;
}

.wa-composer-icon:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.wa-input-pill {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  background: var(--wa-input-bg);
  border-radius: 22px;
  padding: 3px 6px 3px 14px;
  box-shadow: 0 1px 1px rgba(11, 20, 26, 0.08);
}

.wa-input-pill textarea {
  flex: 1;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  min-height: 34px !important;
  max-height: 112px !important;
  padding: 7px 0 !important;
  font-size: 14.5px;
  line-height: 1.38;
  color: var(--wa-bubble-text);
  resize: none;
  outline: none;
}

.wa-suggest-btn {
  width: 34px;
  height: 34px;
  min-height: 34px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.wa-suggest-btn:hover:not(:disabled) {
  background: rgba(0, 168, 132, 0.14) !important;
}

.wa-suggest-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.wa-send-btn {
  width: 42px;
  height: 42px;
  min-height: 42px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  border: 0 !important;
  background: var(--wa-accent) !important;
  color: #ffffff !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 168, 132, 0.28);
}

.wa-send-btn:hover:not(:disabled) {
  background: var(--wa-accent-hover) !important;
}

.wa-send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Mobile Full-Viewport WhatsApp Experience */
@media (max-width: 900px) {
  #tab-chats.active {
    display: flex;
    flex-direction: column;
  }

  .wa-chat-card {
    border-radius: 12px;
    height: calc(100dvh - 134px);
    min-height: 420px;
    display: flex;
    flex-direction: column;
  }

  .wa-layout {
    grid-template-columns: 1fr !important;
    height: 100% !important;
    flex: 1;
    min-height: 0;
  }

  .wa-list-col {
    border-right: 0;
    height: 100%;
  }

  .wa-topbar {
    padding: 0 8px;
    height: 54px;
  }

  .wa-topbar .mobile-back-btn {
    display: inline-flex !important;
    width: 34px;
    height: 34px;
    min-height: 34px !important;
    padding: 0 !important;
  }

  .wa-thread {
    padding: 10px 12px 14px !important;
  }

  .wa-thread .bubble {
    max-width: 86% !important;
    font-size: 14px;
  }

  .wa-composer {
    padding: 6px 8px;
    gap: 4px;
  }

  .wa-composer-icon {
    width: 36px;
    height: 36px;
    min-height: 36px !important;
  }

  .wa-send-btn {
    width: 40px;
    height: 40px;
    min-height: 40px !important;
  }
}
