:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --line: #e4e9ef;
  --text: #1a2332;
  --muted: #6b7785;
  --accent: #0d7a6f;
  --accent-soft: #e6f4f2;
  --accent-dark: #095c54;
  --warn: #c97816;
  --danger: #c4473a;
  --ok: #1f8a5b;
  --shadow: 0 10px 30px rgba(26, 35, 50, 0.08);
  --radius: 16px;
  --font: "Onest", system-ui, sans-serif;
  --display: "Unbounded", system-ui, sans-serif;
  --tabbar-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: #dfe5ec;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

.app {
  width: min(430px, 100%);
  min-height: 100%;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  box-shadow: 0 0 0 1px rgba(0,0,0,.04), 0 20px 60px rgba(26,35,50,.12);
}

.screen { min-height: 100vh; min-height: 100dvh; }
.shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr var(--tabbar-h);
  padding-bottom: var(--safe-b);
}

/* AUTH */
.screen-auth {
  display: grid;
  gap: 1rem;
  padding: 1.25rem 1.1rem 1.5rem;
  background:
    radial-gradient(700px 280px at 50% -10%, rgba(13,122,111,.18), transparent 60%),
    var(--bg);
}
.auth-hero { padding: .5rem .15rem 0; }
.brand, .brand-sm {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--accent);
}
.brand { font-size: 2rem; }
.brand-sm { font-size: .85rem; }
.auth-hero h1 {
  margin: .55rem 0 .6rem;
  font-family: var(--display);
  font-size: 1.35rem;
  line-height: 1.25;
  font-weight: 600;
}
.auth-lead { margin: 0; color: var(--muted); line-height: 1.45; }
.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .35rem;
  padding: .3rem;
  background: var(--bg);
  border-radius: 999px;
  margin-bottom: 1rem;
}
.seg-btn {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: .65rem;
  font-weight: 600;
  color: var(--muted);
}
.seg-btn.is-on {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.form { display: grid; gap: .75rem; }
.form label { display: grid; gap: .35rem; font-size: .85rem; color: var(--muted); font-weight: 500; }
.form input, .form select, .form textarea,
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: .75rem .85rem;
}
.form input:focus, .form select:focus, .form textarea:focus,
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid rgba(13,122,111,.35);
  border-color: var(--accent);
}
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.hint { margin: 0; font-size: .78rem; color: var(--muted); line-height: 1.4; }

.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: .8rem 1.1rem;
  font-weight: 700;
  transition: transform .12s ease, background .15s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-soft { background: var(--accent-soft); color: var(--accent-dark); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-danger { background: #fdeceb; color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { padding: .55rem .9rem; font-size: .88rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* TOP + TABS */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .85rem 1rem .55rem;
  background: rgba(245,247,250,.92);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
}
.top h2 { margin: .15rem 0 0; font-size: 1.2rem; font-family: var(--display); font-weight: 600; }
.icon-btn {
  position: relative;
  width: 42px; height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  display: grid;
  place-items: center;
}
.bell {
  width: 16px;
  height: 16px;
  border: 2px solid var(--text);
  border-radius: 8px 8px 4px 4px;
  position: relative;
}
.bell::after {
  content: "";
  position: absolute;
  left: 3px;
  bottom: -5px;
  width: 6px;
  height: 3px;
  border: 2px solid var(--text);
  border-top: 0;
  border-radius: 0 0 4px 4px;
}
.ti {
  width: 18px;
  height: 18px;
  display: block;
  position: relative;
}
.ti-feed::before, .ti-feed::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
}
.ti-feed::before { top: 4px; box-shadow: 0 5px 0 currentColor; }
.ti-feed::after { bottom: 4px; }
.ti-plus::before, .ti-plus::after {
  content: "";
  position: absolute;
  background: currentColor;
  border-radius: 2px;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
}
.ti-plus::before { width: 14px; height: 2px; }
.ti-plus::after { width: 2px; height: 14px; }
.ti-chat {
  border: 2px solid currentColor;
  border-radius: 5px 5px 5px 2px;
}
.ti-user::before {
  content: "";
  position: absolute;
  width: 8px; height: 8px;
  border: 2px solid currentColor;
  border-radius: 50%;
  left: 3px; top: 0;
}
.ti-user::after {
  content: "";
  position: absolute;
  left: 1px; bottom: 0;
  width: 12px; height: 7px;
  border: 2px solid currentColor;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
}
.ti-help {
  border: 2px solid currentColor;
  border-radius: 50%;
}
.ti-help::before {
  content: "?";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  font-style: normal;
}
.dot {
  position: absolute;
  top: 8px; right: 8px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
}

.main {
  padding: .85rem 1rem 1.25rem;
  overflow: auto;
}

.tabbar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .15rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: .35rem .25rem calc(.35rem + var(--safe-b));
  position: sticky;
  bottom: 0;
  z-index: 10;
}
.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 600;
  padding: .45rem .2rem;
  border-radius: 12px;
  display: grid;
  justify-items: center;
  gap: .2rem;
}
.tab.is-on { color: var(--accent); background: var(--accent-soft); }

/* CARDS / LISTS */
.filters {
  display: grid;
  gap: .55rem;
  margin-bottom: .9rem;
  padding: .85rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.filters-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .55rem;
}
.filters label, .field {
  display: grid;
  gap: .3rem;
  font-size: .78rem;
  color: var(--muted);
  font-weight: 500;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .4rem;
  margin-bottom: .85rem;
}
.mode-switch .btn { width: 100%; }

.meta-line {
  margin: 0 0 .75rem;
  color: var(--muted);
  font-size: .9rem;
}

.list { display: grid; gap: .7rem; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .95rem;
  box-shadow: 0 4px 14px rgba(26,35,50,.04);
}
.card:active { background: #fafbfc; }
.card-top {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  align-items: start;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .22rem .55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: .72rem;
  font-weight: 700;
}
.pill.gray { background: #eef1f5; color: var(--muted); }
.pill.warn { background: #fff3e4; color: var(--warn); }
.pill.ok { background: #e8f7ef; color: var(--ok); }
.card h3 { margin: .45rem 0 .25rem; font-size: 1.05rem; line-height: 1.25; }
.muted { color: var(--muted); }
.pay {
  font-family: var(--display);
  font-size: 1.05rem;
  color: var(--accent-dark);
  white-space: nowrap;
}
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin-top: .75rem;
}
.empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.profile-head {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: .85rem;
  align-items: center;
  margin-bottom: 1rem;
}
.avatar {
  width: 72px; height: 72px;
  border-radius: 20px;
  object-fit: cover;
  background: var(--accent-soft);
  border: 1px solid var(--line);
}
.avatar-ph {
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 700;
  color: var(--accent);
  font-size: 1.4rem;
}
.stars { color: var(--warn); font-weight: 700; letter-spacing: .04em; }
.stack { display: grid; gap: .7rem; }
.review {
  padding: .75rem;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.review strong { display: block; margin-bottom: .2rem; }

.chat-list-item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: .7rem;
  align-items: center;
  text-align: left;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 14px;
  padding: .7rem;
}
.chat-list-item .avatar, .chat-list-item .avatar-ph {
  width: 44px; height: 44px; border-radius: 14px; font-size: 1rem;
}
.chat-thread {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  min-height: 220px;
  max-height: 45vh;
  overflow: auto;
  padding: .25rem;
}
.bubble {
  max-width: 85%;
  padding: .65rem .8rem;
  border-radius: 14px;
  background: #eef1f5;
  line-height: 1.35;
  font-size: .92rem;
}
.bubble.me {
  align-self: flex-end;
  background: var(--accent-soft);
  color: var(--accent-dark);
}
.bubble .when { display: block; margin-top: .25rem; font-size: .7rem; opacity: .7; }
.chat-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .5rem;
  margin-top: .75rem;
}

.help details {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: .85rem 1rem;
}
.help summary { font-weight: 700; cursor: pointer; }
.help p, .help ol { color: var(--muted); line-height: 1.45; }
.help ol { padding-left: 1.1rem; }

/* OVERLAY */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(26,35,50,.4);
  z-index: 40;
  display: grid;
  align-items: end;
}
.sheet {
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  max-height: 88%;
  display: grid;
  grid-template-rows: auto 1fr;
  box-shadow: var(--shadow);
}
.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1rem .4rem;
  border-bottom: 1px solid var(--line);
}
.sheet-head h3 { margin: 0; font-size: 1.05rem; }
.sheet-body {
  overflow: auto;
  padding: 1rem;
  padding-bottom: calc(1rem + var(--safe-b));
}

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 12px + var(--safe-b));
  transform: translateX(-50%) translateY(8px);
  background: var(--text);
  color: #fff;
  border-radius: 999px;
  padding: .7rem 1rem;
  font-size: .88rem;
  font-weight: 600;
  opacity: 0;
  transition: .2s ease;
  z-index: 50;
  max-width: calc(100% - 2rem);
  text-align: center;
}
.toast.is-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.notif-item {
  padding: .8rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  margin-bottom: .55rem;
}
.notif-item.unread { border-color: rgba(13,122,111,.35); background: var(--accent-soft); }
.notif-item time { display: block; margin-top: .3rem; font-size: .75rem; color: var(--muted); }

.rate-row {
  display: flex;
  gap: .35rem;
  margin: .5rem 0 .75rem;
}
.rate-row button {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 1.1rem;
}
.rate-row button.is-on { background: #fff3e4; border-color: #f0c48a; }

@media (min-width: 860px) {
  body { padding: 1.5rem 0; }
  .app { min-height: calc(100vh - 3rem); border-radius: 24px; overflow: hidden; }
}
