/* ============================================================
   WA Portal — theme
   ============================================================ */
:root {
  --wa-green: #25d366;
  --wa-teal: #128c7e;
  --wa-dark: #075e54;
  --wa-bubble: #d9fdd3;
  --brand-grad: linear-gradient(135deg, #0b8f6a 0%, #25d366 100%);
  --sidebar-w: 260px;
  --radius: 16px;
  --app-bg: #f3f6f4;
  --card-bg: #ffffff;
  --card-border: rgba(16, 40, 30, .06);
  --shadow: 0 1px 2px rgba(16, 40, 30, .04), 0 8px 24px rgba(16, 40, 30, .06);
  --muted-bg: #f1f5f3;
  --chat-bg: #efeae2;
  --bs-primary: #128c7e;
  --bs-primary-rgb: 18, 140, 126;
  --bs-link-color: #0f7d70;
  --bs-link-color-rgb: 15, 125, 112;
  --bs-link-hover-color: #075e54;
  --bs-body-font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-border-radius: 10px;
}
[data-bs-theme="dark"] {
  --app-bg: #0e1513;
  --card-bg: #151f1c;
  --card-border: rgba(255, 255, 255, .06);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --muted-bg: #1b2724;
  --wa-bubble: #005c4b;
  --chat-bg: #0b141a;
  --bs-body-bg: #0e1513;
  --bs-link-color: #3ddc97;
  --bs-link-color-rgb: 61, 220, 151;
  --bs-link-hover-color: #6ff0b6;
}

body { background: var(--app-bg); font-size: .925rem; }
a { text-decoration: none; }
.min-w-0 { min-width: 0; }

/* Buttons */
.btn { font-weight: 600; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; gap: .15rem; }
.btn-primary {
  --bs-btn-bg: #128c7e; --bs-btn-border-color: #128c7e;
  --bs-btn-hover-bg: #0d7569; --bs-btn-hover-border-color: #0d7569;
  --bs-btn-active-bg: #075e54; --bs-btn-active-border-color: #075e54;
  --bs-btn-disabled-bg: #128c7e; --bs-btn-disabled-border-color: #128c7e;
  box-shadow: 0 4px 14px rgba(18, 140, 126, .25);
}
.btn-outline-primary {
  --bs-btn-color: #128c7e; --bs-btn-border-color: #128c7e;
  --bs-btn-hover-bg: #128c7e; --bs-btn-hover-border-color: #128c7e;
  --bs-btn-active-bg: #075e54; --bs-btn-active-border-color: #075e54;
}
.btn-success { --bs-btn-bg: #1faa59; --bs-btn-border-color: #1faa59; --bs-btn-hover-bg: #17914b; --bs-btn-hover-border-color: #17914b; }
.btn-outline-success { --bs-btn-color: #128c7e; --bs-btn-border-color: rgba(18,140,126,.35); --bs-btn-hover-bg: #128c7e; --bs-btn-hover-border-color: #128c7e; --bs-btn-active-bg: #128c7e; --bs-btn-active-border-color: #128c7e; }
[data-bs-theme="dark"] .btn-outline-success { --bs-btn-color: #3ddc97; }
.btn-light { --bs-btn-bg: var(--muted-bg); --bs-btn-border-color: transparent; --bs-btn-hover-bg: rgba(18,140,126,.12); --bs-btn-hover-border-color: transparent; --bs-btn-color: var(--bs-body-color); }
.btn-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--muted-bg); border: 0; font-size: 1.15rem; color: var(--bs-body-color); }
.btn-icon:hover { background: rgba(18,140,126,.12); }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: #25d366; box-shadow: 0 0 0 .2rem rgba(37, 211, 102, .18); }
.form-check-input:checked { background-color: #128c7e; border-color: #128c7e; }
.form-label { font-weight: 600; font-size: .85rem; margin-bottom: .35rem; }
.page-link { color: #128c7e; }
.active > .page-link, .page-link.active { background: #128c7e; border-color: #128c7e; }

/* ============ Shell ============ */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: linear-gradient(180deg, #06372f 0%, #075e54 55%, #0a6d60 100%);
  color: #d7efe8; display: flex; flex-direction: column;
}
@media (min-width: 992px) {
  .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
}
@media (max-width: 991.98px) {
  .sidebar.offcanvas-lg { --bs-offcanvas-width: 280px; background: linear-gradient(180deg, #06372f 0%, #075e54 100%); }
}
.sidebar-brand { display: flex; align-items: flex-start; gap: .75rem; padding: 1.25rem 1.25rem 1rem; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 12px; display: inline-grid; place-items: center;
  background: var(--brand-grad); color: #fff; font-size: 1.35rem; box-shadow: 0 6px 18px rgba(37,211,102,.35); flex-shrink: 0;
}
.brand-logo.lg { width: 64px; height: 64px; font-size: 2rem; border-radius: 18px; }
.brand-text { min-width: 0; flex: 1; }
.brand-text strong { display: block; color: #fff; font-size: .92rem; line-height: 1.25; white-space: normal; }
.brand-text small { display: block; color: #b7e6da; font-size: .72rem; line-height: 1.35; margin-top: .2rem; }
.hero-kicker { font-weight: 800; font-size: 1.15rem; line-height: 1.35; }
.sidebar-nav { padding: .5rem .75rem; flex-grow: 1; }
.nav-label { text-transform: uppercase; font-size: .68rem; letter-spacing: .08em; color: #7fc2b1; padding: 1rem .75rem .4rem; font-weight: 700; }
.sidebar-nav a {
  display: flex; align-items: center; gap: .75rem; padding: .62rem .85rem; border-radius: 12px;
  color: #cde9e1; font-weight: 500; margin-bottom: 2px; transition: background .15s, color .15s;
}
.sidebar-nav a i { font-size: 1.1rem; width: 1.25rem; text-align: center; }
.sidebar-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav a.active { background: rgba(255,255,255,.95); color: #075e54; font-weight: 700; box-shadow: 0 6px 16px rgba(0,0,0,.15); }
.sidebar-foot { padding: 1rem 1.25rem; font-size: .75rem; color: #8fc9b9; }
.killswitch { background: rgba(255, 193, 7, .2); color: #ffd666; padding: .45rem .7rem; border-radius: 10px; margin-bottom: .6rem; font-weight: 600; }

.main { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem;
  padding: .85rem 1.5rem; background: color-mix(in srgb, var(--app-bg) 85%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--card-border);
}
.page-title { flex: 1 1 auto; min-width: 0; font-size: 1.3rem; font-weight: 800; margin: 0; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; flex: 0 0 auto; }
.user-chip { display: flex; align-items: center; gap: .55rem; background: var(--muted-bg); border-radius: 14px; padding: .3rem .6rem .3rem .3rem; border: 0; }
.content { padding: 1.5rem; flex-grow: 1; }
@media (max-width: 575.98px) {
  .content { padding: 1rem; }
  .topbar { padding: .7rem 1rem; }
  .page-title { font-size: 1.1rem; }
}

.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; flex-shrink: 0;
  background: var(--brand-grad); color: #fff; font-weight: 700; font-size: .9rem;
}
.avatar.sm { width: 32px; height: 32px; font-size: .8rem; }
.avatar.xl { width: 84px; height: 84px; font-size: 2rem; }

/* ============ Cards ============ */
.card-soft { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-soft > .card-header { background: transparent; border-bottom: 1px solid var(--card-border); font-weight: 700; padding: .9rem 1.25rem; }
.card-soft .table { --bs-table-bg: transparent; margin: 0; }
.table > thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--bs-secondary-color); font-weight: 700; border-bottom-width: 1px; white-space: nowrap; }
.table > :not(caption) > * > * { padding: .75rem 1rem; }
.table-sm > :not(caption) > * > * { padding: .5rem .75rem; }
.row-link { cursor: pointer; }
.table tr.row-link:hover > * { background: rgba(37, 211, 102, .08); }

.welcome-banner {
  background: var(--brand-grad); color: #fff; border-radius: 20px; padding: 1.5rem 1.75rem;
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between;
  position: relative; overflow: hidden; box-shadow: 0 10px 30px rgba(18,140,126,.25);
}
.welcome-banner::after { content: "\F618"; font-family: "bootstrap-icons"; position: absolute; right: -10px; bottom: -40px; font-size: 10rem; opacity: .12; pointer-events: none; }
.welcome-banner h2 { font-weight: 800; font-size: 1.5rem; margin-bottom: .25rem; }
.welcome-banner .btn-light { --bs-btn-bg: #fff; --bs-btn-color: #075e54; }
.welcome-banner .btn-outline-light { border-color: rgba(255,255,255,.6); }

.stat-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.2rem; display: flex; align-items: center; gap: 1rem; height: 100%; transition: transform .15s; }
.stat-card:hover { transform: translateY(-2px); }
.stat-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 1.35rem; flex-shrink: 0; }
.stat-label { color: var(--bs-secondary-color); font-size: .8rem; font-weight: 600; }
.stat-value { font-size: 1.6rem; font-weight: 800; line-height: 1.15; }
@media (max-width: 575.98px) {
  .stat-card { gap: .75rem; padding: .9rem 1rem; }
  .stat-value { font-size: 1.35rem; }
  .stat-icon { width: 42px; height: 42px; font-size: 1.15rem; }
}
.mini-stat { background: var(--muted-bg); border-radius: 14px; padding: .8rem; }
.mini-stat > div { font-size: 1.5rem; font-weight: 800; }
.mini-stat small { color: var(--bs-secondary-color); font-weight: 600; }
.badge-stat { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 999px; padding: .35rem .85rem; font-size: .82rem; }

/* Bar chart */
.bar-chart { display: flex; align-items: flex-end; gap: .75rem; height: 230px; padding-top: .5rem; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bar-stack { flex: 1; width: 100%; max-width: 46px; display: flex; flex-direction: column-reverse; background: var(--muted-bg); border-radius: 10px; overflow: hidden; }
.bar { width: 100%; transition: height .6s ease; }
.bar-sent { background: var(--brand-grad); }
.bar-failed { background: #ef5b6a; }
.bar-num { font-size: .75rem; font-weight: 700; margin-top: .35rem; }
.bar-label { font-size: .72rem; color: var(--bs-secondary-color); }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; }
.progress-lg { height: 22px; border-radius: 999px; font-weight: 700; }

/* Type chips */
.type-chip { display: inline-flex; align-items: center; gap: .3rem; font-size: .76rem; font-weight: 600; padding: .2rem .6rem; border-radius: 999px; background: var(--muted-bg); white-space: nowrap; }
.type-text { color: #0d6efd; } .type-template { color: #128c7e; } .type-image { color: #d63384; }
.type-video { color: #6f42c1; } .type-audio { color: #fd7e14; } .type-document { color: #b02a37; }
.type-bar-text { background: #0d6efd; } .type-bar-template { background: #128c7e; } .type-bar-image { background: #d63384; }
.type-bar-video { background: #6f42c1; } .type-bar-audio { background: #fd7e14; } .type-bar-document { background: #b02a37; }
.role-admin { background: #ffe8cc; color: #a14d00; } .role-operator { background: #d1f2e8; color: #075e54; } .role-viewer { background: #e2e8f0; color: #334155; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .4rem; flex-shrink: 0; }
.group-pill { display: inline-flex; align-items: center; font-size: .74rem; padding: .15rem .55rem; border-radius: 999px; background: var(--muted-bg); color: var(--bs-body-color); margin: 0 .25rem .25rem 0; }

/* Toolbars */
.toolbar { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: space-between; align-items: center; }
.toolbar-filters { display: flex; flex-wrap: wrap; gap: .5rem; flex: 1 1 520px; }
.toolbar-filters .input-group { flex: 1 1 220px; }
.toolbar-filters .form-select { flex: 0 1 170px; }
.bulk-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.bulk-bar .form-select { width: auto; }
.pill-tabs .nav-link { border-radius: 999px; font-weight: 600; color: var(--bs-body-color); padding: .45rem 1rem; }
.pill-tabs .nav-link.active { background: #128c7e; color: #fff; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--bs-secondary-color); }
.empty-state > i { font-size: 3rem; color: #25d366; opacity: .7; display: block; margin-bottom: .5rem; }
.empty-state h4, .empty-state h5 { color: var(--bs-body-color); font-weight: 700; }

/* Groups */
.group-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem; border-top: 4px solid var(--gc); height: 100%; }
.group-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--gc) 15%, transparent); color: var(--gc); font-size: 1.2rem; flex-shrink: 0; }

/* Templates */
.tpl-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem; display: flex; flex-direction: column; }
.wa-bubble { background: var(--wa-bubble); border-radius: 4px 12px 12px 12px; padding: .6rem .8rem; max-height: 180px; overflow: auto; word-break: break-word; }
.wa-tpl-preview { background: var(--muted-bg); border-left: 3px solid #25d366; border-radius: 8px; padding: .6rem .8rem; white-space: pre-wrap; }

/* Compose */
.step-num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--brand-grad); color: #fff; font-size: .78rem; margin-right: .55rem; }
.mode-pills { display: flex; flex-wrap: wrap; gap: .5rem; }
.mode-pills .btn { border-radius: 999px; font-size: .85rem; }
.type-tabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: .6rem; }
.type-tab {
  display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: .85rem .5rem; border-radius: 14px; cursor: pointer;
  border: 2px solid var(--card-border); background: var(--muted-bg); font-weight: 600; font-size: .82rem; text-align: center; transition: all .15s;
}
.type-tab i { font-size: 1.4rem; color: #128c7e; }
.type-tab:hover { border-color: rgba(37,211,102,.5); }
.btn-check:checked + .type-tab { border-color: #25d366; background: rgba(37, 211, 102, .1); box-shadow: 0 4px 14px rgba(37,211,102,.18); }
.type-toggle-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.type-toggle-grid .btn { border-radius: 999px; font-size: .84rem; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; padding: 1.75rem 1rem; width: 100%;
  border: 2px dashed rgba(18,140,126,.35); border-radius: 14px; background: rgba(37, 211, 102, .04); cursor: pointer; text-align: center; transition: all .15s;
}
.dropzone i { font-size: 2rem; color: #25d366; }
.dropzone.drag, .dropzone:hover { background: rgba(37, 211, 102, .1); border-color: #25d366; }
.fmt-bar { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; }
.fmt-bar .btn { font-size: .78rem; padding: .2rem .5rem; font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; background: rgba(37,211,102,.12); color: #075e54; border-radius: 999px; padding: .25rem .4rem .25rem .75rem; font-size: .82rem; font-weight: 600; }
[data-bs-theme="dark"] .chip { color: #9ff0c9; }
.chip button { border: 0; background: rgba(0,0,0,.08); border-radius: 50%; width: 20px; height: 20px; line-height: 1; color: inherit; }
.search-results { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; max-height: 280px; overflow: auto; }
.search-results:empty { display: none; }
.group-pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .5rem; }
.group-pick { display: flex; align-items: center; gap: .3rem; padding: .65rem .8rem; border-radius: 12px; border: 2px solid var(--card-border); background: var(--muted-bg); cursor: pointer; font-weight: 600; min-width: 0; }
.btn-check:checked + .group-pick { border-color: #25d366; background: rgba(37,211,102,.1); }
.recipient-summary { background: var(--muted-bg); border-radius: 12px; padding: .6rem .9rem; }
.role-help { background: var(--muted-bg); border-radius: 12px; padding: .75rem 1rem; display: grid; gap: .25rem; }
.killswitch-row { background: var(--muted-bg); }

/* Phone preview */
.phone-preview { border-radius: 28px; overflow: hidden; border: 8px solid #1d2b27; box-shadow: var(--shadow); background: var(--chat-bg); }
.phone-head { background: #075e54; color: #fff; display: flex; align-items: center; gap: .6rem; padding: .7rem .9rem; }
.phone-head small { display: block; font-size: .7rem; opacity: .8; }
.phone-body {
  min-height: 340px; padding: 1rem; display: flex; flex-direction: column; justify-content: flex-end;
  background-color: var(--chat-bg);
  background-image: radial-gradient(rgba(0,0,0,.05) 1px, transparent 1px); background-size: 18px 18px;
}
.wa-msg { align-self: flex-end; max-width: 88%; background: var(--wa-bubble); border-radius: 12px 4px 12px 12px; padding: .45rem .6rem 1.2rem; position: relative; box-shadow: 0 1px 1px rgba(0,0,0,.1); font-size: .88rem; word-break: break-word; white-space: pre-wrap; min-width: 120px; }
.wa-time { position: absolute; right: .55rem; bottom: .25rem; font-size: .66rem; color: rgba(0,0,0,.45); }
[data-bs-theme="dark"] .wa-time { color: rgba(255,255,255,.55); }
.wa-time i { color: #53bdeb; }
.wa-media { margin: -.2rem -.3rem .4rem; border-radius: 8px; overflow: hidden; background: rgba(0,0,0,.06); }
.wa-media img, .wa-media video { width: 100%; display: block; max-height: 220px; object-fit: cover; }
.wa-media .wa-file { display: flex; align-items: center; gap: .6rem; padding: .7rem; font-weight: 600; }
.wa-media .wa-file i { font-size: 1.6rem; }
.wa-media audio { width: 100%; }

/* Media library */
.media-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); height: 100%; }
.media-thumb { aspect-ratio: 4/3; background: var(--muted-bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem; overflow: hidden; }
.media-thumb img, .media-thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-thumb > i { font-size: 2.4rem; color: #128c7e; }
.media-thumb audio, .media-detail-preview audio, .wa-media audio { width: 100%; max-width: 100%; min-width: 0; height: 36px; }
.tpl-media { width: 100%; height: 140px; object-fit: cover; border-radius: 10px; margin-bottom: .75rem; display: block; }
.media-detail { display: grid; grid-template-columns: 148px 1fr; gap: .85rem; align-items: center; border: 1px solid var(--card-border); border-radius: 12px; padding: .75rem; background: var(--muted-bg); }
.media-detail-preview { height: 112px; border-radius: 8px; overflow: hidden; background: var(--card-bg); display: flex; align-items: center; justify-content: center; }
.media-detail-preview img, .media-detail-preview video { width: 100%; height: 100%; object-fit: cover; }
.media-detail-preview i { font-size: 2rem; color: #128c7e; }
.media-detail-preview audio { width: 92%; }
.media-detail dl { display: grid; grid-template-columns: 92px 1fr; gap: .15rem .5rem; margin: 0; font-size: .82rem; }
.media-detail dt { color: var(--bs-secondary-color); font-weight: 500; }
.media-detail dd { margin: 0; word-break: break-word; }
@media (max-width: 576px) { .media-detail { grid-template-columns: 1fr; } }

.campaign-mini { display: block; padding: .75rem; border-radius: 12px; background: var(--muted-bg); color: inherit; margin-bottom: .6rem; }
.campaign-mini:hover { background: rgba(37,211,102,.1); }
.api-pre { background: var(--muted-bg); padding: .6rem; border-radius: 8px; max-height: 220px; overflow: auto; font-size: .75rem; white-space: pre-wrap; word-break: break-all; }
.section-title { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: #128c7e; margin-bottom: .75rem; }
.security-list li { padding: .15rem 0; }
.security-list i { color: #1faa59; margin-right: .35rem; }
.audit-list .list-group-item { background: transparent; }

/* ============ Auth ============ */
.auth-body { background: var(--app-bg); min-height: 100vh; }
.auth-wrap { min-height: 100vh; display: flex; }
.auth-hero {
  flex: 1; background: var(--brand-grad); color: #fff; align-items: center; justify-content: center; padding: 3rem; position: relative; overflow: hidden;
}
.auth-hero::after { content: "\F618"; font-family: "bootstrap-icons"; position: absolute; right: -60px; bottom: -80px; font-size: 26rem; opacity: .08; }
.auth-hero > div { max-width: 440px; position: relative; z-index: 1; }
.auth-hero h2 { font-weight: 800; font-size: 2.2rem; line-height: 1.2; }
.auth-hero p { opacity: .9; font-size: 1.05rem; }
.auth-hero .brand-logo { background: rgba(255,255,255,.2); box-shadow: none; }
.hero-points { list-style: none; padding: 0; margin-top: 1.5rem; }
.hero-points li { padding: .35rem 0; font-weight: 600; }
.hero-points i { margin-right: .5rem; }
.auth-card { width: 100%; max-width: 480px; margin: auto; padding: 2.5rem 2rem; }
@media (min-width: 992px) { .auth-card { flex: 0 0 480px; padding: 3rem; } }
.pw-toggle { position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); z-index: 5; color: var(--bs-secondary-color); }

/* Choice rows that must wrap (media source, campaign filters) */
.choice-pills { display: flex; flex-wrap: wrap; gap: .4rem; }
.choice-pills > .btn { border-radius: 999px; }
.action-btns { display: inline-flex; flex-wrap: wrap; gap: .25rem; justify-content: flex-end; }
.group-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.group-actions .btn { flex: 1 1 8rem; }

/* Utilities */
.text-bg-success-subtle { background: rgba(37,211,102,.15) !important; }
code, .font-monospace { overflow-wrap: anywhere; }
input[type="date"], input[type="datetime-local"], input[type="time"], input[type="month"], input[type="file"] { min-width: 0; max-width: 100%; }
.form-control-color.w-100 { height: 2.75rem; padding: .3rem; }
.alert { overflow-wrap: anywhere; }
.card-header.d-flex { flex-wrap: wrap; align-items: center; gap: .5rem; }

@media (max-width: 991.98px) {
  .phone-preview { border-width: 6px; border-radius: 22px; max-width: 420px; margin-inline: auto; }
  .phone-body { min-height: 220px; }
  .send-dock {
    position: sticky; bottom: 0; z-index: 20;
    margin-top: .75rem; padding: .75rem 0 calc(.75rem + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--app-bg) 92%, transparent);
    backdrop-filter: blur(8px);
  }
}
@media (min-width: 992px) {
  .phone-preview { max-width: none; margin-inline: 0; }
}

@media (max-width: 767.98px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-filters { flex: 1 1 100%; }
  .toolbar-filters .input-group,
  .toolbar-filters .form-select { flex: 1 1 100%; width: 100%; max-width: 100%; }
  .toolbar-filters > .btn { width: auto; align-self: flex-start; }
  .toolbar-actions { display: grid !important; grid-template-columns: 1fr 1fr; width: 100%; }
  .toolbar-actions .btn,
  .toolbar-actions form .btn { width: 100%; }
  .toolbar-actions form { margin: 0; }
  .bulk-bar { align-items: stretch; }
  .bulk-bar .form-select,
  .bulk-bar .btn { width: 100%; }
  .bulk-bar .ms-auto { margin-left: 0 !important; }
  .pill-tabs { flex-wrap: wrap; gap: .35rem; }
  .page-toolbar { flex-direction: column; align-items: stretch !important; }
  .page-toolbar .ms-auto,
  .page-toolbar .page-toolbar-actions { margin-left: 0 !important; width: 100%; }
  .page-toolbar-actions .btn,
  .page-toolbar-actions form,
  .page-toolbar-actions form .btn { width: 100%; }
  dl.row > dd { overflow-wrap: anywhere; }
}

@media (max-width: 575.98px) {
  .card-soft > .card-header { padding: .8rem 1rem; }
  .table > :not(caption) > * > * { padding: .6rem .6rem; }
  .welcome-banner { padding: 1.15rem; }
  .welcome-banner h2 { font-size: 1.2rem; }
  .welcome-banner .d-flex { width: 100%; }
  .welcome-banner .btn { flex: 1 1 auto; }
  .bar-chart { gap: .3rem; height: 180px; }
  .bar-stack { max-width: none; }
  .content { padding: .85rem .75rem 1.5rem; }
  .topbar { gap: .4rem; padding: .65rem .75rem; }
  .user-chip { padding-right: .3rem; gap: .15rem; }
  .user-chip .bi-chevron-down { display: none; }
  .btn-icon { width: 36px; height: 36px; }
  .auth-card { padding: 1.35rem 1rem 2rem; }
  .card-body > .fs-5 { font-size: 1.05rem !important; }
  .mini-stat > div { font-size: 1.25rem; }
  .killswitch-row.form-switch { padding-left: .75rem; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem; }
  .killswitch-row.form-switch .form-check-input { position: static; float: none; margin: 0; }
  .killswitch-row.form-switch .small { flex-basis: 100%; }

  .table-responsive:has(table.stack-table) { overflow: visible; }
  table.stack-table, table.stack-table tbody, table.stack-table tr { display: block; width: 100%; }
  table.stack-table thead { display: none; }
  table.stack-table tr { border-bottom: 1px solid var(--card-border); padding: .35rem 0 .75rem; }
  table.stack-table tr:last-child { border-bottom: 0; }
  table.stack-table td[data-label] {
    display: block; border: 0; width: auto !important; max-width: none !important;
    padding: .4rem .9rem; text-align: left !important; white-space: normal !important;
  }
  table.stack-table td[data-label]::before {
    content: attr(data-label); display: block; margin-bottom: .12rem;
    font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    color: var(--bs-secondary-color);
  }
  table.stack-table td[data-label=""]::before { content: none; display: none; }
  table.stack-table td[colspan] { display: block; border: 0; white-space: normal !important; }
  table.stack-table td.stack-actions .action-btns { width: 100%; justify-content: flex-start; }
  table.stack-table .progress { min-width: 0; }
}
