/* Limitless SMS: brand palette only (red, black, white, light grey) plus grey tints for hierarchy */
:root {
  --red: #EC1D23;
  --red-soft: #FDE8E9;
  --black: #000000;
  --white: #FFFFFF;
  --grey: #EEEEEE;
  --grey-2: #E5E5E5;
  --ink-2: #777777;
  --ink-3: #8C8C8C;
  --radius-s: 8px;
  --radius-l: 16px;
  /* Same stack the hub and the other tools use */
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --page: #F7F7F7;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 24px rgba(0, 0, 0, 0.06);
  --step--1: 0.8125rem;
  --step-0: 0.9375rem;
  --step-1: 1.125rem;
  --step-2: 1.5rem;
  --step-3: 2.25rem;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 400 var(--step-0)/1.5 var(--font); color: var(--black); background: var(--page); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--white); color: var(--black); border-right: 1px solid var(--grey-2); padding: 22px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 2px 10px 22px; }
.brand img { height: 26px; width: auto; }
.brand .divider { width: 1px; height: 22px; background: var(--grey-2); }
.brand span { font-size: 11px; font-weight: 700; color: var(--red); letter-spacing: 0.5px; text-transform: uppercase; }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; border-radius: 999px; text-decoration: none; color: var(--ink-2); font-weight: 600; }
.nav a:hover { color: var(--black); background: var(--page); }
.nav a.on { color: var(--white); background: var(--red); }
.nav .badge { background: var(--red); color: var(--white); border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.nav a.on .badge { background: var(--white); color: var(--red); }
.nav hr { border: 0; border-top: 1px solid var(--grey-2); margin: 12px 4px; }
.side .me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--grey-2); font-size: var(--step--1); color: var(--ink-3); }
.side .me strong { display: block; color: var(--black); font-weight: 600; }
.side .me button { background: none; border: 0; color: var(--ink-3); padding: 0; margin-top: 6px; cursor: pointer; text-decoration: underline; }
.topbar { display: none; }
main { padding: 28px clamp(16px, 3vw, 40px) 60px; min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
h1 { font-size: var(--step-3); line-height: 1.05; letter-spacing: -0.035em; font-weight: 800; margin: 0; }
h2 { font-size: var(--step-1); font-weight: 700; letter-spacing: -0.01em; margin: 0 0 12px; }
h3 { font-size: var(--step-0); font-weight: 700; margin: 0 0 8px; }
.lede { color: var(--ink-2); margin: 6px 0 0; max-width: 62ch; }
.muted { color: var(--ink-2); }
.small { font-size: var(--step--1); }

/* ---------- surfaces ---------- */
.panel { background: var(--white); border: 1px solid var(--grey-2); border-radius: var(--radius-l); padding: 22px; box-shadow: var(--shadow); }
.panel.flat { background: var(--white); border-color: var(--grey-2); box-shadow: none; }
.grid { display: grid; gap: 18px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

/* ---------- stats ---------- */
.target { display: grid; grid-template-columns: auto 1fr; gap: 6px 24px; align-items: end; }
.target .big { font-size: clamp(3rem, 7vw, 5.25rem); font-weight: 800; letter-spacing: -0.05em; line-height: 0.9; font-variant-numeric: tabular-nums; }
.target .of { color: var(--ink-2); padding-bottom: 8px; }
.bar { height: 10px; background: var(--grey); border-radius: 999px; overflow: hidden; grid-column: 1 / -1; }
.bar i { display: block; height: 100%; background: var(--red); border-radius: 999px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--grey-2); margin-top: 22px; }
.kpis div { padding: 14px 14px 0 0; }
.kpis div + div { padding-left: 14px; border-left: 1px solid var(--grey-2); }
.kpis b { display: block; font-size: var(--step-2); font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.kpis span { color: var(--ink-2); font-size: var(--step--1); }
.weeks { display: flex; align-items: flex-end; gap: 8px; height: 120px; padding-top: 8px; }
.weeks div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; font-size: 11px; color: var(--ink-3); }
.weeks i { width: 100%; background: var(--black); border-radius: 4px 4px 0 0; min-height: 2px; }
.weeks div:last-child i { background: var(--red); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--grey-2); border-radius: var(--radius-l); }
table { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
th { text-align: left; font-weight: 600; color: var(--ink-2); padding: 10px 12px; border-bottom: 1px solid var(--grey-2); white-space: nowrap; background: var(--white); position: sticky; top: 0; }
td { padding: 10px 12px; border-bottom: 1px solid var(--grey); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #F7F7F7; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- chips ---------- */
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--grey); font-size: 12px; line-height: 1.5; white-space: nowrap; margin: 0 4px 2px 0; }
.chip.hot, .chip.warm, .chip.pending, .chip.failed { background: var(--red-soft); color: #B3141A; }
.chip.approved, .chip.sent, .chip.delivered, .chip.done { background: var(--black); color: var(--white); }
.chip.outline { background: none; border: 1px solid var(--grey-2); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--red); margin-right: 6px; }

/* ---------- forms ---------- */
label { display: block; font-size: var(--step--1); font-weight: 600; margin-bottom: 5px; }
label .hint { font-weight: 400; color: var(--ink-3); }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=date], input[type=datetime-local], input[type=time], input[type=search], input[type=url], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--grey-2); border-radius: var(--radius-s); background: var(--white); min-height: 40px;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--black); box-shadow: 0 0 0 3px var(--grey); }
.field { margin-bottom: 14px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-weight: 400; font-size: var(--step-0); margin: 0 14px 8px 0; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--red); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pills label { margin: 0; font-weight: 400; font-size: var(--step--1); }
.pills input { position: absolute; opacity: 0; pointer-events: none; }
.pills span { display: inline-block; padding: 6px 12px; border: 1px solid var(--grey-2); border-radius: 999px; cursor: pointer; user-select: none; }
.pills input:checked + span { background: var(--black); border-color: var(--black); color: var(--white); }
.pills input:focus-visible + span { outline: 2px solid var(--red); outline-offset: 2px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 10px 20px; border-radius: 999px; border: 1px solid var(--grey-2); background: var(--white); cursor: pointer; font-weight: 600; text-decoration: none; white-space: nowrap; transition: all 0.15s; }
.btn:hover { background: #F7F7F7; border-color: #CCCCCC; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); }
.btn.primary { background: var(--red); border-color: var(--red); color: var(--white); }
.btn.primary:hover { background: #C8161B; border-color: #C8161B; }
.btn.dark { background: var(--black); border-color: var(--black); color: var(--white); }
.btn.dark:hover { background: #262626; border-color: #262626; }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--grey); }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: var(--step--1); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; color: var(--black); text-decoration: underline; cursor: pointer; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--grey-2); margin-bottom: 20px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--ink-2); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--black); border-color: var(--red); }

.notice { padding: 12px 14px; border-radius: var(--radius-s); background: var(--grey); font-size: var(--step--1); }
.notice.warn { background: var(--red-soft); color: #7A0A0E; }
.notice ul { margin: 4px 0 0; padding-left: 18px; }
.empty { text-align: center; padding: 48px 16px; color: var(--ink-2); }
.empty h3 { color: var(--black); }

/* ---------- phone preview (the one bold element) ---------- */
.phone { width: 300px; max-width: 100%; margin: 0 auto; border: 10px solid var(--black); border-radius: 38px; background: var(--white); padding: 18px 12px 22px; position: sticky; top: 24px; }
.phone .notch { width: 90px; height: 20px; background: var(--black); border-radius: 0 0 12px 12px; margin: -18px auto 14px; }
.phone .who { text-align: center; font-size: 12px; color: var(--ink-3); margin-bottom: 14px; }
.phone .who b { display: block; color: var(--black); font-size: 13px; }
.bubble { background: var(--grey); border-radius: 18px 18px 18px 4px; padding: 10px 13px; white-space: pre-wrap; word-wrap: break-word; font-size: 14px; line-height: 1.38; max-width: 92%; }
.bubble.me { background: var(--red); color: var(--white); border-radius: 18px 18px 4px 18px; margin-left: auto; }
.meter { margin-top: 16px; font-size: 12px; }
.meter .segs { display: flex; gap: 4px; margin-top: 6px; }
.meter .segs i { flex: 1; height: 6px; border-radius: 3px; background: var(--grey); }
.meter .segs i.full { background: var(--black); }
.meter .segs i.over { background: var(--red); }

/* ---------- inbox ---------- */
.inbox { display: grid; grid-template-columns: 320px 1fr; border: 1px solid var(--grey-2); border-radius: var(--radius-l); overflow: hidden; height: calc(100vh - 170px); min-height: 460px; }
.threads { border-right: 1px solid var(--grey-2); overflow-y: auto; }
.thread { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 13px 16px; border-bottom: 1px solid var(--grey); cursor: pointer; }
.thread:hover { background: #F7F7F7; }
.thread.on { background: var(--grey); }
.thread .t-top { display: flex; justify-content: space-between; gap: 8px; }
.thread .t-name { font-weight: 700; }
.thread .t-msg { color: var(--ink-2); font-size: var(--step--1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo { display: flex; flex-direction: column; min-width: 0; }
.convo-head { padding: 14px 18px; border-bottom: 1px solid var(--grey-2); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.msgs .meta { font-size: 11px; color: var(--ink-3); margin-top: 3px; }
.msgs .in { align-self: flex-start; max-width: 78%; }
.msgs .out { align-self: flex-end; max-width: 78%; text-align: right; }
.msgs .out .bubble { margin-left: auto; text-align: left; }
.compose { border-top: 1px solid var(--grey-2); padding: 12px; display: flex; gap: 8px; }
.compose textarea { min-height: 44px; height: 44px; }

/* ---------- drawer / modal / toast ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--white); z-index: 41; overflow-y: auto; padding: 24px; animation: slide 180ms ease-out; }
.drawer .close { position: absolute; top: 16px; right: 16px; }
@keyframes slide { from { transform: translateX(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--black); color: var(--white); padding: 11px 18px; border-radius: 999px; z-index: 60; font-size: var(--step--1); max-width: 90vw; }
.toast.err { background: var(--red); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login .art { background: var(--black); color: var(--white); padding: clamp(28px, 6vw, 72px); display: flex; flex-direction: column; justify-content: space-between; }
.login .art p { font-size: clamp(2rem, 4.2vw, 3.6rem); font-weight: 800; line-height: 0.98; letter-spacing: -0.045em; margin: 0; max-width: 11ch; }
.login .art .bubble { background: #1C1C1C; color: var(--white); max-width: 340px; font-size: 15px; }
.login .art .bubble.me { background: var(--red); }
.login form { align-self: center; justify-self: center; width: min(360px, 88vw); padding: 24px 0; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .split { grid-template-columns: 1fr; }
  .cols-3 { grid-template-columns: 1fr 1fr; }
  .phone { position: static; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 50; transform: translateX(-100%); transition: transform 180ms; }
  .side.open { transform: none; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--black); color: var(--white); position: sticky; top: 0; z-index: 30; }
  .topbar .brand { padding: 0; }
  .topbar button { background: none; border: 1px solid #333; color: var(--white); border-radius: var(--radius-s); padding: 6px 10px; }
  main { padding-top: 18px; }
  h1 { font-size: var(--step-2); }
  .cols-2, .cols-3, .fields { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpis div:nth-child(3) { border-left: 0; padding-left: 0; }
  .inbox { grid-template-columns: 1fr; height: auto; }
  .inbox.viewing .threads { display: none; }
  .inbox:not(.viewing) .convo { display: none; }
  .msgs { min-height: 50vh; }
  .login { grid-template-columns: 1fr; }
  .login .art { min-height: 38vh; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
