* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; background: #f5f6f8; color: #172033; }
.topbar { position: sticky; top: 0; z-index: 5; background: white; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 12px rgba(0,0,0,.06); }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 18px; margin: 0 0 12px; }
p { margin: 6px 0; }
main { max-width: 720px; margin: 0 auto; padding: 12px; }
.card { background: white; border-radius: 16px; padding: 14px; margin: 12px 0; box-shadow: 0 2px 12px rgba(0,0,0,.06); }
input, select, textarea, button { width: 100%; border-radius: 12px; border: 1px solid #d8deea; padding: 12px; margin: 7px 0; font-size: 15px; }
textarea { min-height: 80px; resize: vertical; }
button { background: #155eef; color: white; border: 0; font-weight: 700; cursor: pointer; }
button.secondary { background: #eef3ff; color: #155eef; }
button.danger { background: #fff1f0; color: #d92d20; width: auto; padding: 9px 12px; }
.hidden { display: none !important; }
.tabs, .bottom-tabs { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; }
.bottom-tabs { grid-template-columns: repeat(5,1fr); position: sticky; top: 72px; z-index: 4; background: #f5f6f8; padding: 8px 0; }
.tab, .nav { background: #e9eefb; color: #344054; padding: 10px 6px; font-size: 13px; }
.tab.active, .nav.active { background: #155eef; color: white; }
.switch-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #eef1f6; }
.switch-row input { width: 22px; height: 22px; }
.category-list { display: grid; gap: 8px; }
.category-title { font-weight: 800; margin-top: 8px; color: #344054; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.place-item, .result-item, .admin-item { border: 1px solid #e5e9f2; border-radius: 14px; padding: 12px; margin: 10px 0; }
.muted { color: #667085; font-size: 13px; }
.wallet-card { display: flex; justify-content: space-between; align-items: center; }
.wallet-card button { width: auto; padding-left: 18px; padding-right: 18px; }
.toast { position: fixed; left: 12px; right: 12px; bottom: 16px; background: #101828; color: white; padding: 12px 14px; border-radius: 12px; z-index: 20; text-align: center; }
.small-actions { display: flex; gap: 8px; }
.small-actions button { padding: 8px; font-size: 13px; }
@media (max-width: 420px) { .bottom-tabs { top: 68px; gap: 4px; } .nav { font-size: 11px; padding: 9px 3px; } }

/* MVP 0.2 */
.small-label { display:block; margin:10px 0 6px; color:#64748b; font-size:13px; }
.chat-messages { max-height:360px; overflow:auto; background:#f8fafc; border:1px solid #e5e7eb; border-radius:14px; padding:10px; margin:12px 0; }
.message { background:#fff; border:1px solid #e5e7eb; border-radius:14px; padding:10px; margin:8px 0; max-width:85%; }
.message.mine { margin-left:auto; background:#eef4ff; border-color:#bfdbfe; }
.message img { max-width:100%; border-radius:12px; display:block; margin-bottom:6px; }
.message p { margin:4px 0; white-space:pre-wrap; }
.message small { color:#64748b; font-size:11px; }
.result-item h3, .admin-item h3 { margin-top:0; }
.hidden { display:none !important; }
@media (max-width: 640px) {
  .bottom-tabs { grid-template-columns: repeat(4, 1fr); gap:8px; }
  .bottom-tabs .nav { padding:10px 6px; font-size:13px; }
}


/* MVP 0.2.1 - Mobile app layout */
:root {
  --blue: #155eef;
  --bg: #f3f6fb;
  --card: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #e5e9f2;
}
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(78px + env(safe-area-inset-bottom));
}
.topbar {
  min-height: 54px;
  padding: 8px 12px;
  align-items: center;
}
.topbar h1 { font-size: 17px; line-height: 1.15; }
.topbar p { font-size: 12px; max-width: 230px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
main { max-width: 760px; padding: 10px; }
.card {
  border-radius: 18px;
  padding: 14px;
  margin: 10px 0;
  box-shadow: 0 2px 14px rgba(16, 24, 40, .06);
}
input, select, textarea, button {
  min-height: 46px;
  border-radius: 14px;
  font-size: 16px;
}
button { touch-action: manipulation; }
.wallet-card {
  padding: 10px 12px;
  margin: 8px 0 6px;
  border-radius: 16px;
}
.wallet-card .muted { margin: 0; font-size: 12px; }
.wallet-card h2 { font-size: 16px; margin: 2px 0 0; }
.wallet-card button { min-height: 40px; border-radius: 14px; padding: 8px 14px; }
.bottom-tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  z-index: 50;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 24px rgba(16, 24, 40, .08);
  scrollbar-width: none;
}
.bottom-tabs::-webkit-scrollbar { display: none; }
.bottom-tabs .nav {
  flex: 0 0 auto;
  width: auto;
  min-width: 76px;
  margin: 0;
  min-height: 48px;
  border-radius: 16px;
  font-size: 13px;
  padding: 8px 10px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.bottom-tabs .nav.active {
  box-shadow: 0 8px 18px rgba(21, 94, 239, .22);
}
.panel { animation: panelIn .14s ease-out; }
@keyframes panelIn { from { opacity: .5; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.switch-row {
  min-height: 48px;
  gap: 10px;
}
.switch-row input {
  min-height: auto;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  margin: 0;
}
.category-title {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  margin: 12px 0 4px;
}
.category-list .switch-row {
  background: white;
  border: 1px solid #eef1f6;
  border-radius: 14px;
  padding: 11px 12px;
  margin: 6px 0;
}
.place-item, .result-item, .admin-item {
  background: #fff;
  border-radius: 16px;
  padding: 12px;
}
.small-actions { flex-wrap: wrap; }
.small-actions button { flex: 1 1 120px; min-height: 42px; }
.chat-messages { max-height: 46vh; }
.message { max-width: 92%; }
.toast {
  bottom: calc(82px + env(safe-area-inset-bottom));
  border-radius: 16px;
}
@media (max-width: 640px) {
  .topbar { position: sticky; }
  .topbar div { min-width: 0; }
  .topbar button.danger { min-height: 38px; padding: 8px 10px; font-size: 13px; }
  main { padding: 8px; }
  .card { margin: 8px 0; padding: 13px; }
  h2 { font-size: 17px; margin-bottom: 10px; }
  .tabs { grid-template-columns: 1fr 1fr; gap: 8px; }
  .grid2 { grid-template-columns: 1fr; gap: 0; }
  .bottom-tabs { gap: 7px; padding-left: 8px; padding-right: 8px; }
  .bottom-tabs .nav { min-width: 74px; font-size: 12px; }
  .wallet-card { position: sticky; top: 54px; z-index: 6; }
}
@media (max-width: 380px) {
  .bottom-tabs .nav { min-width: 68px; font-size: 11.5px; padding-left: 8px; padding-right: 8px; }
  input, select, textarea, button { font-size: 15px; }
  .wallet-card h2 { font-size: 15px; }
}

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.row-actions button { flex: 1; min-width: 120px; }

.link-btn { background: transparent; color: #1d5fd7; width: auto; padding: 4px 0; font-size: 12px; text-align: left; }
button.secondary { background: #eef3ff; color: #0f3d99; }


/* MVP 0.6 - Admin overview */
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 10px 0 16px; }
.stat-card { border: 1px solid #e5e9f2; border-radius: 16px; padding: 12px; background: #f8fafc; }
.stat-card span { display: block; color: #667085; font-size: 12px; margin-bottom: 4px; }
.stat-card b { display: block; font-size: 22px; line-height: 1.2; color: #172033; }
.stat-card small { display: block; color: #667085; margin-top: 4px; }
.stat-card.warn { background: #fff8e6; border-color: #ffd666; }
@media (max-width: 430px) { .stat-grid { grid-template-columns: 1fr; } }


/* MVP 0.7 */
.badge { display:inline-block; background:#fff7ed; color:#c2410c; border:1px solid #fed7aa; border-radius:999px; padding:3px 8px; font-size:12px; font-weight:800; vertical-align:middle; }
.service-summary { background:#f8fafc; border:1px solid #e5e7eb; border-radius:12px; padding:10px; margin:8px 0; }

.result-item.unread { border-left: 4px solid #2563eb; background: #eff6ff; }
.service-summary { padding: 10px 12px; border-radius: 12px; background: #f8fafc; margin: 8px 0; }

/* MVP 0.9 - Search filters */
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted, #667085);
  font-size: 14px;
  padding: 6px 0;
  margin: 4px 0 8px;
}
.check-row input {
  width: 20px;
  height: 20px;
  min-height: 20px;
  margin: 0;
}
.check-row.compact {
  min-height: 46px;
  border: 1px solid #d8deea;
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
  margin: 7px 0;
}
.result-item .badge {
  display: inline-block;
  background: #fff4cc;
  color: #8a5a00;
  border: 1px solid #ffd666;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  vertical-align: middle;
}
@media (max-width: 520px) {
  .grid2 { grid-template-columns: 1fr; }
}

.wallet-grid .stat b { font-size: 22px; }
.wallet-tools { margin: 10px 0; }
.tx-item b { color: #111827; }
.tx-item p { margin: 5px 0; }


/* MVP 1.1 - Wallet always visible */
.wallet-card { gap: 10px; flex-wrap: wrap; }
.wallet-card .ref-block { min-width: 145px; }
.wallet-mini { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; flex: 1 1 260px; }
.wallet-mini span, .wallet-line { background: #f8fafc; border: 1px solid #e5e9f2; border-radius: 999px; padding: 7px 10px; font-size: 13px; color: #344054; }
.wallet-mini b, .wallet-line b { color: #155eef; }
.wallet-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 560px) {
  .wallet-card { align-items: stretch; }
  .wallet-mini { justify-content: flex-start; flex-basis: 100%; }
  .wallet-mini span { flex: 1 1 95px; text-align: center; }
  .wallet-card button { width: 100%; }
  .wallet-grid { grid-template-columns: 1fr; }
}


/* MVP 1.2 - Hoàn thiện Chat */
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.small-btn { width: auto; min-width: 88px; padding: 9px 12px; min-height: 40px; margin: 0; }
.chat-layout { display: grid; grid-template-columns: 0.85fr 1.35fr; gap: 12px; align-items: start; }
.chat-list-card, .chat-box { margin-top: 0; }
.chat-list { display: grid; gap: 8px; }
.chat-item { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 10px; align-items: center; border: 1px solid #e5e9f2; border-radius: 16px; padding: 10px; background: #fff; cursor: pointer; }
.chat-item:hover, .chat-item.active { border-color: #155eef; background: #eff6ff; }
.chat-avatar { width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #e9eefb; color: #155eef; font-weight: 900; }
.chat-item-main { min-width: 0; }
.chat-item-main b, .chat-item-main p { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-open { width: auto; min-width: 54px; min-height: 36px; padding: 7px 10px; font-size: 13px; }
.chat-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; border-bottom: 1px solid #eef1f6; padding-bottom: 8px; margin-bottom: 10px; }
.chat-control-row { display: grid; grid-template-columns: auto minmax(120px, 1fr) auto; gap: 8px; align-items: center; }
.chat-control-row .small-label { margin: 0; white-space: nowrap; }
.chat-control-row select, .chat-control-row button { margin: 0; }
.chat-actions { margin: 10px 0; }
.chat-thread { min-height: 320px; max-height: 58vh; padding: 12px; background: linear-gradient(180deg, #f8fafc 0%, #eef4ff 100%); }
.message-row { display: flex; margin: 8px 0; }
.message-row.mine-row { justify-content: flex-end; }
.message-row.their-row { justify-content: flex-start; }
.message { max-width: min(78%, 520px); box-shadow: 0 1px 4px rgba(16,24,40,.05); }
.message-name { font-size: 12px; font-weight: 800; color: #475467; margin-bottom: 3px; }
.message-meta { color: #64748b; font-size: 11px; margin-top: 6px; }
.message.mine .message-name { color: #155eef; }
.empty-chat { text-align: center; color: #475467; padding: 34px 12px; }
.chat-composer { position: sticky; bottom: calc(78px + env(safe-area-inset-bottom)); background: #fff; border: 1px solid #e5e9f2; border-radius: 16px; padding: 10px; box-shadow: 0 -3px 12px rgba(16,24,40,.05); }
.chat-composer textarea { min-height: 68px; }
.chat-composer button { margin-bottom: 0; }
@media (max-width: 760px) {
  .chat-layout { grid-template-columns: 1fr; gap: 8px; }
  .chat-list-card { margin-bottom: 8px; }
  .section-head, .chat-head { align-items: stretch; }
  .chat-control-row { grid-template-columns: 1fr; }
  .chat-thread { max-height: 48vh; min-height: 280px; }
  .message { max-width: 92%; }
}
@media (min-width: 900px) {
  main { max-width: 1080px; }
}

/* MVP 1.3 - Hoàn thiện địa điểm */
.place-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.badge-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.muted-badge {
  opacity: .65;
  background: #eef2f7;
  color: #64748b;
}
.primary-place {
  border-color: #2563eb;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}
.wrap-actions {
  flex-wrap: wrap;
}
.compact-actions {
  margin: 8px 0;
}
.place-form-card .check-row {
  min-height: 42px;
  align-items: center;
}
@media (max-width: 640px) {
  .place-title-row { flex-direction: column; gap: 4px; }
  .badge-row { justify-content: flex-start; }
}

.connection-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0 16px;
}
.connection-summary > div {
  background: #f6f8fb;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 10px;
  text-align: center;
}
.connection-summary b {
  display: block;
  font-size: 22px;
}
.connection-summary span {
  display: block;
  color: #64748b;
  font-size: 12px;
}
.connection-card {
  border-left: 4px solid #2563eb;
}
.ok-badge { background: #dcfce7; color: #166534; }
.wait-badge { background: #fef9c3; color: #854d0e; }
@media (max-width: 700px) {
  .connection-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}


/* MVP 1.5 - Hoàn thiện Cá nhân */
.profile-preview-card { overflow: hidden; }
.public-profile-card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 1px solid #e5e9f2;
  border-radius: 18px;
  padding: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  margin: 10px 0;
}
.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e9eefb;
  color: #155eef;
  font-size: 26px;
  font-weight: 900;
}
.profile-main h3 { margin: 0 0 4px; }
.profile-main p { margin: 3px 0; color: #475467; }
.left-badges { justify-content: flex-start; margin-top: 7px; }
.profile-info-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}
.profile-info-grid > div {
  border: 1px solid #e5e9f2;
  border-radius: 14px;
  padding: 10px;
  background: #f8fafc;
  min-width: 0;
}
.profile-info-grid span { display: block; color: #64748b; font-size: 12px; margin-bottom: 4px; }
.profile-info-grid b { display: block; color: #172033; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compact-profile-note { margin-top: 8px; }
.profile-check-list { display: grid; gap: 8px; margin: 8px 0 12px; }
.profile-check-list > div {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  border-radius: 14px;
  padding: 9px 10px;
  border: 1px solid #e5e9f2;
}
.profile-check-list b {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.check-ok { background: #f0fdf4; color: #166534; }
.check-ok b { background: #dcfce7; }
.check-warn { background: #fffbeb; color: #92400e; }
.check-warn b { background: #fef3c7; }
.profile-chip-list { display: flex; gap: 7px; flex-wrap: wrap; }
.profile-chip-list span {
  background: #eff6ff;
  color: #155eef;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 700;
}
@media (max-width: 680px) {
  .profile-info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 460px) {
  .public-profile-card { grid-template-columns: 52px minmax(0, 1fr); }
  .profile-avatar { width: 52px; height: 52px; font-size: 22px; }
}


/* MVP 1.6 - Admin tools */
.admin-filter-box{border:1px solid #e5e7eb;border-radius:14px;padding:12px;margin:10px 0;background:#f8fafc}
.admin-filter-box h3{margin:0 0 8px 0;font-size:15px}
.wallet-line{background:#fff7ed;border:1px solid #fed7aa;border-radius:12px;padding:8px 10px}
.wrap-actions{flex-wrap:wrap}
.small-btn{padding:8px 10px;font-size:13px}

/* MVP 1.7 - service package cards */
.service-price-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 10px 0 14px; }
.service-price-card { border: 1px solid #dbe4f0; border-radius: 14px; padding: 10px; background: #f8fafc; }
.service-price-card p { margin: 4px 0; }


.support-ticket { margin-top: 12px; }
.support-thread { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.support-message { border: 1px solid #e5e7eb; border-radius: 12px; padding: 10px; background: #fff; }
.support-message.admin-msg { background: #f0f7ff; }
.support-message.user-msg { background: #fafafa; }
.support-message p { margin: 4px 0; white-space: pre-wrap; }
.support-message small { color: #6b7280; }
