:root {
  --bg: #EEF1EC;
  --surface: #FFFFFF;
  --ink: #1C2B2A;
  --muted: #5E6E6A;
  --line: #DCE2DC;
  --pine: #2F6F5E;
  --pine-deep: #1F3B34;
  --amber: #E3B23C;
  --red: #C94A3F;
  --soft: #F6F8F5;
  --radius-sm: 8px;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  font-family: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg);
}
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 4px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 0; font-weight: 650; }
h3 { font-size: 15px; margin: 0; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* buttons + fields */
.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm);
  padding: 8px 14px; cursor: pointer; font-weight: 550; white-space: nowrap;
}
.btn:hover { border-color: #B9C4BB; }
.btn.primary { background: var(--pine); border-color: var(--pine); color: #fff; }
.btn.primary:hover { background: #285F51; }
.btn.danger { color: var(--red); }
a.btn { text-decoration: none; color: var(--ink); display: inline-block; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
label.field, div.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 550; color: var(--muted); }
.input, select.input, textarea.input {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 12px;
  background: var(--surface); font-size: 15px; font-weight: 400; color: var(--ink); width: 100%;
}
.input:focus { border-color: var(--pine); outline: none; box-shadow: 0 0 0 3px rgba(47,111,94,.18); }
.error { color: var(--red); font-size: 14px; min-height: 20px; margin-bottom: 12px; }

/* auth screens */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.auth-mark { width: 44px; height: 44px; border-radius: 14px 14px 14px 4px; background: var(--pine); display: grid; place-items: center; color: #fff; margin-bottom: 6px; }

/* app shell */
.shell { display: grid; grid-template-columns: 220px 1fr; height: 100%; }
.rail { background: var(--pine-deep); color: #D9E5DF; display: flex; flex-direction: column; padding: 18px 12px; gap: 4px; }
.rail .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: #fff; padding: 4px 8px 20px; }
.rail .brand .auth-mark { width: 30px; height: 30px; margin: 0; border-radius: 10px 10px 10px 3px; background: #3F8A75; }
.nav { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); border: 0; background: transparent; color: inherit; cursor: pointer; text-align: left; font-weight: 500; }
.nav:hover { background: rgba(255,255,255,.07); }
.nav.active { background: rgba(255,255,255,.13); color: #fff; }
.nav .count { margin-left: auto; background: var(--amber); color: var(--ink); font-size: 12px; font-weight: 700; border-radius: 10px; padding: 0 7px; }
.rail .me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid rgba(255,255,255,.12); font-size: 13px; }
.rail .me strong { display: block; color: #fff; font-weight: 600; }
.rail .me .small { display: block; }
.rail .me button { margin-top: 8px; background: transparent; border: 1px solid rgba(255,255,255,.25); color: #D9E5DF; border-radius: var(--radius-sm); padding: 5px 10px; cursor: pointer; font-size: 13px; }
.main { overflow: auto; min-width: 0; }
.page { max-width: 920px; padding: 32px 36px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }

/* inbox */
.inbox { display: grid; grid-template-columns: 320px 1fr 270px; height: 100%; }
.list { border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.list-head { padding: 18px 16px 10px; display: flex; flex-direction: column; gap: 10px; }
.tabs { display: flex; background: var(--bg); border-radius: var(--radius-sm); padding: 3px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 6px; border-radius: 6px; cursor: pointer; font-weight: 550; color: var(--muted); }
.tabs button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(28,43,42,.12); }
.conv-list { overflow-y: auto; flex: 1; }
.conv { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 12px 16px; cursor: pointer; }
.conv:hover { background: var(--soft); }
.conv.on { background: #E4EEE9; box-shadow: inset 3px 0 0 var(--pine); }
.conv-top { display: flex; align-items: center; gap: 8px; }
.conv-top h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-top time { margin-left: auto; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.conv-prev { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv-meta { display: flex; gap: 6px; margin-top: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; background: var(--surface); }
.chip.warn { border-color: #EBCB7A; background: #FBF3DC; color: #7A5A0B; }
.unread { background: var(--amber); color: var(--ink); font-size: 12px; font-weight: 700; border-radius: 10px; padding: 0 7px; margin-left: auto; }
.pres { width: 8px; height: 8px; border-radius: 50%; background: #B7C1BC; flex-shrink: 0; }
.pres.on { background: #3DBB74; }

.thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg); }
.thread-head p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-head { padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--surface); display: flex; align-items: center; gap: 12px; }
.messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 68%; padding: 9px 13px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.visitor { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.agent { align-self: flex-end; background: var(--pine); color: #fff; border-bottom-right-radius: 4px; }
.bubble-meta { font-size: 12px; color: var(--muted); margin: 8px 4px 0; }
.bubble-meta.right { align-self: flex-end; }
.sys { align-self: center; font-size: 12px; color: var(--muted); padding: 6px 0; }
.typing-line { font-size: 13px; color: var(--muted); padding: 0 20px 6px; min-height: 22px; }
.composer { display: flex; gap: 10px; padding: 12px 16px 16px; background: var(--surface); border-top: 1px solid var(--line); }
.composer textarea { flex: 1; resize: none; min-height: 46px; max-height: 160px; }
.empty { margin: auto; text-align: center; max-width: 320px; padding: 24px; color: var(--muted); display: flex; flex-direction: column; gap: 8px; align-items: center; }

.details { border-left: 1px solid var(--line); background: var(--surface); padding: 20px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.details dl { margin: 0; display: grid; gap: 12px; }
.details dt { font-size: 12px; color: var(--muted); }
.details dd { margin: 0; overflow-wrap: anywhere; }
.page-now { background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.page-now a { color: var(--pine); font-weight: 550; text-decoration: none; }
.page-now a:hover { text-decoration: underline; }

/* domains */
.add-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 8px; }
.domain { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.domain-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.swatch { width: 14px; height: 14px; border-radius: 4px; flex-shrink: 0; }
.domain-body { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 18px; }
.agents { display: flex; flex-direction: column; gap: 6px; }
.agent-opt { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.agent-opt:hover { background: var(--soft); }
.agent-opt input { width: 16px; height: 16px; accent-color: var(--pine); }
.embed { grid-column: 1 / -1; }
.code { position: relative; background: var(--pine-deep); color: #D6ECE3; border-radius: var(--radius-sm); padding: 14px 16px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; overflow-x: auto; white-space: pre; margin-top: 6px; }
.code-actions { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.row { display: flex; gap: 10px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 12px; }
input[type=color].input { padding: 2px; height: 40px; width: 64px; cursor: pointer; }

/* team */
.people { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.person { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.person:last-child { border-bottom: 0; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #DCE9E3; color: var(--pine); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; position: relative; }
.avatar .pres { position: absolute; right: -1px; bottom: -1px; border: 2px solid var(--surface); width: 12px; height: 12px; }
.role { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.add-person { display: grid; grid-template-columns: 1fr 1fr 1fr 140px auto; gap: 10px; align-items: end; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 8px; }


/* presence */
.pres.away { background: var(--amber); }
.presence-line { display: inline-flex; align-items: center; gap: 6px; }
.presence-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.presence-card.on { border-color: #B5DCC5; background: #F1F8F3; }
.presence-card.away { border-color: #EBD7A2; background: #FCF7E8; }
.presence-card .btn { white-space: normal; margin-top: 6px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.presence-title { font-weight: 600; }
.nav .count.live { background: #3DBB74; color: #fff; }
.thread-head .btn { display: inline-flex; align-items: center; gap: 6px; }
.thread-head .btn.back { display: none; }

/* typing + receipts */
.typing-prev { color: var(--pine); font-style: italic; }
.typing-line { min-height: 0; padding: 0 20px; }
.typing-bubble { display: inline-flex; align-items: center; gap: 10px; max-width: 70%; background: var(--surface); border: 1px dashed #B9C4BB; border-radius: 14px; border-bottom-left-radius: 4px; padding: 8px 12px; margin-bottom: 8px; font-size: 14px; }
.typing-bubble .preview { color: var(--muted); font-style: italic; white-space: pre-wrap; overflow-wrap: anywhere; }
.dots { display: inline-flex; gap: 3px; flex-shrink: 0; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: #98A4A1; animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
.receipt { align-self: flex-end; font-size: 12px; color: var(--muted); margin: 2px 4px 0; }
.receipt.seen { color: var(--pine); font-weight: 550; }

/* visitors page */
.page.wide { max-width: 1100px; }
.vlist { display: flex; flex-direction: column; gap: 10px; }
.vrow { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.vrow.gone { opacity: .62; }
.vmain { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.vinfo { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.vpage a { color: var(--pine); text-decoration: none; font-weight: 550; }
.vpage a:hover { text-decoration: underline; }
.vpage { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vactions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.vactions .btn { display: inline-flex; align-items: center; gap: 6px; }
.vcompose { display: flex; gap: 8px; padding: 0 16px 14px 66px; }
.vcompose[hidden] { display: none; }
.chip.ok { border-color: #B5DCC5; background: #EAF6EE; color: #22643F; }
.chip.typing-chip { border-color: #B5DCC5; color: var(--pine); font-style: italic; }
@media (max-width: 760px) {
  .vmain { flex-wrap: wrap; }
  .vactions { width: 100%; justify-content: flex-start; padding-left: 50px; }
  .vcompose { padding-left: 16px; }
}
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; opacity: .7; } }

/* pre-chat form builder */
.fb-section, .save-row { grid-column: 1 / -1; }
.fb-section { border-top: 1px solid var(--line); padding-top: 18px; display: flex; flex-direction: column; gap: 4px; }
.fb { display: grid; grid-template-columns: 1fr 260px; gap: 20px; margin-top: 10px; align-items: start; }
.fb-editor { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.fb-list { display: flex; flex-direction: column; gap: 8px; }
.fb-row { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; background: var(--soft); display: flex; flex-direction: column; gap: 8px; }
.fb-main { display: grid; grid-template-columns: minmax(0, 1fr) 150px auto auto; gap: 8px; align-items: center; }
.fb-kind { font-size: 14px; color: var(--muted); padding: 0 12px; border: 1px dashed var(--line); border-radius: var(--radius-sm); height: 40px; display: flex; align-items: center; background: var(--surface); }
.fb-req { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; white-space: nowrap; }
.fb-req input { width: 16px; height: 16px; accent-color: var(--pine); }
.fb-tools { display: flex; }
.btn.icon { padding: 6px 9px; font-size: 16px; line-height: 1; }
.btn.icon:disabled { opacity: .3; }
.btn.icon.danger { color: var(--red); }
.fb-options { font-weight: 500; }
.fb-adds-wrap { display: flex; flex-direction: column; gap: 6px; }
.fb-adds { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fb-preview { border: 1px solid var(--line); border-radius: var(--radius); background: #F4F6F3; padding: 12px; position: sticky; top: 12px; }
.fb-preview-title { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.fb-mock { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.fb-mock-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); overflow-wrap: anywhere; }
.fb-mock-field b { color: var(--red); }
.fb-mock-input { height: 32px; border: 1px solid var(--line); border-radius: 8px; font-weight: 400; font-size: 13px; padding: 6px 10px; color: #98A4A1; }
.fb-mock-input.tall { height: 52px; }
.save-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 16px; }
.details .contact { display: block; color: var(--pine); }
.answers dl { margin-top: 6px; }
@media (max-width: 900px) {
  .fb { grid-template-columns: 1fr; }
  .fb-preview { position: static; }
}
@media (max-width: 560px) {
  .fb-main { grid-template-columns: 1fr auto; }
  .fb-main > .input:first-child { grid-column: 1 / -1; }
}

/* triggers */
.tg-wrap { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.tg-list { display: flex; flex-direction: column; gap: 10px; }
.tg { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--soft); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.tg.off { opacity: .6; }
.tg-head { display: flex; align-items: center; gap: 10px; }
.tg-name { flex: 1; min-width: 0; font-weight: 600; }
.tg-stat { white-space: nowrap; }
.tg-rule { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.tg-rule select.input { width: auto; }
.tg-page { width: 200px; }
.tg-page[hidden] { display: none; }
.tg-num { width: 80px; }
.switch { position: relative; width: 38px; height: 22px; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: #C4CDC7; border-radius: 999px; transition: background .15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--pine); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 3px solid var(--amber); outline-offset: 2px; }
@media (max-width: 560px) { .tg-head { flex-wrap: wrap; } .tg-stat { order: 5; width: 100%; } .tg-page { width: 100%; } }

/* SMS */
.sms-body { display: flex; flex-direction: column; gap: 12px; }
.sms-body[hidden] { display: none; }
.sms-grid { display: grid; grid-template-columns: 1fr auto; gap: 12px; }
.sms-status { font-size: 13px; border-radius: var(--radius-sm); padding: 8px 12px; }
.sms-status.ok { background: #EAF6EE; color: #22643F; }
.sms-status.test { background: #FBF3DC; color: #6A4F07; }
.chip-btn { padding: 2px 10px; border-radius: 999px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.sms-flag { color: var(--pine); margin-top: 4px; }
@media (max-width: 560px) { .sms-grid { grid-template-columns: 1fr; } }

/* roles: add website, admin picker, team pages */
.add-site { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 14px; margin-bottom: 8px; }
.add-row-fields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.new-admin { display: grid; grid-template-columns: 1fr 1fr 1fr 160px; gap: 10px; background: var(--soft); border: 1px dashed #B9C4BB; border-radius: var(--radius-sm); padding: 12px; }
.new-admin[hidden] { display: none; }
.admin-pick { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.admin-pick select { width: auto; min-width: 170px; }
.domain-head .btn.danger { margin-left: 0; }
.team-group { margin-top: 28px; display: flex; flex-direction: column; gap: 8px; }
.team-group h2 { font-size: 16px; }
.limit { display: flex; align-items: center; gap: 6px; }
.warn-text { color: var(--red); font-weight: 600; }
.role.role-superadmin { background: var(--pine-deep); color: #fff; border-color: var(--pine-deep); }
.role.role-admin { background: #E4EEE9; color: var(--pine); border-color: #B5DCC5; }
.add-person { grid-template-columns: 1fr 1fr 1fr 150px 150px auto; }
.add-person.simple { grid-template-columns: 1fr 1fr 1fr auto; }
.add-person label[hidden] { display: none; }
.quota { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.quota-bar { height: 8px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.quota-bar span { display: block; height: 100%; background: var(--pine); border-radius: 999px; }
.quota.full .quota-bar span { background: var(--amber); }
.quota.full { border-color: #EBD7A2; background: #FCF7E8; }
@media (max-width: 900px) {
  .add-row-fields, .new-admin, .add-person, .add-person.simple { grid-template-columns: 1fr; }
  .domain-head { flex-wrap: wrap; }
  .admin-pick { margin-left: 0; width: 100%; }
}

/* notifications control */
.notif-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.notif-hint { line-height: 1.4; }

/* logout button */
.rail .me button.logout { display: inline-flex; align-items: center; gap: 6px; }

/* phone: the top bar becomes an app-style tab bar (icon above label) */
@media (max-width: 760px) {
  .rail { padding: 4px; gap: 2px; overflow: visible; justify-content: space-between; }
  .rail .brand { display: none; }
  .rail .nav { flex: 1 1 0; min-width: 0; flex-direction: column; gap: 3px; padding: 7px 2px 6px; font-size: 11px; font-weight: 600; text-align: center; position: relative; }
  .rail .nav .count { position: absolute; top: 3px; left: calc(50% + 6px); margin: 0; font-size: 10px; line-height: 16px; padding: 0 5px; }
  .rail .me { flex: 1 1 0; min-width: 0; margin: 0; }
  .rail .me button.logout { width: 100%; flex-direction: column; gap: 3px; padding: 7px 2px 6px; border: 0; border-radius: var(--radius-sm); font-size: 11px; font-weight: 600; color: inherit; }
  .rail .me button.logout:hover { background: rgba(255,255,255,.07); }
}

/* website notifications settings */
.notify-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 10px; align-items: start; }
.leave-steps { display: flex; flex-direction: column; gap: 10px; background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.leave-steps[hidden], .agent-opt[hidden] { display: none; }
.leave-steps ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.leave-steps li .btn { margin-left: 4px; }
.leave-steps code { font-size: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; overflow-wrap: anywhere; }
.ok-text { color: #22643F; font-weight: 600; }
@media (max-width: 900px) { .notify-grid { grid-template-columns: 1fr; } }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; }
#toast.show { opacity: 1; }

.back { display: none; }
@media (max-width: 1100px) {
  .inbox { grid-template-columns: 290px 1fr; }
  .details { display: none; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .rail { flex-direction: row; padding: 8px; overflow-x: auto; align-items: center; }
  .rail .brand { padding: 4px 8px; }
  .rail .brand span { display: none; }
  .rail .me { margin: 0 0 0 auto; border: 0; padding: 0; display: flex; align-items: center; gap: 8px; }
  .rail .me strong, .rail .me .small { display: none; }
  .rail .me button { margin: 0; }
  .inbox { grid-template-columns: 1fr; }
  .inbox.has-active .list { display: none; }
  .inbox:not(.has-active) .thread { display: none; }
  .back, .thread-head .btn.back { display: inline-flex; }
  .page { padding: 20px 16px 40px; }
  .add-row, .add-person, .domain-body { grid-template-columns: 1fr; }
  .bubble { max-width: 85%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ===== SaaS: plan banner, Billing, Business ===== */
.main { display: flex; flex-direction: column; }
.main > .inbox { flex: 1; min-height: 0; height: auto; }
.acct-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 20px; font-size: 14px; border-bottom: 1px solid; flex: none; }
.acct-banner p { flex: 1; min-width: 200px; }
.acct-banner.warn { background: #FBF3DC; border-color: #EBCB7A; color: #6A4F07; }
.acct-banner.bad { background: #FBE9E7; border-color: #EDB8B1; color: #8A2C23; }
.acct-banner.info { background: #E8F1F4; border-color: #B9D3DD; color: #24505F; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.chip.info { border-color: #B9D3DD; background: #E8F1F4; color: #24505F; }
.chip.bad { border-color: #EDB8B1; background: #FBE9E7; color: #8A2C23; }
.add-row-fields.two { grid-template-columns: 1fr 1fr; }
.locked { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: var(--soft); border: 1px dashed #B9C4BB; border-radius: var(--radius-sm); padding: 14px 16px; margin-top: 10px; font-size: 14px; }
.locked p { flex: 1; min-width: 220px; }

.bill-card, .bill-change, .bill-payments { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 14px; }
.bill-card { border-radius: 16px 16px 16px 5px; }
.bill-main { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.bill-price { font-size: 15px; color: var(--muted); margin: 6px 0 2px; }
.bill-price strong { font-size: 28px; color: var(--ink); font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.meters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; border-top: 1px solid var(--line); padding-top: 16px; }
.meter { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.meter-top { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); }
.meter-top strong { color: var(--ink); font-weight: 600; }
.cycle-tabs { max-width: 260px; }
.plan-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.plan-opt { display: flex; gap: 10px; align-items: flex-start; border: 1.5px solid var(--line); border-radius: 12px 12px 12px 4px; padding: 12px 14px; cursor: pointer; }
.plan-opt.on { border-color: var(--pine); background: #F3F8F5; }
.plan-opt input { margin-top: 4px; accent-color: var(--pine); }
.plan-opt-body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.addon-opt { padding-left: 0; align-items: flex-start; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 4px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); }
.table td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.table .num { text-align: right; padding-right: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }

.biz-tabs { max-width: 520px; margin-bottom: 20px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat strong { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.customers { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.cust { border-bottom: 1px solid var(--line); }
.cust:last-child { border-bottom: 0; }
.cust-main { display: grid; grid-template-columns: auto minmax(0, 1.4fr) minmax(0, 1.4fr) auto auto; gap: 14px; align-items: center; padding: 14px 18px; }
.cust-who h3, .cust-who p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cust-plan { display: flex; flex-direction: column; gap: 4px; }
.cust-usage { white-space: nowrap; }
.cust-edit { padding: 4px 18px 18px; display: flex; flex-direction: column; gap: 12px; background: var(--soft); border-top: 1px solid var(--line); }
.cust-edit[hidden] { display: none; }
.cust-edit > .grid-3 { padding-top: 14px; }
.pay-box { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.plan-edit-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 14px; }
.plan-edit .domain-head h2 { font-size: 17px; }
.list-edit { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.list-row { width: 100%; display: flex; gap: 10px; align-items: flex-start; background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
.list-fields { flex: 1; display: grid; grid-template-columns: 1fr 2fr; gap: 10px; min-width: 0; }
@media (max-width: 1000px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .cust-main { grid-template-columns: auto minmax(0, 1fr) auto; }
  .cust-plan { grid-column: 2 / -1; }
  .cust-usage { grid-column: 2; }
}
@media (max-width: 760px) {
  .meters, .grid-2, .grid-3, .grid-4, .list-fields, .add-row-fields.two { grid-template-columns: 1fr; }
  .acct-banner { padding: 10px 16px; }
  .table th:nth-child(4), .table td:nth-child(4) { display: none; }
}
