:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #141c2b;
  --muted: #66758a;
  --line: #dde5ee;
  --line-strong: #c6d2df;
  --teal: #0b746d;
  --blue: #2d5bd6;
  --amber: #b96c07;
  --red: #b42318;
  --green: #087a42;
  --slate: #2f3c4f;
  --soft-teal: #e6f4f1;
  --soft-blue: #edf3ff;
  --soft-amber: #fff6e7;
  --soft-red: #fff0ed;
  --sidebar: #101a26;
  --sidebar-soft: #182638;
  --shadow: 0 18px 46px rgba(25, 39, 62, 0.1);
  --shadow-soft: 0 8px 22px rgba(25, 39, 62, 0.07);
  --ring: 0 0 0 4px rgba(11, 116, 109, 0.12);
  --radius: 8px;
  --radius-sm: 6px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, #f9fbff 0%, var(--bg) 320px, #eef3f8 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.45;
}

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

button {
  cursor: pointer;
}

button,
a,
input,
select,
textarea {
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 0;
  box-shadow: var(--ring);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 14px;
  color: #eef6f8;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 220px),
    linear-gradient(180deg, var(--sidebar), #0d1722 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.04);
}

.brand {
  display: grid;
  gap: 5px;
  padding: 12px 12px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand strong {
  font-size: 19px;
  line-height: 1.2;
  letter-spacing: 0;
}

.brand span {
  color: rgba(238, 246, 248, 0.66);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 7px;
  margin-top: 20px;
}

.nav button,
.home-link {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 0 11px;
  color: rgba(238, 246, 248, 0.78);
  text-align: left;
  text-decoration: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 720;
}

.nav button:hover,
.home-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.075);
  border-color: rgba(255, 255, 255, 0.08);
}

.nav button.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.18), rgba(45, 91, 214, 0.14));
  border-color: rgba(148, 163, 184, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.nav .mark {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: #b9fff3;
  font-size: 12px;
  font-weight: 800;
  background: rgba(15, 118, 110, 0.24);
  border: 1px solid rgba(185, 255, 243, 0.22);
  border-radius: var(--radius-sm);
}

.count-pill {
  min-width: 24px;
  padding: 2px 7px;
  color: #0c1723;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  background: #c7f9e9;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.sidebar-footer {
  position: absolute;
  right: 14px;
  bottom: 14px;
  left: 14px;
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-footer button {
  min-height: 38px;
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  font-weight: 800;
}

.sidebar-footer button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 20px 28px;
  background: rgba(248, 251, 255, 0.88);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.72), 0 10px 28px rgba(31, 45, 70, 0.05);
}

.title-block h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.2;
  letter-spacing: 0;
}

.title-block p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.health-text.ok {
  color: var(--green);
  font-weight: 800;
}

.health-text.bad {
  color: var(--red);
  font-weight: 800;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.03);
  font-weight: 800;
  text-decoration: none;
}

.btn:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--teal), #0e8f83);
  border-color: var(--teal);
  box-shadow: 0 10px 24px rgba(11, 116, 109, 0.22);
}

.btn.blue {
  color: #fff;
  background: linear-gradient(135deg, var(--blue), #315ee8);
  border-color: var(--blue);
  box-shadow: 0 10px 24px rgba(45, 91, 214, 0.2);
}

.btn.danger {
  color: var(--red);
  background: #fff;
  border-color: #f0c2bc;
  box-shadow: none;
}

.btn.small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.btn.tiny {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
  white-space: nowrap;
}

.content {
  padding: 24px 28px 42px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.grid {
  display: grid;
  gap: 16px;
}

.metrics {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
}

.dashboard-switch {
  display: inline-flex;
  gap: 5px;
  margin-bottom: 18px;
  padding: 5px;
  background: rgba(229, 236, 244, 0.86);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.74);
}

.dashboard-switch button {
  min-height: 36px;
  padding: 0 18px;
  color: var(--slate);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  font-weight: 900;
}

.dashboard-switch button.active {
  color: #fff;
  background: linear-gradient(135deg, var(--teal), #116f9b);
  box-shadow: 0 10px 22px rgba(11, 116, 109, 0.22);
}

.dashboard-panel {
  min-width: 0;
}

.metric {
  position: relative;
  min-height: 124px;
  overflow: hidden;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 251, 253, 0.96));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--teal), var(--blue));
  opacity: 0.9;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.metric strong {
  display: block;
  margin-top: 12px;
  color: #0f172a;
  font-size: 32px;
  line-height: 1;
  letter-spacing: 0;
}

.metric small {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.board {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 16px;
  margin-top: 16px;
}

.board.single-board {
  grid-template-columns: minmax(0, 1fr);
}

.funnel-list {
  display: grid;
  gap: 15px;
}

.funnel-item,
.stage-card {
  display: grid;
  gap: 8px;
}

.funnel-meta,
.stage-card > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.funnel-meta strong,
.stage-card strong {
  color: #1b2738;
  font-size: 13px;
  font-weight: 900;
}

.funnel-meta span,
.stage-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.funnel-track {
  height: 11px;
  overflow: hidden;
  background: #ecf1f6;
  border: 1px solid #dfe7ee;
  border-radius: 999px;
}

.funnel-track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), #2d8fb8, var(--blue));
  border-radius: inherit;
  box-shadow: 0 0 18px rgba(11, 116, 109, 0.18);
}

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

.alert-card,
.ops-insight-list article,
.portrait-group,
.compact-message {
  border: 1px solid var(--line);
  border-radius: 8px;
}

.alert-card {
  padding: 13px 14px;
  background: var(--panel-soft);
}

.alert-card strong {
  display: block;
  font-size: 13px;
  font-weight: 900;
}

.alert-card p,
.ops-insight-list p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.alert-card.ok {
  background: #effaf4;
  border-color: #c8e7d0;
}

.alert-card.warn {
  background: #fff7e8;
  border-color: #f0d6a8;
}

.alert-card.bad {
  background: #fff0ee;
  border-color: #f1c0ba;
}

.stage-grid {
  display: grid;
  gap: 12px;
}

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

.portrait-group {
  padding: 14px;
  background: var(--panel-soft);
}

.portrait-group h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 900;
}

.ops-insight-list {
  display: grid;
  gap: 12px;
}

.ops-insight-list article {
  padding: 15px;
  background: var(--panel-soft);
}

.ops-insight-list span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ops-insight-list strong {
  display: block;
  margin-top: 6px;
  color: #0f172a;
  font-size: 22px;
  line-height: 1.2;
}

.compact-empty {
  padding: 12px;
  min-height: 48px;
}

.compact-message {
  padding: 12px;
  box-shadow: none;
  background: var(--panel-soft);
}

.panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
  padding: 0 18px;
  background: linear-gradient(180deg, #fff, #fbfdff);
  border-bottom: 1px solid var(--line);
}

.panel-head h2,
.panel-head h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: 0;
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.panel-body {
  padding: 16px 18px 18px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(132px, 180px)) minmax(138px, 160px);
  gap: 11px;
  margin-bottom: 16px;
}

.toolbar-action {
  min-height: 40px;
  white-space: nowrap;
}

.field {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
}

.field:hover {
  border-color: var(--line-strong);
}

.field:focus {
  outline: 0;
  border-color: rgba(11, 116, 109, 0.55);
  box-shadow: var(--ring);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  background: #f6f9fc;
  white-space: nowrap;
}

th,
td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

tbody tr:hover {
  background: #f7fbfb;
}

tr:last-child td {
  border-bottom: 0;
}

tr.selectable {
  cursor: pointer;
}

tr.selectable:hover,
tr.selected {
  background: #eef8f6;
}

.customer-name {
  display: grid;
  gap: 3px;
}

.customer-name strong {
  font-size: 14px;
  line-height: 1.25;
}

.customer-name span {
  color: var(--muted);
  font-size: 12px;
}

.badge-row,
.tag-row,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge,
.tag,
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 2px 9px;
  white-space: nowrap;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid transparent;
}

.badge {
  color: var(--slate);
  background: #eef3f8;
  border-color: #d8e2ed;
}

.owner-cell {
  display: inline-block;
  max-width: 96px;
  overflow-wrap: anywhere;
  font-weight: 900;
}

.owner-cell.muted {
  color: var(--muted);
  font-weight: 800;
}

.country-cell {
  display: inline-block;
  max-width: 92px;
  overflow-wrap: anywhere;
  color: var(--slate);
  font-weight: 900;
}

.country-cell.muted {
  color: var(--muted);
  font-weight: 800;
}

.source-cell {
  display: grid;
  gap: 3px;
  min-width: 118px;
  max-width: 170px;
}

.source-cell strong,
.source-cell span {
  overflow-wrap: anywhere;
}

.source-cell strong {
  color: var(--slate);
  font-size: 12px;
  font-weight: 900;
}

.source-cell span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.time-cell,
.duration-cell {
  display: inline-block;
  min-width: 82px;
  color: var(--slate);
  font-weight: 800;
  line-height: 1.35;
}

.duration-cell {
  min-width: 64px;
  color: #0f5d55;
}

.tag {
  color: #0f5d55;
  background: var(--soft-teal);
  border-color: #bddfd9;
}

.tag.pending {
  color: #875008;
  background: var(--soft-amber);
  border-color: #f0cf9a;
}

.chip {
  color: #24438f;
  background: var(--soft-blue);
  border-color: #c5d6ff;
}

.grade {
  display: inline-grid;
  place-items: center;
  width: 31px;
  height: 31px;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.12);
}

.grade-a {
  background: var(--green);
}

.grade-b {
  background: var(--blue);
}

.grade-c {
  background: var(--amber);
}

.grade-d {
  background: var(--red);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 27px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  border-radius: 999px;
  border: 1px solid transparent;
}

.status::before {
  content: "";
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status.ok {
  color: var(--green);
  background: #eef9f2;
  border-color: #cfeada;
}

.status.warn {
  color: var(--amber);
  background: #fff7e8;
  border-color: #f2d8a7;
}

.status.bad {
  color: var(--red);
  background: #fff0ee;
  border-color: #f0c5bf;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 16px;
}

.profile {
  display: grid;
  gap: 14px;
}

.profile-hero {
  display: grid;
  gap: 10px;
}

.channel-editor {
  display: grid;
  gap: 6px;
}

.channel-editor span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.channel-editor select {
  font-weight: 800;
}

.editable-meta {
  display: grid;
  gap: 8px;
  align-content: start;
}

.compact-field {
  width: 100%;
  min-height: 34px;
  padding: 7px 10px;
  font-weight: 800;
}

.compact-action-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.country-action-field {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.country-action-field .field {
  grid-column: 1 / -1;
}

.country-action-field .btn {
  width: 100%;
}

.source-material-card {
  align-content: start;
}

.source-material-card .field {
  width: 100%;
}

.source-material-card .btn {
  justify-self: end;
}

.profile-hero h2 {
  margin: 0;
  color: #0f172a;
  font-size: 22px;
  line-height: 1.2;
}

.profile-meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.meta-item {
  min-height: auto;
  padding: 10px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.meta-item span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.3;
}

.meta-item strong {
  display: block;
  margin-top: 5px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.grade-control {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.grade-control button {
  min-height: 38px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-weight: 900;
}

.grade-control button:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-soft);
}

.grade-control button.active {
  color: #fff;
  border-color: transparent;
}

.grade-control button[data-grade="A"].active {
  background: var(--green);
}

.grade-control button[data-grade="B"].active {
  background: var(--blue);
}

.grade-control button[data-grade="C"].active {
  background: var(--amber);
}

.grade-control button[data-grade="D"].active {
  background: var(--red);
}

.profile-summary-strip {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.profile-note-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.profile-tag-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.tag-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tag-card-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.2;
}

.note-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.note-card-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.2;
}

.note-card-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.note-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.summary-textarea {
  min-height: 126px;
  line-height: 1.55;
}

.note-context-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.note-context-row > span {
  padding-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tag-selector-panel {
  display: grid;
  gap: 10px;
}

.tag-dropdown-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 8px;
}

.selected-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.selected-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  max-width: 100%;
  padding: 3px 7px 3px 9px;
  color: #0f5d55;
  background: var(--soft-teal);
  border: 1px solid #bddfd9;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.selected-tag-pill span {
  overflow-wrap: anywhere;
}

.selected-tag-pill.grade-tag {
  color: #875008;
  background: var(--soft-amber);
  border-color: #f0cf9a;
}

.selected-tag-pill button {
  min-height: 21px;
  padding: 0 6px;
  color: var(--red);
  background: #fff;
  border: 1px solid #f0c2bc;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.tag-choice-group {
  display: grid;
  gap: 6px;
}

.tag-choice-group > strong {
  color: var(--slate);
  font-size: 12px;
}

.tag-choice-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-choice {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 29px;
  padding: 3px 9px;
  color: var(--slate);
  background: #fff;
  border: 1px solid #d8e2ed;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.tag-choice input {
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: var(--teal);
}

.tag-choice.selected {
  color: #0f5d55;
  background: var(--soft-teal);
  border-color: #bddfd9;
}

.tag-library-layout {
  display: grid;
  gap: 16px;
}

.tag-library-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(180px, 1.2fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.tag-library-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

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

.tag-library-group {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

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

.tag-library-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
}

.tag-library-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tag-library-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-library-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 31px;
  padding: 4px 9px;
  color: var(--slate);
  background: #f8fbfd;
  border: 1px solid #d8e2ed;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.tag-library-pill small {
  color: var(--muted);
  font-weight: 800;
}

.tag-library-pill button {
  min-height: 22px;
  padding: 0 7px;
  color: var(--red);
  background: #fff;
  border: 1px solid #f0c2bc;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
}

.summary-line {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.summary-label {
  padding-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.chip-row.compact,
.tag-row.compact,
.pending-compact {
  gap: 6px;
  min-width: 0;
}

.pending-compact {
  display: flex;
  flex-wrap: wrap;
}

.pending-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 3px;
  background: #fff;
  border: 1px solid #ecd8b4;
  border-radius: 999px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
}

.pending-pill .tag {
  max-width: min(260px, 52vw);
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip-action {
  min-height: 22px;
  padding: 0 7px;
  color: var(--slate);
  background: #f3f7fa;
  border: 1px solid #d8e1e8;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.chip-action.confirm {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
}

.conversation-panel {
  display: grid;
  gap: 10px;
  min-width: 0;
}

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

.conversation-head h3 {
  margin: 0;
  font-size: 15px;
}

.conversation-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.conversation-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.followup-record-list {
  display: grid;
  gap: 8px;
  max-height: 190px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fbfd;
}

.followup-record {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid #d8e2ed;
  border-radius: 8px;
  background: #fff;
}

.followup-record.legacy {
  border-color: #c8d9ea;
  background: #fbfdff;
}

.followup-record-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.followup-record-head strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.followup-record-head time {
  white-space: nowrap;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.followup-record p {
  margin: 0;
  color: var(--slate);
  font-size: 13px;
  line-height: 1.55;
  max-height: 92px;
  overflow: auto;
  white-space: pre-wrap;
}

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

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: clamp(360px, 56vh, 580px);
  overflow: auto;
  padding: 18px 24px;
  border: 1px solid #eadfce;
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(250, 247, 240, 0.92), rgba(250, 247, 240, 0.92)),
    radial-gradient(circle at 20px 20px, rgba(160, 121, 72, 0.08) 1.4px, transparent 2.2px),
    radial-gradient(circle at 8px 9px, rgba(109, 142, 112, 0.06) 1.2px, transparent 2px);
  background-color: #efe7db;
  background-size: auto, 34px 34px, 27px 27px;
}

.chat-date-separator {
  display: flex;
  justify-content: center;
  margin: 14px 0 10px;
}

.chat-date-separator span {
  padding: 4px 12px;
  color: #6b7280;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(115, 125, 134, 0.14);
  border-radius: 7px;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.09);
}

.chat-row {
  display: flex;
  align-items: flex-end;
  width: 100%;
  margin: 1px 0;
}

.chat-row.inbound {
  justify-content: flex-start;
}

.chat-row.outbound {
  justify-content: flex-end;
}

.chat-row.system {
  justify-content: center;
}

.chat-bubble {
  position: relative;
  width: fit-content;
  min-width: 190px;
  max-width: min(72%, 720px);
  padding: 7px 9px 5px;
  border: 0;
  border-radius: 7.5px;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.12);
}

.chat-row.inbound .chat-bubble {
  color: #111b21;
  background: #fff;
  border-top-left-radius: 2px;
}

.chat-row.outbound .chat-bubble {
  color: #111b21;
  background: #d9fdd3;
  border-top-right-radius: 2px;
  min-width: 210px;
}

.chat-row.system .chat-bubble {
  max-width: 72%;
  color: #667781;
  background: rgba(255, 255, 255, 0.86);
  text-align: center;
}

.chat-meta {
  display: none;
}

.chat-meta time {
  white-space: nowrap;
}

.chat-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14.2px;
  line-height: 1.38;
}

.chat-row.deleted .chat-text {
  color: #667781;
  font-style: italic;
}

.chat-translation {
  display: block;
  width: fit-content;
  max-width: min(560px, 100%);
  min-width: min(148px, 100%);
  margin: 6px 0 2px;
  padding: 7px 9px 7px 11px;
  color: #2f80ed;
  background: rgba(255, 255, 255, 0.7);
  border-left: 3px solid #4facfe;
  border-radius: 8px;
  white-space: normal;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.45;
  font-weight: 400;
}

.chat-row.outbound .chat-translation {
  background: rgba(222, 255, 219, 0.72);
}

.chat-translation strong {
  display: block;
  margin-bottom: 3px;
  color: #64748b;
  font-size: 11px;
  white-space: nowrap;
}

.chat-translation-text {
  display: block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-translation.pending {
  color: #667781;
  font-style: italic;
}

.chat-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  min-height: 15px;
  margin-top: 2px;
  color: #667781;
  font-size: 11px;
  line-height: 1;
  text-align: right;
}

.chat-row.outbound .chat-footer {
  color: #4f7f57;
}

.chat-status {
  color: #53bdeb;
  font-size: 12px;
  letter-spacing: -2px;
}

.chat-channel {
  display: none;
  margin-top: 4px;
  color: #7a857f;
  font-size: 10px;
  text-align: right;
}

.event {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.event:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.event time {
  color: var(--muted);
  font-size: 12px;
}

.event strong {
  display: block;
  margin-bottom: 3px;
  font-size: 13px;
}

.event p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.inbox-list,
.duplicate-list,
.integration-list {
  display: grid;
  gap: 10px;
}

.message,
.duplicate,
.integration {
  display: grid;
  gap: 11px;
  padding: 15px;
  background:
    linear-gradient(180deg, #fff, #fbfdff);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
}

.message:hover,
.duplicate:hover,
.integration:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-soft);
}

.message-head,
.duplicate-head,
.integration-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.message h3,
.duplicate h3,
.integration h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
}

.message p,
.duplicate p,
.integration p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.message-body {
  padding: 13px;
  color: var(--slate);
  background: #f7fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  white-space: pre-wrap;
}

.inbox-chat-preview {
  display: block;
  width: 100%;
  min-height: 48px;
  text-align: left;
  font-weight: 500;
}

.inbox-chat-preview:hover {
  border-color: #9fb6c8;
  background: #f1f7fa;
}

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

.duplicate-side {
  padding: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.duplicate-side strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}

.setup-panel {
  margin-top: 14px;
}

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

.setup-grid div {
  display: grid;
  gap: 6px;
}

label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

code {
  display: block;
  overflow: auto;
  padding: 11px 12px;
  color: #e8fff9;
  background: #101a26;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 160px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed #b7c4d1;
  border-radius: var(--radius);
  background: var(--panel-soft);
}

body.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(17, 27, 33, 0.56);
  backdrop-filter: blur(8px);
}

.chat-modal {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  width: min(940px, calc(100vw - 56px));
  max-height: min(760px, calc(100vh - 56px));
  min-height: min(620px, calc(100vh - 56px));
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(209, 216, 220, 0.96);
  border-radius: 8px;
  box-shadow: 0 34px 90px rgba(9, 16, 28, 0.38);
}

.manual-customer-modal {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(780px, calc(100vw - 56px));
  max-height: min(760px, calc(100vh - 56px));
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(209, 216, 220, 0.96);
  border-radius: 8px;
  box-shadow: 0 34px 90px rgba(9, 16, 28, 0.38);
}

.chat-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 16px;
  background: #f0f2f5;
  border-bottom: 1px solid #d8dee4;
}

.chat-modal-head h2 {
  margin: 0;
  color: #111b21;
  font-size: 17px;
  line-height: 1.2;
}

.chat-modal-head p {
  margin: 4px 0 0;
  color: #667781;
  font-size: 12px;
}

.chat-modal-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.translation-select {
  width: auto;
  min-width: 132px;
  min-height: 34px;
  padding: 0 8px;
  font-size: 12px;
}

.manual-customer-form {
  display: grid;
  gap: 14px;
  min-height: 0;
  overflow: auto;
  padding: 18px 22px 20px;
  background: #fff;
}

.manual-customer-form label {
  display: grid;
  gap: 6px;
  color: var(--slate);
  font-size: 12px;
  font-weight: 900;
}

.inline-fields {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 8px;
}

.manual-customer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.modal-close {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: #54656f;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 24px;
  line-height: 1;
}

.modal-close:hover {
  color: #111b21;
  background: #e2e7eb;
}

.remark-editor {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 9px 16px;
  border-bottom: 1px solid #e2e8ee;
  background: #fbfcfd;
}

.modal-chat-thread {
  height: auto;
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 18px 24px;
}

.chat-history-control {
  display: flex;
  justify-content: center;
  min-height: 34px;
  color: #667781;
  font-size: 12px;
  font-weight: 800;
}

.chat-history-control span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(115, 125, 134, 0.12);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  display: none;
  max-width: min(420px, calc(100vw - 44px));
  padding: 13px 15px;
  color: #fff;
  background: #111c29;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  box-shadow: 0 18px 46px rgba(15, 23, 42, 0.28);
}

.toast.show {
  display: block;
}

.activation-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.activation-side {
  display: grid;
  gap: 16px;
}

.activation-detail-panel {
  margin-top: 16px;
}

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

.form-grid {
  display: grid;
  gap: 12px;
}

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

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid label,
.activation-form > label,
.rule-box label {
  display: grid;
  gap: 6px;
  color: var(--slate);
  font-size: 12px;
  font-weight: 900;
}

.textarea {
  min-height: 86px;
  padding-top: 10px;
  resize: vertical;
}

.small-textarea {
  min-height: 64px;
}

.field-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.multi {
  min-height: 112px;
  padding: 8px;
}

.rule-box {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

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

.rule-title strong {
  font-size: 14px;
  font-weight: 900;
}

.rule-title span,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.check-pill,
.toggle-line {
  display: inline-flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 7px !important;
  width: fit-content;
  min-height: 32px;
  padding: 0 10px;
  color: var(--ink) !important;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

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

.activation-summary article {
  min-height: 76px;
  padding: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.activation-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.activation-summary strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1;
}

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

.activation-preview-grid h3 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 900;
}

.mini-list {
  display: grid;
  gap: 8px;
}

.mini-row {
  display: grid;
  gap: 4px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.mini-row strong {
  font-size: 13px;
}

.mini-row span,
.campaign-row small {
  color: var(--muted);
  font-size: 12px;
}

.muted-row {
  background: #f7f9fc;
}

.campaign-list {
  display: grid;
  gap: 8px;
}

.campaign-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  align-items: center;
  width: 100%;
  padding: 12px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.campaign-row.active,
.campaign-row:hover {
  background: #eef8f6;
  border-color: #b6d8d1;
}

.campaign-row strong,
.activation-detail-head h3 {
  display: block;
  margin: 0;
  font-size: 14px;
  font-weight: 900;
}

.campaign-row small:last-child {
  grid-column: 1 / -1;
}

.activation-detail-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.activation-detail-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.activation-actions {
  justify-content: start;
  margin-bottom: 14px;
}

.compact-table table {
  min-width: 760px;
}

.publisher-segments {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.publisher-segment {
  display: grid !important;
  gap: 5px !important;
  min-height: 82px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.publisher-segment input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.publisher-segment strong {
  font-size: 14px;
  font-weight: 900;
}

.publisher-segment span,
.publisher-safety span,
.mini-row p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.publisher-segment.active,
.publisher-segment:has(input:checked) {
  background: #eef8f6;
  border-color: #9dd1c9;
  box-shadow: inset 0 0 0 1px rgba(11, 116, 109, 0.18);
}

.compact-multi {
  min-height: 78px;
}

.publisher-message {
  min-height: 132px;
}

.publisher-safety {
  display: grid;
  align-content: center;
  gap: 5px;
  min-height: 40px;
  padding: 10px 12px;
  background: #effaf4;
  border: 1px solid #c8e7d0;
  border-radius: var(--radius-sm);
}

.publisher-safety strong {
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
}

.publisher-progress {
  margin-bottom: 14px;
}

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

  .board,
  .split,
  .activation-layout,
  .activation-preview-grid {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .setup-grid,
  .form-grid.three,
  .publisher-segments {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

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

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

  .nav button,
  .home-link {
    min-height: 42px;
  }

  .sidebar-footer {
    position: static;
  }

  .topbar {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .top-actions {
    justify-content: start;
  }

  .dashboard-switch {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .dashboard-switch button {
    padding: 0 8px;
  }

  .content {
    padding: 16px;
  }

  .metrics,
  .toolbar,
  .profile-meta,
  .summary-line,
  .duplicate-grid,
  .setup-grid,
  .portrait-grid,
  .form-grid.two,
	  .form-grid.three,
	  .activation-summary,
	  .publisher-segments,
	  .tag-library-form,
	  .tag-library-groups {
	    grid-template-columns: 1fr;
	  }

  .summary-label {
    padding-top: 0;
  }

  .note-card-head {
    align-items: stretch;
    flex-direction: column;
  }

  .note-card-head .btn {
    width: 100%;
  }

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

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

  .tag-dropdown-grid {
    grid-template-columns: 1fr;
  }

  .pending-pill {
    border-radius: 8px;
  }

  .pending-pill .tag {
    max-width: 100%;
    white-space: normal;
  }

  .conversation-head {
    align-items: start;
    flex-direction: column;
  }

  .conversation-actions {
    justify-content: start;
    flex-wrap: wrap;
  }

  .chat-thread {
    height: min(560px, 68vh);
    min-height: 320px;
    padding: 12px;
  }

  .chat-bubble {
    min-width: 0;
    max-width: 88%;
  }

  .chat-meta {
    flex-wrap: wrap;
  }

  .modal-backdrop {
    padding: 10px;
  }

  .chat-modal {
    width: calc(100vw - 20px);
    min-height: calc(100vh - 20px);
    max-height: calc(100vh - 20px);
  }

  .manual-customer-modal {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
  }

  .chat-modal-head {
    align-items: stretch;
    flex-direction: column;
    padding: 14px 12px 11px;
  }

  .chat-modal-tools {
    justify-content: start;
    flex-wrap: wrap;
  }

  .translation-select {
    width: min(180px, 100%);
  }

  .manual-customer-form {
    padding: 14px 12px 16px;
  }

  .inline-fields,
  .manual-customer-actions {
    grid-template-columns: 1fr;
  }

  .manual-customer-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .remark-editor {
    grid-template-columns: 1fr;
    padding: 10px 12px;
  }

  .modal-chat-thread {
    height: auto;
  }
}
