:root {
  --bg: #f4f7fa;
  --panel: #ffffff;
  --ink: #111827;
  --ink-soft: #344054;
  --muted: #667085;
  --line: #d9e2ea;
  --line-strong: #c7d2dc;
  --teal: #08756f;
  --teal-dark: #075e54;
  --cyan: #e7f9f7;
  --blue: #1d4ed8;
  --green: #087f5b;
  --lime: #65a30d;
  --amber: #b45309;
  --red: #c2410c;
  --shadow: 0 18px 55px rgba(16, 24, 40, .10);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  font-family: "Segoe UI", Inter, Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(8, 117, 111, .08), transparent 300px),
    var(--bg);
}

button, input, textarea, select { font: inherit; }

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  background: var(--teal);
  color: #fff;
  font-weight: 750;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

button:hover {
  background: var(--teal-dark);
  box-shadow: 0 10px 22px rgba(8, 117, 111, .18);
  transform: translateY(-1px);
}

button.secondary {
  background: #fff;
  color: var(--teal);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

input, textarea, select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  color: var(--ink);
  outline: none;
  transition: border .16s ease, box-shadow .16s ease;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(8, 117, 111, .12);
}

textarea { min-height: 128px; resize: vertical; }
label { display: grid; gap: 8px; font-weight: 750; color: var(--ink-soft); }
small, p, span { color: var(--muted); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(24px, 3vw, 34px); letter-spacing: 0; line-height: 1.12; }
h2 { font-size: 18px; margin-bottom: 16px; letter-spacing: 0; }
h3 { font-size: 15px; margin: 22px 0 10px; letter-spacing: 0; }

pre {
  margin: 0;
  overflow-x: auto;
  white-space: pre-wrap;
  background: #0f172a;
  color: #e5f2ff;
  border-radius: 8px;
  padding: 16px;
  line-height: 1.5;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr);
}

.login-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(34px, 6vw, 72px);
  overflow: hidden;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(7, 94, 84, .94), rgba(8, 117, 111, .96) 58%, rgba(29, 78, 216, .88)),
    repeating-linear-gradient(135deg, rgba(255,255,255,.08) 0 1px, transparent 1px 20px);
}

.login-brand:after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 120px;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,.12));
  pointer-events: none;
}

.login-brand p {
  margin-top: 10px;
  color: rgba(255,255,255,.78);
  font-size: 17px;
}

.logo-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 46px;
  border-radius: 8px;
  margin-bottom: 18px;
  background: rgba(255,255,255,.16);
  color: #fff;
  border: 1px solid rgba(255,255,255,.22);
  font-weight: 900;
}

.login-highlights {
  width: min(620px, 100%);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 36px;
}

.login-highlights div {
  min-height: 102px;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.20);
  background: rgba(255,255,255,.12);
  backdrop-filter: blur(8px);
}

.login-highlights strong {
  display: block;
  color: #fff;
  margin-bottom: 8px;
}

.login-highlights span { color: rgba(255,255,255,.72); }

.login-card {
  align-self: center;
  justify-self: center;
  width: min(430px, calc(100% - 34px));
  display: grid;
  gap: 16px;
  padding: 30px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

#loginError { color: var(--red); min-height: 18px; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  color: #fff;
  background:
    linear-gradient(180deg, #075e54, #08756f),
    repeating-linear-gradient(0deg, rgba(255,255,255,.08) 0 1px, transparent 1px 24px);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
}

.sidebar-brand .logo-mark {
  width: 46px;
  height: 42px;
  margin: 0;
}

nav { display: grid; gap: 8px; }

.nav-item {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #fff;
  box-shadow: none;
}

.nav-item:hover, .nav-item.active {
  background: rgba(255,255,255,.16);
  box-shadow: none;
  transform: none;
}

.app-main {
  width: min(1220px, 100%);
  padding: 24px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.app-header p { margin-top: 6px; }

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.status-strip div {
  min-height: 94px;
  padding: 18px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 10px 30px rgba(16,24,40,.05);
}

.status-strip span {
  display: block;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--muted);
}

.status-strip strong {
  display: block;
  margin-top: 9px;
  font-size: 22px;
}

.view { display: none; }
.view.active { display: block; }

.panel-grid {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(320px, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  margin-bottom: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 12px 36px rgba(16,24,40,.06);
}

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

.form-stack { display: grid; gap: 14px; }

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

.full { grid-column: 1 / -1; }

.qr-panel { min-height: 360px; }

.qr-empty, .qr-status {
  display: grid;
  place-items: center;
  min-height: 236px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  background: linear-gradient(180deg, #fff, #f7fbfb);
}

.qr-status {
  display: block;
  min-height: auto;
  margin-top: 12px;
  padding: 12px;
}

.qr-img {
  display: block;
  width: 280px;
  max-width: 100%;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(16,24,40,.10);
}

.list { display: grid; gap: 10px; }

.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.list-row small {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  background: #e7f8ef;
  color: var(--green);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.badge.warn {
  background: #fff7ed;
  color: var(--amber);
}

.secret, .result {
  margin-bottom: 14px;
  padding: 13px;
  border-radius: 8px;
  border: 1px dashed var(--teal);
  background: var(--cyan);
  color: var(--teal-dark);
  overflow-wrap: anywhere;
}

.send-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  align-items: start;
}

.send-composer {
  padding: 20px;
}

.breadcrumb {
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.breadcrumb strong {
  color: var(--green);
}

.broadcast-form {
  display: grid;
  gap: 18px;
}

.send-row {
  display: grid;
  grid-template-columns: minmax(260px, .95fr) minmax(280px, 1fr);
  gap: 18px;
  align-items: end;
}

.field-title {
  display: block;
  margin-bottom: 8px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 750;
}

.required {
  color: var(--red);
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf3f7;
  padding: 2px;
}

.segment {
  min-height: 36px;
  border-radius: 6px;
  padding: 8px 14px;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  white-space: nowrap;
}

.segment:hover,
.segment.active {
  background: #fff;
  color: var(--green);
  box-shadow: 0 5px 12px rgba(16,24,40,.08);
  transform: none;
}

.recipient-tab {
  display: none;
}

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

.upload-box,
.contactbook-box {
  display: grid;
  gap: 10px;
  min-height: 118px;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #f8fbfd;
}

.upload-box span,
.contactbook-box p {
  color: var(--muted);
  font-weight: 500;
}

.message-type-row {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.message-type-row p {
  font-size: 13px;
}

.message-meter {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: -10px;
  font-size: 12px;
}

.message-meter span:last-child,
.message-meter span:last-child strong {
  color: var(--red);
}

.send-options {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr);
  gap: 14px;
}

.switch-card {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 78px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfd;
}

.switch-card strong,
.switch-card small {
  display: block;
}

.switch-card input {
  width: 48px;
  min-height: 24px;
  accent-color: var(--green);
}

.send-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid #edf1f4;
}

.danger-ghost {
  background: #fff;
  color: var(--red);
  border: 1px solid #f3b4a6;
  box-shadow: none;
}

.danger-ghost:hover {
  background: #fff7f5;
  color: var(--red);
  box-shadow: none;
}

.send-side {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 18px;
}

.compact-panel {
  padding: 14px;
}

.compact-panel h2 {
  margin-bottom: 12px;
  font-size: 14px;
}

.panel-head.tight {
  margin-bottom: 12px;
}

.check-row {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  font-size: 13px;
}

.check-row input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--green);
}

.side-search {
  min-height: 38px;
  margin: 8px 0 10px;
}

.sender-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.sender-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 9px;
  border-radius: 8px;
  background: #f8fbfd;
  border: 1px solid #edf1f4;
}

.sender-row input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--green);
}

.sender-row strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.sender-row small {
  color: var(--green);
  font-weight: 800;
}

.phone-preview {
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfd;
}

.chat-bubble {
  width: fit-content;
  max-width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #def7e9;
  color: var(--green);
  font-size: 13px;
  font-style: italic;
  overflow-wrap: anywhere;
}

.preview-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.preview-stats div {
  display: grid;
  place-items: center;
  min-height: 58px;
  border-radius: 8px;
  background: #f8fbfd;
}

.preview-stats strong {
  color: var(--green);
  font-size: 18px;
}

.preview-stats span {
  font-size: 11px;
}

@media (max-width: 980px) {
  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-brand {
    min-height: 360px;
  }

  .login-card {
    margin: -60px auto 34px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    position: static;
    height: auto;
    padding-bottom: 14px;
  }

  .sidebar-brand {
    margin-bottom: 18px;
  }

  nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav-item {
    text-align: center;
    padding-inline: 8px;
  }

  .app-main {
    padding: 18px;
  }

  .panel-grid {
    grid-template-columns: 1fr;
  }

  .send-layout {
    grid-template-columns: 1fr;
  }

  .send-side {
    position: static;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 680px) {
  .login-brand {
    min-height: auto;
    padding: 30px 20px 92px;
  }

  .login-highlights {
    grid-template-columns: 1fr;
    margin-top: 24px;
  }

  .login-highlights div {
    min-height: auto;
  }

  .login-card {
    width: calc(100% - 28px);
    margin-top: -70px;
    padding: 22px;
  }

  nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-header {
    align-items: stretch;
    flex-direction: column;
  }

  .app-header button {
    width: 100%;
  }

  .status-strip {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 16px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .send-row,
  .send-options,
  .message-type-row,
  .send-side {
    grid-template-columns: 1fr;
  }

  .segmented {
    width: 100%;
    grid-auto-flow: row;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .segment {
    padding-inline: 8px;
  }

  .send-actions {
    flex-direction: column-reverse;
  }

  .send-actions button {
    width: 100%;
  }

  .full {
    grid-column: auto;
  }

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

  .list-row > div:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
}
