/* Копия Frontpad — оформление. Токены сняты с живого сайта:
   шрифт Arial; тёмная верхняя панель со светлым текстом и бирюзовыми иконками;
   плитки #dfe4e9 радиус 2px; активная категория #bdc3c7 (белый текст);
   выбранная вкладка — белая карточка; фон рабочей области — светлый мятный. */

:root {
  --topbar: #3c4149;         /* тёмная панель */
  --topbar-2: #333840;
  --topbar-ink: #f1f1f1;
  --topbar-muted: #aeb6bf;
  --teal: #57a9c6;           /* акцент/иконки */
  --teal-ink: #2b7f9e;
  --bg: #dcede4;             /* мятный фон приложения (как на «Новый заказ») */
  --panel: #ffffff;
  --line: #cfd8d2;
  --line-2: #dfe4e9;
  --ink: #1a1f24;
  --muted: #6a7480;
  --tile: #dfe4e9;
  --tile-hover: #d3dae0;
  --cat: #eef1f3;
  --cat-active: #bdc3c7;
  --good: #1b8f4d;
  --bad: #b23b30;
  --warn: #b7791f;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 Arial, Helvetica, sans-serif;
}

/* ── Верхняя панель ─────────────────────────────────────────────────────── */
#topbar {
  display: flex; align-items: stretch; background: var(--topbar);
  color: var(--topbar-ink); height: 54px; position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
#topbar .nav { display: flex; align-items: stretch; }
#topbar .spacer { flex: 1 1 auto; }
.navitem {
  position: relative; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; padding: 6px 14px; cursor: pointer;
  color: var(--topbar-ink); font-size: 12px; white-space: nowrap; user-select: none;
}
.navitem svg { width: 20px; height: 20px; stroke: var(--teal); fill: none; stroke-width: 1.7; }
.navitem:hover { background: var(--topbar-2); }
.navitem.active { background: var(--topbar-2); }
.navitem.active svg { stroke: #fff; }
.navitem .caret { display: none; }

/* Выпадающее меню */
.dropdown {
  position: absolute; top: 100%; left: 0; min-width: 210px; background: var(--panel);
  color: var(--ink); border: 1px solid var(--line); border-top: 2px solid var(--teal);
  box-shadow: 0 6px 20px rgba(0,0,0,.2); display: none; z-index: 60; padding: 4px 0;
}
.navitem:hover .dropdown { display: block; }
.dropdown a { display: block; padding: 7px 16px; color: var(--ink); text-decoration: none; font-size: 13px; }
.dropdown a:hover { background: var(--line-2); color: var(--teal-ink); }
.right .navitem { font-size: 12px; }
.right .navitem.link { color: var(--topbar-muted); }

/* ── Рабочая область ─────────────────────────────────────────────────────── */
#content { padding: 14px; max-width: 1280px; margin: 0 auto; }
.section-title { font-size: 18px; font-weight: 700; margin: 2px 0 14px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .grow { flex: 1 1 auto; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 3px; padding: 14px; margin-bottom: 14px; }

/* Кнопки */
button, .btn {
  font: inherit; font-size: 13px; padding: 8px 14px; border: 1px solid transparent;
  border-radius: 3px; background: var(--teal); color: #fff; cursor: pointer;
}
button:hover, .btn:hover { filter: brightness(1.05); }
button.ghost, .btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
button.ghost:hover { background: var(--line-2); }
button.danger { background: var(--bad); }
button.small { padding: 5px 10px; font-size: 12px; }
button:disabled { opacity: .5; cursor: default; }
a.link { color: var(--teal-ink); cursor: pointer; text-decoration: none; }
a.link:hover { text-decoration: underline; }

/* Поля */
label.f { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 3px; }
input, select, textarea {
  width: 100%; padding: 8px 9px; font: inherit; font-size: 14px;
  border: 1px solid var(--line); border-radius: 3px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal); border-color: transparent; }
.inline { display: inline-block; width: auto; }

/* Таблицы */
table { width: 100%; border-collapse: collapse; background: var(--panel); font-size: 13.5px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line-2); }
th { font-size: 12px; color: var(--muted); font-weight: 700; background: #f6f8f9; white-space: nowrap; }
tr:hover td { background: #f9fbfb; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 700; background: #eef2f4; }
.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 3px; }
.empty { color: var(--muted); padding: 20px; text-align: center; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: 12px; font-weight: 700; color: #fff; }

.msg { margin: 10px 0; padding: 10px 12px; border-radius: 3px; font-size: 13px; display: none; }
.msg.show { display: block; }
.msg.ok { background: #e2f1e9; color: var(--good); }
.msg.bad { background: #f7e2df; color: var(--bad); }
.msg.warn { background: #f7efd9; color: var(--warn); }

.hint { background: #f7efd9; color: var(--warn); padding: 10px 12px; border-radius: 3px; font-size: 13px; margin-bottom: 12px; }

/* ── Новый заказ: три колонки ────────────────────────────────────────────── */
.order-grid { display: grid; grid-template-columns: 360px 150px 1fr; gap: 12px; align-items: start; }
.order-left { background: var(--panel); border: 1px solid var(--line); border-radius: 3px; min-height: 420px; display: flex; flex-direction: column; }
.order-tabs { display: flex; background: #eceef0; border-bottom: 1px solid var(--line); }
.order-tab { flex: 1; text-align: center; padding: 9px; cursor: pointer; font-size: 13px; color: var(--muted); }
.order-tab.selected { background: #fff; color: var(--ink); font-weight: 700; }
.order-tabpane { display: none; padding: 10px; flex: 1; }
.order-tabpane.selected { display: block; }
.basket { width: 100%; }
.basket th { background: transparent; }
.basket td, .basket th { padding: 6px 6px; font-size: 13px; }
.basket .del { color: var(--bad); cursor: pointer; font-weight: 700; }
.order-total { margin-top: auto; padding: 10px; border-top: 1px solid var(--line); }
.order-total .row { display: flex; justify-content: space-between; font-size: 14px; margin: 2px 0; }
.order-total .grand { font-size: 17px; font-weight: 700; }

.cat-col { display: flex; flex-direction: column; gap: 4px; }
.fr_cat { padding: 12px 10px; text-align: center; background: var(--cat); border-radius: 2px; cursor: pointer; font-size: 13px; }
.fr_cat:hover { background: var(--tile-hover); }
.fr_cat.selected { background: var(--cat-active); color: #fff; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; align-content: start; }
.fr_prod {
  background: var(--tile); border-radius: 2px; padding: 16px 10px; text-align: center;
  cursor: pointer; user-select: none; border: 1px solid transparent;
}
.fr_prod:hover { background: var(--tile-hover); }
.fr_prod .n { font-size: 13px; margin-bottom: 6px; min-height: 32px; }
.fr_prod .fr_price { font-weight: 700; font-size: 14px; }
.fr_prod.stop { opacity: .5; }

/* Правка на месте (расширим потом) */
.ed { cursor: pointer; border-bottom: 1px dashed var(--muted); }
.ed:hover { background: var(--line-2); }

/* Плитки статистики */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 3px; padding: 14px; text-align: center; }
.stat .v { font-size: 26px; font-weight: 700; }
.stat .k { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Список разделов (справочники как плитки на будущее) */
.subnav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.subnav a { padding: 6px 12px; border: 1px solid var(--line); border-radius: 3px; background: #fff; color: var(--ink); text-decoration: none; font-size: 13px; cursor: pointer; }
.subnav a.active { background: var(--teal); color: #fff; border-color: var(--teal); }

@media (max-width: 900px) {
  .order-grid { grid-template-columns: 1fr; }
  .navitem { padding: 6px 10px; }
  .navitem span.lbl { display: none; }
}

/* ── вход, права, формы (добавлено вместе с авторизацией) ─────────────────── */
#login {
  position: fixed; inset: 0; background: var(--bg); display: flex;
  align-items: center; justify-content: center; z-index: 50;
}
.loginbox {
  background: var(--panel); border: 1px solid var(--line); border-radius: 3px;
  padding: 26px 28px; width: 320px; box-shadow: 0 6px 24px rgba(0,0,0,.12);
}
.logintitle { font-weight: 700; letter-spacing: 2px; text-align: center; margin-bottom: 18px; color: var(--teal-ink); }
.loginbox label { display: block; font-size: 13px; margin-bottom: 12px; color: var(--muted); }
.loginbox input { width: 100%; margin-top: 4px; }
.loginbox button { width: 100%; }

.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px 16px; }
.form label { display: block; font-size: 13px; color: var(--muted); }
.form input, .form select, .form textarea { width: 100%; margin-top: 4px; }
.panel h3 { margin: 0 0 12px; font-size: 15px; }
.panel h4 { margin: 0 0 8px; font-size: 13px; color: var(--teal-ink); }

.rights { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.rights-group { border: 1px solid var(--line); border-radius: 3px; padding: 10px 12px; }
.chk { display: block; font-size: 13px; margin: 4px 0; cursor: pointer; }
.chk input { width: auto; margin-right: 6px; }

.del { color: var(--bad); cursor: pointer; font-weight: 700; }
.muted { color: var(--muted); font-size: 12px; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat-tile { background: var(--panel); border: 1px solid var(--line); border-radius: 3px; padding: 12px; text-align: center; }
.stat-tile .v { font-size: 22px; font-weight: 700; }
.stat-tile .l { font-size: 12px; color: var(--muted); }
.report-menu { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 14px; }
.report-menu a { display: block; font-size: 13px; padding: 3px 0; color: var(--ink); text-decoration: none; cursor: pointer; }
.report-menu a:hover { color: var(--teal-ink); }
tr.head td { font-weight: 700; background: var(--line-2); }
tr.total td { font-weight: 700; }
