:root {
  color-scheme: dark;
  --bg: #050706;
  --panel: #171416;
  --panel-soft: #201b1f;
  --panel-border: rgba(39, 230, 124, .38);
  --text: #f6f7f5;
  --muted: #8d8a91;
  --line: rgba(255, 255, 255, .08);
  --green: #25d366;
  --green-strong: #18bf5a;
  --gold: #f8bd3b;
  --danger: #ff5d67;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

body.light-mode {
  color-scheme: light;
  --bg: #f7faf8;
  --panel: #ffffff;
  --panel-soft: #f1f7f4;
  --panel-border: rgba(18, 132, 76, .2);
  --text: #102019;
  --muted: #68756f;
  --line: rgba(18, 50, 34, .12);
  --green: #12a65a;
  --green-strong: #0f8e4d;
  --gold: #b77900;
  --danger: #d83345;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { min-height: 100%; }
body {
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% -6%, rgba(19,185,91,.28), transparent 31rem),
    radial-gradient(circle at 0% 23%, rgba(30,178,121,.12), transparent 16rem),
    var(--bg);
  color: var(--text);
}
body.light-mode {
  background:
    linear-gradient(180deg, #e8f7ee 0, #f7faf8 18rem),
    radial-gradient(circle at 8% 2%, rgba(33, 204, 116, .18), transparent 12rem),
    var(--bg);
}
button, input, textarea { font: inherit; }
button { cursor: pointer; outline: none; transition: transform .16s ease, background-color .16s ease, border-color .16s ease, filter .16s ease, box-shadow .16s ease; }
button:active { transform: translateY(1px) scale(.992); }
button:focus-visible { box-shadow: 0 0 0 3px rgba(37,211,102,.22); }
body.light-mode button:active { filter: none; }

.app-shell { position: relative; width: min(100%, 460px); min-height: 100dvh; margin: 0 auto; padding: calc(12px + var(--safe-top)) 16px calc(118px + var(--safe-bottom)); overflow: visible; }
.app-shell::before { content: ""; position: fixed; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(0,0,0,.55), transparent 8.5rem), linear-gradient(0deg, rgba(0,0,0,.45), transparent 12rem); }
body.light-mode .app-shell::before { background: none; }
.topbar, .view, .tabbar { position: relative; z-index: 1; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; direction: ltr; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; }
.brand > div:last-child { min-width: 0; }
.brand-mark, .service-icon { display: grid; place-items: center; color: #fff; font-weight: 900; background: linear-gradient(135deg, #33e283, #08744a); box-shadow: 0 0 28px rgba(35,225,119,.38); }
.brand-mark { width: 38px; height: 38px; border-radius: 19px; flex: 0 0 auto; }
.brand strong { display: block; font-size: 18px; line-height: 1.2; }
.brand span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-left: auto; flex: 0 0 auto; }
.icon-button, .ghost-button { border: 1px solid var(--line); background: rgba(28,24,28,.92); color: var(--text); }
body.light-mode .icon-button, body.light-mode .ghost-button { background: rgba(255,255,255,.96); border-color: rgba(18, 50, 34, .1); box-shadow: 0 8px 18px rgba(25, 65, 43, .05); }
.icon-button, .top-avatar { width: 42px; min-width: 42px; max-width: 42px; height: 42px; min-height: 42px; max-height: 42px; flex: 0 0 42px; border-radius: 14px; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; line-height: 1; font-size: 18px; font-weight: 800; }
.top-avatar { position: relative; display: block; overflow: hidden; border: 1px solid rgba(255,255,255,.18); background: #fff; color: #fff; padding: 0; box-shadow: 0 0 24px rgba(37,211,102,.18); }
.top-avatar > img, .top-avatar > span { position: absolute; inset: 0; display: grid; place-items: center; width: 100%; max-width: 100%; height: 100%; max-height: 100%; border-radius: inherit; }
.top-avatar > img { object-fit: cover; }
.top-avatar > span { background: linear-gradient(135deg, #31d777, #0f8e4d); font-weight: 900; }
body.light-mode .top-avatar { border-color: rgba(18, 50, 34, .1); box-shadow: 0 8px 18px rgba(25, 65, 43, .05); }
body.light-mode .icon-button:active, body.light-mode .top-avatar:active, body.light-mode .service-card:active, body.light-mode .profile-menu-row:active { box-shadow: 0 6px 16px rgba(25, 65, 43, .06); }
.ghost-button { min-height: 36px; padding: 0 12px; border-radius: 18px; }

.hero { margin: 28px 0 18px; }
.eyebrow { color: var(--green); font-size: 13px; font-weight: 800; }
h1, h2, h3, p { margin: 0; }
h1 { margin-top: 8px; font-size: 28px; line-height: 1.16; }
.hero p, .muted { margin-top: 9px; color: var(--muted); font-size: 14px; line-height: 1.55; }

.service-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.service-card { position: relative; display: flex; min-height: 180px; flex-direction: column; justify-content: space-between; overflow: hidden; border: 1px solid var(--panel-border); border-radius: 18px; background: radial-gradient(circle at 86% 8%, rgba(32,212,103,.18), transparent 9rem), linear-gradient(145deg, rgba(34,36,35,.96), rgba(24,20,24,.96)); padding: 16px; color: var(--text); text-align: left; }
body.light-mode .service-card { background: radial-gradient(circle at 86% 8%, rgba(32,212,103,.13), transparent 8rem), linear-gradient(145deg, rgba(255,255,255,.98), rgba(246,250,248,.98)); box-shadow: 0 10px 26px rgba(31, 76, 49, .055); }
.service-card::after { content: "›"; position: absolute; top: 14px; right: 16px; color: var(--green); font-size: 24px; line-height: 1; }
.service-icon { width: 56px; height: 56px; border-radius: 15px; font-size: 28px; }
.service-card h2, .product-info h3 { font-size: 18px; line-height: 1.25; }
.service-card p, .product-info p { color: var(--muted); font-size: 13px; line-height: 1.55; }
.service-card p { display: -webkit-box; min-height: 60px; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }

.panel { border: 1px solid var(--line); border-radius: 20px; background: rgba(23,20,23,.88); overflow: hidden; }
body.light-mode .panel { background: rgba(255,255,255,.96); box-shadow: 0 10px 28px rgba(26, 54, 38, .055); }
.service-summary { display: grid; grid-template-columns: 62px 1fr; gap: 14px; padding: 18px; border-color: var(--panel-border); background: radial-gradient(circle at 88% 12%, rgba(35,225,119,.18), transparent 10rem), rgba(23,20,23,.9); }
body.light-mode .service-summary { background: radial-gradient(circle at 88% 12%, rgba(35,225,119,.13), transparent 9rem), #ffffff; }
.service-summary h1 { margin-top: 0; font-size: 23px; }
.input-card { margin: 12px 0; padding: 16px; }
.field { display: grid; gap: 8px; margin-top: 12px; }
.field:first-child { margin-top: 0; }
.field label { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--text); font-weight: 800; }
.field label em { border-radius: 999px; background: rgba(37,211,102,.12); color: var(--green); padding: 2px 8px; font-size: 11px; font-style: normal; }
.field input, .field textarea { width: 100%; min-height: 56px; border: 1px solid var(--line); border-radius: 16px; background: #0b090b; color: var(--text); padding: 0 16px; outline: none; }
body.light-mode .field input, body.light-mode .field textarea { background: #f8fbf9; }
.field textarea { min-height: 76px; padding-top: 14px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: rgba(37,211,102,.62); box-shadow: 0 0 0 4px rgba(37,211,102,.12); }
.field input.is-invalid, .field textarea.is-invalid { border-color: rgba(255,93,103,.78); box-shadow: 0 0 0 4px rgba(255,93,103,.13); }

.account-bar, .balance-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 64px; padding: 0 18px; }
.account-bar strong, .balance-line strong { color: var(--gold); font-size: 20px; }
.product-list { margin-top: 12px; }
.product-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; min-height: 88px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.product-row:last-child { border-bottom: 0; }
.product-info { min-width: 0; }
.price { color: var(--gold); font-size: 18px; font-weight: 900; white-space: nowrap; }
.price small { color: var(--muted); font-size: 11px; font-weight: 700; margin-left: 3px; }

.primary-button, .secondary-button, .danger-button { min-height: 46px; border: 0; border-radius: 18px; padding: 0 18px; font-weight: 900; }
.primary-button { background: linear-gradient(180deg, #27dc6b, #18b955); color: #021b0c; box-shadow: 0 18px 42px rgba(11,214,93,.22); }
.secondary-button { border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--text); }
body.light-mode .secondary-button { background: #ffffff; border-color: rgba(18, 50, 34, .14); box-shadow: inset 0 -1px 0 rgba(18, 50, 34, .04); }
.danger-button { background: rgba(255,93,103,.14); color: #ff9aa1; }

.profile-card, .order-empty { padding: 20px; }
.profile-dashboard { margin-top: 28px; }
.profile-user-card { display: grid; grid-template-columns: 72px 1fr; gap: 14px; align-items: center; min-height: 82px; }
.profile-userline { display: grid; gap: 6px; min-width: 0; margin-top: 0; }
.profile-userline h2 { font-size: 24px; line-height: 1.12; overflow-wrap: anywhere; }
.profile-userline p { color: var(--muted); font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.avatar { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 18px; background: linear-gradient(135deg, #24d566, #1aa4ff); font-weight: 900; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-main-avatar { width: 64px; height: 64px; border: 2px solid rgba(110,231,143,.75); border-radius: 50%; background: linear-gradient(135deg, #24d566, #1aa4ff); box-shadow: 0 0 22px rgba(37,211,102,.18); font-size: 20px; }
.profile-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.stat-card { min-height: 94px; border: 1px solid rgba(255,255,255,.1); border-radius: 16px; background: rgba(21,21,21,.96); padding: 15px; box-shadow: inset 0 1px 0 rgba(255,255,255,.04); }
body.light-mode .stat-card { background: #ffffff; border-color: rgba(18, 50, 34, .1); box-shadow: 0 8px 20px rgba(26,54,38,.045); }
.stat-card span { display: block; color: var(--muted); font-size: 13px; font-weight: 800; }
.stat-card strong { display: block; margin-top: 13px; color: #6ee78f; font-size: 28px; line-height: 1; letter-spacing: 0; }
body.light-mode .stat-card strong { color: #12884d; }
.balance { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; margin-top: 16px; padding: 16px; border-radius: 18px; background: #0f0c0f; border: 1px solid var(--line); }
body.light-mode .balance { background: linear-gradient(180deg, #fbfefc, #eef8f2) !important; border-color: rgba(18, 132, 76, .14); box-shadow: inset 0 1px 0 rgba(255,255,255,.85); }
.balance strong { color: var(--gold); font-size: 24px; }
body.light-mode .balance strong { color: #12884d; }
body.light-mode .balance .muted { color: #61746b; }
.profile-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.action-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; border-radius: 14px; font-size: 16px; box-shadow: 0 12px 26px rgba(37,211,102,.16); }
.action-icon, .menu-icon { display: inline-grid; place-items: center; color: currentColor; }
.action-icon svg, .menu-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.profile-menu { margin-top: 16px; border: 1px solid var(--line); border-radius: 20px; background: rgba(23,20,23,.88); overflow: hidden; }
body.light-mode .profile-menu { background: rgba(255,255,255,.96); box-shadow: 0 10px 28px rgba(26,54,38,.055); }
.profile-menu-row { display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 12px; width: 100%; min-height: 70px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); padding: 0 18px; text-align: left; }
.profile-menu-row:last-child { border-bottom: 0; }
.profile-menu-row strong { display: block; font-size: 16px; line-height: 1.2; }
.profile-menu-row em { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; font-style: normal; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-menu-row b { color: var(--muted); font-size: 28px; font-weight: 500; }
.menu-icon { color: #6ee78f; }
body.light-mode .menu-icon { color: #12884d; }
.order-row { display: grid; gap: 8px; padding: 16px; border-bottom: 1px solid var(--line); }
.order-row:last-child { border-bottom: 0; }
.order-top { display: flex; justify-content: space-between; gap: 12px; }
.status-pill { display: inline-grid; place-items: center; min-height: 26px; border-radius: 13px; padding: 0 10px; background: rgba(37,211,102,.12); color: var(--green); font-size: 12px; font-weight: 800; }
.status-pill.warn { color: var(--gold); background: rgba(248,189,59,.12); }
.status-pill.danger { color: var(--danger); background: rgba(255,93,103,.12); }

.tabbar { position: fixed; z-index: 20; left: 50%; bottom: 0; transform: translateX(-50%); display: grid; width: min(100%, 460px); min-height: calc(78px + var(--safe-bottom)); grid-template-columns: repeat(3, 1fr); padding: 10px 18px calc(10px + var(--safe-bottom)); border-top: 0; background: rgba(18,16,20,.96); backdrop-filter: blur(16px); box-shadow: 0 -18px 44px rgba(0,0,0,.38); }
body.light-mode .tabbar { background: rgba(255,255,255,.98); box-shadow: 0 -16px 38px rgba(26, 54, 38, .08); }
.tab { appearance: none; display: grid; gap: 3px; place-items: center; min-height: 54px; border: 0; background: transparent; color: var(--muted); font-size: 12px; }
.tab-icon { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 12px; }
.tab-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tab.is-active { color: var(--green); }
.tab.is-active .tab-icon { background: rgba(37,211,102,.12); }

.search-box { margin: -4px 0 14px; }
.search-box input { width: 100%; min-height: 52px; border: 1px solid var(--line); border-radius: 16px; background: rgba(12,10,12,.9); color: var(--text); padding: 0 16px; outline: none; }
body.light-mode .search-box input { background: rgba(255,255,255,.92); }
.search-box input:focus { border-color: rgba(37,211,102,.62); box-shadow: 0 0 0 4px rgba(37,211,102,.12); }

.sheet-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.58); backdrop-filter: blur(8px); }
.sheet { position: fixed; z-index: 40; left: 50%; bottom: 0; width: min(100%, 460px); max-height: calc(92dvh - var(--safe-top)); overflow-y: auto; transform: translateX(-50%); border: 1px solid var(--panel-border); border-bottom: 0; border-radius: 22px 22px 0 0; background: #171316; box-shadow: 0 -26px 70px rgba(0,0,0,.58); padding: 20px 18px calc(20px + var(--safe-bottom)); }
body.light-mode .sheet { background: #ffffff; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.sheet h2 { font-size: 21px; }
.sheet-fields { margin-top: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.035); }
body.light-mode .sheet-fields { background: rgba(15,127,69,.04); }
.sheet-fields h3 { font-size: 17px; }
.sheet-fields .muted { margin-top: 6px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.notice { margin-top: 14px; border: 1px solid rgba(248,189,59,.55); border-radius: 10px; background: rgba(248,189,59,.12); color: #ffe2a0; padding: 12px; font-size: 13px; line-height: 1.5; word-break: break-all; }
body.light-mode .notice { border-color: rgba(183, 121, 0, .28); background: #fff7df; color: #7c5200; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(88px + var(--safe-bottom)); max-width: min(360px, calc(100vw - 32px)); transform: translateX(-50%); border-radius: 18px; background: rgba(26,23,27,.96); color: var(--text); box-shadow: 0 20px 52px rgba(0,0,0,.38); padding: 12px 16px; font-size: 14px; }
body.light-mode .toast { background: rgba(255,255,255,.96); }

html[dir="rtl"] .product-info { text-align: right; }
html[dir="rtl"] .service-card { text-align: right; }

@media (max-width: 380px) {
  .app-shell { padding-inline: 12px; }
  .top-actions { gap: 6px; }
  .icon-button, .top-avatar { width: 40px; min-width: 40px; max-width: 40px; height: 40px; min-height: 40px; max-height: 40px; flex-basis: 40px; }
  .service-grid { gap: 10px; }
  .service-card { min-height: 168px; padding: 14px; }
  .profile-dashboard { margin-top: 24px; }
  .profile-user-card { grid-template-columns: 64px 1fr; gap: 12px; min-height: 74px; }
  .profile-main-avatar { width: 58px; height: 58px; }
  .profile-userline h2 { font-size: 22px; }
  .profile-userline p { font-size: 12px; }
  .profile-stats, .profile-actions { gap: 10px; }
  .stat-card { min-height: 88px; padding: 13px; }
  .stat-card strong { font-size: 24px; }
  .action-button { min-height: 50px; font-size: 15px; }
  .product-row { grid-template-columns: 1fr auto; }
  .price { grid-column: 1 / -1; }
}
