:root{
  --bg:#070A12;
  --card:#0B1220;
  --muted:#94A3B8;
  --text:#E5E7EB;
  --line:rgba(148,163,184,.18);
  --accent:#38BDF8;
  --accent2:#A78BFA;
  --danger:#FB7185;
  --ok:#34D399;

  /* iOS safe-area */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background: radial-gradient(1200px 800px at 30% -20%, rgba(56,189,248,.15), transparent 55%),
              radial-gradient(900px 700px at 90% 0%, rgba(167,139,250,.14), transparent 55%),
              var(--bg);
  color:var(--text);
  font: 16px/1.35 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif;
  -webkit-text-size-adjust:100%;
  padding: 0;
}

/* iOS tap */
button, a { -webkit-tap-highlight-color: rgba(0,0,0,0); }

a{color:inherit;text-decoration:none}
img{max-width:100%;display:block}

.app-shell{
  min-height: 100dvh; /* modern */
  min-height: 100vh;  /* fallback */
  display:flex;
  flex-direction:column;
}

.topbar{
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: calc(10px + var(--sat));
  padding-left: calc(12px + var(--sal));
  padding-right: calc(12px + var(--sar));
  padding-bottom: 10px;
  backdrop-filter: blur(10px);
  background: rgba(7,10,18,.55);
  border-bottom: 1px solid var(--line);
}
.topbar-inner{
  display:flex;
  align-items:center;
  gap:10px;
  justify-content:space-between;
}
.brand{
  display:flex;
  align-items:center;
  gap:10px;
  border:0;
  background:transparent;
  color:inherit;
  padding:0;
  text-align:left;
}
.brand-logo{
  width:42px;height:42px;
  border-radius:14px;
  overflow:hidden;
  border:1px solid var(--line);
  background: rgba(255,255,255,.03);
}
.brand-name{font-weight:700;letter-spacing:.2px}
.brand-sub{font-size:12px;color:var(--muted);margin-top:1px}
.topbar-actions{display:flex;gap:8px}

.content{
  padding: 14px calc(12px + var(--sal)) 0 calc(12px + var(--sar));
}

.hero-card{
  background: linear-gradient(180deg, rgba(56,189,248,.12), rgba(167,139,250,.10));
  border:1px solid var(--line);
  border-radius:18px;
  padding:14px;
}
.hero-title{font-weight:800;font-size:18px}
.hero-sub{color:var(--muted);font-size:13px;margin-top:4px}

.chip{
  border:1px solid var(--line);
  background: rgba(255,255,255,.04);
  color:var(--text);
  padding:8px 10px;
  border-radius:999px;
  font-size:13px;
}
.chip.danger{border-color: rgba(251,113,133,.35); background: rgba(251,113,133,.10);}

.category-strip{
  display:flex;
  gap:8px;
  overflow:auto;
  padding:12px 0 6px;
  -webkit-overflow-scrolling: touch;
}
.category-strip::-webkit-scrollbar{display:none}

.grid{
  display:grid;
  grid-template-columns: 1fr;
  gap:10px;
  padding: 10px 0 0;
}

.card{
  background: rgba(11,18,32,.9);
  border:1px solid var(--line);
  border-radius:18px;
  padding:14px;
  box-shadow: 0 10px 24px rgba(0,0,0,.22);
}

.pcard{
  display:flex;
  gap:12px;
  align-items:flex-start;
}
.pimg{
  width:76px;height:76px;
  border-radius:16px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.03);
  overflow:hidden;
  flex: 0 0 auto;
}
.pmeta{flex:1 1 auto; min-width:0}
.ptitle{font-weight:800}
.psub{color:var(--muted);font-size:13px;margin-top:2px}
.pprice{margin-top:8px;font-weight:800}
.pactions{display:flex;gap:8px;margin-top:10px}

.btn{
  border:1px solid var(--line);
  background: rgba(255,255,255,.04);
  color:var(--text);
  padding:10px 12px;
  border-radius:14px;
  font-weight:700;
}
.btn.small{padding:8px 10px; border-radius:12px; font-size:13px}
.btn.primary{
  border-color: rgba(56,189,248,.40);
  background: rgba(56,189,248,.14);
}
.btn.danger{
  border-color: rgba(251,113,133,.40);
  background: rgba(251,113,133,.12);
}

.bottombar{
  position: fixed;
  left:0; right:0;
  bottom:0;
  padding-bottom: calc(10px + var(--sab));
  padding-left: calc(10px + var(--sal));
  padding-right: calc(10px + var(--sar));
  padding-top: 10px;
  background: rgba(7,10,18,.65);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display:flex;
  gap:10px;
  z-index: 30;
}
.bb-btn{
  flex:1 1 0;
  border:1px solid var(--line);
  background: rgba(255,255,255,.04);
  color:var(--text);
  padding:12px;
  border-radius:16px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  font-weight:800;
}
.bb-badge{
  min-width:26px;
  height:26px;
  border-radius:999px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background: rgba(56,189,248,.18);
  border:1px solid rgba(56,189,248,.35);
  font-size:13px;
  padding:0 8px;
}

.spacer-bottom{height: 92px;}

.overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 40;
}

.sheet{
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 50;
  padding-left: calc(12px + var(--sal));
  padding-right: calc(12px + var(--sar));
  padding-bottom: calc(12px + var(--sab));
  background: rgba(11,18,32,.96);
  border-top: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  transform: translateY(110%);
  transition: transform .22s ease;
  will-change: transform;
  max-height: calc(85dvh);
  max-height: calc(85vh);
  overflow: hidden;
}
.sheet.open{ transform: translateY(0); }
.sheet-handle{
  width: 44px;
  height: 4px;
  border-radius: 999px;
  background: rgba(148,163,184,.35);
  margin: 10px auto 6px;
}
.sheet-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding: 8px 2px 10px;
}
.sheet-title{font-weight:900}
.icon-btn{
  width:36px;height:36px;
  border-radius:14px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.04);
  color:var(--text);
  font-weight:900;
}
.sheet-body{
  overflow:auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6px;
  max-height: calc(75dvh);
  max-height: calc(75vh);
}

.field{display:block;margin:10px 0}
.field-label{display:block;color:var(--muted);font-size:12px;margin-bottom:6px}
.input{
  width:100%;
  border:1px solid var(--line);
  background: rgba(255,255,255,.03);
  color:var(--text);
  padding:12px 12px;
  border-radius:14px;
  outline:none;
  font-size:16px; /* important for iOS: disables zoom */
}
textarea.input{resize:vertical}

.hint{color:var(--muted);font-size:12px;margin-top:8px}
.divider{height:1px;background:var(--line);margin:12px 0}

.row{display:flex;align-items:center}
.row-between{display:flex;align-items:flex-start;justify-content:space-between;gap:10px}
.gap{gap:10px}
.grow{flex:1 1 auto}
.wrap{flex-wrap:wrap}

.muted{color:var(--muted);font-size:12px}
.money{font-weight:900}

.details summary{cursor:pointer}
.details-body{margin-top:10px}

.breakdown{display:flex;flex-direction:column;gap:10px}
.b-row{display:flex;justify-content:space-between;gap:10px;border:1px solid var(--line);border-radius:16px;padding:10px;background:rgba(255,255,255,.03)}
.b-title{font-weight:800}
.b-right{text-align:right}

.alert{border:1px solid var(--line);border-radius:16px;padding:10px;margin:10px 0;background:rgba(255,255,255,.03)}
.alert.error{border-color: rgba(251,113,133,.4); background: rgba(251,113,133,.10)}
.alert.warn{border-color: rgba(250,204,21,.35); background: rgba(250,204,21,.08)}
.alert.ok{border-color: rgba(52,211,153,.35); background: rgba(52,211,153,.10)}

.admin-shell{min-height:100dvh;min-height:100vh}
.admin-top{
  position:sticky; top:0; z-index:10;
  padding: calc(12px + var(--sat)) calc(12px + var(--sal)) 12px calc(12px + var(--sar));
  border-bottom:1px solid var(--line);
  background: rgba(7,10,18,.75);
  backdrop-filter: blur(10px);
}
.admin-title{font-weight:900}
.admin-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px}
.admin-content{padding: 14px calc(12px + var(--sal)) calc(12px + var(--sab)) calc(12px + var(--sar));}

.stack{display:flex;flex-direction:column;gap:12px}
.page-head .h1{font-size:20px;font-weight:900}
.grid-2{display:grid;grid-template-columns:1fr;gap:12px}
.grid-3{display:grid;grid-template-columns:1fr;gap:12px}
@media(min-width: 900px){
  .grid{grid-template-columns: 1fr 1fr;}
  .grid-2{grid-template-columns: 1fr 1fr;}
  .grid-3{grid-template-columns: 1fr 1fr 1fr;}
}
.card-title{font-weight:900;margin-bottom:8px}
.big{font-size:22px;font-weight:900}

.table{display:flex;flex-direction:column;gap:6px}
.tr{display:grid;grid-template-columns: 50px 1.2fr 1fr 120px 80px 90px 1.1fr;gap:8px;align-items:center}
.tr.th{color:var(--muted);font-size:12px}
.tr{padding:8px;border:1px solid var(--line);border-radius:14px;background:rgba(255,255,255,.02)}
.thumb{width:120px;border-radius:14px;border:1px solid var(--line);margin-top:8px}
.check{display:flex;align-items:center;gap:8px;color:var(--muted);font-size:13px;margin:10px 0}
/* Hide inline category chips (keep only top "Категории" button + sheet) */
#categoryStrip { display: none !important; }
