:root {
  --rose: #D9608C;
  --rose-d: #B8456F;
  --rose-l: #FBE3EC;
  --lav: #9C7FD9;
  --lav-l: #EEE7FB;
  --peach: #F8B7A0;
  --bg: #FFF7FA;
  --card: #FFFFFF;
  --ink: #3B2A35;
  --muted: #9A8592;
  --line: #F2DDE6;
  --green: #2E9E73;
  --red: #D64560;
  --shadow: 0 6px 24px rgba(201, 84, 127, .10);
  --r: 20px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); min-height: 100vh; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* header */
.top { display: flex; align-items: center; gap: 10px; padding: calc(14px + env(safe-area-inset-top)) 18px 6px; }
.top img { width: 38px; height: 38px; border-radius: 11px; box-shadow: var(--shadow); }
.top h1 { font-size: 21px; margin: 0; letter-spacing: .3px; font-weight: 700; }
.top .sub { font-size: 12px; color: var(--muted); }
.top .right { margin-left: auto; }
.wrap { padding: 8px 16px 20px; max-width: 640px; margin: 0 auto; }

/* hero */
.hero { border-radius: 26px; padding: 20px; color: #fff; background: linear-gradient(135deg, #E7799F 0%, #C77DD6 60%, #9C7FD9 100%); box-shadow: 0 14px 34px rgba(199, 102, 160, .35); position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; background: rgba(255,255,255,.13); }
.hero .lbl { font-size: 13px; opacity: .9; }
.hero .big { font-size: 34px; font-weight: 750; margin: 2px 0 2px; letter-spacing: .3px; }
.hero .meta { font-size: 13px; opacity: .92; }
.hero .row { display: flex; gap: 10px; margin-top: 14px; position: relative; z-index: 1; }
.hero .pill { flex: 1; min-width: 0; background: rgba(255,255,255,.18); border-radius: 14px; padding: 9px 11px; text-align: left; color: #fff; }
.hero .pill b { display: block; font-size: 14px; white-space: nowrap; letter-spacing: -.2px; }
.hero .pill span { font-size: 11.5px; opacity: .9; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.card { background: var(--card); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
.kpi .v { font-size: 15px; font-weight: 750; white-space: nowrap; letter-spacing: -.2px; }
.kpi .l { font-size: 12px; color: var(--muted); }
.sec { margin: 20px 4px 8px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; display: flex; align-items: center; }
.sec a, .sec button { margin-left: auto; text-transform: none; letter-spacing: 0; color: var(--rose); font-weight: 600; text-decoration: none; }

.rates { display: flex; gap: 8px; margin-top: 12px; }
.chip { flex: 1; background: var(--card); border-radius: 16px; padding: 10px 12px; box-shadow: var(--shadow); text-align: left; }
.chip .l { font-size: 11.5px; color: var(--muted); }
.chip .v { font-weight: 700; font-size: 15.5px; }
.chip .e { float: right; color: var(--rose); font-size: 12px; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.btn-big { border-radius: 18px; padding: 16px 12px; font-weight: 700; font-size: 16px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-sell { background: var(--rose); color: #fff; box-shadow: 0 8px 20px rgba(217, 96, 140, .35); }
.btn-buy { background: var(--lav); color: #fff; box-shadow: 0 8px 20px rgba(156, 127, 217, .35); }
.mini-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.mini { background: var(--card); border-radius: 16px; padding: 10px 4px; font-size: 11.5px; text-align: center; box-shadow: var(--shadow); line-height: 1.2; }
.mini i { display: block; font-style: normal; font-size: 20px; margin-bottom: 3px; }

/* list */
.list { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.item:last-child { border-bottom: 0; }
.ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 17px; flex: none; }
.ico.sell { background: var(--rose-l); }
.ico.buy { background: var(--lav-l); }
.ico.other { background: #FFF0E8; }
.item .t { font-weight: 600; font-size: 14.5px; }
.item .s { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .mid { flex: 1; min-width: 0; }
.item .amt { text-align: right; font-weight: 700; font-size: 14.5px; }
.item .amt small { display: block; font-weight: 600; font-size: 12px; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

/* nav */
.nav { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,.94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); display: flex; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.nav a { flex: 1; text-align: center; padding: 8px 0 9px; font-size: 11px; color: var(--muted); text-decoration: none; }
.nav a i { display: block; font-style: normal; font-size: 21px; line-height: 1.25; filter: grayscale(1); opacity: .6; }
.nav a.on { color: var(--rose); font-weight: 700; }
.nav a.on i { filter: none; opacity: 1; }

/* forms / sheet */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-bg { position: absolute; inset: 0; background: rgba(59, 42, 53, .35); }
.sheet-box { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow: auto; background: var(--bg); border-radius: 26px 26px 0 0; padding: 10px 18px calc(22px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.grab { width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 2px auto 10px; }
.sheet-box h2 { margin: 0 0 12px; font-size: 19px; }
.f { margin-bottom: 12px; }
.f label { display: block; font-size: 12.5px; color: var(--muted); margin: 0 0 5px 4px; font-weight: 600; }
.f input, .f select, .f textarea { width: 100%; padding: 13px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; outline: none; font-size: 16px; }
.f input:focus, .f select:focus, .f textarea:focus { border-color: var(--rose); }
.f .suffix { position: relative; }
.f .suffix span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; pointer-events: none; }
.seg { display: flex; background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: 3px; gap: 3px; }
.seg button { flex: 1; padding: 9px 4px; border-radius: 11px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--rose); color: #fff; }
.calc { background: var(--card); border-radius: 16px; padding: 12px 14px; margin: 6px 0 14px; box-shadow: var(--shadow); }
.calc div { display: flex; justify-content: space-between; padding: 3px 0; font-size: 14px; }
.calc b { font-size: 15px; }
.btn { width: 100%; border-radius: 16px; padding: 15px; font-weight: 700; font-size: 16px; background: var(--rose); color: #fff; box-shadow: 0 8px 20px rgba(217, 96, 140, .3); }
.btn.lav { background: var(--lav); box-shadow: 0 8px 20px rgba(156, 127, 217, .3); }
.btn.ghost { background: #fff; color: var(--rose); box-shadow: none; border: 1.5px solid var(--line); }
.btn.danger { background: #fff; color: var(--red); box-shadow: none; border: 1.5px solid #F6CFD8; }
.btn + .btn { margin-top: 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* auth */
.auth { max-width: 420px; margin: 0 auto; padding: calc(40px + env(safe-area-inset-top)) 22px 40px; }
.auth .logo { width: 96px; height: 96px; border-radius: 28px; display: block; margin: 0 auto 14px; box-shadow: 0 14px 34px rgba(199, 102, 160, .35); }
.auth h1 { text-align: center; margin: 0; font-size: 30px; }
.auth p.c { text-align: center; color: var(--muted); margin: 4px 0 26px; }
.err { color: var(--red); font-size: 13.5px; margin: -4px 4px 10px; min-height: 1em; }

/* report */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button { flex: 1; padding: 10px; border-radius: 14px; background: #fff; font-weight: 600; color: var(--muted); box-shadow: var(--shadow); }
.tabs button.on { background: var(--rose); color: #fff; }
.period { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.period button { width: 40px; height: 40px; border-radius: 13px; background: #fff; box-shadow: var(--shadow); font-size: 18px; color: var(--rose); }
.period b { font-size: 15px; }
.profit-hero { text-align: center; padding: 18px 14px; }
.profit-hero .v { font-size: 30px; font-weight: 800; }
.chart { width: 100%; height: 150px; display: block; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { text-align: right; color: var(--muted); font-weight: 600; font-size: 12px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.t td { text-align: right; padding: 8px 4px; border-bottom: 1px solid var(--line); }
table.t th:first-child, table.t td:first-child { text-align: left; }
table.t tr:last-child td { border-bottom: 0; }
.kv { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }

.filters { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters button { white-space: nowrap; padding: 8px 13px; border-radius: 12px; background: #fff; box-shadow: var(--shadow); font-size: 13px; font-weight: 600; color: var(--muted); }
.filters button.on { background: var(--rose); color: #fff; }
.search { width: 100%; padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; margin-bottom: 10px; font-size: 16px; outline: none; }

.hist .item { align-items: flex-start; }
.diff { font-size: 12.5px; margin-top: 4px; }
.diff s { color: var(--red); }
.diff ins { color: var(--green); text-decoration: none; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 8px; font-weight: 700; }
.b-create { background: #E5F6EE; color: var(--green); }
.b-update { background: var(--lav-l); color: #6C4FBF; }
.b-delete { background: #FDE6EA; color: var(--red); }
.b-restore { background: #FFF0E0; color: #B86A1E; }

.toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 14px; font-size: 14px; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 90vw; text-align: center; }

@media print {
  .nav, .top .right, .noprint { display: none !important; }
  body { background: #fff; padding: 0; }
  .card, .list { box-shadow: none; border: 1px solid var(--line); }
}
.row2 .btn + .btn { margin-top: 0; }
