:root {
  --bg: #0a1128;
  --surface: #121d3f;
  --surface2: #182752;
  --border: #243566;
  --text: #e8eefc;
  --muted: #8d9bc4;
  --accent: #3b82f6;
  --accent2: #2563eb;
  --green: #34d399;
  --red: #f87171;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px; line-height: 1.4;
  padding-top: calc(56px + env(safe-area-inset-top));
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }

.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  height: calc(56px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.top h1 { margin: 0; font-size: 18px; font-weight: 600; }
.top-spacer, .burger { width: 56px; }
.burger {
  height: 56px; background: none; border: 0; cursor: pointer;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 5px;
}
.burger span { display: block; width: 22px; height: 2px; background: var(--text); border-radius: 2px; }

.bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 30; opacity: 0; pointer-events: none; transition: opacity .2s; }
.bg.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; width: 78%; max-width: 320px; z-index: 40;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: calc(16px + env(safe-area-inset-top)) 12px 16px; overflow-y: auto;
  transform: translateX(-102%); transition: transform .22s ease;
}
.drawer.open { transform: none; }
.drawer .who { padding: 4px 12px 14px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.drawer .who b { display: block; font-size: 17px; }
.drawer .who span { color: var(--muted); font-size: 14px; }
.drawer button {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 13px 12px; border-radius: 10px; font-size: 16px; cursor: pointer;
}
.drawer button:active, .drawer button.active { background: var(--surface2); }

main { max-width: 560px; margin: 0 auto; padding: 14px 14px calc(28px + env(safe-area-inset-bottom)); }
h2 { font-size: 20px; margin: 4px 0 12px; }
h3 { font-size: 16px; margin: 16px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px; margin-bottom: 12px; }
.net-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.net-name { font-size: 18px; font-weight: 600; }
.net-price { color: var(--muted); font-size: 13px; margin-top: 2px; }
.icon {
  width: 44px; height: 44px; border-radius: 12px; flex: none; object-fit: cover;
  background: var(--surface2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--accent);
}
.icon.sm { width: 32px; height: 32px; border-radius: 9px; font-size: 14px; }
.net-actions { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 12px; }
.pill {
  min-width: 120px; padding: 8px 22px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 600; text-align: center;
}
.pill:active { background: var(--accent2); }
.pill:disabled { background: var(--surface2); color: var(--muted); cursor: default; }
.stock { font-size: 13px; display: flex; align-items: center; gap: 6px; }
.stock i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; }
.stock.out i { background: var(--red); }
.stock.out { color: var(--muted); }

.btn {
  display: block; width: 100%; padding: 13px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 16px; text-align: center;
}
.btn:active { background: var(--accent2); }
.btn:disabled { background: var(--surface2); color: var(--muted); }
.btn.ghost { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: #7f1d1d; }
.btn.small-btn { display: inline-block; width: auto; padding: 8px 14px; font-size: 14px; border-radius: 10px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; min-width: 0; }
.row > .fixed { flex: none; }
.gap { height: 10px; }

input[type=text], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 140px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; }
label.lbl { display: block; margin: 10px 0 4px; font-size: 13px; color: var(--muted); }

.bal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.bal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px; }
.bal .v { font-size: 26px; font-weight: 700; margin-top: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip {
  padding: 8px 14px; border-radius: 999px; background: var(--surface2); border: 1px solid var(--border);
  cursor: pointer; font-size: 14px;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.code-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border);
}
.code-row code { flex: 1; min-width: 0; word-break: break-all; font-size: 14px; }
.code-row button {
  flex: none; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; cursor: pointer; font-size: 13px;
}
.tx { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid var(--border); }
.tx:first-child { border-top: 0; }
.tx .amt { font-weight: 600; white-space: nowrap; }
.tx .amt.plus { color: var(--green); }
.tx .amt.minus { color: var(--red); }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; max-width: 560px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--border); border-bottom: 0;
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto; transform: translateY(105%); transition: transform .22s ease;
}
.sheet.open { transform: none; }
.sheet h2 { margin-top: 0; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface2); font-size: 22px; cursor: pointer;
}
.stepper input { text-align: center; font-size: 18px; }
.total { display: flex; justify-content: space-between; margin: 14px 0 12px; font-size: 17px; }
.total b { font-size: 20px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: #0f1a3a; border: 1px solid var(--border); padding: 10px 16px; border-radius: 12px; z-index: 60;
  opacity: 0; pointer-events: none; transition: all .2s; max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.notice { background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin: 10px 0; }
.notice.err { border-color: #7f1d1d; }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 4px; }
.tabs .chip { white-space: nowrap; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--border); vertical-align: top; }
.scroll-x { overflow-x: auto; }
.switch { display: flex; align-items: center; gap: 8px; margin: 10px 0 4px; }
.switch input { width: 20px; height: 20px; }
