/* FaxWire — small hand-written stylesheet (no build step). */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5d6877;
  --border: #dde2e8;
  --accent: #0f6b8c;
  --accent-text: #ffffff;
  --ok-bg: #e3f4ea;
  --ok-text: #1d6b3d;
  --warn-bg: #fdf0dc;
  --warn-text: #8a5300;
  --alert-bg: #fde8e8;
  --alert-text: #9b1c1c;
  --outbound-bg: #e4f1f6;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --surface: #1b212a;
    --text: #e6eaf0;
    --muted: #9aa5b4;
    --border: #2c3542;
    --accent: #5bb6d6;
    --accent-text: #0b1218;
    --ok-bg: #173826;
    --ok-text: #8fdcac;
    --warn-bg: #3d2c10;
    --warn-text: #f3c77a;
    --alert-bg: #451c1c;
    --alert-text: #f5aaaa;
    --outbound-bg: #17303a;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font:
    15px/1.5 system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  background: var(--bg);
  color: var(--text);
}
a {
  color: var(--accent);
}
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  overflow-wrap: anywhere;
}
h1 {
  font-size: 1.4rem;
  margin: 0 0 1rem;
}
h2 {
  font-size: 1.1rem;
  margin: 0 0 0.5rem;
}
.muted {
  color: var(--muted);
}

/* top bar */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand {
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
  margin: 0;
}
.topbar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  flex: 1;
}
.topbar nav a {
  text-decoration: none;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}
.topbar nav a[aria-current="page"] {
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.logout {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}
.who {
  font-size: 0.85rem;
}

main {
  max-width: 64rem;
  margin: 0 auto;
  padding: 1.25rem 1rem;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.empty {
  padding: 2rem 0;
  text-align: center;
}
.stack-lg > * + * {
  margin-top: 1.5rem;
}

/* public pages */
body.public {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
}
.narrow {
  max-width: 26rem;
  margin: 0;
}

/* forms */
.stack {
  display: grid;
  gap: 0.85rem;
}
label {
  display: grid;
  gap: 0.3rem;
  font-weight: 500;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
textarea {
  font: inherit;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  width: 100%;
}
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button {
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
}
button.link {
  background: none;
  color: var(--accent);
  padding: 0;
  font-weight: 500;
}
.alert {
  background: var(--alert-bg);
  color: var(--alert-text);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
}
ul.alert {
  padding-left: 1.6rem;
}

/* tables, badges */
.table-wrap {
  overflow-x: auto;
}
table {
  border-collapse: collapse;
  width: 100%;
}
th,
td {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
}
.badge.ok {
  background: var(--ok-bg);
  color: var(--ok-text);
}
.badge.warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}
.health {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.35rem;
}
.webhooks dt {
  font-weight: 600;
  margin-top: 0.5rem;
}
.webhooks dd {
  margin: 0.15rem 0 0;
}

/* HTMX request indicators (htmx's injected CSS is disabled for a strict CSP) */
.htmx-indicator {
  opacity: 0;
  visibility: hidden;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
  visibility: visible;
  transition: opacity 200ms ease-in;
}

/* ---- SMS inbox ---- */
.inbox {
  display: grid;
  grid-template-columns: minmax(14rem, 20rem) 1fr;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 720px) {
  .inbox {
    grid-template-columns: 1fr;
  }
}
.conv-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
}
.conv-list ul {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.25rem;
}
.conv-list li a {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 0.5rem;
  padding: 0.5rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
}
.conv-list li a:hover,
.conv-list li a[aria-current="page"] {
  background: var(--bg);
}
.conv-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}
.conv-time {
  font-size: 0.75rem;
}
.conv-preview {
  grid-column: 1 / -1;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.empty-small {
  margin: 0.75rem 0 0;
}
.button-link {
  display: block;
  text-align: center;
  font-weight: 600;
  padding: 0.5rem;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text);
  text-decoration: none;
}
.thread {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: grid;
  gap: 1rem;
  min-width: 0;
}
.thread-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
}
.thread-head h1 {
  margin: 0;
  overflow-wrap: anywhere;
}
.thread-head p {
  margin: 0.2rem 0 0;
}
.messages {
  display: grid;
  gap: 0.5rem;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 0.25rem;
}
.bubble {
  max-width: min(36rem, 85%);
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.bubble.inbound {
  justify-self: start;
  background: var(--bg);
}
.bubble.outbound {
  justify-self: end;
  background: var(--outbound-bg);
}
.bubble .body {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bubble .meta {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
}
.error-text {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--alert-text);
}
textarea {
  font: inherit;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  width: 100%;
  resize: vertical;
}
button.secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.badge.bad {
  background: var(--alert-bg);
  color: var(--alert-text);
}
.badge.info {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* ---- contacts ---- */
.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.85rem;
}
.contact-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.25rem;
}
.contact-list details {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}
.contact-list summary {
  cursor: pointer;
}
.contact-list form {
  margin-top: 0.75rem;
}

/* faxes */
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.panel-head .button-link,
.row-actions .button-link {
  display: inline-block;
  padding: 0.5rem 1rem;
}
.tabs {
  display: flex;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
}
.tabs a {
  text-decoration: none;
  padding: 0.35rem 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a[aria-current="page"] {
  border-bottom-color: var(--accent);
  font-weight: 600;
}
td.actions {
  white-space: nowrap;
}
.details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1rem;
  margin: 0;
}
.details dt {
  font-weight: 600;
}
.details dd {
  margin: 0;
  overflow-wrap: anywhere;
}
@media (max-width: 720px) {
  .details {
    grid-template-columns: 1fr;
  }
  .details dd {
    margin-bottom: 0.4rem;
  }
}
.row-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}
.row-actions form {
  margin: 0;
}
input[type="file"] {
  font: inherit;
  max-width: 100%;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- accessibility helpers ---- */
.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -3rem;
  z-index: 10;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text);
}
.skip-link:focus {
  top: 0.5rem;
}
@media (max-width: 480px) {
  .who {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* ---- settings: needs attention ---- */
h3 {
  font-size: 1rem;
  margin: 0 0 0.35rem;
}
.notice {
  background: var(--ok-bg);
  color: var(--ok-text);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
}
.review-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: grid;
  gap: 0.75rem;
}
.review-list > li {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  overflow-wrap: anywhere;
}
.review-list p {
  margin: 0;
}
.review-actions {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}
.inline-form label {
  display: inline;
}
.inline-form input[type="text"] {
  width: auto;
  flex: 1 1 14rem;
}
