:root{
  --bg1:#0c1630;
  --bg2:#24131f;
  --card: rgba(255,255,255,.06);
  --card2: rgba(0,0,0,.18);
  --stroke: rgba(255,255,255,.12);
  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.70);
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  color: var(--text);
  background:
    radial-gradient(1000px 600px at 15% 20%, rgba(82,122,255,.30), transparent 60%),
    radial-gradient(900px 600px at 80% 10%, rgba(255,120,160,.20), transparent 60%),
    linear-gradient(120deg, var(--bg1), var(--bg2));
}

.app{
  max-width: 1200px;
  margin: 22px auto;
  padding: 0 16px 40px;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  flex-wrap:wrap;
  padding:18px;
  border-radius:18px;
  border:1px solid var(--stroke);
  background: var(--card);
  backdrop-filter: blur(10px);
}

.brand .title{ font-size:28px; font-weight:800; }
.brand .subtitle{ color: var(--muted); margin-top:4px; }

.topbar-right{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:12px;
  flex-wrap:wrap;
  flex: 1 1 auto;
}

.tabs{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
  justify-content:flex-end;
}

.tab{
  border:1px solid var(--stroke);
  background: rgba(0,0,0,.18);
  color: var(--text);
  padding:10px 14px;
  border-radius: 14px;
  cursor:pointer;
}
.tab.is-active{
  background: rgba(110,140,255,.20);
  border-color: rgba(110,140,255,.55);
}

.userbar{
  display:flex;
  gap:8px;
  align-items:center;
}

.userbadge{
  padding:9px 10px;
  border:1px solid var(--stroke);
  background: rgba(0,0,0,.18);
  border-radius: 12px;
  font-size: 13px;
  color: var(--muted);
}

.content{ margin-top:18px; }

.card{
  border:1px solid var(--stroke);
  background: var(--card);
  backdrop-filter: blur(10px);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 16px;
}

.row{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}

.input{
  border:1px solid var(--stroke);
  background: rgba(0,0,0,.22);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  min-width: 220px;
  outline:none;
}
.input--small{ min-width: 160px; }

.btn{
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.08);
  color: var(--text);
  border-radius: 14px;
  padding: 11px 14px;
  cursor:pointer;
}
.btn--primary{
  background: rgba(110,140,255,.25);
  border-color: rgba(110,140,255,.55);
}

.hint{
  margin-top:10px;
  color: var(--muted);
  font-size: 13px;
}

.list{
  margin-top:10px;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.pill{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px 14px;
  border:1px solid var(--stroke);
  border-radius: 14px;
  background: rgba(0,0,0,.18);
}

.msg{ margin-left: 8px; color: var(--muted); }
.msg.ok{ color: rgba(120,255,180,.9); }
.msg.bad{ color: rgba(255,120,120,.95); }

.hr{
  border:none;
  border-top:1px solid rgba(255,255,255,.12);
  margin:12px 0;
}

.table{
  width:100%;
  border-collapse: collapse;
}
.table th, .table td{
  padding:10px 10px;
  border-bottom:1px solid rgba(255,255,255,.10);
  text-align:left;
}
.table th{
  color: rgba(255,255,255,.85);
  font-weight:700;
}
.table tr:hover td{
  background: rgba(255,255,255,.06);
}

.page{ display:none; }
.page.is-active{ display:block; }

/* LOGIN OVERLAY */
.overlay{
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0,0,0,.55);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
  backdrop-filter: blur(8px);
}
.loginCard{
  width: min(760px, 100%);
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  padding: 16px;
}

/* lock background while login */
.app.locked{
  pointer-events:none;
  user-select:none;
  filter: blur(1px);
}
/* =========================
   RESPONSIVE (paste at end)
   ========================= */

/* 1) Таблицы: безопасный горизонтальный скролл */
.table-wrap{
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 14px;
}

/* если table вставлена напрямую, тоже не ломаем */
#stocksTable, #historyTable, #docsTable{
  overflow-x:auto;
  -webkit-overflow-scrolling: touch;
}

/* 2) Более гибкие input/select/button */
.input, .btn, .tab{
  max-width: 100%;
}

/* 3) Планшеты */
@media (max-width: 900px){
  .app{ padding: 0 12px 28px; }
  .topbar{ padding: 14px; }
  .brand .title{ font-size: 24px; }

  .input{ min-width: 200px; }
  .input--small{ min-width: 150px; }
}

/* 4) Телефоны */
@media (max-width: 600px){
  .topbar{
    gap: 12px;
  }

  .brand .title{ font-size: 22px; }
  .brand .subtitle{ font-size: 12px; }

  /* вкладки компактнее */
  .tab{
    padding: 9px 10px;
    border-radius: 12px;
    font-size: 13px;
  }

  /* формы в колонку */
  .row{
    flex-direction: column;
    align-items: stretch;
  }

  /* поля и кнопки на всю ширину */
  .input, .btn, select.input{
    width: 100%;
    min-width: 0 !important;
  }

  /* списки: кнопка "Удалить" не вылезает */
  .pill{
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  .pill > .btn{
    width: auto;
  }

  /* карточки компактнее */
  .card{
    padding: 14px;
    border-radius: 16px;
  }
}

/* 5) Очень маленькие экраны */
@media (max-width: 380px){
  .brand .title{ font-size: 20px; }
  .tab{ font-size: 12px; }
}
/* === Fix: одинаковая высота контролов (эталон: "Цена") === */
:root {
  --ctrl-h: 44px; /* если "Цена" выше/ниже — поменяй это число */
}

input,
select,
button.btn {
  height: var(--ctrl-h);
  box-sizing: border-box;
  padding-top: 0;
  padding-bottom: 0;
  line-height: calc(var(--ctrl-h) - 2px);
}
