* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #1B1830;
  --bg2: #141126;
  --card: #221E3D;
  --line: #2E2952;
  --line2: #3A3466;
  --text: #ECEAF6;
  --muted: #B9B2D9;
  --muted2: #8B84B0;
  --primary: #7B5CFF;
  --primary-h: #8E73FF;
  --accent: #FF8A00;
  --green: #4CB944;
  --red: #FF6B81;
  --blue: #6FB1FF;
  --ok: #2ECC71;
}
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
a { color: inherit; text-decoration: none; }
code { font-family: Consolas, monospace; font-size: 12px; color: var(--muted); word-break: break-all; }

.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 40;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 10px);
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
}
.topbar-brand { font-weight: 700; font-size: 17px; }
.iconbtn {
  background: transparent;
  border: 1px solid var(--line2);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 15px;
}
.iconbtn.round {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}
.topbar-actions { display: flex; gap: 8px; margin-left: auto; }
.topbar-actions .iconbtn:disabled { opacity: 0.4; }
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 300px;
  flex: 0 0 300px;
  background: var(--bg2);
  border-right: 1px solid var(--line);
  padding: 22px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 14px; }
.histrow { display: flex; gap: 10px; margin-bottom: 10px; }
.histrow .hist-btn { flex: 1; font-weight: 600; }
.histrow .hist-btn:disabled { opacity: 0.4; }
.brand.center { margin-bottom: 6px; }
.nav { display: flex; flex-direction: column; gap: 6px; }
.shopbtn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  appearance: none;
  -webkit-appearance: none;
  background: #1B1830;
  border: 1px solid var(--line);
  border-left: 4px solid transparent;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  text-align: left;
}
.shoplogo {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
}
.shopbtn:hover { background: #221E3D; border-left-color: #19C6A6; }
.shopbtn.active { background: #1B1830; border-left-color: #19C6A6; color: var(--text); }
.shopbtn.expanded { background: #19C6A6; border-left-color: #fff; color: #fff; }
.shopbtn.expanded:hover { background: #19C6A6; }
.shopbtn.active .chev { color: var(--muted2); }
.shopbtn.expanded .chev { color: #fff; }
.shopbtn .chev { margin-left: auto; font-size: 14px; color: var(--muted2); transition: transform 0.15s; }
.shopbtn.expanded .chev { transform: rotate(180deg); }
.shopbtn { cursor: pointer; width: 100%; font-family: inherit; }
.stages { display: none; flex-direction: column; gap: 4px; margin: 2px 0 6px; }
.stages.open { display: flex; }
.navbtn {
  padding: 11px 14px;
  border-radius: 10px;
  border-left: 3px solid transparent;
  color: var(--muted);
  background: transparent;
}
.navbtn:hover { background: #221E3D; color: var(--text); border-left-color: #19C6A6; }
.navbtn.done { background: var(--green); border-left-color: #fff; color: #fff; font-weight: 600; }
.navbtn.active { background: #353059; border-left-color: #19C6A6; color: #fff; font-weight: 600; }
.sidefoot { margin-top: auto; padding-top: 12px; }
.logout { color: var(--muted2); font-size: 14px; }
.logout:hover { color: var(--red); }

.content { flex: 1; padding: 30px 36px 24px; max-width: 980px; }
.pagehead { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.title { font-size: 26px; font-weight: 700; }
.crumb { color: var(--muted); }
.descr { margin-bottom: 14px; color: var(--muted); }
.descr summary {
  cursor: pointer;
  color: #8E73FF;
  font-weight: 600;
  font-size: 14px;
  list-style: none;
}
.descr summary::-webkit-details-marker { display: none; }
.descr[open] summary { margin-bottom: 6px; }
.descr p { margin: 6px 0; white-space: pre-line; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cardtitle { font-size: 17px; font-weight: 600; }
.hint { color: var(--muted); font-size: 14px; }
.hint.center, .center { text-align: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: var(--primary);
  transition: background 0.15s;
}
.btn:hover { background: var(--primary-h); }
.btn:disabled { background: #4A3F7A; color: var(--muted); cursor: default; }
.btn.big { padding: 14px 22px; font-size: 16px; font-weight: 700; }
.btn.full { width: 100%; }
.btn.secondary { background: #2A2547; color: var(--text); font-weight: 500; }
.btn.secondary:hover { background: #353059; }
.btn.secondary:disabled { background: #262243; color: #6E679A; }
.btn.accent { background: var(--accent); }
.btn.accent:hover { background: #FFA033; }
.btn.success { background: var(--green); }
.btn.success:hover { background: #5BC94F; }
.btn.success:disabled { background: var(--green); color: #fff; }
.btn.fail { background: #A93B52; }
.btn.fail:disabled { background: #A93B52; color: #fff; }
.btn.danger { background: #3A2430; color: var(--red); font-weight: 500; }
.btn.danger:hover { background: #4A2C3C; }
.btn.small { padding: 9px 14px; font-size: 14px; }

.input {
  background: #171430;
  border: 1px solid var(--line2);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  width: 100%;
  font-size: 15px;
}
.input:focus { outline: none; border-color: var(--primary); }
.input.big { padding: 13px 14px; font-size: 17px; }
.lbl { color: var(--muted); font-size: 14px; margin-top: 4px; }

.alert { border-radius: 10px; padding: 10px 14px; font-weight: 600; }
.alert.err { background: #3A2430; color: var(--red); }

.logbox {
  background: #141126;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #C9C4E8;
  font-family: Consolas, monospace;
  font-size: 13px;
  padding: 12px;
  min-height: 90px;
  max-height: 340px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.logbox:empty::before { content: attr(placeholder); color: #6E679A; }

.counters { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.counter { font-weight: 600; }
.counter.was { color: var(--red); }
.counter.now { color: var(--blue); }

.filelist { display: flex; flex-direction: column; gap: 6px; }
.filehead { color: var(--muted); font-size: 14px; font-weight: 600; }
.fileitem {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #1B1830;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
}
.fileitem:hover { border-color: var(--line2); background: #241F42; }
.fmain {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.fname { font-weight: 600; word-break: break-all; font-size: 17px; }
.fmeta { color: var(--muted2); font-size: 16px; }
.fnamerow { display: flex; align-items: center; gap: 8px; min-width: 0; }
.dl-ico { flex: 0 0 auto; color: var(--muted2); }
.fileitem.downloaded .dl-ico { color: #4CB944; }
.fdel {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line2);
  background: transparent;
  color: var(--red);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.fdel:hover { background: #3A2430; border-color: var(--red); }
.fdel.success { background: var(--green); border-color: var(--green); color: #fff; }
.fdel.fail { background: #A93B52; border-color: #A93B52; color: #fff; }
.btn.secondary.success, .upload-label.success { background: var(--green); color: #fff; }
.btn.secondary.fail, .upload-label.fail { background: #A93B52; color: #fff; }

.storecard {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #1B1830;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 18px;
}
.storelogo {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5A48C8, #19C6A6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
  color: #fff;
}
.storelogo.nfile { border-radius: 12px; font-size: 14px; }
.storelogoimg {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
}
.storeinfo { flex: 1; min-width: 0; }
.storename { font-weight: 600; }
.storemeta { color: var(--muted); font-size: 14px; word-break: break-all; }
.storestatus { color: var(--muted2); font-size: 14px; }
.storestatus.ok { color: var(--ok); font-weight: 600; }
.storestatus.bad { color: var(--red); font-weight: 600; }
.storebtns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.addstore summary { list-style: none; cursor: pointer; display: inline-flex; }
.addstore summary::-webkit-details-marker { display: none; }
.addstoreform { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; max-width: 460px; }

.backupday { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.backupdate { color: var(--muted); font-weight: 600; font-size: 14px; }
.backuprow {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: #1B1830;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
}
.backuprow .fmain { flex: 1; min-width: 160px; }

.upload-label { position: relative; overflow: hidden; }
.upload-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-label.is-busy { opacity: 0.6; }
.upload-label.success { background: var(--green) !important; color: #fff; }
.upload-label.fail { background: #A93B52 !important; color: #fff; }
.fitrow { display: flex; justify-content: flex-start; }

.loginbody { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 20px; padding-top: calc(env(safe-area-inset-top, 0px) + 20px); }
.logincard {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.logincard form { display: flex; flex-direction: column; gap: 12px; }

.scrim { display: none; }

@media (max-width: 900px) {
  .topbar { display: flex; }
  .layout { display: block; }
  .sidebar {
    position: fixed;
    z-index: 50;
    left: 0;
    top: 0;
    bottom: 0;
    width: 300px;
    max-width: 84vw;
    height: auto;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    padding-top: calc(env(safe-area-inset-top, 0px) + 22px);
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,0.5); }
  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }
  .scrim.show { opacity: 1; pointer-events: auto; }
  .content { padding: 18px 14px 90px; }
  .title { font-size: 22px; }
  .card { padding: 16px 14px; }
  .storecard { flex-wrap: wrap; }
  .storeinfo { flex: 1 1 60%; }
  .storebtns { flex: 1 1 100%; justify-content: stretch; }
  .storebtns .btn, .storebtns a.btn { flex: 1; }
  .backuprow .btn { flex: 1 1 100%; }
  .counters { gap: 10px; }
  .counters .btn { flex: 1 1 100%; }
  .btn.big { padding: 14px 16px; font-size: 16px; }
}

/* напоминание о балансе WB */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 18, 34, .72); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal-overlay[hidden] { display: none; }
.modal { background: #fff; color: #000; border-radius: 14px; padding: 22px; max-width: 460px; width: 100%; box-shadow: 0 18px 50px rgba(0, 0, 0, .35); }
.modal-head { font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.wb-text { font-size: 15px; line-height: 1.55; margin-bottom: 16px; }
.wb-row { text-align: right; }
.wb-row .btn { min-width: 96px; }

/* svg-иконки кнопок */
.iconbtn svg.ico { vertical-align: -3px; display: inline-block; }

/* форма редактирования ключа магазина */
.editform { display: flex; flex-direction: column; gap: 8px; max-width: 460px; padding: 12px 14px; margin: 0 0 12px; border: 1px dashed var(--line, #d5d9e4); border-radius: 12px; }
.editform .rowbtns { display: flex; gap: 8px; }
.editform[hidden] { display: none; }

/* автоотправка листов недели */
.mailrow { display: flex; gap: 10px; align-items: center; margin: 8px 0; }
.mailrow .input { flex: 1 1 auto; }
.mailshop { min-width: 200px; color: #444; font-size: 14px; }
