:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #202c32;
  background: #f5f7f7;
  font-size: 14px;
  --accent: #087f71;
  --line: #dde4e5;
  --muted: #64737a;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
textarea,
select {
  font: inherit;
}
button {
  border: 1px solid #cad5d7;
  background: white;
  color: #263b42;
  padding: 10px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
button:hover {
  background: #eff5f4;
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
button.primary:hover {
  background: #076b60;
}
button.danger {
  color: #b23b3b;
  border-color: #e7caca;
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid #65bfb2;
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1 {
  font-size: 28px;
  line-height: 1.2;
  margin-bottom: 10px;
  font-weight: 650;
}
h2 {
  font-size: 21px;
  margin-bottom: 0;
}
h3 {
  font-size: 16px;
  margin-bottom: 12px;
}
a {
  color: var(--accent);
}
small,
.muted {
  color: var(--muted);
}
.eyebrow {
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
}
.shell {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  padding: 28px 18px;
  background: white;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 30px;
}
.brand {
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 21px;
  font-weight: 700;
}
.brand small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  margin-top: 4px;
}
.brand-mark {
  background: #e1f2ec;
  color: #087462;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
}
.department-label {
  font-size: 12px;
  color: var(--muted);
}
nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.nav-item {
  text-align: left;
  border: 0;
  background: transparent;
  font-weight: 550;
  padding: 12px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-item span {
  font-size: 19px;
  width: 20px;
  text-align: center;
}
.nav-item.active {
  background: #e6f3ef;
  color: #076b60;
}
.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12px;
}
.text-button {
  border: 0;
  background: none;
  padding: 5px 0;
  text-align: left;
  color: var(--accent);
}
.main {
  padding: 36px 38px;
  min-width: 0;
  max-width: 1600px;
  width: 100%;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}
.page-header p:last-child {
  margin-bottom: 0;
  line-height: 1.5;
}
.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  margin-bottom: 24px;
}
.stat {
  padding: 20px 24px;
  border-right: 1px solid var(--line);
}
.stat:last-child {
  border: 0;
}
.stat strong {
  display: block;
  font-size: 27px;
  font-weight: 650;
  margin: 7px 0 0;
}
.stat span {
  font-size: 12px;
  color: var(--muted);
}
.panel {
  border: 1px solid var(--line);
  background: white;
  border-radius: 8px;
  overflow: hidden;
}
.panel-toolbar {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.panel-toolbar h3 {
  margin: 0;
}
.panel-toolbar input {
  max-width: 270px;
  margin: 0;
}
.table-scroll {
  overflow-x: auto;
}
table {
  border-collapse: collapse;
  width: 100%;
  text-align: left;
  white-space: nowrap;
}
th {
  font-size: 11px;
  color: var(--muted);
  font-weight: 650;
  background: #f9fbfb;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 16px 18px;
  border-bottom: 1px solid #edf0f0;
  font-size: 13px;
  vertical-align: middle;
}
tbody tr:last-child td {
  border-bottom: 0;
}
td.title-cell {
  min-width: 220px;
  white-space: normal;
  max-width: 350px;
}
.title-cell strong {
  display: block;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}
.subtext {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.row-actions {
  display: flex;
  gap: 6px;
}
.row-actions button {
  padding: 7px 10px;
  font-size: 12px;
}
.badge {
  display: inline-block;
  font-size: 11px;
  line-height: 1.5;
  padding: 4px 9px;
  border-radius: 5px;
  background: #eef1f3;
  color: #51616b;
  white-space: nowrap;
}
.badge.running,
.badge.delivered,
.badge.online,
.badge.completed {
  background: #e5f4ed;
  color: #146b4c;
}
.badge.paused,
.badge.unknown {
  background: #fff3d9;
  color: #886111;
}
.badge.pending {
  background: #eef1f3;
  color: #51616b;
}
.badge.processing,
.badge.inbound {
  background: #eaf1fb;
  color: #3d6392;
}
.badge.failed,
.badge.cancelled,
.badge.offline {
  background: #fbeaea;
  color: #9b4444;
}
.badge.sent {
  background: #fff3d9;
  color: #886111;
}
.empty {
  padding: 50px 22px;
  text-align: center;
  color: var(--muted);
  line-height: 1.6;
}
.empty strong {
  color: #34464f;
  display: block;
  font-size: 17px;
  margin-bottom: 8px;
}
.empty button {
  margin-top: 14px;
}
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}
input:not([type="checkbox"]),
textarea,
select {
  display: block;
  width: 100%;
  border: 1px solid #cbd6d9;
  border-radius: 6px;
  padding: 10px 12px;
  background: white;
  color: #202c32;
  margin-top: 7px;
  min-height: 41px;
}
textarea {
  resize: vertical;
  min-height: 105px;
  line-height: 1.55;
}
input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
label small {
  font-weight: 400;
  display: block;
  line-height: 1.5;
  margin-top: 7px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 24px;
}
.span-2 {
  grid-column: span 2;
}
.field-heading {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 9px;
}
.device-options {
  border: 1px solid var(--line);
  border-radius: 6px;
  max-height: 180px;
  overflow: auto;
  margin-bottom: 16px;
}
.check-option {
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 11px 13px;
  border-bottom: 1px solid #edf1f1;
  font-weight: 500;
  margin: 0;
}
.check-option:last-child {
  border-bottom: 0;
}
.check-option small {
  margin: 0 0 0 auto;
  text-align: right;
  font-size: 11px;
}
.form-footer {
  border-top: 1px solid var(--line);
  padding-top: 20px;
  display: flex;
  gap: 9px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 20px;
}
.note {
  background: #f2f7f6;
  border-left: 3px solid #70ab9c;
  padding: 13px 15px;
  line-height: 1.55;
  color: #50645f;
  font-size: 12px;
  margin: 14px 0;
}
.note.warning {
  background: #fff8e9;
  border-color: #d7b262;
  color: #80631e;
}
.error-text {
  color: #b23b3b;
  line-height: 1.5;
  font-size: 13px;
  white-space: pre-wrap;
}
.message-preview {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #f3f6f6;
  border-radius: 6px;
  padding: 18px;
  line-height: 1.6;
  margin: 12px 0;
}
.summary-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.summary-list div {
  padding: 10px 0;
}
.summary-list span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
}
dialog {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  width: min(780px, calc(100vw - 32px));
  max-height: 90vh;
  box-shadow: 0 20px 90px #142d3838;
  color: inherit;
}
dialog::backdrop {
  background: #15252d70;
}
.modal-header {
  padding: 22px 26px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}
#modal-body {
  padding: 24px 26px;
}
.icon-button {
  border: 0;
  font-size: 24px;
  padding: 0 6px;
  color: var(--muted);
  line-height: 30px;
}
.notifications {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 10;
  max-width: min(440px, calc(100vw - 40px));
}
.toast {
  background: #203b35;
  color: white;
  padding: 15px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 24px #0002;
  margin-top: 8px;
  line-height: 1.5;
}
.toast.error {
  background: #873b3b;
}
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #f1f5f3;
}
.login-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 36px;
  max-width: 420px;
  width: 100%;
}
.login-card .brand-mark {
  margin-bottom: 24px;
}
.login-card h1 {
  font-size: 25px;
}
.login-card .muted {
  line-height: 1.6;
  margin-bottom: 26px;
}
.login-card button {
  width: 100%;
}
.login-card .error-text:empty {
  display: none;
}
.conversation-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.conversation-list button {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 18px 22px;
  background: white;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(430px, 520px);
  align-items: center;
  gap: 26px;
}
.conversation-list button:hover {
  background: #f4f8f7;
}
.conversation-preview {
  display: block;
  min-width: 0;
}
.conversation-preview strong {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
}
.conversation-list .subtext {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conversation-row-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 140px;
  gap: 16px;
  align-items: center;
  min-width: 0;
}
.conversation-row-meta > span {
  display: block;
  min-width: 0;
}
.conversation-row-meta small {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.conversation-row-meta b {
  display: block;
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}
.thread {
  max-height: 42vh;
  overflow: auto;
  padding: 4px 0 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.message-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 0;
  width: min(100%, 700px);
  flex: 0 0 auto;
  align-self: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}
.message-card.out {
  align-self: flex-end;
}
.message-text {
  min-width: 0;
  padding: 14px 16px;
  background: #f6f8f8;
}
.message-card.out .message-text {
  background: #eaf5f0;
}
.message-text p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
}
.message-meta {
  margin: 0;
  padding: 12px 14px;
  border-left: 1px solid var(--line);
  background: white;
  display: grid;
  align-content: center;
  gap: 9px;
}
.message-meta div {
  min-width: 0;
}
.message-meta dt {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.message-meta dd {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.qr-box {
  text-align: center;
}
.qr-box img {
  max-width: 240px;
  width: 100%;
  height: auto;
}
.toggle-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}
.actions-inline {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.progress {
  height: 4px;
  min-width: 85px;
  background: #e8eeee;
  border-radius: 3px;
  margin: 7px 0;
}
.progress i {
  height: 100%;
  background: #4eab91;
  display: block;
  border-radius: 3px;
}
.search-empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
}
@media (max-width: 1100px) {
  .main {
    padding: 28px 22px;
  }
  .shell {
    grid-template-columns: 200px minmax(0, 1fr);
  }
  .page-header {
    flex-direction: column;
  }
  .stat {
    padding: 17px;
  }
  .sidebar {
    padding: 24px 14px;
  }
  .header-actions {
    width: 100%;
  }
  .conversation-list button {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .conversation-row-meta {
    padding-top: 12px;
    border-top: 1px solid var(--line);
  }
}
@media (max-width: 700px) {
  .shell {
    display: block;
  }
  .sidebar {
    padding: 15px 16px;
    gap: 15px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand {
    font-size: 17px;
  }
  .brand small {
    display: none;
  }
  .brand-mark {
    width: 36px;
    height: 36px;
  }
  .department-label {
    position: absolute;
    right: 16px;
    top: 10px;
    width: 140px;
    font-size: 10px;
  }
  .department-label select {
    padding: 7px 9px;
    min-height: 32px;
    margin-top: 3px;
  }
  .sidebar nav {
    flex-direction: row;
    overflow-x: auto;
    gap: 3px;
  }
  .nav-item {
    white-space: nowrap;
    padding: 9px 10px;
    font-size: 12px;
  }
  .nav-item span {
    display: none;
  }
  .sidebar-footer {
    margin: 0;
    padding: 0;
    border: 0;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
  }
  .sidebar-footer .text-button {
    margin-left: auto;
  }
  .main {
    padding: 24px 16px;
  }
  h1 {
    font-size: 25px;
  }
  .header-actions button {
    flex: 1;
  }
  .stats {
    grid-template-columns: 1fr 1fr;
  }
  .stat {
    padding: 16px;
  }
  .stat:nth-child(2) {
    border-right: 0;
  }
  .stat:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }
  .stat strong {
    font-size: 24px;
  }
  .panel-toolbar {
    padding: 15px;
    flex-wrap: wrap;
  }
  .panel-toolbar input {
    max-width: none;
  }
  .form-grid {
    display: block;
  }
  #modal-body {
    padding: 20px 18px;
  }
  .modal-header {
    padding: 17px 18px;
  }
  dialog {
    width: calc(100vw - 20px);
    max-height: 94vh;
  }
  .form-footer button {
    flex: 1;
  }
  .summary-list {
    gap: 8px;
  }
  .message-card {
    grid-template-columns: 1fr;
    width: 100%;
  }
  .message-meta {
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: start;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .message-meta div:not(:first-child) {
    text-align: right;
  }
  .conversation-row-meta {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px 18px;
  }
  .conversation-row-meta > span:last-child {
    grid-column: 1/-1;
  }
  .login-card {
    padding: 27px;
  }
  .row-actions {
    flex-wrap: wrap;
  }
}
@media (prefers-reduced-motion: no-preference) {
  button {
    transition: background 0.12s ease;
  }
}

.single-sms { max-width: 760px; padding: 24px; }
@media (max-width: 600px) { .single-sms { padding: 16px; } }
#conversation-filters { flex-wrap: wrap; align-items: flex-end; }
#conversation-filters label { flex: 1 1 230px; min-width: 0; margin: 0; }
#conversation-filters input { max-width: none; }

.pending-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin-top: 8px; }
