:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #0e7490;
  --brand-soft: #e0f2fe;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --warn: #b45309;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Devanagari", sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: env(safe-area-inset-bottom);
}

[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--brand); color: #fff;
}
.logo { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.logo img { border-radius: 6px; }
.logo small { font-weight: 400; font-size: 11px; opacity: .8; }
.top nav a { color: #cffafe; text-decoration: none; margin-left: 16px; font-weight: 600; }
.top nav a.active { color: #fff; border-bottom: 2px solid #fff; }

main { max-width: 560px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; margin-bottom: 16px;
}

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 16px 0 8px; }

.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.warn { color: var(--warn); margin: 8px 0; }
.warn:empty { display: none; }

input {
  width: 100%; font: inherit; padding: 12px; margin-bottom: 12px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}

button {
  font: inherit; font-weight: 600; padding: 12px 16px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer;
}
button:disabled { opacity: .5; cursor: default; }
button.loading { position: relative; color: transparent; }
button.loading::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px;
  border: 2px solid currentColor; border-color: #fff #fff transparent transparent;
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.big { width: 100%; padding: 16px; font-size: 18px; margin-top: 8px; }
button.link { border: 0; background: none; color: var(--brand); padding: 4px 0; }

.state { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 600; }
.state.ok { background: var(--ok-soft); color: var(--ok); }
.state.bad { background: var(--bad-soft); color: var(--bad); }
.state:empty { display: none; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.metric { background: var(--brand-soft); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; }
.metric small { color: var(--muted); }
.metric b { font-size: 20px; }
.metric span { font-size: 13px; color: var(--muted); }
.quality { margin: 12px 0 0; font-weight: 600; color: var(--brand); }
.quality:empty { display: none; }

.balance-card { text-align: center; }
.balance { font-size: 44px; font-weight: 800; color: var(--brand); line-height: 1.1; margin: 4px 0; }
.pour { margin-top: 8px; font-size: 18px; }

.stepper { display: flex; align-items: center; justify-content: center; gap: 24px; margin: 8px 0 16px; }
.stepper button { width: 52px; height: 52px; font-size: 24px; border-radius: 50%; padding: 0; }
.stepper span { font-size: 28px; font-weight: 700; min-width: 80px; text-align: center; }
.total { font-size: 18px; padding: 8px 0; border-top: 1px solid var(--line); }

.available { margin: 12px 0; font-size: 18px; }
.inline { display: flex; gap: 8px; }
.inline input { margin: 0; }
.inline button { white-space: nowrap; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 8px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.list li:last-child { border-bottom: 0; }
.list li small { flex-basis: 100%; color: var(--muted); }
.list li.device { display: block; cursor: pointer; }
.list li.device .row { padding: 2px 0; font-size: 14px; }
.list li.device .row:first-child { font-size: 16px; }

.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--line); font-weight: 600; }
.tag.paid { background: var(--ok-soft); color: var(--ok); }
.tag.requested { background: var(--brand-soft); color: var(--brand); }
.tag.rejected { background: var(--bad-soft); color: var(--bad); }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 16px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 528px; margin: 0 auto; background: var(--ink); color: #fff;
  padding: 14px 16px; border-radius: 10px; z-index: 5;
}
