/* textdesk — a sending console. The numbers on these screens decide whether
   to keep sending or stop, so they get the weight and the space. */

:root {
  --paper:  #FAFAF8;
  --panel:  #FFFFFF;
  --ink:    #17202A;
  --body:   #3F4C5A;
  --muted:  #6C7884;
  --rule:   #DEE3E8;
  --hover:  #F3F5F7;

  --go:     #1F6F52;
  --wait:   #B0700F;
  --stop:   #A63328;
  --idle:   #A9B2BB;

  --sans: ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--body);
  font: 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--mono); font-size: .88em; font-variant-numeric: tabular-nums; }
.legal { color: var(--muted); font-size: .84em; }
.empty { color: var(--muted); padding: 2rem 0; }
.warn { color: var(--wait); }
code { font-family: var(--mono); font-size: .85em; background: var(--hover);
       padding: .1rem .3rem; border-radius: 2px; }

a { color: var(--go); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--go); outline-offset: 2px; }

h1 { font-size: 1.35rem; font-weight: 600; margin: 0; color: var(--ink); letter-spacing: -.015em; }

/* --- chrome ------------------------------------------------------------- */

.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0 1.25rem; height: 52px;
  background: var(--panel); border-bottom: 1px solid var(--rule);
}
.wordmark { color: var(--ink); font-weight: 600; letter-spacing: -.02em; }
.topbar nav { flex: 1; display: flex; gap: 1.25rem; }
.topbar nav a { color: var(--muted); }
.topbar nav a:hover { color: var(--ink); text-decoration: none; }

button, .btn {
  font: inherit; font-size: .95rem;
  padding: .45rem 1rem;
  border: 1px solid var(--rule); border-radius: 3px;
  background: var(--panel); color: var(--ink);
  cursor: pointer; display: inline-block;
}
button:hover, .btn:hover { border-color: var(--muted); text-decoration: none; }
button.quiet { border-color: transparent; color: var(--muted); }

main { padding: 1.5rem 1.25rem 4rem; max-width: 1100px; }

.notice { border-left: 3px solid var(--go); background: var(--panel);
          padding: .75rem 1rem; margin-bottom: 1.25rem; }
.notice p { margin: 0; }

.pagehead { display: flex; align-items: center; justify-content: space-between;
            gap: 1rem; margin-bottom: .5rem; flex-wrap: wrap; }
.pagehead .actions { display: flex; gap: .5rem; }
.meta { color: var(--muted); margin: 0 0 1.25rem; }
.back { display: inline-block; color: var(--muted); margin-bottom: 1rem; }
.section { font-size: .8em; font-weight: 500; color: var(--muted); text-transform: none;
           border-bottom: 1px solid var(--rule); padding-bottom: .35rem; margin: 2.25rem 0 1rem; }

/* --- sign in ------------------------------------------------------------ */

.signin { max-width: 21rem; margin: 5rem auto; }
.signin h1 { margin-bottom: 1.5rem; }
.signin label { display: block; font-size: .85em; color: var(--muted); margin-bottom: .3rem; }
.signin input { width: 100%; font: inherit; padding: .5rem .65rem; margin-bottom: 1rem;
                border: 1px solid var(--rule); border-radius: 3px; background: var(--panel); }
.signin button { width: 100%; }

/* --- tables ------------------------------------------------------------- */

.ledger { width: 100%; border-collapse: collapse; background: var(--panel); }
.ledger th { text-align: left; font-size: .78em; font-weight: 500; color: var(--muted);
             padding: .5rem .75rem; border-bottom: 1px solid var(--rule); }
.ledger td { padding: .45rem .75rem; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
.ledger .num { text-align: right; }
.ledger tbody tr:hover td { background: var(--hover); }
.ledger td .legal { display: block; }

.ledger tbody tr td:first-child { border-left: 3px solid transparent; }
.st-sending td:first-child { border-left-color: var(--go); }
.st-queued  td:first-child { border-left-color: var(--wait); }
.st-paused  td:first-child { border-left-color: var(--wait); }
.st-done    td:first-child { border-left-color: var(--idle); }
.st-canceled td:first-child { border-left-color: var(--stop); }
.st-draft td, .st-done td, .st-canceled td { color: var(--muted); }

.pager { display: flex; gap: 1.25rem; align-items: center; padding-top: 1rem; color: var(--muted); }

/* --- campaign dashboard -------------------------------------------------- */

.bar { height: 5px; background: var(--rule); border-radius: 3px; overflow: hidden; margin-bottom: 1.5rem; }
.bar .fill { height: 100%; background: var(--go); transition: width .4s ease; }

/* The six numbers that decide whether to keep sending. */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
         gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 3px; }
.stats > div { background: var(--panel); padding: .9rem 1rem; }
.stats .n { display: block; font-size: 1.45rem; color: var(--ink); line-height: 1.2; }
.stats .k { display: block; font-size: .78em; color: var(--muted); margin-top: .15rem; }

.alarm { border-left: 3px solid var(--stop); background: var(--panel);
         padding: .9rem 1.1rem; margin-top: 1.25rem; color: var(--ink); }

.preview { background: var(--panel); border: 1px solid var(--rule); border-radius: 3px;
           padding: 1rem 1.15rem; max-width: 42ch; white-space: pre-wrap;
           overflow-wrap: anywhere; margin-bottom: .5rem; }

.reply { border-left: 2px solid var(--rule); padding: 0 0 .85rem .9rem; }
.reply .stamp { color: var(--muted); margin: 0 0 .15rem; }
.reply .body { margin: 0; max-width: 60ch; }

/* --- forms -------------------------------------------------------------- */

.stacked { max-width: 34rem; }
.stacked label { display: block; font-size: .87em; color: var(--ink); font-weight: 500; margin: 1.15rem 0 .3rem; }
.stacked input[type=text], .stacked input[type=email], .stacked input[type=number],
.stacked input[type=time], .stacked input[type=file], .stacked select, .stacked textarea,
.stacked input:not([type]) {
  width: 100%; font: inherit; padding: .5rem .65rem;
  border: 1px solid var(--rule); border-radius: 3px; background: var(--panel); color: var(--ink);
}
.stacked textarea { resize: vertical; font-family: var(--mono); font-size: .92rem; line-height: 1.55; }
.stacked .inline { display: flex; align-items: center; gap: .6rem; }
.stacked .inline input { width: auto; }
.stacked label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
.stacked label.check input { width: auto; }
.stacked button[type=submit] { margin-top: 1.5rem; }
.stacked p.legal { margin: .4rem 0 0; }

/* The live cost readout under the composer. Segments are what you're billed
   for, so the number appears before the send, not on the invoice. */
.meter {
  background: var(--panel); border: 1px solid var(--rule); border-left: 3px solid var(--go);
  border-radius: 3px; padding: .7rem .9rem; margin-top: .9rem;
  font-size: .9rem; color: var(--body);
}
.meter strong { color: var(--ink); font-family: var(--mono); }

@media (max-width: 720px) {
  main { padding: 1rem .75rem 3rem; }
  .topbar { gap: .75rem; padding: 0 .75rem; }
  .topbar nav { gap: .85rem; font-size: .92rem; }
  .ledger th:nth-child(n+5), .ledger td:nth-child(n+5) { display: none; }
}

/* --- dashboard chart ------------------------------------------------------ */

/* Full bar is sent, inner bar is delivered. The gap between them is the
   signal — it widens before anything else tells you carriers are filtering. */
.spark { display: flex; align-items: flex-end; gap: 2px; height: 120px;
         background: var(--panel); border: 1px solid var(--rule); border-radius: 3px;
         padding: .75rem; margin-bottom: .5rem; }
.spark .col { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.spark .sent { width: 100%; background: var(--rule); border-radius: 1px;
               display: flex; align-items: flex-end; min-height: 2px; }
.spark .delivered { width: 100%; background: var(--go); border-radius: 1px; }
.ledger .bad { color: var(--stop); }

/* --- inbox ---------------------------------------------------------------- */

.threads { border: 1px solid var(--rule); border-radius: 3px; overflow: hidden; }
.thread { display: grid; grid-template-columns: 14rem 1fr auto; gap: 1rem;
          align-items: baseline; padding: .7rem .9rem; background: var(--panel);
          border-bottom: 1px solid var(--rule); color: var(--body); }
.thread:last-child { border-bottom: 0; }
.thread:hover { background: var(--hover); text-decoration: none; }
.thread.unread { border-left: 3px solid var(--go); }
.thread.unread .preview { color: var(--ink); font-weight: 500; }
.thread .who .name { display: block; color: var(--ink); font-weight: 500; }
.thread .preview { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.thread-view { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1.5rem; }
.bubble { max-width: 34rem; padding: .6rem .85rem; border-radius: 10px; }
.bubble .text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .stamp { margin: .3rem 0 0; font-size: .78em; }
.bubble.inbound { background: var(--panel); border: 1px solid var(--rule);
                  align-self: flex-start; border-bottom-left-radius: 3px; }
.bubble.inbound .stamp { color: var(--muted); }
.bubble.outbound { background: var(--go); color: #fff; align-self: flex-end;
                   border-bottom-right-radius: 3px; }
.bubble.outbound .stamp { color: rgba(255,255,255,.75); }
.bubble.outbound .warn { color: #FFD79A; }

.softwarn { border-left: 3px solid var(--wait); background: var(--panel);
            padding: .85rem 1.05rem; margin-bottom: .75rem; max-width: 40rem; }
.softwarn strong { color: var(--ink); }

.replybox { max-width: 40rem; }
.replybox textarea { width: 100%; font: inherit; padding: .65rem .8rem;
                     border: 1px solid var(--rule); border-radius: 3px;
                     background: var(--panel); color: var(--ink); resize: vertical; }
.replyfoot { display: flex; align-items: center; justify-content: space-between;
             margin-top: .6rem; }
.replyfoot .check { display: flex; align-items: center; gap: .45rem;
                    font-size: .88rem; color: var(--wait); }

/* --- contact record ------------------------------------------------------- */

.cols { display: grid; grid-template-columns: minmax(0, 24rem) minmax(0, 1fr);
        gap: 2.5rem; align-items: start; }
.cols .stacked { max-width: none; }
.inline2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.inline3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: .75rem; }
.facts { display: grid; grid-template-columns: 6.5rem 1fr; gap: .35rem .75rem; margin: 0 0 1.25rem; }
.facts dt { color: var(--muted); font-size: .87em; }
.facts dd { margin: 0; font-size: .93em; }

.event { border-left: 2px solid var(--rule); padding: 0 0 .85rem .9rem; }
.event.outbound { border-left-color: var(--go); }
.event .stamp { color: var(--muted); margin: 0 0 .15rem; font-size: .8em; }
.event .body { margin: 0; max-width: 58ch; white-space: pre-wrap; overflow-wrap: anywhere; }

/* --- api keys ------------------------------------------------------------- */

.newkey { border-left: 3px solid var(--wait); background: var(--panel);
          padding: 1rem 1.2rem; margin-bottom: 1.5rem; }
.newkey p { margin: 0 0 .6rem; }
.keyval { display: block; font-family: var(--mono); font-size: .9rem;
          background: var(--hover); padding: .6rem .75rem; border-radius: 3px;
          overflow-wrap: anywhere; user-select: all; }

.filters { display: flex; gap: .5rem; margin-bottom: 1.25rem; }
.filters input { flex: 1; font: inherit; padding: .45rem .65rem;
                 border: 1px solid var(--rule); border-radius: 3px; background: var(--panel); }

@media (max-width: 860px) {
  .cols { grid-template-columns: 1fr; gap: 1.75rem; }
  .thread { grid-template-columns: 1fr; gap: .2rem; }
  .thread .when { display: none; }
}
