/* ═══════════════════════════════════════════════════════════
   НашСундук — Дизайн-система v2 (clean, soft, professional)
   ═══════════════════════════════════════════════════════════ */

/* Cera Pro */
@font-face {
  font-family: 'Cera Pro';
  src: url('../fonts/CeraPro-Regular.woff2') format('woff2'),
       url('../fonts/CeraPro-Regular.woff')  format('woff');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Cera Pro';
  src: url('../fonts/CeraPro-Medium.woff2')  format('woff2'),
       url('../fonts/CeraPro-Medium.woff')   format('woff');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Cera Pro';
  src: url('../fonts/CeraPro-Bold.woff2')    format('woff2'),
       url('../fonts/CeraPro-Bold.woff')     format('woff');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Cera Pro';
  src: url('../fonts/CeraPro-Black.woff2')   format('woff2'),
       url('../fonts/CeraPro-Black.woff')    format('woff');
  font-weight: 800; font-style: normal; font-display: swap;
}

/* ─────────── DESIGN TOKENS ─────────── */
:root {
  --font: 'Cera Pro', 'Nunito', -apple-system, 'Segoe UI', sans-serif;

  /* surfaces */
  --bg:           #F0F4F8;
  --surface:      #FFFFFF;
  --surface-2:    #F8FAFC;

  /* borders */
  --border:       #E5E7EB;
  --border-soft:  #EEF1F5;

  /* text */
  --text:           #0F172A;
  --text-secondary: #475569;
  --text-muted:     #94A3B8;

  /* accent (indigo) */
  --accent:        #6366F1;
  --accent-dark:   #4F46E5;
  --accent-light:  #818CF8;
  --accent-soft:   #EEF2FF;
  --accent-soft-2: #E0E7FF;

  /* semantics */
  --success:      #10B981;
  --success-soft: #D1FAE5;
  --warning:      #F59E0B;
  --warning-soft: #FEF3C7;
  --danger:       #EF4444;
  --danger-soft:  #FEE2E2;
  --info:         #0EA5E9;
  --info-soft:    #DBEAFE;

  /* sizes */
  --sidebar-w:   264px;
  --topbar-h:    60px;

  --radius-sm:   8px;
  --radius:      12px;
  --radius-lg:   16px;

  --shadow-xs:   0 1px 2px rgba(15, 23, 42, .04);
  --shadow-sm:   0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow:      0 4px 16px rgba(15, 23, 42, .07);
  --shadow-lg:   0 16px 40px rgba(15, 23, 42, .12);

  --transition:  .18s cubic-bezier(.4, 0, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─────────── LAYOUT ─────────── */
.wrapper {
  display: flex;
  min-height: 100vh;
}

/* ═══════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════ */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition), width var(--transition), min-width var(--transition);
  z-index: 200;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
#sidebar::-webkit-scrollbar { width: 6px; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
#sidebar::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Полное скрытие шторки (и на десктопе, и на мобильном) */
#sidebar.hidden {
  transform: translateX(-100%);
  width: 0;
  min-width: 0;
  border-right: 0;
}

/* ─── Header ─── */
.sidebar-header {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
  white-space: nowrap;
}
.sidebar-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(99, 102, 241, .35);
}

/* ─── Nav ─── */
.sidebar-nav {
  list-style: none;
  padding: 12px 8px;
  margin: 0;
  flex: 1;
}

.nav-category {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  user-select: none;
  transition: color var(--transition);
}
.nav-category:hover { color: var(--text-secondary); }
.nav-category[data-section] { cursor: pointer; }
.section-chevron {
  font-size: 11px;
  transition: transform var(--transition);
  opacity: .7;
}
.nav-category.section-closed .section-chevron { transform: rotate(-90deg); }

.nav-section {
  overflow: hidden;
  max-height: 700px;
  transition: max-height var(--transition), opacity var(--transition);
  opacity: 1;
}
.nav-section.section-collapsed {
  max-height: 0;
  opacity: 0;
}

.nav-item {
  list-style: none;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin: 1px 0;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  position: relative;
}
.nav-link i {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: color var(--transition);
}
.nav-link:hover {
  background: var(--bg);
  color: var(--text);
}
.nav-link:hover i { color: var(--text-secondary); }
.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 600;
}
.nav-link.active i { color: var(--accent); }

/* ─── Footer (User card) ─── */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-light), var(--accent-dark));
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}
.user-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.logout-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.logout-btn:hover {
  background: var(--danger-soft);
  color: var(--danger);
}
.logout-btn i { font-size: 16px; }

/* ─── Mobile overlay ─── */
#sidebarOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .35);
  z-index: 1040;
  backdrop-filter: blur(2px);
  transition: opacity var(--transition);
}
#sidebarOverlay.active { display: block; }

/* На мобильном — шторка как overlay (поверх контента и подложки) */
@media (max-width: 991px) {
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    z-index: 1050;       /* ВЫШЕ оверлея 1040 — чтобы по ссылкам можно было кликать */
  }
  #sidebar.open {
    transform: translateX(0);
  }
}

/* ═══════════════════════════════════════════════════════════
   TOPBAR + CONTENT
   ═══════════════════════════════════════════════════════════ */
#content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
}
.topbar .btn-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.topbar .btn-icon:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border-soft);
}

.topbar .breadcrumb {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}
.topbar .breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition);
}
.topbar .breadcrumb a:hover { color: var(--accent); }
.topbar .breadcrumb-item.active { color: var(--text); font-weight: 500; }
.topbar .breadcrumb-item + .breadcrumb-item::before {
  color: var(--text-muted);
  content: "/";
}

.scan-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.scan-btn:hover { background: var(--accent-dark); color: #fff; }
.scan-btn:active { transform: scale(.98); }

.content-body {
  flex: 1;
  padding: 24px;
}
@media (min-width: 768px) {
  .content-body { padding: 32px; }
}

/* ═══════════════════════════════════════════════════════════
   LOGIN
   ═══════════════════════════════════════════════════════════ */
.login-page {
  background: linear-gradient(135deg, #EEF2FF 0%, #F0F4F8 50%, #FDF4FF 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  font-family: var(--font);
}
.login-wrapper { width: 100%; max-width: 420px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .08);
}
.login-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 18px;
  box-shadow: 0 8px 24px rgba(99, 102, 241, .3);
}
.login-title {
  font-size: 26px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 6px;
  letter-spacing: -.02em;
  color: var(--text);
}
.login-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 28px;
}
.login-hint { text-align: center; margin-top: 24px; }

/* ═══════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
  overflow: hidden;
}
.card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0 !important;
  padding: 16px 20px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}
.card-body { padding: 20px; }

/* ═══════════════════════════════════════════════════════════
   STAT CARDS
   ═══════════════════════════════════════════════════════════ */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent);
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -.02em;
  color: var(--text);
}
.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 500;
}

.stat-total::before    { background: var(--accent); }
.stat-total .stat-icon { background: var(--accent-soft); color: var(--accent-dark); }
.stat-active::before    { background: var(--success); }
.stat-active .stat-icon { background: var(--success-soft); color: #047857; }
.stat-repair::before    { background: var(--warning); }
.stat-repair .stat-icon { background: var(--warning-soft); color: #92400E; }
.stat-writeoff::before    { background: var(--danger); }
.stat-writeoff .stat-icon { background: var(--danger-soft); color: #991B1B; }

/* ═══════════════════════════════════════════════════════════
   TYPOGRAPHY
   ═══════════════════════════════════════════════════════════ */
.page-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text);
  margin: 0;
}
.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

.detail-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 700;
  margin-bottom: 4px;
}
.detail-value {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

.depr-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}
.depr-value {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text);
}

/* ═══════════════════════════════════════════════════════════
   AUDIT FEED
   ═══════════════════════════════════════════════════════════ */
.audit-feed {
  padding: 4px 16px;
  max-height: 360px;
  overflow-y: auto;
}
.audit-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
}
.audit-item:last-child { border-bottom: none; }
.audit-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 7px;
  flex-shrink: 0;
}
.audit-action {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.audit-meta {
  font-size: 12px;
  color: var(--text-muted);
}
.audit-details { font-size: 13px; color: var(--text-secondary); }

/* ═══════════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════════ */
.table {
  font-family: var(--font);
  margin-bottom: 0;
}
.table > :not(caption) > * > * {
  padding: 12px 16px;
  border-bottom-color: var(--border-soft);
}
.table thead th {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody tr {
  transition: background var(--transition);
}
.table tbody tr:hover { background: var(--surface-2); }
.table-responsive { -webkit-overflow-scrolling: touch; }

/* ═══════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════ */
.btn {
  font-family: var(--font);
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 14px;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), transform var(--transition),
              box-shadow var(--transition);
}
.btn:active { transform: scale(.98); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-primary:focus { box-shadow: 0 0 0 3px rgba(99, 102, 241, .25); }

.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.btn-success:hover { background: #059669; border-color: #059669; }

.btn-warning {
  background: var(--warning);
  border-color: var(--warning);
  color: #fff;
}
.btn-warning:hover { background: #D97706; border-color: #D97706; color: #fff; }

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #DC2626; border-color: #DC2626; }

.btn-outline-primary {
  color: var(--accent);
  border-color: var(--accent);
  background: transparent;
}
.btn-outline-primary:hover {
  background: var(--accent);
  color: #fff;
}

.btn-outline-secondary {
  color: var(--text-secondary);
  border-color: var(--border);
  background: var(--surface);
}
.btn-outline-secondary:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* ═══════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════ */
.form-control, .form-select {
  font-family: var(--font);
  font-size: 14px;
  border-radius: var(--radius-sm);
  border-color: var(--border);
  background: var(--surface);
  padding: 8px 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
}
.form-label {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input-group-text {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-secondary);
  font-size: 14px;
}

/* ═══════════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════════ */
.badge {
  font-family: var(--font);
  font-weight: 600;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: .01em;
}
.badge.bg-primary   { background: var(--accent-soft) !important; color: var(--accent-dark); }
.badge.bg-success   { background: var(--success-soft) !important; color: #047857; }
.badge.bg-warning   { background: var(--warning-soft) !important; color: #92400E; }
.badge.bg-danger    { background: var(--danger-soft) !important; color: #991B1B; }
.badge.bg-info      { background: var(--info-soft) !important; color: #1E40AF; }
.badge.bg-secondary { background: var(--bg) !important; color: var(--text-secondary); }
.badge.bg-light     { background: var(--bg) !important; color: var(--text-secondary); }

/* ═══════════════════════════════════════════════════════════
   ALERTS
   ═══════════════════════════════════════════════════════════ */
.alert {
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 500;
  padding: 12px 16px;
}
.alert-success { background: var(--success-soft); border-color: #A7F3D0; color: #065F46; }
.alert-warning { background: var(--warning-soft); border-color: #FDE68A; color: #92400E; }
.alert-danger  { background: var(--danger-soft);  border-color: #FECACA; color: #991B1B; }
.alert-info    { background: var(--info-soft);    border-color: #BFDBFE; color: #1E40AF; }

/* ═══════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════ */
.modal-content {
  border-radius: var(--radius-lg);
  border: none;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  border-bottom: 1px solid var(--border);
  padding: 18px 22px;
}
.modal-title {
  font-family: var(--font);
  font-weight: 700;
  font-size: 17px;
}
.modal-body { padding: 22px; }
.modal-footer {
  border-top: 1px solid var(--border);
  padding: 14px 22px;
}

/* ═══════════════════════════════════════════════════════════
   CODE / INLINE
   ═══════════════════════════════════════════════════════════ */
code {
  background: var(--surface-2);
  padding: 2px 7px;
  border-radius: 5px;
  color: var(--accent-dark);
  font-size: .85em;
  font-weight: 600;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  border: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════
   MISC
   ═══════════════════════════════════════════════════════════ */
.object-fit-cover { object-fit: cover; }

/* ═══════════════════════════════════════════════════════════
   MOBILE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 991px) {
  #sidebar { width: 78vw; min-width: 78vw; max-width: 320px; }
}

@media (max-width: 767px) {
  body { font-size: 14.5px; }

  .page-title { font-size: 18px; }
  .content-body { padding: 16px; }
  .topbar { padding: 0 14px; gap: 8px; }
  .topbar .breadcrumb { display: none; }
  .scan-btn { font-size: 12px; padding: 6px 10px; }

  .card-body { padding: 16px; }
  .card-header { padding: 14px 16px; font-size: 14px; }

  .btn { min-height: 42px; padding: 10px 16px; font-size: 14px; }
  .btn-sm { min-height: 36px; padding: 7px 12px; font-size: 13px; }

  .form-control, .form-select { min-height: 44px; font-size: 16px; }
  .form-control-sm, .form-select-sm { min-height: 36px; font-size: 14px; }

  .d-flex.justify-content-between.align-items-center {
    flex-wrap: wrap;
    justify-content: center !important;
    gap: 10px;
  }
  .d-flex.justify-content-between.align-items-center > .btn,
  .d-flex.justify-content-between.align-items-center > a.btn { width: 100%; }

  .table > :not(caption) > * > * { padding: 10px 10px; font-size: 13px; }
  .table thead th { font-size: 10px; padding: 10px 10px; }

  .d-flex.gap-2 { flex-wrap: wrap; }

  .modal-dialog { margin: 8px; }
  .modal-body { padding: 16px; }

  .stat-value { font-size: 20px; }
  .stat-icon { width: 40px; height: 40px; font-size: 18px; }
  .stat-label { font-size: 12px; }

  .detail-label { font-size: 10px; }
  .detail-value { font-size: 13px; }

  .card-body form .row > [class*='col-'] { margin-bottom: 6px; }

  .alert { padding: 10px 14px; font-size: 13px; }
}

@media (max-width: 575px) {
  .page-title { font-size: 17px; }
  .inv-item-card { min-width: 100%; }
  .table .d-none-xs, .hide-xs { display: none !important; }
}
