:root {
  --green: #76b900;
  --green-dark: #5a8d00;
  --focus-light: #3b7c00;
  --ink: #000;
  --body: #1a1a1a;
  --canvas: #fff;
  --soft: #f7f7f7;
  --hairline: #ccc;
  --mute: #666;
  --error: #e52020;
  --radius: 2px;
}

* { box-sizing: border-box; }
html { background: var(--soft); color: var(--body); font-family: Inter, Arial, Helvetica, sans-serif; }
body { margin: 0; min-width: 320px; }
button, input, textarea { font: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus-light); outline-offset: 2px; }
.app-header :focus-visible { outline-color: var(--green); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-header {
  align-items: center;
  background: var(--ink);
  color: #fff;
  display: flex;
  height: 44px;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-brand { align-items: center; display: inline-flex; font-size: 14px; font-weight: 700; gap: 9px; min-height: 44px; min-width: 44px; text-decoration: none; }
.brand-mark { align-items: center; background: var(--green); color: var(--ink); display: inline-flex; font-size: 15px; font-weight: 800; height: 24px; justify-content: center; width: 24px; }
.header-account { align-items: center; display: flex; gap: 14px; }
.header-account form { margin: 0; }
.account-email { color: rgba(255,255,255,.72); font-size: 12px; }
.button-header { background: transparent; border: 1px solid #fff; border-radius: var(--radius); color: #fff; cursor: pointer; min-height: 44px; padding: 5px 11px; }
.button-header:active { background: #1a1a1a; }

.page-shell { margin: 0 auto; max-width: 1440px; padding: 28px 24px 48px; }
.page-heading { align-items: end; display: flex; justify-content: space-between; margin-bottom: 22px; }
.eyebrow { color: #356f00; font-size: 11px; font-weight: 700; letter-spacing: .04em; margin: 0 0 6px; }
h1 { color: var(--ink); font-size: 26px; line-height: 1.2; margin: 0; }
.page-summary { color: var(--mute); font-size: 14px; margin: 6px 0 0; }
.message-stat { border-left: 4px solid var(--green); display: flex; flex-direction: column; min-width: 145px; padding: 4px 0 4px 14px; }
.message-stat strong { color: var(--ink); font-size: 25px; line-height: 1; }
.message-stat span { color: var(--mute); font-size: 12px; margin-top: 5px; }

.send-panel { background: var(--canvas); border: 1px solid var(--hairline); margin-bottom: 12px; padding: 14px 16px; }
.send-heading { align-items: end; display: flex; justify-content: space-between; margin-bottom: 12px; }
.send-heading h2 { color: var(--ink); font-size: 17px; margin: 0; }
.send-heading .eyebrow { margin-bottom: 3px; }
.send-heading > span { color: var(--mute); font-size: 12px; }
.send-form { align-items: end; display: grid; gap: 10px; grid-template-columns: minmax(180px, .7fr) minmax(280px, 2fr) auto; }
.send-field { display: grid; gap: 5px; }
.send-field label { color: var(--ink); font-size: 12px; font-weight: 700; }
.send-field input, .send-field textarea { border: 1px solid var(--hairline); border-radius: var(--radius); padding: 10px 12px; width: 100%; }
.send-field input { height: 44px; }
.send-field textarea { min-height: 44px; resize: vertical; }
.send-field input:focus, .send-field textarea:focus { border: 2px solid var(--focus-light); outline: none; }
.button-send { background: var(--green); border: 0; border-radius: var(--radius); color: var(--ink); cursor: pointer; font-weight: 700; min-height: 44px; padding: 9px 18px; }
.button-send:active { background: var(--green-dark); }
.alert-success { background: #eff9e5; border-left: 4px solid var(--green-dark); color: #244600; font-size: 13px; margin: 0 0 10px; padding: 9px 12px; }
.outbound-panel { background: var(--canvas); border: 1px solid var(--hairline); margin-bottom: 12px; }
.outbound-list { display: grid; }
.outbound-row { align-items: start; border-top: 1px solid #e4e4e4; display: grid; gap: 14px; grid-template-columns: minmax(145px,.7fr) minmax(240px,2fr) auto; padding: 11px 16px; }
.outbound-row:first-child { border-top: 0; }
.outbound-row div strong, .outbound-row div span { display: block; overflow-wrap: anywhere; }
.outbound-row div span { color: var(--mute); font-size: 11px; margin-top: 3px; text-transform: uppercase; }
.outbound-row p { line-height: 1.4; margin: 0; white-space: pre-wrap; }
.status-badge { background: var(--soft); border: 1px solid var(--hairline); border-radius: var(--radius); font-size: 11px; font-weight: 700; padding: 5px 8px; text-transform: uppercase; }
.status-sent { border-color: var(--green-dark); color: #356f00; }
.status-failed { border-color: var(--error); color: #650b0b; }
.status-unknown { border-color: #9b6200; color: #704600; }

.toolbar { align-items: center; background: var(--canvas); border: 1px solid var(--hairline); display: flex; justify-content: space-between; margin-bottom: 12px; padding: 10px; }
.search-form { align-items: center; display: flex; flex: 1; gap: 8px; max-width: 700px; }
.search-form input { border: 1px solid var(--hairline); border-radius: var(--radius); height: 44px; min-width: 0; padding: 9px 12px; width: min(460px, 100%); }
.search-form input:focus { border: 2px solid var(--focus-light); outline: none; }
.button-outline, .button-refresh, .clear-link { align-items: center; border-radius: var(--radius); display: inline-flex; font-size: 14px; font-weight: 700; justify-content: center; min-height: 44px; text-decoration: none; }
.button-outline { background: #fff; border: 2px solid var(--focus-light); cursor: pointer; padding: 8px 16px; }
.button-refresh { background: var(--ink); border: 1px solid var(--ink); color: #fff; padding: 8px 16px; }
.clear-link { color: #0046a4; font-weight: 400; padding: 8px; text-decoration: underline; }

.message-panel { background: var(--canvas); border: 1px solid var(--hairline); position: relative; }
.message-panel::before { background: var(--green); content: ""; height: 10px; left: -1px; position: absolute; top: -1px; width: 10px; }
.panel-heading { align-items: center; border-bottom: 1px solid var(--hairline); display: flex; justify-content: space-between; min-height: 48px; padding: 10px 16px 10px 22px; }
.panel-heading h2 { color: var(--ink); font-size: 16px; margin: 0; }
.panel-heading span { color: var(--mute); font-size: 12px; }
.table-scroll { overflow-x: auto; }
.table-scroll:focus-visible { outline-offset: -3px; }
table { border-collapse: collapse; width: 100%; }
th { background: var(--soft); color: var(--ink); font-size: 11px; letter-spacing: .035em; padding: 10px 14px; text-align: left; text-transform: uppercase; }
td { border-top: 1px solid #e4e4e4; font-size: 13px; padding: 13px 14px; vertical-align: top; }
tbody tr:first-child td { border-top: 0; }
tbody tr:hover { background: #fbfbfb; }
th:nth-child(1) { width: 20%; }
th:nth-child(2) { width: 48%; }
th:nth-child(3) { width: 10%; }
th:nth-child(4) { width: 22%; }
.sender-name, .sender-number { display: block; overflow-wrap: anywhere; }
.cell-value { min-width: 0; }
.sender-name { color: var(--ink); font-size: 14px; }
.sender-number { color: var(--mute); margin-top: 4px; }
.message-body { color: var(--body); line-height: 1.45; margin: 0; white-space: pre-wrap; }
.message-id { color: var(--mute); display: block; font-size: 10px; margin-top: 7px; max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.type-badge { background: var(--soft); border: 1px solid var(--hairline); border-radius: var(--radius); color: var(--body); display: inline-block; font-size: 11px; font-weight: 700; padding: 4px 8px; text-transform: uppercase; }
time { color: var(--mute); white-space: nowrap; }
.pagination { align-items: center; border-top: 1px solid var(--hairline); display: flex; font-size: 13px; justify-content: space-between; padding: 12px 16px; }
.pagination a { color: #0046a4; min-height: 44px; padding: 13px 4px; }
.pagination span { color: var(--mute); }
.empty-state { padding: 72px 24px; text-align: center; }
.empty-icon { color: var(--green-dark); display: block; font-size: 34px; font-weight: 700; }
.empty-state h2 { color: var(--ink); font-size: 18px; margin: 12px 0 6px; }
.empty-state p { color: var(--mute); font-size: 14px; margin: 0; }

.login-page { background: var(--ink); }
.login-shell { align-items: center; display: flex; justify-content: center; min-height: 100vh; padding: 24px; }
.login-card { background: var(--canvas); border-radius: var(--radius); max-width: 420px; padding: 32px; position: relative; width: 100%; }
.corner-square { background: var(--green); height: 12px; left: 0; position: absolute; top: 0; width: 12px; }
.brand-lockup { align-items: center; display: flex; font-size: 14px; font-weight: 700; gap: 9px; margin-bottom: 36px; }
.login-card h1 { font-size: 28px; }
.login-intro { color: var(--mute); font-size: 14px; line-height: 1.5; margin: 8px 0 24px; }
.login-form { display: grid; gap: 8px; }
.login-form label { color: var(--ink); font-size: 13px; font-weight: 700; margin-top: 8px; }
.login-form input { border: 1px solid var(--hairline); border-radius: var(--radius); height: 44px; padding: 11px 13px; width: 100%; }
.login-form input:focus { border: 2px solid var(--focus-light); outline: none; }
.button-primary { background: var(--green); border: 0; border-radius: var(--radius); color: var(--ink); cursor: pointer; font-weight: 700; height: 44px; margin-top: 16px; padding: 11px 24px; }
.button-primary:active { background: var(--green-dark); }
.alert-error { background: #fff2f2; border-left: 4px solid var(--error); color: #650b0b; font-size: 13px; margin-bottom: 12px; padding: 10px 12px; }

@media (max-width: 700px) {
  .app-header { padding: 0 12px; }
  .app-brand > span:last-child { display: none; }
  .account-email { display: none; }
  .page-shell { padding: 20px 12px 32px; }
  .page-heading { align-items: flex-start; gap: 18px; }
  h1 { font-size: 23px; }
  .message-stat { min-width: 100px; }
  .toolbar { align-items: stretch; flex-direction: column; gap: 8px; }
  .send-heading { align-items: start; flex-direction: column; gap: 5px; }
  .send-form { grid-template-columns: 1fr; }
  .button-send { width: 100%; }
  .outbound-row { grid-template-columns: 1fr; gap: 8px; }
  .status-badge { justify-self: start; }
  .search-form { align-items: stretch; display: grid; grid-template-columns: 1fr auto; max-width: none; }
  .search-form input { grid-column: 1 / -1; width: 100%; }
  .clear-link { position: absolute; right: 24px; }
  .button-refresh { width: 100%; }
  .table-scroll { overflow: visible; }
  table, tbody { display: block; }
  thead { display: none; }
  tr { border-bottom: 1px solid var(--hairline); display: block; padding: 10px 14px; }
  tr:last-child { border-bottom: 0; }
  td { border: 0; display: grid; gap: 12px; grid-template-columns: 82px minmax(0,1fr); padding: 7px 0; }
  td::before { color: var(--mute); content: attr(data-label); font-size: 10px; font-weight: 700; letter-spacing: .035em; padding-top: 2px; text-transform: uppercase; }
  .message-id { max-width: 100%; }
  time { white-space: normal; }
  .login-card { padding: 28px 22px; }
}

@media (max-width: 420px) {
  .page-heading { display: block; }
  .message-stat { margin-top: 18px; }
}
