/* Админ-панель. Направление: спокойный рабочий инструмент — графитовые поверхности, один тёплый акцент (сиена) для выбранного и ссылок,
   цвет только там, где он что-то значит (статусы, деньги). Без градиентов и свечения; глубина — ступенями поверхности и тонкими линиями. */
:root {
  --bg: #141415; --sidebar: #0f0f10; --panel: #19191b; --panel2: #141415; --raised: #232325;
  --border: rgba(237, 237, 237, .09); --text: #ededed; --text2: #a1a1a6; --muted: #85858b;
  --accent: #d98a55; --on-accent: #1d1309;
  --green: #4cc38a; --red: #e5484d; --orange: #e0a458; --blue: #a1a1a6;
  --radius: 14px; --r-ctl: 10px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 400 14px/1.45 'Inter', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
b, strong { font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* каркас */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 240px; flex-shrink: 0; background: var(--sidebar); border-right: 1px solid var(--border); padding: 16px 12px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.logo { font-size: 17px; font-weight: 600; color: var(--text); padding: 4px 8px 20px; display: flex; gap: 10px; align-items: center; }
.logo i { color: var(--muted); font-size: 16px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 12px; margin-bottom: 2px; border-radius: 8px; color: var(--text2); background: none; border: 0; font: 500 13px/1 'Inter', sans-serif; cursor: pointer; text-align: left; transition: background-color .15s var(--ease), color .15s var(--ease); }
.nav-item i { width: 18px; text-align: center; color: var(--muted); font-size: 14px; }
.nav-item:hover { background: var(--raised); color: var(--text); }
.nav-item.active { background: var(--raised); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav-item.active i { color: var(--accent); }
.logout { margin-top: auto; }
.main { flex: 1; min-width: 0; padding: 24px 32px 64px; max-width: 1600px; }
h1 { font-size: 24px; line-height: 32px; margin: 0 0 2px; font-weight: 500; letter-spacing: -.01em; }
.page-sub { color: var(--text2); font-size: 13px; margin-bottom: 20px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* карточки */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card h2 { margin: 0 0 16px; font-size: 15px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.card h2 i { color: var(--muted); font-size: 14px; }
.grid { display: grid; gap: 16px; }
.g6 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; display: flex; justify-content: space-between; gap: 12px; min-height: 96px; }
.stat .lbl { font-size: 13px; color: var(--text2); margin-bottom: 8px; }
.stat .val { font-size: 28px; line-height: 32px; font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .sub { font-size: 12px; margin-top: 6px; color: var(--muted); }
.stat .ico { width: auto !important; height: auto !important; background: none !important; color: var(--muted) !important; font-size: 15px; flex-shrink: 0; }
.mini { background: var(--panel2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; }
.mini .lbl { font-size: 12px; color: var(--text2); }
.mini .val { font-size: 18px; font-weight: 500; margin-top: 4px; font-variant-numeric: tabular-nums; }
.up { color: var(--green); } .down { color: var(--red); }

/* таблицы */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th.sortable { cursor: pointer; } th.sortable:hover { color: var(--text); }
td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: rgba(237, 237, 237, .025); }
td.num { font-variant-numeric: tabular-nums; }
.code { font: 400 12px var(--mono); background: var(--raised); padding: 2px 6px; border-radius: 6px; color: var(--text2); }
.empty { text-align: center; color: var(--muted); padding: 32px; }
.thumb { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; background: var(--raised); vertical-align: middle; margin-right: 12px; flex-shrink: 0; }
.cell-flex { display: flex; align-items: center; }

/* поля и кнопки */
input, select, textarea { background: var(--panel2); border: 1px solid var(--border); color: var(--text); border-radius: var(--r-ctl); padding: 0 12px; height: 38px; font: inherit; width: 100%; outline: none; transition: border-color .15s var(--ease); }
textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 72px; }
input:focus, select:focus, textarea:focus { border-color: rgba(217, 138, 85, .7); }
input::placeholder, textarea::placeholder { color: var(--muted); }
input[type=checkbox] { width: 16px; height: 16px; padding: 0; accent-color: var(--accent); }
input[type=file] { height: auto; padding: 8px 12px; }
label.f { display: block; font-size: 13px; color: var(--text2); font-weight: 400; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.btn { background: var(--raised); border: 1px solid var(--border); color: var(--text); height: 36px; padding: 0 14px; border-radius: var(--r-ctl); font: 500 13px/1 'Inter', sans-serif; cursor: pointer; display: inline-flex; gap: 8px; align-items: center; white-space: nowrap; transition: background-color .15s var(--ease), border-color .15s var(--ease), opacity .15s var(--ease); }
.btn:hover { background: #2c2c2f; text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary, .btn-green { background: var(--text); border-color: var(--text); color: #141415; }
.btn-primary:hover, .btn-green:hover { background: #fff; }
.btn-red { background: transparent; border-color: rgba(229, 72, 77, .5); color: var(--red); }
.btn-red:hover { background: rgba(229, 72, 77, .1); }
.btn-blue { background: var(--raised); }
.btn-orange { background: transparent; color: var(--orange); border-color: rgba(224, 164, 88, .4); }
.btn-orange:hover { background: rgba(224, 164, 88, .08); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn-ico { height: 30px; min-width: 30px; padding: 0 8px; border-radius: 8px; font-size: 12px; justify-content: center; }
.btn-block { width: 100%; justify-content: center; }

/* метки: только статус несёт цвет, всё остальное — спокойный нейтральный тег */
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--raised); color: var(--text2); border: 1px solid var(--border); }
.b-gray, .b-purple, .b-blue { background: var(--raised); color: var(--text2); border-color: var(--border); }
.b-green { background: rgba(76, 195, 138, .1); color: var(--green); border-color: rgba(76, 195, 138, .25); }
.b-red { background: rgba(229, 72, 77, .1); color: var(--red); border-color: rgba(229, 72, 77, .28); }
.b-orange { background: rgba(224, 164, 88, .1); color: var(--orange); border-color: rgba(224, 164, 88, .28); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; padding: 3px; background: var(--panel2); border: 1px solid var(--border); border-radius: 12px; width: fit-content; max-width: 100%; }
.tab { background: none; border: 0; color: var(--text2); height: 32px; padding: 0 14px; border-radius: 9px; font: 500 13px 'Inter', sans-serif; cursor: pointer; transition: background-color .15s var(--ease), color .15s var(--ease); }
.tab:hover { color: var(--text); }
.tab.active { background: var(--raised); color: var(--text); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: 16px; color: var(--muted); font-size: 13px; }
.toolbar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.toolbar input[type=text], .toolbar input[type=search] { max-width: 320px; }
.toolbar select { width: auto; min-width: 140px; }

/* карточки моделей */
.models { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.mcard { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.mcard .t { display: flex; justify-content: space-between; color: var(--text); font-weight: 500; font-size: 14px; margin-bottom: 12px; border-bottom: 1px solid var(--border); padding-bottom: 12px; }

/* окна */
.overlay { position: fixed; inset: 0; background: rgba(8, 8, 9, .7); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; backdrop-filter: blur(2px); }
.overlay.side { justify-content: flex-end; align-items: stretch; padding: 0; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto; padding: 24px; box-shadow: 0 24px 64px rgba(0, 0, 0, .5); }
.modal.wide { max-width: 680px; }
.side .modal { border-radius: 0; max-height: none; height: 100%; max-width: 400px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 500; display: flex; gap: 10px; align-items: center; }
.modal-head h3 i { color: var(--muted); font-size: 14px; }
.x { background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; }
.x:hover { color: var(--text); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.kv > div { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.kv .k { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.kv .v { font-weight: 500; font-size: 14px; }
.box { background: var(--panel2); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin: 12px 0; }
.stack > .btn { width: 100%; justify-content: center; margin-bottom: 8px; }

.drop { border: 1px dashed rgba(237, 237, 237, .22); border-radius: 12px; padding: 24px; text-align: center; cursor: pointer; color: var(--text2); transition: border-color .15s var(--ease); }
.drop:hover { border-color: var(--accent); }
.drop i { font-size: 24px; color: var(--muted); margin-bottom: 8px; }
.previews { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.previews div { position: relative; }
.previews img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }
.previews button { position: absolute; top: -6px; right: -6px; background: var(--raised); color: var(--text); border: 1px solid var(--border); border-radius: 50%; width: 20px; height: 20px; cursor: pointer; font-size: 10px; }
.progress { height: 8px; background: var(--raised); border-radius: 4px; overflow: hidden; margin: 12px 0; }
.progress > div { height: 100%; background: var(--accent); transition: width .4s var(--ease); }

#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--raised); border: 1px solid var(--border); border-left: 3px solid var(--green); padding: 12px 16px; border-radius: 10px; font-weight: 500; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); animation: in .2s var(--ease); max-width: 360px; }
.toast.err { border-left-color: var(--red); }
@keyframes in { from { transform: translateY(8px); opacity: 0; } }

/* вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 32px; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 16px; }
.login-card .logo { padding: 0; }
.err { color: var(--red); font-size: 13px; min-height: 16px; }

.chart-box { height: 340px; position: relative; }
.sticky-save { position: sticky; bottom: 0; background: linear-gradient(rgba(20, 20, 21, 0), var(--bg) 40%); padding: 20px 0 0; display: flex; justify-content: flex-end; }

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; padding: 8px; }
  .sidebar .logo { width: 100%; padding-bottom: 6px; }
  #nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .nav-item { width: auto; padding: 0 10px; }
  .main { padding: 16px 16px 64px; }
  .two { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.notice { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--raised); color: var(--text2); font-size: 13px; line-height: 1.5; }
.notice.ok { border-color: rgba(76, 195, 138, .35); background: rgba(76, 195, 138, .08); color: var(--text); }
