/* CHNS Hosting Customer Portal — neutral business theme */
:root {
  --navy: #1f3a5f;
  --navy-dark: #162b47;
  --navy-light: #e8eef6;
  --text: #1f2933;
  --muted: #616e7c;
  --border: #d9e0e8;
  --bg: #f3f5f8;
  --white: #ffffff;
  --green: #1e7b4a;
  --green-bg: #e3f4ea;
  --amber: #8a5a00;
  --amber-bg: #fdf1d8;
  --red: #b42318;
  --red-bg: #fde8e7;
  --blue: #1d5fa8;
  --blue-bg: #e2eefb;
  --gray-bg: #eceff3;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html { font-size: 15px; }

body {
  margin: 0;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a { color: var(--navy); }
a:hover { color: var(--navy-dark); }

h1, h2, h3 { color: var(--navy-dark); line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; font-weight: 600; }
h2 { font-size: 1.15rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 .75rem; }

.muted { color: var(--muted); }
.small { font-size: .87rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }

/* ---------- Header ---------- */
.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
}
.site-header .inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  min-height: 64px;
}
.brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  text-decoration: none;
  color: var(--navy-dark);
}
.brand img { height: 44px; width: auto; }
.brand .brand-name { font-weight: 700; font-size: 1.05rem; line-height: 1.1; }
.brand .brand-sub { display: block; font-weight: 400; font-size: .8rem; color: var(--muted); }

.main-nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.main-nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 1.3rem .75rem 1.15rem;
  border-bottom: 3px solid transparent;
  font-weight: 500;
}
.main-nav a:hover { color: var(--navy); }
.main-nav a.active { color: var(--navy); border-bottom-color: var(--navy); }

.user-menu { display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.user-menu form { margin: 0; }
.admin-tag {
  background: var(--navy);
  color: var(--white);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: .15rem .45rem;
  border-radius: 3px;
}

/* ---------- Layout ---------- */
.container { max-width: 1200px; margin: 0 auto; padding: 1.75rem 1.25rem 3rem; }
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.page-head p { margin: 0; }
.breadcrumb { font-size: .87rem; margin-bottom: .35rem; }
.breadcrumb a { text-decoration: none; }

.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4, .grid-main { grid-template-columns: 1fr; }
  .site-header .inner { flex-wrap: wrap; gap: .5rem; padding-top: .5rem; }
  .main-nav a { padding: .5rem .6rem; }
}

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .85rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.card-head h2 { margin: 0; }
.card-body { padding: 1.1rem; }
.card-body > :last-child { margin-bottom: 0; }
.card-foot { padding: .75rem 1.1rem; border-top: 1px solid var(--border); background: #fafbfc; }

/* ---------- Stats ---------- */
.stat { padding: 1rem 1.1rem; }
.stat .label { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 1.6rem; font-weight: 600; color: var(--navy-dark); margin-top: .15rem; }
.stat .value.owed { color: var(--red); }
.stat .value.credit { color: var(--green); }
.stat .sub { font-size: .85rem; color: var(--muted); }

/* ---------- Details list ---------- */
.details { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.25rem; margin: 0; }
.details dt { color: var(--muted); font-size: .9rem; }
.details dd { margin: 0; font-weight: 500; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .65rem 1.1rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 600;
  background: #fafbfc;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfd; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.actions { white-space: nowrap; text-align: right; }
td.actions form { display: inline; }
.empty { padding: 1.5rem 1.1rem; color: var(--muted); text-align: center; }
.amount-charge { color: var(--red); }
.amount-credit { color: var(--green); }
tfoot td { font-weight: 600; background: #fafbfc; border-top: 1px solid var(--border); }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: .12rem .55rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--gray-bg);
  color: var(--muted);
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-navy { background: var(--navy-light); color: var(--navy); }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.field { margin-bottom: 1rem; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 1rem; }
.hint { font-size: .82rem; color: var(--muted); margin-top: .25rem; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=tel], input[type=file], select, textarea {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid #c3ccd7;
  border-radius: var(--radius);
  font: inherit;
  color: var(--text);
  background: var(--white);
}
input[type=file] { padding: .4rem; }
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(31, 58, 95, .15);
}
.checkbox { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.checkbox input { width: auto; margin: 0; }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline-form select, .inline-form input { width: auto; }

/* Priority picker */
.priority-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; }
@media (max-width: 700px) { .priority-options { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.priority-option { position: relative; margin: 0; }
.priority-option input { position: absolute; opacity: 0; }
.priority-option span {
  display: block;
  border: 1px solid #c3ccd7;
  border-radius: var(--radius);
  padding: .6rem .75rem;
  cursor: pointer;
  font-weight: 600;
}
.priority-option small { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }
.priority-option input:checked + span { border-color: var(--navy); background: var(--navy-light); box-shadow: 0 0 0 1px var(--navy); }
.priority-option input:focus-visible + span { box-shadow: 0 0 0 3px rgba(31, 58, 95, .3); }

/* Help bubble */
.help {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--navy-light);
  color: var(--navy);
  font-size: .75rem;
  font-weight: 700;
  cursor: help;
  vertical-align: middle;
  margin-left: .25rem;
}
.help .help-text {
  display: none;
  position: absolute;
  left: 50%;
  top: 130%;
  transform: translateX(-50%);
  width: 260px;
  background: var(--navy-dark);
  color: var(--white);
  font-weight: 400;
  font-size: .82rem;
  line-height: 1.45;
  padding: .6rem .75rem;
  border-radius: var(--radius);
  z-index: 10;
  text-align: left;
}
.help:hover .help-text, .help:focus .help-text { display: block; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--navy);
  background: var(--navy);
  color: var(--white);
  font: inherit;
  font-weight: 600;
  font-size: .9rem;
  text-decoration: none;
  cursor: pointer;
  line-height: 1.4;
}
.btn:hover { background: var(--navy-dark); color: var(--white); }
.btn-secondary { background: var(--white); color: var(--navy); border-color: #c3ccd7; }
.btn-secondary:hover { background: var(--navy-light); color: var(--navy-dark); }
.btn-danger { background: var(--white); color: var(--red); border-color: #f0b8b3; }
.btn-danger:hover { background: var(--red-bg); color: var(--red); }
.btn-success { background: var(--green); border-color: var(--green); }
.btn-success:hover { background: #17633b; }
.btn-sm { padding: .25rem .6rem; font-size: .8rem; }
.btn-block { display: block; width: 100%; text-align: center; }
.link-btn { background: none; border: none; padding: 0; color: var(--navy); font: inherit; cursor: pointer; text-decoration: underline; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---------- Alerts ---------- */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid;
  font-size: .93rem;
}
.alert-success { background: var(--green-bg); border-color: #b5dfc5; color: #155c37; }
.alert-error { background: var(--red-bg); border-color: #f4b9b4; color: #8f1c13; }
.alert-info { background: var(--blue-bg); border-color: #b8d3f1; color: #174d88; }
.alert-warning { background: var(--amber-bg); border-color: #f1d69b; color: #6f4800; }

/* ---------- Auth pages ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-box { width: 100%; max-width: 420px; }
.auth-box.wide { max-width: 560px; }
.auth-logo { text-align: center; margin-bottom: 1.25rem; }
.auth-logo img { height: 110px; width: auto; }
.auth-logo h1 { font-size: 1.3rem; margin-top: .75rem; }
.auth-links { text-align: center; font-size: .9rem; margin-top: 1rem; }

/* ---------- Ticket thread ---------- */
.thread { display: flex; flex-direction: column; gap: 1rem; }
.message { border: 1px solid var(--border); border-radius: var(--radius); background: var(--white); }
.message-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .55rem .9rem;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
  border-radius: var(--radius) var(--radius) 0 0;
}
.message-head strong { color: var(--navy-dark); }
.message-body { padding: .85rem .9rem; word-wrap: break-word; }
.message.staff { border-left: 4px solid var(--navy); }
.message.internal { border-color: #f1d69b; background: #fffbf1; border-left: 4px solid #d9a21b; }
.message.internal .message-head { background: var(--amber-bg); }
.event { font-size: .85rem; color: var(--muted); padding: 0 .9rem; display: flex; gap: .5rem; }
.event::before { content: "—"; }
.attachments { list-style: none; padding: 0; margin: .65rem 0 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.attachments a {
  display: inline-block;
  font-size: .85rem;
  padding: .2rem .6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  text-decoration: none;
  background: #fafbfc;
}

/* Timer */
.timer-running { display: flex; align-items: center; gap: .6rem; font-weight: 600; color: var(--green); }
.timer-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); animation: pulse 1.5s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.timer-clock { font-variant-numeric: tabular-nums; font-size: 1.2rem; }

.overdue { color: var(--red); font-weight: 600; }

.site-footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem 0 2rem; }
.code-box {
  font-family: Consolas, "Courier New", monospace;
  background: var(--gray-bg);
  padding: .45rem .7rem;
  border-radius: var(--radius);
  letter-spacing: .08em;
  word-break: break-all;
}
.qr { width: 200px; height: 200px; border: 1px solid var(--border); padding: .5rem; background: var(--white); }
.filter-bar { display: flex; gap: .75rem; flex-wrap: wrap; align-items: end; }
.filter-bar .field { margin: 0; }
.tabs { display: flex; gap: .35rem; }
.tabs a { padding: .35rem .8rem; border-radius: 999px; text-decoration: none; font-size: .88rem; color: var(--muted); border: 1px solid var(--border); background: var(--white); }
.tabs a.active { background: var(--navy); color: var(--white); border-color: var(--navy); }

/* Narrow sidebar tables (e.g. time entries) */
table.compact th, table.compact td { padding: .5rem .6rem; }
table.compact th:first-child, table.compact td:first-child { padding-left: 1.1rem; }

textarea.short { min-height: 60px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

.timer-paused { color: var(--amber); }
.timer-paused .timer-dot { background: var(--amber); animation: none; }

/* ---------- Onboarding ---------- */
.steps { display: flex; gap: .5rem; list-style: none; padding: 0; margin: 0 0 1.25rem; flex-wrap: wrap; }
.steps li {
  display: flex; align-items: center; gap: .5rem; flex: 1 1 0; min-width: 150px;
  padding: .55rem .8rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--white); color: var(--muted); font-weight: 600; font-size: .9rem;
}
.steps .step-num {
  display: inline-flex; align-items: center; justify-content: center; width: 1.6rem; height: 1.6rem;
  border-radius: 50%; background: #e6eaf0; font-size: .82rem;
}
.steps li.current { border-color: var(--navy); color: var(--navy); box-shadow: 0 0 0 1px var(--navy); }
.steps li.current .step-num { background: var(--navy); color: var(--white); }
.steps li.done { color: var(--text); }
.steps li.done .step-num { background: var(--green-bg); color: #155c37; }
.choice-options { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 1rem; }
@media (max-width: 700px) { .choice-options { grid-template-columns: 1fr; } }
.choice-panel[hidden] { display: none; }
.req { color: var(--red, #c0392b); font-weight: 700; }
.pager { display: flex; gap: .75rem; align-items: center; justify-content: center; }

/* ---------- Referral program ---------- */
.share-box { display: flex; gap: .5rem; flex-wrap: wrap; }
.share-box input { flex: 1 1 260px; min-width: 0; background: var(--gray-bg); font-family: Consolas, "Courier New", monospace; font-size: .9rem; }
.share-box .btn[hidden] { display: none; }
.code-inline { font-family: Consolas, "Courier New", monospace; letter-spacing: .08em; color: var(--navy-dark); }
.promo {
  display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: linear-gradient(135deg, var(--navy) 0%, #2c5282 100%); color: var(--white);
  border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1.25rem; box-shadow: var(--shadow);
}
.promo-text { display: flex; flex-direction: column; gap: .2rem; flex: 1 1 320px; }
.promo-text strong { font-size: 1.05rem; }
.promo-text span { opacity: .9; font-size: .93rem; }
.promo .btn { background: var(--white); color: var(--navy); border-color: var(--white); }
.promo .btn-secondary { background: transparent; color: var(--white); border-color: rgba(255, 255, 255, .5); }
.promo form { margin: 0; }
.how-steps { margin: 0 0 1rem; padding-left: 1.25rem; display: flex; flex-direction: column; gap: .6rem; }
.plain-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .4rem; }
.referral-actions { justify-content: flex-end; }
.referral-actions .inline-form input { width: 150px; }

/* =====================================================================
   Mobile / installed-app experience
   Desktop layout is unchanged; everything below targets phones and the
   installed (standalone) app.
   ===================================================================== */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; }

/* Smooth cross-page fades in browsers that support them (Chrome/Edge 126+, Safari 18.2+) */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .15s; }
.site-header, .tabbar { view-transition-name: none; }

/* Hidden on desktop */
.account-menu, .tabbar { display: none; }

/* Shared popover menu (built on <details> so it works without JavaScript) */
.popover { position: relative; }
.popover > summary { list-style: none; cursor: pointer; }
.popover > summary::-webkit-details-marker { display: none; }
.popover-panel {
  position: absolute;
  right: 0;
  min-width: 220px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(16, 24, 40, .18);
  padding: .35rem;
  z-index: 60;
  display: flex;
  flex-direction: column;
}
.popover-panel a, .popover-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: .75rem .85rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font: inherit;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
}
.popover-panel a:active, .popover-btn:active, .popover-panel a.active { background: var(--navy-light); color: var(--navy); }
.popover-panel form { margin: 0; }
.popover-btn.danger { color: var(--red); }
.popover-btn[hidden] { display: none; }
.popover-who { padding: .6rem .85rem .7rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; display: flex; flex-direction: column; gap: .1rem; }
.popover-who .admin-tag { align-self: flex-start; }
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--white);
  font-weight: 700;
  font-size: .85rem;
  letter-spacing: .02em;
}

/* Offline page */
.offline-box { text-align: center; }
.offline-logo { width: 96px; height: 96px; margin-bottom: 1rem; border-radius: 22px; box-shadow: 0 4px 14px rgba(16, 24, 40, .12); }

@media (max-width: 900px) {
  /* ---- App shell: slim sticky header + bottom tab bar ---- */
  .site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    padding-top: env(safe-area-inset-top);
  }
  .site-header .inner {
    flex-wrap: nowrap;
    min-height: 56px;
    padding: 0 max(1rem, env(safe-area-inset-right)) 0 max(1rem, env(safe-area-inset-left));
    justify-content: space-between;
  }
  .brand img { height: 34px; }
  .brand .brand-sub { display: none; }
  .main-nav, .user-menu { display: none; }
  .account-menu { display: block; }
  .account-menu .popover-panel { top: calc(100% + .5rem); }

  body.has-tabbar { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    background: rgba(255, 255, 255, .96);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    backdrop-filter: saturate(180%) blur(12px);
    border-top: 1px solid var(--border);
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  .tabbar > .tab, .tabbar > .tab-more { flex: 1 1 0; }
  .tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 64px;
    color: var(--muted);
    text-decoration: none;
    font-size: .72rem;
    font-weight: 600;
    user-select: none;
  }
  .tab .icon { padding: 3px 18px; box-sizing: content-box; border-radius: 999px; transition: background-color .15s; }
  .tab.active { color: var(--navy); }
  .tab.active .icon { background: var(--navy-light); }
  .tab-more .popover-panel { bottom: calc(100% + .5rem); right: .5rem; }

  /* ---- Content ---- */
  .container { padding: 1rem max(.85rem, env(safe-area-inset-right)) 1.5rem max(.85rem, env(safe-area-inset-left)); }
  h1 { font-size: 1.35rem; }
  .page-head { margin-bottom: 1rem; }
  .page-head > .btn, .page-head > .btn-row { width: 100%; }
  .page-head > .btn { text-align: center; }
  .card { border-radius: 12px; margin-bottom: 1rem; }
  .card-head { padding: .8rem .95rem; flex-wrap: wrap; }
  .card-body { padding: .95rem; }
  .stat .value { font-size: 1.4rem; }
  .grid { gap: .85rem; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .site-footer { padding-bottom: 1rem; }

  /* ---- Touch-friendly controls ---- */
  /* 16px inputs stop iOS zooming in on focus */
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
  input[type=tel], input[type=file], select, textarea { font-size: 16px; min-height: 44px; }
  .btn { min-height: 44px; padding: .6rem 1rem; display: inline-flex; align-items: center; justify-content: center; }
  .btn-sm { min-height: 36px; padding: .35rem .75rem; }
  .btn-block { display: flex; }
  .inline-form select, .inline-form input { flex: 1 1 140px; }
  .checkbox input { width: 20px; height: 20px; }
  .filter-bar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .filter-bar .field { min-width: 0; }
  .tabs { overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { white-space: nowrap; padding: .5rem .9rem; }
  .help .help-text { width: min(260px, 75vw); }
  .share-box .btn { flex: 1 1 0; }
  .promo { border-radius: 12px; }
  .promo .btn-row { width: 100%; }
  .promo .btn-row > * { flex: 1 1 0; }
  .promo .btn-row .btn { width: 100%; }
  .referral-actions { justify-content: stretch; }
  .referral-actions .inline-form input { width: auto; }
  .message-head { flex-wrap: wrap; gap: .25rem .75rem; }
  .steps li { min-width: 0; flex-basis: 100%; }
  .auth-page { min-height: 100dvh; padding: calc(1.5rem + env(safe-area-inset-top)) 1rem calc(1.5rem + env(safe-area-inset-bottom)); }
  .auth-logo img { height: 88px; }
}

/* ---- Tables become stacked cards on phones (app.js labels each cell from its column header) ---- */
@media (max-width: 700px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tfoot, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { padding: .7rem .95rem; border-bottom: 1px solid var(--border); }
  table.stack tbody tr:last-child { border-bottom: none; }
  table.stack td { border: none; padding: .2rem 0; text-align: right; overflow-wrap: anywhere; }
  table.stack td::before {
    content: attr(data-label);
    float: left;
    margin-right: 1rem;
    color: var(--muted);
    font-size: .82rem;
    font-weight: 500;
  }
  table.stack td.num { white-space: normal; }
  table.stack td[data-label=""]::before { display: none; }
  table.stack td:empty { display: none; }
  table.stack tfoot tr { background: #fafbfc; }
  table.stack td.actions { padding-top: .5rem; }
  /* First column is the card's title */
  table.stack td:first-child { font-weight: 600; font-size: 1rem; text-align: left; padding-bottom: .35rem; }
  table.stack td:first-child::before { display: none; }
  /* Ticket tables lead with "#": show it as a small prefix and use the subject as the title */
  table.stack.id-first td:first-child { font-size: .8rem; font-weight: 600; color: var(--muted); padding-bottom: 0; }
  table.stack.id-first td:first-child:not(:empty)::before { display: inline; float: none; content: "#"; margin: 0; font-size: inherit; font-weight: inherit; }
  table.stack.id-first td:nth-child(2) { text-align: left; font-weight: 600; font-size: 1rem; padding-bottom: .35rem; }
  table.stack.id-first td:nth-child(2)::before { display: none; }
}

/* ---- Installed app: no browser chrome, so drop page-y extras ---- */
@media (display-mode: standalone) {
  .site-footer { display: none; }
  body { overscroll-behavior-y: none; }
  .site-header, .tabbar { user-select: none; -webkit-user-select: none; }
}
