/* ===================== Общее ===================== */
:root {
  --primary:   #2563eb;
  --primary-d: #1d4ed8;
  --accent:    #0ea5e9;
  --success:   #10b981;
  --danger:    #ef4444;
  --warning:   #f59e0b;
  --bg:        #f1f5f9;
  --card:      #ffffff;
  --text:      #0f172a;
  --muted:     #64748b;
  --border:    #e2e8f0;
  --sidebar:   linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  --radius:    12px;
  --shadow:    0 1px 3px rgba(15,23,42,.06), 0 4px 12px rgba(15,23,42,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===================== Авторизация ===================== */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 600px at 30% 20%, #1e40af22, transparent 60%),
              radial-gradient(1000px 500px at 80% 90%, #0ea5e922, transparent 60%),
              linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #334155 100%);
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 18px;
  padding: 36px 32px 28px;
  box-shadow: 0 25px 60px rgba(0,0,0,.35);
}
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand .brand-logo { margin: 0 auto 14px; }
.auth-brand h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: .5px; }
.auth-brand p  { margin: 0; color: var(--muted); font-size: 13px; }
.auth-footer   { text-align: center; color: var(--muted); font-size: 12px; margin-top: 20px; }

/* ===================== Лого ===================== */
.brand-logo {
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff; font-weight: 800; font-size: 22px;
  box-shadow: 0 6px 16px rgba(37,99,235,.35);
}

/* ===================== Layout ===================== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: transform .25s ease;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid #33415555;
}
.brand-text .brand-name { font-weight: 700; font-size: 18px; color: #fff; letter-spacing: .3px; }
.brand-text .brand-sub  { font-size: 11px; color: #94a3b8; line-height: 1.3; margin-top: 2px; }

.nav { padding: 14px 12px; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #cbd5e1;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: #ffffff14; color: #fff; text-decoration: none; }
.nav-item.active { background: linear-gradient(135deg, #2563eb, #0ea5e9); color: #fff; box-shadow: 0 6px 14px rgba(37,99,235,.35); }
.nav-icon { width: 22px; text-align: center; font-size: 16px; }

.sidebar-footer { padding: 16px; border-top: 1px solid #33415555; }
.user-box { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.user-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 16px;
}
.user-meta .user-name { font-weight: 600; font-size: 13.5px; color: #fff; }
.user-meta .user-role { font-size: 11.5px; color: #94a3b8; }

/* ===================== Main ===================== */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky; top: 0; z-index: 20;
}
.page-title { font-size: 18px; font-weight: 700; margin: 0; flex: 1; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.chip {
  background: #eff6ff; color: var(--primary);
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.burger {
  display: none;
  background: transparent; border: 0; font-size: 22px; cursor: pointer;
  color: var(--text);
}

.content { padding: 24px; flex: 1; }
.footer {
  padding: 14px 24px;
  color: var(--muted);
  font-size: 12.5px;
  border-top: 1px solid var(--border);
  background: #fff;
}

.overlay {
  position: fixed; inset: 0;
  background: #00000080;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
  z-index: 15;
}
.overlay.show { opacity: 1; pointer-events: auto; }

/* ===================== Карточки, сетки ===================== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.card-title { font-size: 16px; font-weight: 700; margin: 0; }
.card-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 1000px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 700px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}

/* ===================== KPI ===================== */
.kpi {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 14px;
  position: relative; overflow: hidden;
}
.kpi::after {
  content: ''; position: absolute; right: -30px; top: -30px;
  width: 90px; height: 90px; border-radius: 50%;
  background: linear-gradient(135deg, #2563eb15, #0ea5e915);
}
.kpi-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff; flex-shrink: 0;
}
.kpi-icon.blue   { background: linear-gradient(135deg, #2563eb, #0ea5e9); }
.kpi-icon.green  { background: linear-gradient(135deg, #10b981, #34d399); }
.kpi-icon.orange { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.kpi-icon.purple { background: linear-gradient(135deg, #8b5cf6, #a78bfa); }
.kpi-icon.red    { background: linear-gradient(135deg, #ef4444, #f87171); }
.kpi-value { font-size: 22px; font-weight: 800; line-height: 1.1; }
.kpi-label { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* ===================== Кнопки ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 600; font-size: 13.5px;
  cursor: pointer; text-decoration: none;
  transition: background .15s, box-shadow .15s, transform .05s;
  line-height: 1;
}
.btn:active { transform: translateY(1px); }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); text-decoration: none; color:#fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; text-decoration: none; color:#fff; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; text-decoration: none; color:#fff; }
.btn-warning  { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; text-decoration: none; color:#fff; }
.btn-ghost    { background: #ffffff14; color: #e2e8f0; border-color: #ffffff1f; }
.btn-ghost:hover { background: #ffffff24; color: #fff; text-decoration: none; }
.btn-outline  { background: #fff; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: #f8fafc; text-decoration: none; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* ===================== Таблицы ===================== */
.table-wrap { overflow-x: auto; border-radius: 10px; }
table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table th, .table td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th {
  background: #f8fafc;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.table tbody tr:hover { background: #f8fafc; }
.table .right { text-align: right; }
.table .center { text-align: center; }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* ===================== Формы ===================== */
.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  font-size: 12.5px; font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.field input[type=text],
.field input[type=password],
.field input[type=email],
.field input[type=date],
.field input[type=month],
.field input[type=number],
.field input[type=tel],
.field input[type=file],
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px #2563eb22;
}
.field textarea { resize: vertical; min-height: 80px; }
.field .help { display:block; font-size:11.5px; color: var(--muted); margin-top:4px; }

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 0 16px;
}
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr; } }

.form-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--border);
}

/* ===================== Уведомления ===================== */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 13.5px;
  border-left: 4px solid transparent;
}
.alert-info    { background: #eff6ff; color: #1e40af; border-color: #3b82f6; }
.alert-success { background: #ecfdf5; color: #065f46; border-color: #10b981; }
.alert-danger  { background: #fef2f2; color: #991b1b; border-color: #ef4444; }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #f59e0b; }

/* ===================== Бейджи ===================== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  line-height: 1.4;
}
.badge-gray   { background: #f1f5f9; color: #475569; }
.badge-green  { background: #dcfce7; color: #166534; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* ===================== Тулбар фильтров ===================== */
.toolbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: end;
  margin-bottom: 16px;
}
.toolbar .field { margin-bottom: 0; min-width: 160px; flex: 0 0 auto; }
.toolbar .field.grow { flex: 1 1 220px; }
.toolbar .field > span { font-size: 11.5px; }

/* ===================== Ссылка на файл ===================== */
.file-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--primary); font-weight: 600; font-size: 12.5px;
}
.file-link:hover { text-decoration: underline; }

/* ===================== Мобильный вид ===================== */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    z-index: 30;
    box-shadow: 0 20px 40px rgba(0,0,0,.4);
  }
  .sidebar.open { transform: translateX(0); }
  .burger { display: block; }
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
}

/* ===================== Печать ===================== */
@media print {
  .sidebar, .topbar, .footer, .no-print, .burger { display: none !important; }
  .layout { display: block; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  body { background: #fff; }
}