/*
 * Оформление – как в supply.his.kz (Tailwind 4): светлый фон slate-50, темная
 * панель slate-900, фирменный оранжевый brand-600, шрифт Inter, скругления
 * rounded-xl/2xl. Здесь без сборки, поэтому значения палитры выписаны токенами.
 */
:root {
  --slate-50: #f8fafc; --slate-100: #f1f5f9; --slate-200: #e2e8f0; --slate-300: #cbd5e1;
  --slate-400: #94a3b8; --slate-500: #64748b; --slate-600: #475569; --slate-700: #334155;
  --slate-800: #1e293b; --slate-900: #0f172a;
  --brand-50: #fff7ed; --brand-100: #ffedd5; --brand-200: #fed7aa; --brand-500: #f97316;
  --brand-600: #ea580c; --brand-700: #c2410c;

  --bg: var(--slate-50); --panel: #fff; --text: var(--slate-900); --muted: var(--slate-500);
  --line: var(--slate-200); --accent: var(--brand-600); --accent-weak: var(--brand-50);
  --ok: #047857; --ok-weak: #d1fae5; --warn: #b45309; --warn-weak: #fef3c7;
  --bad: #b91c1c; --bad-weak: #fee2e2;
  --radius: 16px; --radius-sm: 12px;
  --sb-width: 16rem;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
  font: 14px/1.5 'Inter', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; font-weight: 700; line-height: 1.3; margin: 0 0 24px; color: var(--slate-900); }
h2 { font-size: 16px; font-weight: 600; margin: 24px 0 12px; color: var(--slate-900); }
.panel > h2:first-child { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.icon { width: 20px; height: 20px; flex-shrink: 0; }

/* --- Каркас: панель слева на всю высоту, сворачивается в узкую (как AppLayout supply) --- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; width: var(--sb-width); flex-shrink: 0; z-index: 40;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--slate-900); color: var(--slate-300); transition: width .2s, transform .2s;
}
.sb-head { height: 64px; display: flex; align-items: center; gap: 8px; padding: 0 16px; border-bottom: 1px solid var(--slate-800); flex-shrink: 0; }
.sb-title { font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px; background: var(--brand-600); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.brand-mark:hover, .brand-link:hover { text-decoration: none; }
.brand-link { display: flex; flex-shrink: 0; }
.brand-mark.logo { background: none; object-fit: contain; }
.brand-mark.lg { width: 44px; height: 44px; border-radius: 12px; font-size: 16px; }
.sb-close, .sb-open { display: none; background: none; border: 0; color: inherit; cursor: pointer; padding: 4px; }
.sb-close { margin-left: auto; }

.sb-nav { flex: 1; padding: 16px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.sb-nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px;
  color: var(--slate-300); font-size: 14px; font-weight: 500; white-space: nowrap; transition: background .15s, color .15s;
}
.sb-nav a:hover { background: var(--slate-800); color: #fff; text-decoration: none; }
.sb-nav a.on { background: var(--brand-600); color: #fff; }

.sb-foot { border-top: 1px solid var(--slate-800); padding: 10px; flex-shrink: 0; position: relative; }
.sb-account, .sb-collapse {
  width: 100%; display: flex; align-items: center; gap: 12px; border: 0; background: none; cursor: pointer;
  color: var(--slate-400); font: inherit; font-size: 14px; border-radius: 8px; transition: background .15s, color .15s;
}
.sb-account { padding: 8px; color: inherit; }
.sb-collapse { padding: 8px 12px; margin-top: 4px; }
.sb-account:hover, .sb-account.open, .sb-collapse:hover { background: var(--slate-800); color: #fff; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--brand-700); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.sb-who { min-width: 0; flex: 1; text-align: left; display: flex; flex-direction: column; }
.sb-name { color: #fff; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-role { color: var(--slate-400); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { width: 16px; height: 16px; transform: rotate(180deg); transition: transform .15s; }
.sb-account.open .chev { transform: none; }
.account-menu {
  position: absolute; left: 10px; right: 10px; bottom: calc(100% - 4px); z-index: 50;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 20px 25px -5px rgb(0 0 0 / .15); padding: 4px 0;
}
.account-menu form { margin: 0; }
.account-menu button {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 0; background: none;
  font: inherit; font-size: 14px; color: var(--slate-700); cursor: pointer; text-align: left;
}
.account-menu button.danger { color: #dc2626; }
.account-menu button:hover { background: #fef2f2; }

html.sb-collapsed { --sb-width: 4rem; }
html.sb-collapsed .sb-label { display: none; }
html.sb-collapsed .sb-head { justify-content: center; padding: 0; }
html.sb-collapsed .sb-nav a, html.sb-collapsed .sb-account, html.sb-collapsed .sb-collapse { justify-content: center; padding-left: 0; padding-right: 0; }
html.sb-collapsed .sb-collapse .icon { transform: rotate(180deg); }
/* Узкая панель обрезает содержимое – меню открываем справа от нее. */
html.sb-collapsed .account-menu { position: fixed; left: calc(4rem + 12px); right: auto; bottom: 56px; width: 15rem; }

.sb-backdrop { display: none; }
.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 64px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center;
  gap: 16px; padding: 0 24px; position: sticky; top: 0; z-index: 20;
}
.spacer { flex: 1; }
main { flex: 1; padding: 32px; width: 100%; max-width: 1280px; margin: 0 auto; }

/* --- Блоки --- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-bottom: 16px; }
.grid .panel { margin-bottom: 0; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.head h1 { margin: 0; }
.stat { font-size: 28px; font-weight: 700; color: var(--slate-900); line-height: 1.3; margin: 4px 0; }

/* Таблица – белая карточка rounded-2xl, шапка slate-50, строки с подсветкой (как списки supply). */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; margin-bottom: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 16px; vertical-align: top; }
thead th, table tr:first-child th { background: var(--slate-50); color: var(--slate-500); font-weight: 500; }
td { border-top: 1px solid var(--slate-100); }
tbody tr:hover td { background: var(--slate-50); }
.panel table th, .panel table td { padding-left: 0; }
.panel table thead th { background: none; }
.panel table tbody tr:hover td { background: none; }

dl.props { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; margin: 0; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; }

/* --- Формы --- */
form.filters { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
input, select, textarea {
  font: inherit; font-size: 14px; color: var(--text); background: #fff; border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm); padding: 9px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-200); }
input[type=checkbox] { padding: 0; width: 16px; height: 16px; accent-color: var(--brand-600); }
textarea { width: 100%; min-height: 90px; }
label { display: block; font-size: 14px; font-weight: 500; color: var(--slate-700); margin-bottom: 6px; }
.fields { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.fields input, .fields select, .block { width: 100%; }
.field-full { grid-column: 1 / -1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; border: 1px solid var(--slate-300); background: #fff; color: var(--slate-700);
  padding: 9px 16px; border-radius: var(--radius-sm); transition: background .15s, border-color .15s; white-space: nowrap;
}
.btn:hover { text-decoration: none; background: var(--slate-50); }
.btn.primary { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.btn.primary:hover { background: var(--brand-700); border-color: var(--brand-700); }
.btn.dark { background: var(--slate-900); border-color: var(--slate-900); color: #fff; }
.btn.dark:hover { background: var(--slate-800); }
.btn.danger { color: #dc2626; border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 0; font-weight: 500; }
.btn.link:hover { text-decoration: underline; background: none; }
.btn.block { display: flex; width: 100%; padding: 12px 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 20px; }

/* Метки статусов – rounded-full bg-*-100 text-*-700, как StatusBadge supply. */
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; background: #dbeafe; color: #1d4ed8; white-space: nowrap; }
.badge.ok { background: var(--ok-weak); color: var(--ok); }
.badge.warn { background: var(--warn-weak); color: var(--warn); }
.badge.bad { background: var(--bad-weak); color: var(--bad); }
.badge.mute { background: var(--slate-100); color: var(--slate-600); }

/* Настройки: строка "подпись слева – поле справа", как в настройках supply. */
.settings-import { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--brand-50); border-color: var(--brand-200); }
.settings { padding-bottom: 0; }
.settings-head { display: flex; gap: 16px; align-items: center; justify-content: space-between; padding-bottom: 12px; }
.settings-head h2 { margin: 0; }
.setting-row { display: grid; grid-template-columns: minmax(200px, 320px) minmax(0, 1fr); gap: 8px 32px; padding: 14px 0; border-top: 1px solid var(--line); align-items: center; }
.setting-label label { margin: 0; }
.setting-label .small { margin-top: 2px; }
.setting-control { display: flex; gap: 8px 16px; align-items: center; flex-wrap: wrap; max-width: 520px; }
.setting-control > input:not([type=checkbox]):not([type=file]), .setting-control > select { flex: 1 1 100%; }
.setting-control > input.short:not([type=checkbox]) { flex: 0 0 120px; }
.setting-logo { width: 44px; height: 44px; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); }
label.check { display: inline-flex; gap: 8px; align-items: center; margin: 0; font-weight: 500; color: inherit; white-space: nowrap; }
.env { font-size: 11px; font-weight: 500; color: var(--slate-500); background: var(--slate-100); border-radius: 4px; padding: 0 5px; margin-left: 4px; vertical-align: 1px; }
.settings-foot { display: flex; justify-content: flex-end; padding: 16px 0 20px; border-top: 1px solid var(--line); }
@media (max-width: 720px) { .setting-row { grid-template-columns: 1fr; } }

/* --- Сообщения --- */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; border: 1px solid; }
.flash.ok { background: #ecfdf5; color: var(--ok); border-color: #a7f3d0; }
.flash.error { background: #fef2f2; color: var(--bad); border-color: #fecaca; }
.errors { margin: 0 0 16px; padding: 12px 16px 12px 32px; background: #fef2f2; color: var(--bad); border: 1px solid #fecaca; border-radius: var(--radius-sm); }
.toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 60; max-width: 28rem; padding: 12px 16px; border-radius: 12px;
  color: #fff; font-size: 14px; background: var(--slate-800); box-shadow: 0 10px 15px -3px rgb(0 0 0 / .2);
  cursor: pointer; transition: opacity .3s, transform .3s;
}
.toast.ok { background: #059669; }
.toast.error { background: #dc2626; }
.toast.hide { opacity: 0; transform: translateY(8px); pointer-events: none; }

.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 8px 0; border-bottom: 1px solid var(--slate-100); }
.list-plain li:last-child { border-bottom: 0; }

.pager { display: flex; gap: 6px; padding: 12px 16px; flex-wrap: wrap; }
.pager a, .pager span { padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 14px; color: var(--slate-600); }
.pager a:hover { background: var(--slate-50); text-decoration: none; }
.pager .on { background: var(--brand-600); color: #fff; border-color: var(--brand-600); }
details summary { cursor: pointer; color: var(--accent); font-weight: 500; }

/* --- Вход: карточка по центру на мягком градиенте (GuestLayout supply) --- */
main.guest {
  max-width: none; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 16px; background: linear-gradient(to bottom right, var(--slate-100), #fff, var(--brand-50));
}
main.guest > * { width: 100%; max-width: 28rem; }
.login-card { background: #fff; border: 1px solid var(--slate-100); border-radius: var(--radius); padding: 32px; box-shadow: 0 20px 25px -5px rgb(0 0 0 / .08), 0 8px 10px -6px rgb(0 0 0 / .08); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-brand h1 { font-size: 18px; font-weight: 600; margin: 0; }
.divider { position: relative; text-align: center; margin: 24px 0 16px; }
.divider::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--slate-200); }
.divider span { position: relative; background: #fff; padding: 0 12px; font-size: 12px; color: var(--slate-400); }

/* --- Узкий экран: панель выдвигается поверх, как в supply --- */
@media (max-width: 1023px) {
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); width: 16rem; }
  html.sb-open .sidebar { transform: none; }
  html.sb-open .sb-backdrop { display: block; position: fixed; inset: 0; z-index: 30; background: rgb(0 0 0 / .4); }
  html.sb-collapsed .sb-label { display: revert; }
  html.sb-collapsed .sb-nav a, html.sb-collapsed .sb-account { justify-content: flex-start; padding-left: 12px; }
  html.sb-collapsed .sb-head { justify-content: flex-start; padding: 0 16px; }
  html.sb-collapsed .account-menu { position: absolute; left: 10px; right: 10px; bottom: calc(100% - 4px); width: auto; }
  .sb-close, .sb-open { display: block; }
  .sb-collapse { display: none; }
  .topbar { padding: 0 16px; }
  main { padding: 16px; }
  dl.props { grid-template-columns: 1fr; }
}
