/* Message Center: large, high-contrast, keyboard-friendly. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #111418;
  --muted: #4a5360;
  --border: #c9cfd8;
  --accent: #0b57d0;
  --accent-text: #ffffff;
  --unread: #fff6d6;
  --unread-border: #b88a00;
  --ok-bg: #e3f4e6; --ok-text: #0f5a1e;
  --err-bg: #fde7e7; --err-text: #8a1111;
  --info-bg: #e5eefc; --info-text: #123d82;
  --focus: #ff9e00;
  --scale: 1;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1b2027;
    --text: #f1f3f6;
    --muted: #b3bcc8;
    --border: #3a4350;
    --accent: #8ab4ff;
    --accent-text: #0b1830;
    --unread: #2c2614;
    --unread-border: #e0b33a;
    --ok-bg: #143320; --ok-text: #b9f0c6;
    --err-bg: #3d1616; --err-text: #ffc4c4;
    --info-bg: #15284a; --info-text: #c8dbff;
  }
}

* { box-sizing: border-box; }
html { font-size: calc(112.5% * var(--scale)); } /* 18px base */
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.5;
}
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 1.6rem; margin: 1rem 0; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 .75rem; }

.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; background: var(--surface); padding: .5rem; z-index: 10; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; padding-top: .6rem; padding-bottom: .6rem; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.topbar nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.topbar nav a { text-decoration: none; padding: .25rem 0; border-bottom: 3px solid transparent; }
.topbar nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.topbar-tools { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
.topbar-tools form { margin: 0; }

.btn {
  display: inline-block; font: inherit; font-weight: 600; cursor: pointer;
  padding: .55rem 1rem; min-height: 44px; border-radius: 8px;
  border: 2px solid var(--border); background: var(--surface); color: var(--text);
  text-decoration: none; line-height: 1.3;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.small { padding: .3rem .7rem; min-height: 36px; font-size: .9rem; }
.btn.big { width: 100%; font-size: 1.1rem; padding: .8rem 1rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem; margin: 1rem 0; }
.card.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.card.empty { text-align: center; color: var(--muted); }

.flash { padding: .75rem 1rem; border-radius: 8px; margin: 1rem 0; font-weight: 600; }
.flash-ok { background: var(--ok-bg); color: var(--ok-text); }
.flash-error { background: var(--err-bg); color: var(--err-text); }
.flash-info { background: var(--info-bg); color: var(--info-text); }

.stack { display: flex; flex-direction: column; gap: 1rem; }
label { font-weight: 600; }
input[type=text], input[type=password], input[type=search], select {
  display: block; width: 100%; margin-top: .3rem; font: inherit; color: var(--text);
  background: var(--bg); border: 2px solid var(--border); border-radius: 8px; padding: .55rem .7rem; min-height: 44px;
}
label.check { display: flex; align-items: center; gap: .4rem; white-space: nowrap; }
label.check input { width: 1.2rem; height: 1.2rem; }

.tabs { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1.25rem 0 1rem; }
.tabs a {
  text-decoration: none; padding: .5rem 1rem; border-radius: 999px; border: 2px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 600;
}
.tabs a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.badge { display: inline-block; font-size: .8rem; padding: 0 .45rem; border-radius: 999px; background: var(--unread-border); color: #000; }

.searchbar { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center; }
.searchbar .grow { flex: 1 1 260px; }
.searchbar .grow input { margin-top: 0; }

.messages { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .75rem; }
.msg { background: var(--surface); border: 1px solid var(--border); border-left: 6px solid var(--border); border-radius: 10px; padding: 1rem; }
.msg.unread { background: var(--unread); border-left-color: var(--unread-border); }
.msg-head { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center; }
.msg-head time { margin-left: auto; color: var(--muted); }
.type { font-weight: 700; text-transform: uppercase; font-size: .85rem; letter-spacing: .04em; }
.newflag { font-weight: 700; font-size: .8rem; padding: .05rem .5rem; border-radius: 999px; background: var(--unread-border); color: #000; }
.msg-who { margin: .4rem 0; display: flex; flex-wrap: wrap; gap: .25rem .6rem; align-items: baseline; font-size: 1.1rem; }
.msg-body { margin: .5rem 0; padding: .75rem; border-radius: 8px; background: var(--bg); white-space: normal; overflow-wrap: anywhere; }
.msg-body.sms { font-size: 1.1rem; }
.msg-media { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin: .5rem 0; }
.msg-media audio { flex: 1 1 280px; min-width: 0; height: 48px; }
.msg-actions { margin: .5rem 0 0; }

.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin: 1.5rem 0 2rem; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
tr.inactive td { color: var(--muted); }
tr.run-error td { color: var(--err-text); }
td.actions { display: flex; flex-wrap: wrap; gap: .4rem; }
td.actions form { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0; }
td.pre { white-space: pre-wrap; font-size: .9rem; }
details summary { list-style: none; }
details summary::-webkit-details-marker { display: none; }
form.inline { display: flex; gap: .4rem; align-items: center; margin-top: .4rem; }
form.inline input { margin-top: 0; min-width: 12rem; }

@media (max-width: 600px) {
  .topbar-tools { margin-left: 0; }
  .msg-head time { margin-left: 0; width: 100%; }
}
