:root {
  --bg: #0e1016; --panel: #161a22; --panel2: #1d222c; --panel3: #242a36; --line: #262c38; --text: #e8eaf0; --muted: #8a92a6; --muted2: #5f677a;
  --accent: #7c9cff; --accent2: #5b7cf5; --green: #37d389; --red: #ff6b6b; --amber: #ffb347; --purple: #c084fc; --cyan: #5eead4; --pink: #f472b6;
  --shadow: 0 6px 24px rgba(0,0,0,.28); --radius: 14px; --radius-sm: 10px;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f3f4f8; --panel: #ffffff; --panel2: #f4f5f9; --panel3: #e9ebf2; --line: #e4e7ef; --text: #141722; --muted: #6a7187; --muted2: #9aa1b4; --shadow: 0 6px 24px rgba(22,28,45,.08); --accent2: #3f63e8; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 22px; font-weight: 800; letter-spacing: -.01em; margin: 0 0 16px; }
h2 { font-size: 12px; margin: 16px 0 10px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
h2:first-child { margin-top: 0; }
.muted { color: var(--muted); } .faint { color: var(--muted2); } .small { font-size: 12px; } .mono { font-family: ui-monospace, Consolas, monospace; }
.up { color: var(--red); } .down { color: var(--green); } .ok { color: var(--green); } .err { color: var(--red); }

/* header */
.top { display: flex; align-items: center; gap: 22px; padding: 10px 22px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 800; font-size: 16px; display: flex; align-items: center; gap: 9px; color: var(--text); }
.logo { width: 30px; height: 30px; border-radius: 9px; box-shadow: 0 2px 8px rgba(91,124,245,.35); }
.brand span { font-weight: 500; } .brand b { font-weight: 800; }
nav { display: flex; gap: 2px; } nav a { color: var(--muted); padding: 7px 11px; border-radius: 8px; font-weight: 600; font-size: 13px; }
nav a:hover { background: var(--panel2); color: var(--text); } nav a.active { color: var(--text); background: var(--panel3); }
.status { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.who { display: flex; align-items: center; gap: 8px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--pink), var(--amber)); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 12px; text-transform: uppercase; }

main { padding: 22px; max-width: 1320px; margin: 0 auto; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; } @media (max-width: 960px) { .grid2 { grid-template-columns: 1fr; } }
.grid-main { display: grid; grid-template-columns: 1fr 380px; gap: 18px; align-items: start; } @media (max-width: 1100px) { .grid-main { grid-template-columns: 1fr; } }

/* cards */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow); }
.panel.tight { padding: 0; overflow: hidden; } .panel.tight > .ph { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.ph { display: flex; align-items: center; justify-content: space-between; gap: 10px; } .ph h2 { margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow); }
.kpi .ic { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-size: 18px; flex: none; }
.kpi .n { font-size: 22px; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; } .kpi .l { color: var(--muted); font-size: 12px; margin-top: 2px; }
.ic.blue { background: rgba(124,156,255,.15); color: var(--accent); } .ic.green { background: rgba(55,211,137,.15); color: var(--green); }
.ic.amber { background: rgba(255,179,71,.15); color: var(--amber); } .ic.purple { background: rgba(192,132,252,.15); color: var(--purple); }
.ic.pink { background: rgba(244,114,182,.15); color: var(--pink); } .ic.cyan { background: rgba(94,234,212,.15); color: var(--cyan); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.card { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 13px; }
.card .n { font-size: 17px; font-weight: 800; letter-spacing: -.01em; } .card .l { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }

/* chart */
.chart { width: 100%; height: 150px; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); } .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* forms */
input, select, button, textarea { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button { cursor: pointer; font-weight: 600; } button:hover { background: var(--panel3); }
button.primary { background: var(--accent2); color: #fff; border-color: transparent; } button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; } button.danger { color: var(--red); } button:disabled { opacity: .5; cursor: default; }
button.sm { padding: 5px 9px; font-size: 12px; border-radius: 8px; }
button.icon { width: 34px; height: 34px; padding: 0; display: grid; place-items: center; font-size: 15px; }
.fld { display: block; font-size: 12px; color: var(--muted); margin: 8px 0; font-weight: 600; } .fld input, .fld select { display: block; margin-top: 4px; width: 100%; max-width: 420px; color: var(--text); font-weight: 400; }
.row .fld { margin: 0; } .row .fld input { width: auto; }
.chk { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 13px; cursor: pointer; } .chk input { margin: 0; }
.stack { display: flex; flex-direction: column; } .indent { margin-left: 22px; margin-bottom: 10px; } .indent .fld { margin: 4px 0; }
.search { position: relative; } .search input { padding-left: 32px; min-width: 220px; } .search::before { content: '⌕'; position: absolute; left: 11px; top: 7px; color: var(--muted); font-size: 16px; }

/* tables */
table { width: 100%; border-collapse: collapse; } th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; } tbody tr:hover td { background: var(--panel2); } tbody tr:last-child td { border-bottom: none; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--panel2); border: 1px solid var(--line); white-space: nowrap; }
.tag.product_added, .tag.back_in_stock, .tag.bestseller_entered { color: var(--green); border-color: rgba(55,211,137,.3); }
.tag.product_removed, .tag.out_of_stock, .tag.app_removed, .tag.collection_removed, .tag.variant_removed, .tag.bestseller_left { color: var(--red); border-color: rgba(255,107,107,.3); }
.tag.price_changed, .tag.rank, .tag.low_stock { color: var(--amber); border-color: rgba(255,179,71,.3); } .tag.sale_started { color: var(--purple); } .tag.sale_ended { color: var(--muted); }
.tag.app_installed, .tag.theme_changed, .tag.theme_renamed { color: var(--cyan); } .tag.collection_added, .tag.variant_added, .tag.product_renamed, .tag.bestseller_climbed { color: var(--accent); }
.tag.plat { text-transform: capitalize; }

/* shop rows */
.shoplogo { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; background: var(--panel2); border: 1px solid var(--line); flex: none; }
.shoplogo.lg { width: 72px; height: 72px; border-radius: 16px; }
.shoprow td:first-child { width: 44%; }
.shopname { display: flex; align-items: center; gap: 12px; } .shopname b { font-size: 14px; } .shopname .d { color: var(--muted); font-size: 12px; }
.bell { background: none; border: 1px solid var(--line); border-radius: 50%; width: 32px; height: 32px; display: grid; place-items: center; color: var(--muted2); padding: 0; font-size: 14px; }
.bell.on { color: var(--amber); border-color: rgba(255,179,71,.4); background: rgba(255,179,71,.1); }

/* events */
.ev { display: grid; grid-template-columns: 46px 1fr auto; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: center; }
.ev:last-child { border-bottom: none; }
.ev img, .ev .noimg, .prod img, .prod .noimg { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line); }
.ev .t { font-weight: 600; } .ev .d { color: var(--muted); font-size: 12px; margin-top: 2px; }
.ev .when { color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; }
.ev .when button.star { font-size: 16px; }

/* products */
.prod { display: grid; grid-template-columns: 46px 1fr auto; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.prod:last-child { border-bottom: none; }
.prod .t { font-weight: 600; } .prod .m { color: var(--muted); font-size: 12px; margin-top: 2px; }
.price { font-weight: 700; white-space: nowrap; } .price s { color: var(--muted); font-weight: 400; margin-left: 4px; }
.rankno { display: inline-block; min-width: 30px; font-weight: 800; color: var(--amber); }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.pcard { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.pcard .img { aspect-ratio: 1; background: #fff; display: grid; place-items: center; position: relative; } .pcard .img img { width: 100%; height: 100%; object-fit: contain; }
.pcard .img .rankno { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.65); color: var(--amber); padding: 2px 7px; border-radius: 999px; font-size: 12px; min-width: 0; }
.pcard .img .star { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.5); border-radius: 50%; width: 30px; height: 30px; color: #fff; }
.pcard .b { padding: 10px 11px; display: flex; flex-direction: column; gap: 3px; flex: 1; } .pcard .t { font-weight: 600; font-size: 13px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard .m { color: var(--muted); font-size: 11px; } .pcard .price { margin-top: auto; }
button.star { background: none; border: none; padding: 0 4px; font-size: 18px; line-height: 1; color: var(--muted2); cursor: pointer; vertical-align: middle; }
button.star:hover, button.star.on { color: var(--pink); background: none; }
.subtabs { display: inline-flex; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.subtabs button { background: none; border: none; padding: 6px 12px; border-radius: 8px; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.subtabs button.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.toggle button { width: 32px; height: 32px; padding: 0; } .toggle button.active { background: var(--panel3); }

/* apps grid */
.appgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.appcard { display: flex; gap: 11px; align-items: center; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.appcard .ai { width: 36px; height: 36px; border-radius: 9px; background: #fff; display: grid; place-items: center; font-weight: 800; color: #333; flex: none; overflow: hidden; } .appcard .ai img { width: 22px; height: 22px; }
.appcard .al { font-weight: 600; font-size: 13px; line-height: 1.25; } .appcard .ac { color: var(--muted); font-size: 11px; }
.appcard.gone { opacity: .45; } .appcard.gone .al { text-decoration: line-through; }

/* shop header */
.shophead { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.shophead .info { flex: 1; min-width: 240px; } .shophead h1 { margin: 0 0 4px; }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.meta .l { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; } .meta .v { font-weight: 700; margin-top: 2px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); padding: 10px 14px; font-weight: 600; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); } .tabs button:hover { background: none; color: var(--text); }
.tabs button .cnt { color: var(--muted2); font-weight: 500; margin-left: 4px; }

.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: s 1s linear infinite; vertical-align: -2px; }
@keyframes s { to { transform: rotate(360deg); } }
.empty { color: var(--muted); padding: 28px; text-align: center; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; box-shadow: var(--shadow); z-index: 20; }
.toast.show { opacity: 1; }
.prod.fav { grid-template-columns: auto 1fr auto; } .prod.fav label { cursor: pointer; display: flex; align-items: center; gap: 10px; }
@media (max-width: 720px) { main { padding: 14px; } .top { padding: 10px 14px; gap: 12px; } nav a { padding: 6px 8px; } .status { display: none; } .meta { grid-template-columns: 1fr 1fr; } }
/* filter bars + chips */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input { padding: 7px 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chipbtn { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; font-size: 12px; font-weight: 600; color: var(--muted); }
.chipbtn.active { background: var(--accent2); color: #fff; border-color: transparent; }
.chipbtn .n { opacity: .7; margin-left: 4px; font-weight: 500; }
.range { display: inline-flex; align-items: center; gap: 4px; } .range input { width: 84px; }
.rowcount { color: var(--muted); font-size: 12px; }
.sortbtn { background: none; border: none; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; padding: 0; cursor: pointer; } .sortbtn.active { color: var(--text); }
.ev .d .dir { font-weight: 700; }
.btnlink { display: inline-flex; align-items: center; gap: 4px; background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 7px 11px; font-weight: 600; font-size: 13px; color: var(--text); white-space: nowrap; }
.btnlink:hover { background: var(--panel3); }

/* ---------- mobile (≤ 720px) ---------- */
html, body { max-width: 100%; overflow-x: hidden; }
.panel.tight { overflow-x: auto; -webkit-overflow-scrolling: touch; }   /* wide tables scroll inside their card */
.panel.tight table { min-width: 560px; }
@media (max-width: 720px) {
  .top { flex-wrap: wrap; gap: 8px 12px; padding: 8px 12px; }
  .top .brand { order: 1; } .top .who { order: 2; margin-left: auto; } .top .status { display: none; }
  .top nav { order: 3; flex-basis: 100%; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 0 12px; }
  .top nav::-webkit-scrollbar { display: none; } .top nav a { flex: none; padding: 6px 9px; font-size: 12.5px; }
  main { padding: 12px; }
  h1 { font-size: 19px; }
  .row.between { flex-direction: column; align-items: stretch; } .row.between > .row { justify-content: flex-start; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; } .kpi { padding: 10px 12px; gap: 9px; } .kpi .ic { width: 34px; height: 34px; font-size: 16px; } .kpi .n { font-size: 18px; }
  .cards { grid-template-columns: 1fr 1fr; }
  .filters, .panel.row { gap: 6px; } .filters > *, .panel.row > * { flex: 1 1 calc(50% - 6px); min-width: 0; }
  .filters .search, .panel.row .search { flex-basis: 100%; } .search input { width: 100%; min-width: 0; }
  .filters .rowcount { flex-basis: 100%; text-align: right; } .range input { width: 70px; }
  .chips { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; padding-bottom: 2px; } .chips::-webkit-scrollbar { display: none; }
  .subtabs { width: 100%; } .subtabs button { flex: 1; padding: 6px 6px; font-size: 11px; }
  .pgrid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .prod, .ev { grid-template-columns: 40px 1fr; } .prod > .row, .ev .when { grid-column: 2; justify-content: flex-start; text-align: left; }
  .prod img, .prod .noimg, .ev img, .ev .noimg { width: 40px; height: 40px; }
  .shophead { gap: 12px; } .shoplogo.lg { width: 52px; height: 52px; border-radius: 12px; }
  .meta { grid-template-columns: 1fr 1fr; gap: 10px; }
  .grid2, .grid-main { grid-template-columns: 1fr; gap: 12px; }
  .tabs button { padding: 9px 10px; font-size: 13px; }
  .appgrid { grid-template-columns: 1fr; }
  .legend { display: none; }
  .fld input, .fld select { max-width: none; }
  .indent { margin-left: 12px; }
  .toast { width: calc(100% - 24px); text-align: center; }
  button, .btnlink, select, input { font-size: 14px; }   /* 14px+ avoids iOS zoom-on-focus feel while staying compact */
  input, select { font-size: 16px; }                     /* iOS zooms inputs under 16px */
}
@media (max-width: 420px) { .pgrid { grid-template-columns: 1fr 1fr; } .kpi .l { font-size: 11px; } }
/* grid tracks must be allowed to shrink below their content (tables, charts, long titles) */
.grid-main, .grid2 { grid-template-columns: minmax(0, 1fr) 380px; }
.grid2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .grid-main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 960px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
.grid-main > *, .grid2 > *, .panel, .ev > div, .prod > div, .shophead .info, .appcard > div { min-width: 0; }
.ev .t, .prod .t, .ev .d, .prod .m, .appcard .al { overflow-wrap: anywhere; }
.chart { max-width: 100%; }
a.appcard { color: inherit; text-decoration: none; } a.appcard:hover { border-color: var(--accent); background: var(--panel3); }
.appcard .ac .lk { color: var(--accent); margin-left: 4px; }
.qty { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: rgba(55,211,137,.12); color: var(--green); border: 1px solid rgba(55,211,137,.3); margin-left: 6px; white-space: nowrap; }
.qty.low { background: rgba(255,179,71,.12); color: var(--amber); border-color: rgba(255,179,71,.35); }
/* navigation feel */
#progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: linear-gradient(90deg, var(--accent), var(--purple)); z-index: 50; opacity: 0; transition: width .25s ease, opacity .3s ease; }
#progress.on { opacity: 1; width: 70%; transition: width 6s cubic-bezier(.1,.6,.2,1), opacity .1s; }
#progress.done { width: 100%; opacity: 0; transition: width .15s ease, opacity .4s ease .15s; }
#view.in { animation: viewin .18s ease; } @keyframes viewin { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
#refresh { font-size: 15px; } #refresh.spin-once { animation: s .6s linear 1; }
/* simple bar strips (sales by day, traffic by month) */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding-top: 6px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.bars .bar i { display: block; width: 100%; max-width: 38px; min-height: 2px; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, var(--accent), var(--accent2)); }
.bars .bar span { font-size: 10px; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; max-width: 100%; }
