/* TIH staff workspace (live /hub-staff). */
:root { --primary: #002868; --primary-mid: #1565d8; --primary-light: #eaf4ff; --red: #E31E24; --text: #0B1F3A; --muted: #5b6b8c; --border: #dbe7f7; --bg: #f4f7fc; --ok: #047857; --ok-bg: #e7f8ef; --wait: #92400e; --wait-bg: #fff4dc; --bad: #9b2634; --bad-bg: #fde8ea; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--primary-mid); }
h1, h2 { font-family: Poppins, Inter, sans-serif; letter-spacing: -.02em; margin: 0; }
.st-muted { color: var(--muted); margin: .2rem 0 0; font-size: .9rem; }
.st-center { text-align: center; font-size: .85rem; margin: 1rem 0 0; }
.st-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; color: #33415c; }

/* Brand */
.st-brand { display: flex; align-items: center; gap: .7rem; }
.st-brand img { width: 48px; height: 48px; object-fit: contain; }
.st-brand span { display: flex; flex-direction: column; line-height: 1.15; }
.st-brand strong { font: 800 1.2rem Poppins, Inter, sans-serif; color: var(--primary); letter-spacing: -.02em; }
.st-brand em { font-style: normal; color: var(--red); }
.st-brand small { font-size: .74rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.st-brand-sm img { width: 36px; height: 36px; }
.st-brand-sm strong { font-size: 1rem; }

/* Buttons & inputs */
.st-btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 40px; padding: .5rem 1rem; border-radius: 10px; border: 1.5px solid var(--border); background: #fff; color: var(--primary); font: 700 .88rem Inter, system-ui, sans-serif; text-decoration: none; cursor: pointer; white-space: nowrap; }
.st-btn:hover { border-color: var(--primary); }
.st-btn:disabled { opacity: .6; cursor: wait; }
.st-btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.st-btn-primary:hover { background: #00357f; }
.st-btn-ghost { background: #fff; }
.st-btn-sm { min-height: 34px; padding: .35rem .75rem; font-size: .8rem; border-radius: 8px; }
.st-block { width: 100%; min-height: 50px; margin-top: 1rem; font-size: 1rem; border-radius: 12px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #72a7ff; outline-offset: 2px; }
label { display: block; font-size: .84rem; font-weight: 700; margin: .9rem 0 .3rem; }
input, select { width: 100%; min-height: 46px; padding: .65rem .85rem; border: 1.5px solid var(--border); border-radius: 10px; background: #fbfcfe; font: inherit; color: var(--text); }
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(0,40,104,.12); background: #fff; }

/* Messages */
.st-msg { margin: .8rem 0 0; padding: .7rem .9rem; border-radius: 10px; background: #f2f6fd; color: #23395f; font-size: .88rem; }
.st-msg:empty { display: none; }
.st-msg[data-state=error], #verification[data-state=error] { background: var(--bad-bg); color: var(--bad); }
.st-msg[data-state=success] { background: var(--ok-bg); color: var(--ok); }
#verification[data-state=success] { color: var(--ok); font-weight: 600; }

/* Sign in */
.st-login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; padding: 1.5rem 1rem;
  background: radial-gradient(ellipse 70% 50% at 100% 0%, #dbe8ff 0%, transparent 60%), linear-gradient(160deg, #f7faff 0%, #eef4ff 55%, #fdf1f2 100%); }
.st-login-card { width: 100%; max-width: 430px; background: #fff; border-radius: 20px; border-top: 5px solid var(--red); padding: 2rem 1.75rem 1.6rem; box-shadow: 0 24px 64px rgba(11,31,58,.12); }
.st-login-card h1 { font-size: 1.55rem; margin-top: 1.3rem; }
.st-foot { font-size: .8rem; color: var(--muted); margin: 0; }

/* App shell */
.st-app { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; grid-template-rows: auto 1fr; }
.st-top { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 1.25rem; background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.st-top-right { display: flex; gap: .5rem; }
.st-nav { display: flex; flex-direction: column; gap: .2rem; padding: 1rem .75rem; background: #fff; border-right: 1px solid var(--border); position: sticky; top: 61px; align-self: start; height: calc(100vh - 61px); }
.st-nav button { text-align: left; border: 0; background: none; padding: .65rem .85rem; border-radius: 10px; font: 600 .9rem Inter, system-ui, sans-serif; color: #33415c; cursor: pointer; }
.st-nav button:hover { background: var(--primary-light); color: var(--primary); }
.st-nav button.active { background: var(--primary); color: #fff; }
.st-main { padding: 1.5rem 1.75rem 3rem; min-width: 0; }
.st-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.st-head h1 { font-size: 1.55rem; }
.st-tools { display: flex; gap: .5rem; align-items: center; }
.st-tools input { min-height: 40px; width: 240px; }

/* Overview cards */
.st-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.st-card { text-align: left; display: flex; flex-direction: column; gap: .15rem; padding: 1.2rem 1.25rem; background: #fff; border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 2px 10px rgba(11,31,58,.05); cursor: pointer; font: inherit; color: var(--text); transition: transform .15s, box-shadow .15s; }
.st-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(11,31,58,.10); }
.st-card strong { font: 800 2rem Poppins, Inter, sans-serif; color: var(--primary); line-height: 1.1; }
.st-card span { font-weight: 700; }
.st-card small { color: var(--muted); font-size: .78rem; }
.st-card.attention { border-color: #f5c46b; background: linear-gradient(180deg, #fffaf0, #fff); }
.st-card.attention strong { color: #b45309; }
.st-card.attention small { color: #b45309; font-weight: 700; }

/* Tables */
.st-table { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; font-size: .88rem; }
.st-table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: #f7f9fd; padding: .7rem .85rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.st-table td { padding: .7rem .85rem; border-bottom: 1px solid #edf2fa; vertical-align: middle; overflow-wrap: anywhere; }
.st-table tbody tr:last-child td { border-bottom: 0; }
.st-table tbody tr:hover td { background: #fafcff; }
.st-actions { white-space: nowrap; text-align: right; }
.st-actions .st-btn + .st-btn { margin-left: .35rem; }
.st-badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 700; background: #eef2f7; color: #475569; text-transform: capitalize; }
.st-badge.ok { background: var(--ok-bg); color: var(--ok); }
.st-badge.wait { background: var(--wait-bg); color: var(--wait); }
.st-badge.bad { background: var(--bad-bg); color: var(--bad); }
.st-empty { background: #fff; border: 1px dashed var(--border); border-radius: 14px; padding: 2rem; text-align: center; color: var(--muted); }
.st-pager { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; }
.st-panel { margin-top: 1.5rem; background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 1.1rem 1.25rem; }
.st-panel h2 { font-size: 1.05rem; margin-bottom: .6rem; }
.st-inline { display: flex; gap: .5rem; }
.st-inline input { flex: 1; }

/* Dialog */
.st-modal { position: fixed; inset: 0; z-index: 50; background: rgba(11,31,58,.45); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.st-modal-card { width: 100%; max-width: 460px; max-height: calc(100vh - 2rem); overflow: auto; background: #fff; border-radius: 18px; padding: 1.4rem 1.4rem 1.2rem; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.st-modal-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.st-modal-head h2 { font-size: 1.2rem; }
.st-x { border: 0; background: #f1f5f9; width: 36px; height: 36px; border-radius: 50%; font-size: 1.3rem; line-height: 1; cursor: pointer; color: #334155; }
.st-note { font-size: .78rem; color: var(--muted); margin: .6rem 0 0; }

/* Phones & tablets */
@media (max-width: 860px) {
  .st-app { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; align-content: start; }
  .st-nav { flex-direction: row; overflow-x: auto; position: sticky; top: 57px; height: auto; z-index: 15; border-right: 0; border-bottom: 1px solid var(--border); padding: .5rem .75rem; scrollbar-width: none; }
  .st-nav button { white-space: nowrap; padding: .5rem .8rem; font-size: .84rem; }
  .st-main { padding: 1.1rem 1rem 3rem; }
  .st-hide-sm { display: none; }
  .st-tools, .st-tools input { width: 100%; }
  .st-tools input { flex: 1; }
  /* Table rows become cards */
  .st-table, .st-table tbody, .st-table tr, .st-table td { display: block; width: 100%; }
  .st-table { background: none; border: 0; }
  .st-table thead { display: none; }
  .st-table tr { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: .6rem .9rem; margin-bottom: .75rem; }
  .st-table td { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; border: 0; text-align: right; }
  .st-table td::before { content: attr(data-label); font-size: .75rem; font-weight: 700; color: var(--muted); text-align: left; flex-shrink: 0; }
  .st-table td.st-actions { justify-content: flex-end; padding-top: .6rem; }
  .st-table td.st-actions::before { content: none; }
  .st-cards { grid-template-columns: 1fr 1fr; gap: .7rem; }
  .st-card { padding: 1rem; }
  .st-card strong { font-size: 1.6rem; }
}

/* Messages view: form submissions */
.st-message { max-width: 420px; min-width: 220px; }
.st-badge { white-space: nowrap; }
.st-message summary { cursor: pointer; color: var(--text, #0b1f3a); }
.st-message dl { margin: .5rem 0 0; display: grid; grid-template-columns: auto 1fr; gap: .25rem .75rem; font-size: .85rem; }
.st-message dt { font-weight: 700; color: #475569; text-transform: capitalize; }
.st-message dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---- Messages inbox (2026-12) ---- */
.mb { display: grid; gap: .9rem; }
.mb-tabs { display: inline-flex; gap: .25rem; padding: .25rem; background: #e9eef7; border-radius: 12px; justify-self: start; }
.mb-tab { display: inline-flex; align-items: center; gap: .45rem; min-height: 36px; padding: .35rem .85rem; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: 700 .85rem Inter, system-ui, sans-serif; cursor: pointer; }
.mb-tab.on { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgba(11,31,58,.12); }
.mb-count { min-width: 1.5rem; padding: .05rem .4rem; border-radius: 999px; background: rgba(0,40,104,.08); font-size: .75rem; text-align: center; }
.mb-tab.on .mb-count { background: var(--primary); color: #fff; }
.mb-list { list-style: none; margin: 0; padding: 0; background: #fff; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; box-shadow: 0 1px 2px rgba(11,31,58,.04); }
.mb-item + .mb-item { border-top: 1px solid #edf2fa; }
.mb-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .9rem; width: 100%; padding: .95rem 1.1rem; border: 0; background: transparent; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.mb-head:hover { background: #f8faff; }
.mb-item.is-open .mb-head { background: #f5f8ff; }
.mb-av { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; font: 800 .9rem Inter, system-ui, sans-serif; color: #fff; background: #5b6b8c; letter-spacing: .02em; }
.mb-av[data-tone="0"] { background: #1565d8; } .mb-av[data-tone="1"] { background: #0f766e; } .mb-av[data-tone="2"] { background: #b45309; } .mb-av[data-tone="3"] { background: #7c3aed; } .mb-av[data-tone="4"] { background: #be123c; }
.mb-main { display: grid; gap: .15rem; min-width: 0; }
.mb-line1 { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.mb-who { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mb-item.is-new .mb-who { font-weight: 800; }
.mb-chip { flex-shrink: 0; padding: .1rem .5rem; border-radius: 999px; background: var(--primary-light); color: var(--primary); font-size: .72rem; font-weight: 700; }
.mb-preview { color: var(--muted); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mb-item.is-new .mb-preview { color: #33415c; }
.mb-meta { display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; }
.mb-time { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.mb-item.is-new .mb-time { color: var(--primary-mid); font-weight: 700; }
.mb-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary-mid); box-shadow: 0 0 0 3px rgba(21,101,216,.15); }
.mb-body { padding: .2rem 1.1rem 1.1rem calc(1.1rem + 42px + .9rem); background: #f5f8ff; }
.mb-contact { display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; font-size: .84rem; color: var(--muted); }
.mb-contact a { font-weight: 600; }
.mb-subject { margin: .7rem 0 0; font-weight: 700; color: var(--text); }
.mb-fields { margin: .7rem 0 0; padding: .9rem 1rem; display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: .45rem 1rem; background: #fff; border: 1px solid var(--border); border-radius: 12px; font-size: .9rem; }
.mb-fields dt { font-weight: 700; color: var(--muted); text-transform: capitalize; }
.mb-fields dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.mb-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .9rem; }
.mb-actions a.st-btn { text-decoration: none; }
.mb-wa { border-color: #25d366; color: #128c4a; }
.mb-wa:hover { border-color: #128c4a; }
.mb-done { border-color: var(--ok); color: var(--ok); }
.mb-handled { font-size: .8rem; color: var(--muted); }
.mb-empty { display: grid; gap: .3rem; justify-items: center; padding: 2.5rem 1rem; background: #fff; border: 1px dashed var(--border); border-radius: 16px; color: var(--muted); text-align: center; }
.mb-empty strong { color: var(--text); font-size: 1.05rem; }
@media (max-width: 640px) {
  .mb-tabs { justify-self: stretch; } .mb-tab { flex: 1; justify-content: center; }
  .mb-head { gap: .7rem; padding: .85rem .9rem; }
  .mb-av { width: 36px; height: 36px; font-size: .8rem; }
  .mb-body { padding: .2rem .9rem 1rem; }
  .mb-fields { grid-template-columns: 1fr; gap: .1rem; } .mb-fields dd { margin-bottom: .5rem; }
  .mb-actions .st-btn { flex: 1; }
}
