/* ===== Relay — design tokens ===== */
:root {
  --navy-950: #0a1c29;
  --navy-900: #0f2a3d;
  --navy-800: #16394f;
  --navy-700: #204a63;
  --teal-500: #1fa97f;
  --teal-400: #35c79a;
  --teal-050: #e8f7f1;
  --bg: #f4f7f6;
  --surface: #ffffff;
  --ink-900: #0f2027;
  --ink-700: #33474f;
  --ink-500: #5c727a;
  --ink-300: #8ea0a6;
  --border: #dfe7e5;
  --border-strong: #c7d3d1;
  --amber: #d9922f;
  --amber-bg: #fbf1de;
  --red: #cf5b52;
  --red-bg: #fbe9e7;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 1px 2px rgba(15, 32, 39, 0.06), 0 1px 1px rgba(15, 32, 39, 0.04);
  --font-ui: "Manrope", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink-900);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
:focus-visible { outline: 2px solid var(--teal-500); outline-offset: 2px; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }

/* ===== Login ===== */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 880px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-aside { display: none; }
}
.login-aside {
  background: linear-gradient(165deg, var(--navy-950), var(--navy-800));
  color: #eef5f3;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-aside .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; }
.login-aside .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--teal-400); }
.login-aside .pitch { max-width: 420px; }
.login-aside .pitch h1 { font-size: 34px; line-height: 1.2; font-weight: 700; }
.login-aside .pitch p { margin-top: 14px; color: #b9cdc7; font-size: 15px; line-height: 1.6; }
.login-aside .foot { font-family: var(--font-mono); font-size: 12px; color: #7d9891; }

.login-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}
.login-card { width: 100%; max-width: 360px; }
.login-card .brand-mobile { display: none; font-weight: 800; font-size: 18px; margin-bottom: 28px; }
@media (max-width: 880px) {
  .login-card .brand-mobile { display: flex; align-items: center; gap: 8px; }
  .login-card .brand-mobile .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--teal-500); }
}
.login-card h2 { font-size: 22px; }
.login-card .sub { color: var(--ink-500); font-size: 14px; margin-top: 6px; }
.field { margin-top: 20px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-700); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  font-size: 14px;
  background: var(--surface);
}
.field input:focus-visible { outline-offset: 0; border-color: var(--teal-500); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 700;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn-primary { background: var(--teal-500); color: #fff; }
.btn-primary:hover { background: var(--teal-400); }
.btn-block { width: 100%; margin-top: 22px; }
.btn-ghost { background: transparent; color: var(--ink-700); border-color: var(--border-strong); }
.btn-ghost:hover { border-color: var(--ink-500); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.error-msg {
  margin-top: 16px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--red-bg); color: #9c3c34; font-size: 13px; display: none;
}
.error-msg.show { display: block; }
.demo-hint {
  margin-top: 26px; padding: 14px; border-radius: var(--radius-md);
  background: var(--teal-050); font-size: 12.5px; color: var(--ink-700); line-height: 1.7;
}
.demo-hint b { font-family: var(--font-mono); background: #fff; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border); }

/* ===== Dashboard shell ===== */
.app-shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
@media (max-width: 860px) { .app-shell { grid-template-columns: 0 1fr; } .sidebar { display: none; } }

.sidebar {
  background: var(--navy-900);
  color: #d9e6e2;
  padding: 18px 12px 16px;
  display: flex;
  flex-direction: column;
}
.sidebar .brand { display: flex; align-items: center; gap: 9px; padding: 8px 10px 18px; font-weight: 800; font-size: 17px; color: #fff; }
.sidebar .brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--teal-400); }
.workspace-pill {
  margin: 0 4px 14px; padding: 9px 11px; border-radius: var(--radius-sm);
  background: var(--navy-800); font-size: 12.5px; color: #a9c1bb;
  display: flex; align-items: center; gap: 8px;
}
.workspace-pill .avatar {
  width: 22px; height: 22px; border-radius: 6px; background: var(--teal-500);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.nav-group { margin-top: 6px; }
.nav-label { font-size: 10.5px; letter-spacing: 0.06em; color: #6f8a83; padding: 10px 12px 6px; font-weight: 700; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; color: #bfd3ce; margin-bottom: 2px;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.85; }
.nav-item:hover { background: var(--navy-800); color: #fff; }
.nav-item.active { background: var(--teal-500); color: #fff; }
.nav-item.active svg { opacity: 1; }
.nav-item .badge-count {
  margin-left: auto; font-family: var(--font-mono); font-size: 10.5px; background: rgba(255,255,255,0.16);
  padding: 1px 6px; border-radius: 20px;
}
.sidebar-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--navy-800); }

.main-col { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px; flex-shrink: 0; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
}
.topbar h1 { font-size: 17px; }
.topbar .topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar .user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-700); }
.topbar .user-chip .av { width: 26px; height: 26px; border-radius: 50%; background: var(--navy-800); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }

.view-root { padding: 26px 28px 60px; overflow-y: auto; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.view-head h2 { font-size: 21px; }
.view-head .desc { color: var(--ink-500); font-size: 13.5px; margin-top: 4px; }

/* ===== Cards / KPIs / grid ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
@media (max-width: 720px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px; }
.kpi-card .label { font-size: 12px; color: var(--ink-500); font-weight: 600; }
.kpi-card .value { font-size: 25px; font-weight: 800; margin-top: 6px; }
.kpi-card .delta { font-size: 12px; margin-top: 6px; font-weight: 700; }
.kpi-card .delta.up { color: var(--teal-500); }
.kpi-card .delta.down { color: var(--red); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-card); }
.card-head { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-head h3 { font-size: 14.5px; }
.card-body { padding: 18px; }

.chart-bars { display: flex; align-items: flex-end; gap: 8px; height: 140px; padding: 18px; }
.chart-bars .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.chart-bars .bar { width: 100%; background: var(--teal-500); border-radius: 4px 4px 0 0; opacity: 0.85; }
.chart-bars .bar-col:hover .bar { opacity: 1; }
.chart-bars .lbl { font-size: 10.5px; color: var(--ink-300); font-family: var(--font-mono); }

/* ===== Table ===== */
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th { text-align: left; font-size: 11.5px; text-transform: none; color: var(--ink-500); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--ink-700); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafcfb; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.badge-teal { background: var(--teal-050); color: #157a5c; }
.badge-amber { background: var(--amber-bg); color: #96650f; }
.badge-red { background: var(--red-bg); color: #9c3c34; }
.badge-gray { background: #eef1f0; color: var(--ink-500); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ===== Inbox ===== */
.inbox-grid { display: grid; grid-template-columns: 300px 1fr 260px; gap: 0; height: calc(100vh - 172px); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; background: var(--surface); }
@media (max-width: 1100px) { .inbox-grid { grid-template-columns: 260px 1fr; } .thread-info { display: none; } }
.conv-list { border-right: 1px solid var(--border); overflow-y: auto; }
.conv-search { padding: 12px; border-bottom: 1px solid var(--border); }
.conv-search input { width: 100%; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); font-size: 13px; }
.conv-item { padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; gap: 10px; }
.conv-item:hover { background: #f8faf9; }
.conv-item.active { background: var(--teal-050); }
.conv-item .av { width: 34px; height: 34px; border-radius: 50%; background: var(--navy-800); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.conv-item .meta { min-width: 0; flex: 1; }
.conv-item .row1 { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; }
.conv-item .row1 time { font-weight: 500; font-size: 11px; color: var(--ink-300); font-family: var(--font-mono); }
.conv-item .snippet { font-size: 12px; color: var(--ink-500); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chan-tag { font-size: 9.5px; font-weight: 700; padding: 1px 6px; border-radius: 20px; margin-top: 5px; display: inline-block; }
.chan-whatsapp { background: #e6f6ec; color: #1f8a4c; }
.chan-widget { background: #eaf1fb; color: #2b5fa8; }

.thread { display: flex; flex-direction: column; min-width: 0; }
.thread-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.thread-head .av { width: 32px; height: 32px; border-radius: 50%; background: var(--navy-800); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.thread-body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 68%; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.5; }
.msg.in { background: #eef2f1; align-self: flex-start; border-bottom-left-radius: 3px; }
.msg.out { background: var(--teal-500); color: #fff; align-self: flex-end; border-bottom-right-radius: 3px; }
.msg time { display: block; font-size: 10px; margin-top: 4px; opacity: 0.6; font-family: var(--font-mono); }
.thread-compose { border-top: 1px solid var(--border); padding: 12px 14px; display: flex; gap: 8px; }
.thread-compose input { flex: 1; padding: 10px 12px; border-radius: 20px; border: 1px solid var(--border-strong); font-size: 13.5px; }
.thread-info { border-left: 1px solid var(--border); padding: 18px; font-size: 13px; }
.thread-info h4 { font-size: 12px; color: var(--ink-500); margin-bottom: 10px; }
.thread-info .info-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--ink-300); }
.empty-state svg { width: 36px; height: 36px; margin-bottom: 10px; opacity: 0.6; }

/* ===== Forms / settings ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }
.form-row label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-700); margin-bottom: 6px; }
.form-row .hint { font-size: 11.5px; color: var(--ink-500); margin-top: 5px; }
.form-row input[type=text], .form-row input[type=number], .form-row select, .form-row textarea {
  width: 100%; padding: 9px 11px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); font-size: 13.5px; background: #fff;
}
.form-row textarea { resize: vertical; min-height: 70px; font-family: var(--font-ui); }
.swatches { display: flex; gap: 8px; margin-top: 4px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.swatch.selected { border-color: var(--ink-900); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.toggle-row:last-child { border-bottom: none; }
.toggle-row .tlabel { font-size: 13.5px; font-weight: 600; }
.toggle-row .tsub { font-size: 12px; color: var(--ink-500); margin-top: 2px; }
.switch { width: 38px; height: 22px; border-radius: 20px; background: var(--border-strong); position: relative; flex-shrink: 0; transition: background 0.15s; }
.switch.on { background: var(--teal-500); }
.switch .knob { width: 18px; height: 18px; border-radius: 50%; background: #fff; position: absolute; top: 2px; left: 2px; transition: left 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,0.25); }
.switch.on .knob { left: 18px; }

.code-block {
  background: var(--navy-950); color: #cfe7df; font-family: var(--font-mono); font-size: 12.3px;
  padding: 14px 16px; border-radius: var(--radius-sm); overflow-x: auto; line-height: 1.7; white-space: pre;
}
.copy-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.copy-row .copy-hint { font-size: 11.5px; color: var(--ink-500); }

/* ===== Widget preview ===== */
.widget-preview-frame {
  background: #eef2f4; border: 1px solid var(--border); border-radius: var(--radius-md);
  height: 460px; position: relative; overflow: hidden; background-image: radial-gradient(circle at 30% 20%, #f6f9f8, #e7edec);
}
.widget-preview-frame .fake-page { position: absolute; inset: 16px 16px auto 16px; }
.widget-preview-frame .fake-line { height: 8px; background: #d8e0de; border-radius: 4px; margin-bottom: 8px; }
.widget-preview-frame .fake-line.w60 { width: 60%; }
.widget-preview-frame .fake-line.w80 { width: 80%; }
.widget-preview-frame .fake-line.w40 { width: 40%; }

.wchat-bubble {
  position: absolute; bottom: 18px; width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: #fff; box-shadow: 0 6px 16px rgba(0,0,0,0.18);
}
.wchat-bubble.pos-right { right: 18px; }
.wchat-bubble.pos-left { left: 18px; }
.wchat-bubble svg { width: 24px; height: 24px; }

.wchat-panel {
  position: absolute; bottom: 84px; width: 240px; border-radius: 14px; overflow: hidden;
  box-shadow: 0 14px 30px rgba(10,28,41,0.22); background: #fff;
}
.wchat-panel.pos-right { right: 18px; }
.wchat-panel.pos-left { left: 18px; }
.wchat-panel .whead { color: #fff; padding: 12px 14px; font-size: 12.5px; font-weight: 700; }
.wchat-panel .wbody { padding: 12px 14px; background: #f6f8f7; min-height: 70px; }
.wchat-panel .wgreet { background: #fff; border-radius: 10px; border-bottom-left-radius: 3px; padding: 8px 10px; font-size: 12px; line-height: 1.5; box-shadow: 0 1px 2px rgba(0,0,0,0.06); max-width: 90%; }
.wchat-panel .winput { padding: 9px 12px; border-top: 1px solid #ececec; font-size: 11.5px; color: var(--ink-300); }

/* ===== Login-style workspace switch banner ===== */
.super-banner {
  background: linear-gradient(120deg, var(--navy-900), var(--navy-800)); color: #dce9e5; border-radius: var(--radius-md);
  padding: 16px 20px; margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; font-size: 13px;
}
.super-banner b { color: #fff; }

.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

.stack-gap { display: flex; flex-direction: column; gap: 16px; }
