:root {
  --primary: #1da1f2;
  --primary-active: #0d8fd4;
  --accent: #f05b72;
  --ink: #26251e;
  --body: #5a5852;
  --muted: #807d72;
  --muted-soft: #a09c92;
  --hairline: #e6e5e0;
  --hairline-soft: #efeee8;
  --hairline-strong: #cfcdc4;
  --canvas: #f7f7f4;
  --canvas-soft: #fafaf7;
  --card: #ffffff;
  --surface-strong: #e6e5e0;
  --on-primary: #ffffff;
  --success: #1f8a65;
  --error: #cf2d56;
  --brand: var(--primary);
  --brand-d: var(--primary-active);
  --line: var(--hairline);
  --bg: var(--canvas);
  --green: var(--success);
  --green-s: #e8f4ef;
  --pink: var(--error);
  --radius: 12px;
  --radius-md: 8px;
  --font: Inter, system-ui, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body {
  font-family: var(--font);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--ink);
  background: var(--canvas);
}
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* Admin top bar */
.topnav {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 64px;
  padding: 0 32px;
  background: var(--canvas);
  border-bottom: 1px solid var(--hairline);
}

/* Portal — one shell card: rail + page, expand pushes content */
body.portal-app {
  --rail: 72px;
  --shell-pad: 12px;
  min-height: 100vh;
  padding: var(--shell-pad);
  overflow: hidden;
}
.app-shell {
  display: flex;
  align-items: stretch;
  height: calc(100vh - var(--shell-pad) * 2);
  min-height: 0;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(38, 37, 30, 0.04);
}
.sidebar {
  position: relative;
  flex: 0 0 auto;
  width: var(--rail);
  height: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 0 12px;
  background: var(--card);
  border-right: 1px solid var(--hairline);
  overflow: hidden;
  z-index: 2;
  transition: width .18s ease;
}
.sidebar:hover,
.sidebar:focus-within,
body.account-open .sidebar {
  width: 248px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 500; letter-spacing: 0;
  text-decoration: none; color: var(--ink);
}
.sidebar .brand {
  height: 44px;
  margin: 0 0 10px;
  padding: 0 0 0 22px;
  gap: 12px;
  white-space: nowrap;
}
.brand-mark,
.brand-logo {
  width: 28px; height: 28px; border-radius: var(--radius-md);
  background: #fff; color: var(--primary);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600; flex-shrink: 0;
  object-fit: contain;
  border: 1px solid var(--hairline);
}
.brand-logo { padding: 0; }
.nav-ico {
  width: 20px; height: 20px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.nav-label { white-space: nowrap; overflow: hidden; }
.sidebar .nav-label {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}
.sidebar:hover .nav-label,
.sidebar:focus-within .nav-label,
body.account-open .sidebar .nav-label,
body.portal-app.nav-open .sidebar .nav-label {
  max-width: 160px;
  opacity: 1;
  pointer-events: auto;
}
.nav-links { display: flex; flex-wrap: wrap; gap: 4px; }
.sidebar .nav-links {
  flex: 1; flex-direction: column; flex-wrap: nowrap;
  gap: 2px; min-height: 0;
}
.nav-links a, .nav-links button.nav-btn {
  border: 0; background: transparent;
  padding: 8px 12px; border-radius: var(--radius-md);
  font-size: 14px; font-weight: 500; line-height: 1.4;
  color: var(--body); text-decoration: none;
}
.sidebar .nav-links a {
  display: flex; align-items: center; gap: 12px;
  width: auto; height: 36px;
  margin: 0 10px; padding: 0 10px 0 16px;
  color: var(--body);
}
.sidebar .nav-links a:hover {
  background: var(--hairline-soft);
  color: var(--ink);
}
.nav-links a.active, .nav-links button.nav-btn.active {
  background: var(--ink); color: var(--canvas);
}
.sidebar .nav-links a.active {
  background: transparent;
  color: var(--primary);
  font-weight: 600;
}
.sidebar-foot {
  margin-top: auto;
  padding: 12px 0 4px;
  border-top: 1px solid var(--hairline);
  display: flex; flex-direction: column; align-items: stretch; gap: 6px;
}
.userbox { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.topnav .userbox { font-size: 13px; }
.userbox img { width: 28px; height: 28px; border-radius: 9999px; }
.account-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 8px 8px 4px;
}
.sidebar:hover .account-row,
.sidebar:focus-within .account-row,
body.account-open .account-row {
  flex-direction: row;
  align-items: center;
}
.topnav .account-row {
  flex-direction: row;
  margin: 0;
}
.account-row-guest:has(.update-btn.hidden) { display: none; }
.sidebar-user {
  display: flex; align-items: center; gap: 12px;
  height: 36px; margin: 0; padding: 0 8px 0 12px;
  border: 0; background: transparent;
  font-size: 13px; font-weight: 500; color: var(--ink); white-space: nowrap;
  text-align: left; cursor: pointer; min-width: 0;
}
.sidebar:hover .sidebar-user,
.sidebar:focus-within .sidebar-user,
body.account-open .sidebar-user { flex: 1; }
.topnav .sidebar-user { height: 40px; padding: 0 10px; }
.sidebar-user:hover { background: var(--hairline-soft); border-radius: 8px; }
.sidebar-user img,
.sidebar-user .brand-mark,
.sidebar-user .user-avatar { width: 24px; height: 24px; border-radius: 9999px; flex-shrink: 0; }
.sidebar-user .brand-mark { border-radius: 6px; font-size: 9px; }
.sidebar-user .user-avatar {
  display: grid; place-items: center;
  background: var(--hairline-soft); color: var(--body);
  font-size: 9px; font-weight: 600; letter-spacing: 0.02em;
}
.sidebar-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.update-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 9999px;
  background: var(--ink);
  color: var(--canvas);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  overflow: hidden;
  transition: width .18s ease, padding .18s ease, gap .18s ease;
}
.update-btn .update-ico {
  width: 16px; height: 16px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.update-btn .update-label {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: max-width .18s ease, opacity .18s ease;
}
.update-btn:hover,
.update-btn:focus,
.update-btn:focus-visible,
.update-btn.is-wide {
  width: 108px;
  padding: 0 12px 0 10px;
  gap: 6px;
}
.update-btn:hover .update-label,
.update-btn:focus .update-label,
.update-btn:focus-visible .update-label,
.update-btn.is-wide .update-label {
  max-width: 72px;
  opacity: 1;
}
.account-pop {
  position: fixed;
  z-index: 70;
  width: 260px;
  padding: 8px;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(38, 37, 30, .08);
}
.update-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #eef6fc;
  color: var(--primary);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
}
.btn-install {
  background: var(--ink);
  color: var(--canvas);
  border: 0;
  border-radius: 6px;
  height: 28px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
}
.account-pop-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  text-align: left;
}
.account-pop-item:hover { background: var(--hairline-soft); }
.account-pop-item .nav-ico { width: 18px; height: 18px; color: var(--body); }
.account-pop-rule {
  height: 1px;
  background: var(--hairline);
  margin: 6px 4px;
}
.nav-foot-btn {
  display: flex; align-items: center; gap: 12px;
  height: 36px; margin: 0 10px; padding: 0 10px 0 16px;
  border: 0; border-radius: var(--radius-md);
  background: transparent; color: var(--body);
  font-size: 14px; font-weight: 500; text-align: left; white-space: nowrap;
}
.nav-foot-btn:hover { background: var(--hairline-soft); color: var(--ink); }
.nav-foot-btn.primary { color: var(--primary); font-weight: 500; }

.btn {
  border: 0; border-radius: var(--radius-md);
  padding: 10px 18px; height: 40px;
  font-size: 14px; font-weight: 500; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition-property: background-color, color, border-color, transform;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}
.btn:active { transform: scale(0.96); }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-active); }
.btn-ghost {
  background: var(--card);
  border: 1px solid var(--hairline-strong);
  color: var(--ink);
}
.btn-ghost:hover { background: var(--canvas-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.sidebar-toggle, .sidebar-scrim { display: none; }

body.portal-app main#app {
  flex: 1; min-width: 0; width: auto;
  max-width: none;
  margin: 0; padding: 40px 32px 80px;
  overflow-x: clip;
  overflow-y: auto;
  background: var(--canvas-soft);
}
@media (prefers-reduced-motion: reduce) {
  .sidebar, .btn, .update-btn, .update-btn .update-label { transition: none; }
  .btn:active { transform: none; }
}

main { max-width: 1200px; margin: 0 auto; padding: 32px 20px 80px; min-width: 0; }

.hero { min-width: 0; }
.hero h1 {
  font-size: clamp(28px, 4vw, 36px); font-weight: 400; line-height: 1.2;
  letter-spacing: -0.72px; margin: 0 0 8px;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.hero p {
  margin: 0 0 8px; color: var(--body); max-width: 40rem;
  font-size: 16px; text-wrap: pretty;
}
.share-home {
  margin-top: 20px;
  max-width: 40rem;
  min-width: 0;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}
.share-home h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.2px;
}
.share-home .hint {
  margin: 4px 0 12px;
  color: var(--muted);
  font-size: 13px;
  text-wrap: pretty;
}
.share-home .copy-row { margin-top: 0; }

.group-block { margin-top: 40px; min-width: 0; }
.group { margin: 0 0 14px; }
.group h2 {
  margin: 0; font-size: 22px; font-weight: 400;
  line-height: 1.3; letter-spacing: -0.11px;
  text-wrap: balance;
}
.group .hint { color: var(--muted); font-size: 14px; margin-top: 4px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 16px;
  align-items: stretch;
  min-width: 0;
}
.card {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; flex-direction: column; gap: 10px;
  min-width: 0;
  height: 100%;
}
.card-top {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 8px; min-width: 0;
}
.card-badges {
  display: flex; flex-wrap: wrap; gap: 4px;
  justify-content: flex-end; min-width: 0;
}
.mark {
  width: 40px; height: 40px; border-radius: var(--radius-md);
  display: grid; place-items: center;
  font-weight: 600; font-size: 13px;
  color: var(--ink); background: var(--canvas-soft);
  border: 1px solid var(--hairline);
  flex-shrink: 0;
}
.mark.phone, .mark.addons, .mark.tapmego, .mark.credits {
  background: var(--canvas-soft); color: var(--ink);
}
.badge {
  font-size: 11px; font-weight: 600; letter-spacing: 0.88px;
  text-transform: uppercase; line-height: 1.4;
  padding: 4px 10px; border-radius: 9999px;
  background: var(--surface-strong); color: var(--ink);
  white-space: nowrap;
}
.badge.hot { background: var(--accent); color: var(--on-primary); }
.card h3 {
  margin: 0; font-size: 18px; font-weight: 600; line-height: 1.4;
  overflow-wrap: anywhere;
}
.card .tagline {
  margin: 0; color: var(--body); font-size: 14px;
  min-height: 0; text-wrap: pretty;
  overflow-wrap: anywhere;
}
.price {
  font-size: 22px; font-weight: 400; letter-spacing: -0.11px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.price span { font-size: 14px; font-weight: 400; color: var(--muted); }
.features {
  margin: 0; padding-left: 18px; color: var(--body); font-size: 14px;
  overflow-wrap: anywhere;
}
.copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: auto;
  width: 100%;
  min-width: 0;
  align-items: center;
}
.copy-row input {
  width: 100%;
  min-width: 0;
  height: 40px;
  border: 1px solid var(--hairline); border-radius: var(--radius-md);
  padding: 0 12px; font-size: 13px; color: var(--muted);
  background: var(--card); font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.copy-row .btn {
  height: 40px;
  padding: 0 14px;
  white-space: nowrap;
  flex-shrink: 0;
}
.copy-row-login { grid-template-columns: 1fr; }
.copy-row-login .btn { width: 100%; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: 12px; margin-bottom: 22px; }
.kpi {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 24px;
  min-width: 0;
}
.kpi .lbl {
  font-size: 11px; font-weight: 600; letter-spacing: 0.88px;
  text-transform: uppercase; color: var(--muted);
}
.kpi .val {
  font-size: clamp(20px, 3vw, 26px); font-weight: 400; letter-spacing: -0.325px;
  margin-top: 6px; font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.panel {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 100%;
  min-width: 0;
}
.table-wrap,
.panel:has(table) {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 14px;
  table-layout: auto;
}
th, td {
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
  white-space: nowrap;
  vertical-align: middle;
  padding: 12px 16px;
}
th {
  text-align: left; font-size: 11px; font-weight: 600;
  letter-spacing: 0.88px; text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--hairline);
}
td {
  border-bottom: 1px solid var(--hairline-soft);
  color: var(--body);
}
tbody tr:hover td { background: var(--canvas-soft); }
td.cell-text {
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  max-width: 220px;
  line-height: 1.4;
}
td.cell-email {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
td.num {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.when {
  display: flex;
  flex-direction: column;
  gap: 2px;
  white-space: nowrap;
  line-height: 1.3;
}
.when-t { font-size: 12px; color: var(--muted); }
.type-pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 8px; border-radius: 9999px;
  background: var(--canvas-soft); color: var(--body);
  white-space: nowrap;
}
.type-pill.type-payment { background: var(--green-s); color: var(--success); }
.type-pill.type-signup { background: var(--surface-strong); color: var(--ink); }
.type-pill.type-recurring { background: #e8f1fb; color: var(--primary); }
.status {
  display: inline-flex;
  align-items: center;
  font-size: 11px; font-weight: 600; letter-spacing: 0.88px;
  text-transform: uppercase; padding: 4px 10px; border-radius: 9999px;
  background: var(--surface-strong); color: var(--ink);
  white-space: nowrap;
}
.status.pending { background: var(--surface-strong); color: var(--ink); }
.status.active, .status.approved, .status.paid {
  background: var(--green-s); color: var(--success);
}
.status.paused, .status.reserved { background: var(--canvas-soft); color: var(--body); }
.status.requested { background: var(--surface-strong); color: var(--ink); }
.status.reversed, .status.rejected { background: #f8e8ec; color: var(--error); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; color: var(--ink); min-width: 0; }
.field input, .field textarea, .field select {
  border: 1px solid var(--hairline); border-radius: var(--radius-md);
  padding: 12px 16px; height: 44px; font-weight: 400;
  background: var(--card); color: var(--ink);
  width: 100%; min-width: 0;
}
.field textarea { height: auto; min-height: 88px; }
.banner {
  background: var(--canvas-soft);
  border: 1px solid var(--hairline);
  color: var(--body);
  border-radius: var(--radius); padding: 12px 16px;
  font-size: 14px; margin-bottom: 16px;
}

.modal-bg {
  position: fixed; inset: 0;
  background: rgba(38, 37, 30, .4);
  display: grid; place-items: center; z-index: 80; padding: 20px;
}
.modal {
  width: 100%; max-width: 400px;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 32px; text-align: center;
}
.modal h2 {
  margin: 0 0 20px;
  font-size: 22px; font-weight: 400;
  letter-spacing: -0.11px; line-height: 1.3;
}
.modal p { color: var(--body); font-size: 14px; margin: 0 0 20px; }
#google-signin-btn, #admin-google-btn { display: flex; justify-content: center; min-height: 44px; }
.err { color: var(--error); font-size: 13px; font-weight: 500; margin-top: 12px; }
.empty { color: var(--muted); font-size: 14px; padding: 24px 0; text-align: center; }

.tabs {
  display: flex; gap: 6px;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 4px; width: fit-content; margin-bottom: 18px;
}
.tab {
  border: 0; background: transparent;
  padding: 9px 16px; border-radius: 6px;
  font-size: 14px; font-weight: 500; color: var(--muted);
}
.tab.active { background: var(--ink); color: var(--canvas); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; min-width: 0; }
.toolbar input, .toolbar select {
  border: 1px solid var(--hairline); border-radius: var(--radius-md);
  padding: 8px 12px; height: 40px; background: var(--card); color: var(--ink);
  min-width: 0; flex: 1 1 160px;
}
.mono { font-family: var(--font-mono); font-size: 12px; }

@media (max-width: 720px) {
  .topnav { flex-wrap: wrap; height: auto; padding: 10px 14px; }
  .hero h1 { font-size: 28px; letter-spacing: -0.5px; }
  .form-grid { grid-template-columns: 1fr; }
  body.portal-app {
    padding: 0;
    overflow: hidden;
  }
  .app-shell {
    height: 100vh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  body.portal-app main#app { padding: 64px 16px 80px; }
  .copy-row {
    grid-template-columns: 1fr;
  }
  .copy-row .btn { width: 100%; }
  .tabs { width: 100%; overflow-x: auto; }
  table { min-width: 640px; }

  .sidebar-toggle {
    display: inline-flex;
    position: fixed; top: 12px; left: 12px; z-index: 60;
    border: 1px solid var(--hairline-strong); background: var(--card); color: var(--ink);
    border-radius: var(--radius-md); padding: 8px 12px;
    font-weight: 500; font-size: 14px; height: 40px;
  }
  .sidebar-scrim {
    display: none; position: fixed; inset: 0; z-index: 45;
    background: rgba(38, 37, 30, .4);
  }
  body.portal-app.nav-open .sidebar-scrim { display: block; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 50;
    flex: none;
    width: 248px;
    height: 100vh;
    transform: translateX(-105%);
    transition: transform .2s ease;
    border-right: 1px solid var(--hairline);
    box-shadow: 8px 0 24px rgba(38, 37, 30, .08);
  }
  .sidebar:hover,
  .sidebar:focus-within,
  body.account-open .sidebar {
    flex-basis: 248px;
    width: 248px;
  }
  body.portal-app.nav-open .sidebar { transform: translateX(0); }
  .sidebar-foot {
    padding: 12px 0 max(16px, env(safe-area-inset-bottom));
  }
  .account-row {
    flex-direction: column;
    align-items: stretch;
    margin: 4px 10px 8px;
    gap: 4px;
  }
  .sidebar-user {
    width: 100%;
    padding: 0 10px 0 16px;
  }
  .update-btn,
  .update-btn:hover,
  .update-btn:focus,
  .update-btn:focus-visible,
  .update-btn.is-wide {
    width: 100%;
    height: 36px;
    justify-content: flex-start;
    padding: 0 10px 0 16px;
    gap: 12px;
    border-radius: var(--radius-md);
  }
  .update-btn .update-label,
  .update-btn:hover .update-label,
  .update-btn:focus .update-label,
  .update-btn.is-wide .update-label {
    max-width: 80px;
    opacity: 1;
  }
}
