/* ================================================================
   ДИЗАЙН-ТОКЕНЫ НеоБухгалтерия. Та же система, что в CRM и НеоСкладе,
   но гамма синяя — чтобы вкладку с деньгами не спутать со складом.
   ================================================================ */
:root {
  --bg: #eef2f7;
  --panel: #ffffff;
  --panel2: #f4f7fb;
  --panel3: #e2e9f2;

  --line: #c9d5e3;
  --line-strong: #8ea3bb;

  --text: #15202b;
  --muted: #4f6072;

  --accent: #2f5d8a;
  --accent-hover: #244a70;
  --accent-soft: #e1ebf5;
  --green: #2f7d32;
  --green-soft: #e2f2dc;
  --red: #b3261e;
  --red-soft: #fbe6e3;
  --yellow: #8a6a12;
  --yellow-soft: #f6eed3;

  --r-sm: 8px;
  --r-md: 10px;
  --r-btn: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-pill: 999px;

  --sh-1: 0 1px 2px rgba(21,32,43,.06), 0 1px 3px rgba(21,32,43,.10);
  --sh-2: 0 4px 12px rgba(21,32,43,.10), 0 2px 4px rgba(21,32,43,.06);
  --sh-3: 0 24px 60px rgba(21,32,43,.22), 0 8px 20px rgba(21,32,43,.12);
  --ring: 0 0 0 3px rgba(47,93,138,.30);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-btn); padding: 10px 12px; outline: none;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: var(--ring); }
input[type=number] { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.spacer { flex: 1; }
h2 { font-size: 16px; margin: 0; }
.hint { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.neg { color: var(--red); }
.pos { color: var(--green); }

/* ---------- кнопки ---------- */
.btn {
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  border-radius: var(--r-btn); padding: 10px 16px; font-weight: 600; white-space: nowrap;
  box-shadow: var(--sh-1);
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: var(--panel); color: var(--accent); border-color: var(--line); box-shadow: none; }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { background: var(--red); border-color: var(--red); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.icon { padding: 6px 9px; }

/* ---------- вход ---------- */
#login { display: none; min-height: 100vh; align-items: center; justify-content: center; padding: 20px; }
#login.show { display: flex; }
.login-card {
  width: 100%; max-width: 380px; background: var(--panel); border-radius: var(--r-xl);
  padding: 28px 24px; box-shadow: var(--sh-2);
}
.login-card h1 { margin: 0 0 4px; font-size: 26px; }
.login-card h1 span, .logo span { color: var(--accent); }
.login-card p { margin: 0 0 20px; color: var(--muted); }
.login-card label { display: block; margin: 12px 0 6px; font-size: 13px; color: var(--muted); }
.login-card .btn { width: 100%; margin-top: 18px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; font-size: 18px; }
.err { color: var(--red); min-height: 20px; margin-top: 10px; font-size: 14px; }

/* ---------- шапка ---------- */
header {
  position: sticky; top: 0; z-index: 10; background: var(--panel);
  border-bottom: 1px solid var(--line); box-shadow: var(--sh-1);
}
.hdr-top, .hdr-bottom {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; max-width: 1200px; margin: 0 auto;
}
.hdr-bottom { padding-top: 0; flex-wrap: wrap; }
.logo { font-weight: 800; font-size: 20px; }
.who { text-align: right; line-height: 1.2; font-size: 13px; color: var(--muted); }
.who b { display: block; color: var(--text); }
.tabs { display: flex; gap: 4px; background: var(--panel3); padding: 4px; border-radius: var(--r-pill); }
.tab {
  border: 0; background: transparent; color: var(--muted); font-weight: 600;
  padding: 8px 18px; border-radius: var(--r-pill);
}
.tab.active { background: var(--panel); color: var(--accent); box-shadow: var(--sh-1); }
.month-nav { display: flex; align-items: center; gap: 6px; }
.month-input { width: auto; padding: 6px 10px; font-weight: 600; }

/* ---------- основное ---------- */
main { max-width: 1200px; margin: 0 auto; padding: 16px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin: 20px 0 10px; flex-wrap: wrap; }
.status { color: var(--muted); font-size: 13px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.check input { width: auto; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kpi { background: var(--panel); border-radius: var(--r-lg); padding: 12px 14px; box-shadow: var(--sh-1); }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi.main { background: var(--accent); color: #fff; }
.kpi.main .l { color: rgba(255,255,255,.8); }

.notice { background: var(--yellow-soft); color: var(--yellow); border-radius: var(--r-md); padding: 10px 14px; margin-top: 12px; font-size: 14px; }
.notice.red { background: var(--red-soft); color: var(--red); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  border-radius: var(--r-pill); padding: 6px 12px; font-size: 13px; font-weight: 600;
}
.chip.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.badge { display: inline-block; padding: 2px 8px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.gray { background: var(--panel3); color: var(--muted); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }

/* ---------- карточки юрлиц ---------- */
.ent { background: var(--panel); border-radius: var(--r-lg); box-shadow: var(--sh-1); margin-bottom: 14px; overflow: hidden; }
.ent-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ent-head .name { font-weight: 700; font-size: 16px; }
.ent-body { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.ent-in { padding: 14px 16px; border-right: 1px solid var(--line); }
.ent-out { padding: 14px 16px; }
.ent-in .fld { margin-bottom: 10px; }
.fld label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.fld-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lines { width: 100%; border-collapse: collapse; font-size: 14px; }
.lines td { padding: 5px 0; border-bottom: 1px dashed var(--line); vertical-align: top; }
.lines td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.lines tr.total td { border-bottom: 0; font-size: 16px; font-weight: 800; padding-top: 10px; }
.lines .sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.ent-foot { padding: 10px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.ent-foot summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.ent-foot ul { margin: 8px 0 0; padding-left: 18px; }
.ent-foot li { margin: 3px 0; }
.warn { background: var(--yellow-soft); color: var(--yellow); border-radius: var(--r-sm); padding: 8px 10px; font-size: 13px; margin-top: 10px; }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; background: var(--panel); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 720px; }
table.grid th, table.grid td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.grid th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--panel2); position: sticky; top: 0; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tr.total td { font-weight: 800; background: var(--panel2); }
table.grid tr.group td { font-weight: 700; color: var(--accent); background: var(--accent-soft); }
table.grid tr.dim td { color: var(--muted); }
table.grid input.cell { width: 120px; padding: 6px 8px; text-align: right; }
table.grid td.name { white-space: normal; min-width: 160px; }
table.grid td.name .sub { display: block; font-size: 12px; color: var(--muted); }
table.grid .link { background: none; border: 0; color: var(--accent); padding: 0; font-weight: 600; }

/* ---------- списки ---------- */
.list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.card { background: var(--panel); border-radius: var(--r-lg); padding: 12px 14px; box-shadow: var(--sh-1); cursor: pointer; }
.card:hover { box-shadow: var(--sh-2); }
.card .t { font-weight: 700; display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.card .s { color: var(--muted); font-size: 13px; margin-top: 4px; }
.card .v { font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 6px; }
.card.off { opacity: .55; }
.empty { color: var(--muted); padding: 24px; text-align: center; }

/* ---------- блоки ---------- */
.block { background: var(--panel); border-radius: var(--r-lg); box-shadow: var(--sh-1); margin-top: 20px; padding: 0 16px 16px; }
.block summary { list-style: none; cursor: pointer; padding: 14px 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.block summary::-webkit-details-marker { display: none; }
.block summary::before { content: "▸"; color: var(--muted); }
.block[open] summary::before { content: "▾"; }
.block .table-wrap { box-shadow: none; border: 1px solid var(--line); }
.params { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.params .fld input { width: 100%; }
.params-foot { display: flex; gap: 10px; margin-top: 14px; align-items: center; flex-wrap: wrap; }

/* ---------- модалка ---------- */
#modal { position: fixed; inset: 0; background: rgba(21,32,43,.45); display: none; z-index: 20; align-items: flex-end; justify-content: center; }
#modal.show { display: flex; }
.sheet {
  background: var(--panel); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: var(--sh-3); padding: 0 20px 24px;
}
@media (min-width: 700px) {
  #modal { align-items: center; }
  .sheet { border-radius: var(--r-xl); }
}
.sheet-head { position: sticky; top: 0; background: var(--panel); display: flex; align-items: center; gap: 10px; padding: 16px 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 14px; z-index: 1; }
.sheet-head h3 { margin: 0; font-size: 18px; flex: 1; }
.sheet .x { background: none; border: 0; font-size: 22px; color: var(--muted); padding: 4px 8px; }
.sheet .fld { margin-bottom: 12px; }
.sheet .actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.sheet .actions .btn { flex: 1; }
.sheet .err { margin-top: 8px; }
.sheet .hint-box { background: var(--panel2); border-radius: var(--r-sm); padding: 8px 10px; font-size: 13px; color: var(--muted); }

/* ---------- тост ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff; padding: 10px 16px; border-radius: var(--r-pill);
  opacity: 0; transition: .2s; z-index: 30; pointer-events: none; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: var(--red); }

/* ---------- телефон ---------- */
@media (max-width: 700px) {
  .ent-body { grid-template-columns: 1fr; }
  .ent-in { border-right: 0; border-bottom: 1px solid var(--line); }
  .hdr-top { padding: 8px 12px; }
  .hdr-bottom { padding: 0 12px 8px; }
  main { padding: 12px; }
  .tab { padding: 8px 12px; }
  .kpi .v { font-size: 17px; }
}
@media (max-width: 480px) {
  /* на телефоне шапке тесно: имя пользователя убираем, логотип ужимаем */
  .who { display: none; }
  .logo { font-size: 18px; }
  .hdr-top { gap: 6px; }
}
