/* ===== Mint SMS palette ===== */
:root {
  --p1: #B0EFD4;
  --p2: #71E4A9;
  --p3: #4DCC87;
  --p4: #45B08C;
  --white: #FFFFFF;
  --light-grey: #EBEFF0;
  --blue-grey: #CCDADD;
  --soft-green: #C3E8BA;
  --aqua: #81DBD1;
  --teal: #00A4AB;
  --dark-teal: #00565F;
  --black: #000000;

  --ink: #0E2A2D;
  --ink-soft: #4A6468;
  --border: #DDE6E8;
  --shadow: 0 1px 3px rgba(0, 86, 95, 0.07), 0 6px 18px rgba(0, 86, 95, 0.06);
  --radius: 14px;
  --sidebar-w: 232px;
  --sidebar-collapsed-w: 76px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--light-grey);
  display: flex;
  overflow: hidden;
}

button { font: inherit; cursor: pointer; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 650; }
.hidden, [hidden] { display: none !important; }

.login-screen {
  min-height: 100vh;
  width: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 0%, rgba(255,255,255,.45), transparent 34%),
    linear-gradient(135deg, var(--p3), var(--p4) 48%, var(--dark-teal));
}

.login-card {
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  border: 1px solid rgba(255,255,255,.46);
  border-radius: 16px;
  padding: 22px;
  background: var(--white);
  box-shadow: 0 28px 80px rgba(0, 49, 54, .22);
}

.login-card .brand {
  justify-content: center;
  padding: 0 0 8px;
  text-align: center;
}
.login-card .brand-icon {
  background: linear-gradient(135deg, var(--dark-teal), var(--p4));
  box-shadow: 0 6px 16px rgba(0, 86, 95, .16);
}
.login-card .brand-name { color: var(--ink); }
.login-card .brand-name strong { color: var(--p4); font-weight: 650; }
.login-card .brand-sub { color: var(--teal); opacity: 1; }
.login-hint { color: var(--ink-soft); font-size: 12px; }
.totp-card { width: min(520px, 100%); }
.totp-qr-wrap {
  display: grid;
  place-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #F7FAFA;
}
.totp-qr {
  width: 220px;
  height: 220px;
  display: block;
  border-radius: 8px;
  background: var(--white);
}
.totp-qr[src=""] { display: none; }
.totp-secret {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .08em;
}
.totp-uri {
  min-height: 82px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.totp-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.shell { display: contents; }
.signout { width: 100%; justify-content: center; margin-top: 10px; }
.form-error { min-height: 18px; color: #c0392b; font-size: 12.5px; }
.form-hint { margin: 0; color: #7f1d1d; font-size: 12px; font-weight: 650; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--dark-teal) 0%, #00444C 100%);
  color: var(--white);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  height: 100vh;
  transition: width .18s ease, padding .18s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 22px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--p2), var(--p4));
  color: var(--dark-teal);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.brand-icon img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  display: block;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-size: 17px; font-weight: 400; letter-spacing: .2px; }
.brand-name strong { font-weight: 750; color: var(--p1); }
.brand-sub { font-size: 11px; color: var(--aqua); opacity: .85; }
.sidebar-toggle {
  margin-left: auto;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, .82);
  background: rgba(255, 255, 255, .1);
}
.sidebar-toggle:hover { color: var(--white); background: rgba(255, 255, 255, .16); }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  transition: background .15s, color .15s;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { background: rgba(255, 255, 255, 0.08); color: var(--white); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(113, 228, 169, .22), rgba(113, 228, 169, .08));
  color: var(--p1);
  box-shadow: inset 3px 0 0 var(--p2);
}

.nav-badge {
  margin-left: auto;
  background: var(--p2);
  color: var(--dark-teal);
  font-size: 11px;
  font-weight: 700;
  border-radius: 99px;
  padding: 1px 7px;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 8px 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-user { display: flex; flex-direction: column; line-height: 1.25; }
.sidebar-user-name { font-size: 13px; font-weight: 600; }
.sidebar-user-role { font-size: 11px; color: var(--aqua); }

.shell.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-w);
  padding-inline: 12px;
}
.shell.sidebar-collapsed .brand {
  justify-content: center;
  padding-inline: 0;
}
.shell.sidebar-collapsed .brand-text,
.shell.sidebar-collapsed .nav-label,
.shell.sidebar-collapsed .sidebar-user,
.shell.sidebar-collapsed .signout-label {
  display: none;
}
.shell.sidebar-collapsed .sidebar-toggle {
  position: absolute;
  top: 64px;
  left: 47px;
  width: 24px;
  height: 24px;
}
.shell.sidebar-collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}
.shell.sidebar-collapsed .nav-item,
.shell.sidebar-collapsed .signout {
  justify-content: center;
  padding-inline: 0;
}
.shell.sidebar-collapsed .nav-item {
  width: 44px;
  height: 42px;
}
.shell.sidebar-collapsed .sidebar-footer {
  justify-content: center;
  padding-inline: 0;
}
.shell.sidebar-collapsed .signout {
  width: 44px;
  min-height: 40px;
  align-self: center;
}
.shell.sidebar-collapsed .signout::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-left-color: transparent;
  border-radius: 50%;
}

/* ===== Main / pages ===== */
.main {
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  padding: 26px 30px;
}

.page { display: none; flex-direction: column; height: 100%; }
.page.active { display: flex; }

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.page-sub { color: var(--ink-soft); font-size: 13px; margin-top: 3px; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.field-inline { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); font-weight: 500; }
.field-inline select { min-width: 180px; }

/* ===== Buttons / inputs ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: none;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  transition: filter .15s, background .15s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--p3), var(--p4));
  color: var(--white);
  box-shadow: 0 3px 10px rgba(77, 204, 135, 0.35);
}
.btn-primary:hover { filter: brightness(1.06); }

.btn-ghost {
  background: var(--white);
  color: var(--dark-teal);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--p1); border-color: var(--p2); }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }

.btn-icon {
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 6px;
  color: var(--ink-soft);
  display: inline-grid;
  place-items: center;
}
.btn-icon:hover { background: var(--light-grey); color: var(--dark-teal); }
.btn-icon.danger:hover { background: #FDE8E8; color: #C0392B; }

.input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  background: var(--white);
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--p3); box-shadow: 0 0 0 3px rgba(77, 204, 135, 0.18); }
select.input { cursor: pointer; }
textarea.input { resize: vertical; }

/* ===== Cards / tables ===== */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(204, 218, 221, 0.45);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--light-grey);
}

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--ink-soft);
  background: #F6F9FA;
  padding: 11px 20px;
  border-bottom: 1px solid var(--light-grey);
}
.table td {
  padding: 13px 20px;
  border-bottom: 1px solid var(--light-grey);
  font-size: 13.5px;
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #FAFCFC; }
.t-right { text-align: right; }
td.t-right { white-space: nowrap; }

.table-empty { padding: 28px; text-align: center; color: var(--ink-soft); }
.t-nowrap { white-space: nowrap; }

.cell-person { display: flex; align-items: center; gap: 11px; font-weight: 600; }
.cell-muted { color: var(--ink-soft); }

/* ===== Avatars / badges ===== */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--dark-teal);
  background: var(--p1);
  flex-shrink: 0;
}
.avatar.av-0 { background: var(--p1); }
.avatar.av-1 { background: var(--soft-green); }
.avatar.av-2 { background: var(--aqua); }
.avatar.av-3 { background: var(--blue-grey); }
.avatar-mint { background: linear-gradient(135deg, var(--p2), var(--aqua)); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 650;
  border-radius: 99px;
  padding: 3px 10px;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.badge-online { background: rgba(113, 228, 169, 0.25); color: #1E7A4C; }
.badge-online .dot { background: var(--p3); }
.badge-offline { background: #FDE8E8; color: #C0392B; }
.badge-offline .dot { background: #E05B4D; }
.badge-teal { background: rgba(0, 164, 171, 0.12); color: var(--dark-teal); }
.badge-grey { background: var(--light-grey); color: var(--ink-soft); }

.chip {
  display: inline-block;
  background: var(--p1);
  color: var(--dark-teal);
  border-radius: 99px;
  padding: 2px 9px;
  font-size: 11.5px;
  font-weight: 600;
  margin: 2px 4px 2px 0;
}

/* ===== Messaging ===== */
.messaging-grid {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 18px;
  flex: 1;
  min-height: 0;
}

.conv-panel { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }

.conv-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px;
  padding: 8px 12px;
  background: var(--light-grey);
  border-radius: 10px;
  color: var(--ink-soft);
}
.conv-search input { border: none; background: transparent; outline: none; font: inherit; width: 100%; color: var(--ink); }
.conv-search.standalone { margin: 0; background: var(--white); border: 1px solid var(--border); min-width: 220px; }
.conv-hidden-toggle { margin: 0 12px 10px; justify-content: center; }

.conv-list { flex: 1; overflow-y: auto; }

.conv-item {
  display: flex;
  gap: 11px;
  padding: 12px 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .12s;
}
.conv-item:hover { background: #F4FBF7; }
.conv-item.active { background: linear-gradient(90deg, rgba(176, 239, 212, 0.45), rgba(176, 239, 212, 0.12)); border-left-color: var(--p3); }
.conv-item.handled .conv-name { color: var(--dark-teal); }

.conv-body { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.conv-name { font-weight: 650; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.handled-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-right: 5px;
  border-radius: 999px;
  background: var(--p1);
  color: var(--dark-teal);
  font-size: 10.5px;
  font-weight: 650;
  vertical-align: -1px;
}
.conv-time { font-size: 11px; color: var(--ink-soft); flex-shrink: 0; }
.conv-preview {
  font-size: 12.5px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.conv-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}
.conv-device {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  max-width: min(100%, 132px);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--dark-teal);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--device-border, rgba(0, 164, 171, 0.28));
  border-radius: 99px;
  padding: 2px 8px 2px 6px;
  box-shadow: 0 1px 2px rgba(0, 86, 95, 0.08);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-device::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--device-color, var(--teal));
  box-shadow: 0 0 0 2px var(--device-bg, rgba(0, 164, 171, 0.12));
  flex: 0 0 auto;
}
.conv-unread {
  margin-left: auto;
  background: var(--p3);
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
  border-radius: 99px;
  min-width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  padding: 0 5px;
}

.conv-list-empty { padding: 30px 20px; text-align: center; color: var(--ink-soft); font-size: 13px; }

/* Thread */
.thread-panel { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }

.thread-empty[hidden], .thread[hidden] { display: none; }

.thread-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--blue-grey);
}
.thread-empty p { color: var(--ink-soft); }

.thread { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.thread-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--light-grey);
}
.btn-handled {
  min-width: 106px;
  justify-content: center;
  font-weight: 600;
}
.btn-handled.active {
  background: var(--p1);
  border-color: var(--p3);
  color: var(--dark-teal);
}
.handled-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px 8px 72px;
  border-bottom: 1px solid rgba(77, 204, 135, 0.28);
  background: rgba(176, 239, 212, 0.22);
  color: var(--dark-teal);
  font-size: 12.5px;
  font-weight: 500;
}
.handled-status strong { font-weight: 650; }
.handled-status-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--p3);
  color: var(--white);
  font-size: 11px;
  font-weight: 650;
  flex: 0 0 auto;
}
.thread-headings { display: flex; flex-direction: column; line-height: 1.3; }
.thread-title { font-weight: 650; font-size: 14.5px; }
.thread-sub { font-size: 12px; color: var(--ink-soft); }
.wa-window {
  margin-left: auto;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  white-space: nowrap;
}
.wa-window.open {
  color: #064e3b;
  background: #d1fae5;
  border: 1px solid #86efac;
}
.wa-window.expired {
  color: #7f1d1d;
  background: #fee2e2;
  border: 1px solid #fca5a5;
}

.thread-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background:
    radial-gradient(circle at 85% 10%, rgba(176, 239, 212, 0.18), transparent 45%),
    #FBFDFD;
}

.bubble-row { display: flex; }
.bubble-row.out { justify-content: flex-end; }

.bubble {
  max-width: 64%;
  padding: 9px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.45;
  box-shadow: 0 1px 2px rgba(0, 86, 95, 0.08);
}
.bubble-row.in .bubble {
  background: var(--white);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
}
.bubble-row.out .bubble {
  background: linear-gradient(135deg, var(--p3), var(--p4));
  color: var(--white);
  border-bottom-right-radius: 5px;
}
.bubble-row.out.failed .bubble {
  background: #fee2e2;
  color: #7f1d1d;
  border: 1px solid #fca5a5;
}
.bubble-row.failed .message-status {
  color: #a33232;
  font-weight: 650;
  opacity: 1;
}
.bubble-header {
  display: block;
  margin-bottom: 3px;
  font-weight: 650;
  white-space: pre-wrap;
}
.bubble-text {
  white-space: pre-wrap;
}
.bubble-time { display: block; font-size: 10.5px; margin-top: 4px; opacity: .78; }
.sensitive-marker {
  display: inline-flex;
  align-items: center;
  border-radius: 99px;
  padding: 1px 6px;
  color: var(--dark-teal);
  background: rgba(255, 255, 255, 0.86);
  font-weight: 700;
}

.composer {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--light-grey);
  background: var(--white);
}
.composer-controls {
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(140px, 200px) minmax(150px, 220px) auto 1fr;
  align-items: center;
  gap: 10px;
}
.composer-device,
.composer-template,
.composer-reference {
  width: 100%;
  border-radius: 99px;
  min-height: 42px;
  padding-right: 34px;
}
.composer-message-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}
.composer textarea {
  width: 100%;
  min-height: 42px;
  max-height: 136px;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 10px 18px;
  font: inherit;
  line-height: 1.45;
  outline: none;
  resize: none;
  overflow-y: auto;
}
.composer textarea:focus { border-color: var(--p3); box-shadow: 0 0 0 3px rgba(77, 204, 135, 0.18); }
textarea.template-locked,
.input.template-locked {
  color: var(--ink-soft);
  background: #eef4f4;
  border-color: #cfdede;
  cursor: default;
}
textarea.template-locked::placeholder,
.input.template-locked::placeholder {
  color: #8aa0a3;
}
textarea.template-locked:focus,
.input.template-locked:focus {
  border-color: var(--border);
  box-shadow: none;
}
.btn-send { border-radius: 50%; width: 42px; height: 42px; padding: 0; justify-content: center; }
.btn-private { border-radius: 99px; white-space: nowrap; }
.char-count {
  justify-self: end;
  padding-right: 2px;
}
.private-fields { display: grid; gap: 8px; }
.private-fields:empty { display: none; }
.private-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px dashed rgba(0, 86, 95, .28);
  border-radius: 10px;
  padding: 10px;
  background: #fbfdfd;
}
.private-add { align-self: flex-start; }
.template-fields {
  display: grid;
  gap: 8px;
}
.template-fields:empty { display: none; }
.template-fields-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--dark-teal);
}
.template-fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}
.template-value-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 650;
  color: var(--ink-soft);
}
.template-field-editor {
  display: grid;
  gap: 8px;
}
.template-field-row {
  display: grid;
  grid-template-columns: auto minmax(170px, 1fr) 112px minmax(170px, 220px) auto auto;
  align-items: center;
  gap: 8px;
}
.template-button-field-row {
  grid-template-columns: auto minmax(170px, 1fr) 112px minmax(170px, 220px) auto;
}
.template-param-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border: 1px solid rgba(0, 86, 95, 0.16);
  border-radius: 999px;
  padding: 2px 9px;
  color: var(--dark-teal);
  background: rgba(77, 204, 135, 0.14);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}
.template-param-label[hidden] { display: none; }
.template-field-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.sync-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 99px;
  padding: 3px 10px;
  color: var(--dark-teal);
  background: rgba(0, 164, 171, .12);
  font-size: 11.5px;
  font-weight: 650;
}
.conv-item {
  width: 100%;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  background: transparent;
  text-align: left;
}
.conv-number {
  color: var(--ink-soft);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bubble-time .conv-device { margin-right: 5px; }
.thread-header .btn-sm { margin-left: 0; }
.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 600;
}
.check-row input { accent-color: var(--p3); }
.field input[type="color"] { min-height: 42px; padding: 4px; }
.provider-fields {
  display: contents;
}
.provider-fields[hidden] {
  display: none;
}

/* ===== Contacts ===== */
#page-contacts .card,
#page-templates .card { overflow: hidden; overflow-x: auto; }

/* ===== LTE Status ===== */
.lte-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 18px;
  align-content: start;
}

.lte-card { padding: 20px; }
.lte-card.offline { opacity: .75; }

.lte-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.lte-name { font-size: 15px; font-weight: 700; }
.lte-number { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }

.signal-bars { display: flex; align-items: flex-end; gap: 3px; height: 22px; margin: 14px 0 4px; }
.signal-bars span { width: 7px; border-radius: 3px; background: var(--blue-grey); }
.signal-bars span:nth-child(1) { height: 20%; }
.signal-bars span:nth-child(2) { height: 40%; }
.signal-bars span:nth-child(3) { height: 60%; }
.signal-bars span:nth-child(4) { height: 80%; }
.signal-bars span:nth-child(5) { height: 100%; }
.signal-bars span.on { background: linear-gradient(180deg, var(--p2), var(--p4)); }
.signal-label { font-size: 12px; color: var(--ink-soft); margin-bottom: 12px; min-height: 16px; }

.lte-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  border-top: 1px solid var(--light-grey);
  padding-top: 13px;
}
.lte-stat { display: flex; justify-content: space-between; font-size: 12.5px; gap: 8px; }
.lte-stat .k { color: var(--ink-soft); }
.lte-stat .v { font-weight: 600; text-align: right; overflow-wrap: anywhere; }

.lte-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--light-grey);
  font-size: 12px;
  color: var(--ink-soft);
}
.lte-foot strong { color: var(--dark-teal); }

/* ===== Admin ===== */
.admin-stack { display: flex; flex-direction: column; gap: 20px; padding-bottom: 20px; }
.admin-stack .card { overflow: hidden; overflow-x: auto; }
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  padding: 16px 20px 8px;
}
.health-tile {
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 104px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #F7FAFA;
}
.health-tile strong {
  color: var(--dark-teal);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.health-label {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 650;
}
.health-device-list { padding: 8px 20px 20px; overflow-x: auto; }
.health-alerts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.admin-keywords-body {
  display: grid;
  gap: 10px;
  padding: 16px 20px 20px;
}

/* ===== Modals ===== */
.modal-overlay[hidden] { display: none; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 60, 67, 0.45);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 20px;
}

.modal {
  background: var(--white);
  border-radius: 16px;
  width: 100%;
  max-width: min(760px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  box-shadow: 0 20px 60px rgba(0, 50, 56, 0.3);
  animation: pop .18s ease-out;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@keyframes pop {
  from { transform: translateY(10px) scale(.98); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 0;
}
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  border: none;
  background: var(--light-grey);
  border-radius: 8px;
  width: 28px;
  height: 28px;
  font-size: 17px;
  line-height: 1;
  color: var(--ink-soft);
}
.modal-close:hover { background: var(--blue-grey); }

.modal form {
  padding: 16px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }

.char-count { font-size: 11.5px; color: var(--ink-soft); text-align: right; }

.check-list {
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 150px;
  overflow-y: auto;
}
.check-list label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--light-grey);
  cursor: pointer;
  font-size: 13px;
}
.check-list label:last-child { border-bottom: none; }
.check-list label:hover { background: #F4FBF7; }
.check-list input { accent-color: var(--p3); width: 15px; height: 15px; }
.check-list .cl-sub { margin-left: auto; font-size: 11.5px; color: var(--ink-soft); }

.modal-actions {
  position: sticky;
  bottom: -22px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 4px -22px -22px;
  padding: 12px 22px 22px;
  background: linear-gradient(180deg, rgba(255,255,255,0.92), var(--white) 42%);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--dark-teal);
  color: var(--white);
  padding: 11px 22px;
  border-radius: 99px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 50, 56, 0.35);
  z-index: 100;
  animation: pop .2s ease-out;
}
.toast.success { background: var(--p4); }

/* ===== Scrollbars ===== */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--blue-grey); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--p4); border: 2px solid transparent; background-clip: content-box; }

/* ===== Responsive ===== */
@media (max-width: 1000px) {
  .messaging-grid {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(240px, 38vh) minmax(420px, 1fr);
  }
}

@media (max-width: 760px) {
  .composer-controls {
    grid-template-columns: 1fr 1fr;
  }

  .composer-controls .btn-private,
  .composer-controls .char-count {
    grid-column: 1 / -1;
  }

  .template-field-row {
    grid-template-columns: 1fr;
  }
}
