/* ==========================================================================
   Steel Road Group ERP — Enterprise Design System (Sprint 1)
   ========================================================================== */

:root {
  /* Surface & Background */
  --bg: #f8fafc;
  --bg-workspace: #f8fafc;
  --surface: #ffffff;
  --surface-subtle: #f1f5f9;
  --surface-hover: #f8fafc;
  --surface-active: #e2e8f0;
  
  --panel-bg: #ffffff;
  --panel-border: #e2e8f0;
  --panel-head: #ffffff;
  --line: #edf2f7;

  /* Borders */
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-focus: #1e40af;

  /* Text & Typography */
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-disabled: #94a3b8;
  --text-main: #0f172a;
  --text-light: #94a3b8;

  /* Brand / Primary: Industrial Steel Navy */
  --primary: #1e40af;
  --primary-hover: #1d4ed8;
  --primary-active: #1e3a8a;
  --primary-subtle: #eff6ff;
  --primary-blue: #1e40af;
  --primary-blue-hover: #1d4ed8;

  /* Topbar & Sidebar */
  --topbar-bg: #0f172a;
  --topbar-text: #ffffff;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #1e40af;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --sidebar-border: rgba(255, 255, 255, 0.08);

  /* Semantic Colors */
  --success: #059669;
  --success-hover: #047857;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --success-text: #065f46;
  --green: #059669;

  --warning: #d97706;
  --warning-hover: #b45309;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --warning-text: #92400e;
  --orange: #d97706;

  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --danger-text: #991b1b;
  --red: #dc2626;

  --info: #0284c7;
  --info-hover: #0369a1;
  --info-bg: #f0f9ff;
  --info-border: #bae6fd;
  --info-text: #075985;
  --blue: #1e40af;

  /* Layout dimensions */
  --topbar-height: 48px;
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 58px;

  /* Radii */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.03);

  /* Transitions */
  --transition-fast: 120ms ease;
  --transition-normal: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

body.theme-dark {
  --bg: #090e17;
  --bg-workspace: #090e17;
  --surface: #111827;
  --surface-subtle: #1a2234;
  --surface-hover: #1e293b;
  --surface-active: #334155;

  --panel-bg: #111827;
  --panel-border: #1e293b;
  --panel-head: #141f36;
  --line: #1e293b;

  --border: #1e293b;
  --border-strong: #334155;
  --border-focus: #3b82f6;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-disabled: #64748b;
  --text-main: #f8fafc;
  --text-light: #64748b;

  --primary: #2563eb;
  --primary-hover: #3b82f6;
  --primary-active: #1d4ed8;
  --primary-subtle: rgba(37, 99, 235, 0.15);
  --primary-blue: #2563eb;
  --primary-blue-hover: #3b82f6;

  --topbar-bg: #0b0f19;
  --sidebar-bg: #0b0f19;
  --sidebar-hover: #162036;
  --sidebar-active: #2563eb;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --sidebar-border: rgba(255, 255, 255, 0.06);

  --success: #10b981;
  --success-hover: #059669;
  --success-bg: rgba(16, 185, 129, 0.15);
  --success-border: rgba(16, 185, 129, 0.3);
  --success-text: #34d399;

  --warning: #f59e0b;
  --warning-hover: #d97706;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --warning-border: rgba(245, 158, 11, 0.3);
  --warning-text: #fbbf24;

  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --danger-border: rgba(239, 68, 68, 0.3);
  --danger-text: #f87171;

  --info: #0ea5e9;
  --info-hover: #0284c7;
  --info-bg: rgba(14, 165, 233, 0.15);
  --info-border: rgba(14, 165, 233, 0.3);
  --info-text: #38bdf8;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text-main);
  background: var(--bg-workspace);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--primary); text-decoration: none; }

label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

input, select, textarea {
  font-size: 13px;
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-subtle);
}

input::placeholder, textarea::placeholder {
  color: var(--text-disabled);
}

body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-primary);
}

/* 1. ВЕРХНЯЯ СИНЯЯ ПАНЕЛЬ iBox (TOPBAR) */
.ibox-topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #ffffff;
  text-decoration: none;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.2px;
}

.topbar-logo {
  height: 28px;
  width: auto;
  max-width: 32px;
  object-fit: contain;
}

.topbar-collapse {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #ffffff;
  width: 26px;
  height: 26px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-size: 17px;
  line-height: 1;
  transition: background 0.15s;
}

.topbar-collapse:hover {
  background: rgba(255, 255, 255, 0.28);
}

.topbar-fav {
  background: #ffffff;
  color: #1e293b;
  border: none;
  border-radius: 4px;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.topbar-fav .star {
  color: #f59e0b;
  font-size: 13px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-company-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar-company {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.16);
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.topbar-company:hover {
  background: rgba(255, 255, 255, 0.26);
}

.topbar-company .arrow {
  font-size: 10px;
  opacity: 0.85;
  margin-left: 2px;
}

.topbar-add-company-btn {
  background: rgba(255, 255, 255, 0.16);
  border: none;
  color: #ffffff;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
}

.topbar-add-company-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.company-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 260px;
  background: #ffffff;
  color: #1e293b;
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2), 0 2px 8px rgba(0, 0, 0, 0.08);
  border: 1px solid #cbd5e1;
  display: none;
  flex-direction: column;
  z-index: 1200;
  overflow: hidden;
  animation: compDropdownFade 0.15s ease;
}

@keyframes compDropdownFade {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.company-dropdown-menu.show {
  display: flex;
}

body.theme-dark .company-dropdown-menu {
  background: #1e293b;
  color: #f1f5f9;
  border-color: #334155;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.company-dropdown-head {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f1f5f9;
  background: #f8fafc;
}

body.theme-dark .company-dropdown-head {
  background: #0f172a;
  border-bottom-color: #334155;
  color: #94a3b8;
}

.company-dropdown-plus {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #186be8;
  font-size: 15px;
  font-weight: bold;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  cursor: pointer;
  line-height: 1;
}

.company-dropdown-plus:hover {
  background: #186be8;
  color: #ffffff;
}

.company-dropdown-list {
  max-height: 240px;
  overflow-y: auto;
  padding: 4px 0;
}

.company-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s ease;
}

.company-item:hover {
  background: #f1f5f9;
}

body.theme-dark .company-item:hover {
  background: #334155;
}

.company-item.active {
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
}

body.theme-dark .company-item.active {
  background: #1e3a8a;
  color: #93c5fd;
}

.company-item-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.company-item-check {
  font-size: 13px;
  color: #186be8;
  font-weight: bold;
}

.company-row {
  display: flex;
  align-items: stretch;
}

.company-row .company-item {
  flex: 1;
  min-width: 0;
}

.company-edit-btn {
  border: 0;
  background: transparent;
  padding: 0 12px;
  font-size: 12px;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.12s ease, background 0.12s ease;
}

.company-row:hover .company-edit-btn,
.company-edit-btn:focus-visible {
  opacity: 1;
}

.company-edit-btn:hover {
  background: #f1f5f9;
}

body.theme-dark .company-edit-btn:hover {
  background: #334155;
}

.company-dropdown-foot {
  padding: 8px 12px;
  border-top: 1px solid #f1f5f9;
  background: #f8fafc;
}

body.theme-dark .company-dropdown-foot {
  background: #0f172a;
  border-top-color: #334155;
}

.btn-new-company {
  width: 100%;
  border: 1px dashed #cbd5e1;
  background: transparent;
  color: #186be8;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-new-company:hover {
  border-color: #186be8;
  background: rgba(24, 107, 232, 0.06);
}

.topbar-icon-btn {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  border-radius: 4px;
  color: #ffffff;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  font-size: 13px;
  transition: background 0.15s;
}

.topbar-icon-btn:hover {
  background: rgba(255, 255, 255, 0.24);
}

.topbar-help-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #ffffff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}

.topbar-help-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

.topbar-avatar {
  background: #186be8;
  border: 1.5px solid rgba(255, 255, 255, 0.75);
  color: #ffffff;
  padding: 2px 7px;
  height: 26px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  gap: 3px;
  font-weight: 700;
  font-size: 11px;
  cursor: pointer;
}

.topbar-avatar .avatar-arrow {
  font-size: 9px;
  opacity: 0.85;
}

/* 2. ЛАЙАУТ ПРИЛОЖЕНИЯ */
.app-layout {
  display: flex;
  margin-top: var(--topbar-height);
  min-height: calc(100vh - var(--topbar-height));
}

/* 3. БОКОВАЯ СИСТЕМА НАВИГАЦИИ (SIDEBAR) */
.ibox-sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  position: fixed;
  top: var(--topbar-height);
  bottom: 0;
  left: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--sidebar-border);
  transition: width var(--transition-normal);
  user-select: none;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--sidebar-border);
  background: rgba(0, 0, 0, 0.12);
  transition: all var(--transition-fast);
}

.sidebar-brand-logo {
  width: 26px;
  height: 26px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-brand-text .brand-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: #ffffff;
}

.sidebar-brand-text .brand-sub {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.8px;
  color: var(--sidebar-text);
  opacity: 0.75;
}

nav {
  padding: 8px 6px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

nav::-webkit-scrollbar {
  width: 4px;
}
nav::-webkit-scrollbar-track {
  background: transparent;
}
nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

.nav-section-label {
  padding: 10px 10px 4px 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.9px;
  color: #64748b;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-group {
  margin-bottom: 2px;
}

nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 1px;
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

nav a:hover {
  background: var(--sidebar-hover);
  color: #ffffff;
}

nav a.active {
  background: var(--sidebar-active);
  color: #ffffff;
  font-weight: 600;
}

nav a.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: #60a5fa;
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: inherit;
  opacity: 0.9;
  flex-shrink: 0;
}

.nav-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-chevron {
  font-size: 11px;
  opacity: 0.6;
  font-weight: bold;
  margin-left: auto;
}

.nav-sub {
  display: flex;
  flex-direction: column;
  padding: 2px 0 3px 0;
}

.nav-sub a {
  padding: 5px 10px 5px 34px;
  font-size: 12px;
  color: #94a3b8;
  font-weight: 400;
  margin-bottom: 1px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-sub a:hover {
  color: #ffffff;
  background: var(--sidebar-hover);
}

.nav-sub a.active {
  background: rgba(30, 64, 175, 0.4);
  color: #ffffff;
  font-weight: 600;
}

.nav-sub-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #64748b;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.nav-sub a:hover .nav-sub-dot {
  background: #cbd5e1;
}

.nav-sub a.active .nav-sub-dot {
  background: #60a5fa;
  box-shadow: 0 0 6px #60a5fa;
}

.nav-divider {
  height: 1px;
  background: var(--sidebar-border);
  margin: 6px 8px;
}

/* Свёрнутый сайдбар (58px) */
.ibox-sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.ibox-sidebar.collapsed .sidebar-brand-text,
.ibox-sidebar.collapsed .nav-name,
.ibox-sidebar.collapsed .nav-chevron,
.ibox-sidebar.collapsed .nav-section-label,
.ibox-sidebar.collapsed .nav-sub,
.ibox-sidebar.collapsed .sidebar-bottom small {
  display: none;
}

.ibox-sidebar.collapsed .sidebar-brand {
  justify-content: center;
  padding: 10px 0;
}

.ibox-sidebar.collapsed nav a {
  justify-content: center;
  padding: 9px 0;
}

.ibox-sidebar.collapsed .sidebar-bottom {
  padding: 10px 0;
  text-align: center;
  font-size: 0;
}

.ibox-sidebar.collapsed .sidebar-bottom .dot {
  margin: 0;
}

.sidebar-bottom {
  margin-top: auto;
  padding: 12px 14px;
  font-size: 11px;
  border-top: 1px solid var(--sidebar-border);
  color: #94a3b8;
  background: rgba(0, 0, 0, 0.12);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-bottom small {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  color: #64748b;
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  margin-right: 6px;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

/* 4. ОСНОВНАЯ РАБОЧАЯ ОБЛАСТЬ */
.workspace {
  margin-left: var(--sidebar-width);
  flex: 1;
  background: var(--bg-workspace);
  min-height: calc(100vh - var(--topbar-height));
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-normal);
}

.workspace.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed-width);
}

.workspace-header {
  height: 42px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  font-size: 12px;
}

body.theme-dark .workspace-header {
  background: #111a2e;
  border-bottom-color: #1e293b;
}

.workspace-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.breadcrumb-item { color: var(--text-light); }
.breadcrumb-item.active { color: var(--text-main); font-weight: 600; }
.slash { color: #cbd5e1; }
.workspace-meta { color: var(--text-muted); font-size: 11px; }

main {
  padding: 20px 24px;
  flex: 1;
  width: 100%;
}

.page-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Кнопки действий */
.actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition-fast);
  cursor: pointer;
  user-select: none;
}

.btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn:active {
  background: var(--surface-active);
}

.btn:disabled, .btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

body.theme-dark .btn {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-primary);
}

body.theme-dark .btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.btn.primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #ffffff;
}

.btn.secondary {
  background: var(--surface-subtle);
  border-color: var(--border);
  color: var(--text-primary);
}

.btn.secondary:hover {
  background: var(--surface-active);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text-secondary);
}

.btn.ghost:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.btn.danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}

.btn.block-btn {
  width: 100%;
  justify-content: flex-start;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 8px;
}

.btn.small {
  padding: 4px 9px;
  font-size: 11px;
}

.btn.btn-income {
  background: var(--success);
  border-color: var(--success);
  color: #ffffff;
  font-weight: 600;
}
.btn.btn-income:hover {
  background: var(--success-hover);
  border-color: var(--success-hover);
}
.btn.btn-expense {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
  font-weight: 600;
}
.btn.btn-expense:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}
.btn.btn-transfer {
  background: var(--surface-subtle);
  border-color: var(--border);
  color: var(--text-secondary);
  font-weight: 500;
}
.btn.btn-transfer:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
body.theme-dark .btn.btn-transfer {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-primary);
}
body.theme-dark .btn.btn-transfer:hover {
  background: var(--surface-hover);
}

/* Бейджи и статусы */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.2px;
  background: var(--surface-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.badge.green, .badge-success {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}

.badge.orange, .badge-warning {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning-text);
}

.badge.red, .badge-danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-text);
}

.badge.blue, .badge-info {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info-text);
}

/* Состояние загрузки и Спиннер */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Скелетон-загрузчик (Skeleton) */
.skeleton {
  background: linear-gradient(90deg, var(--surface-subtle) 25%, var(--surface-active) 50%, var(--surface-subtle) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text {
  height: 14px;
  margin: 6px 0;
  border-radius: var(--radius-xs);
}

.skeleton-title {
  height: 20px;
  width: 50%;
  margin-bottom: 12px;
}

.skeleton-rect {
  height: 64px;
  width: 100%;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  text-align: center;
}

.empty-state-icon {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--surface-subtle);
  display: grid;
  place-items: center;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.empty-state-desc {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 400px;
  line-height: 1.5;
  margin-bottom: 16px;
}

.text-green { color: #10b981 !important; }
.text-red { color: #ef4444 !important; }
.text-blue { color: #186be8 !important; }

.ibox-kpi-card.card-neutral {
  border-left: 4px solid #94a3b8;
}
.card-neutral .kpi-title {
  color: #475569;
}
body.theme-dark .card-neutral .kpi-title {
  color: #94a3b8;
}

.ibox-kpi-card.active-kpi-filter {
  outline: 2px solid #186be8;
  outline-offset: -1px;
  background: #f0f7ff;
}
body.theme-dark .ibox-kpi-card.active-kpi-filter {
  outline: 2px solid #3b82f6;
  background: #172554;
}

.kpi-edit-icon {
  background: transparent;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s, border-color 0.15s;
}
.kpi-edit-icon:hover {
  opacity: 1;
  border-color: #186be8;
  background: rgba(24, 107, 232, 0.08);
}

/* 5. ЧЕТЫРЕ КАРТОЧКИ ДАШБОРДА В ТОЧНОСТИ КАК В IBOX */
.ibox-dashboard-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}

.ibox-kpi-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 16px 18px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.ibox-kpi-card.card-blue { border-left: 4px solid #186be8; }
.ibox-kpi-card.card-orange { border-left: 4px solid #f59e0b; }
.ibox-kpi-card.card-red { border-left: 4px solid #ef4444; }
.ibox-kpi-card.card-green { border-left: 4px solid #10b981; }

.kpi-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.kpi-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.card-blue .kpi-title { color: #186be8; }
.card-orange .kpi-title { color: #f59e0b; }
.card-red .kpi-title { color: #ef4444; }
.card-green .kpi-title { color: #10b981; }

.kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.kpi-badge-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
}

.icon-blue { background: #eff6ff; color: #186be8; }
.icon-orange { background: #fffbeb; color: #f59e0b; }
.icon-red { background: #fef2f2; color: #ef4444; }
.icon-green { background: #ecfdf5; color: #10b981; }

.kpi-row {
  padding: 9px 0 3px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.kpi-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.kpi-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.kpi-value.debt-highlight {
  color: #ef4444;
}

/* 6. ВТОРАЯ СТРОКА ДАШБОРДА (САМЫЕ ПРОДАВАЕМЫЕ + ОСТАТКИ ДЕНЕГ) */
.ibox-row-two {
  display: grid;
  grid-template-columns: 2.4fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}

.ibox-panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

.ibox-panel-head {
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel-head);
}

.ibox-panel-head h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  margin: 0;
}

.ibox-head-tools {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ibox-pill-filter {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  border-radius: 4px;
  font-size: 11px;
  color: #475569;
  padding: 4px 10px;
  font-weight: 500;
}

body.theme-dark .ibox-pill-filter {
  background: #162036;
  border-color: #26354f;
  color: #cbd5e1;
}

.ibox-panel-body {
  padding: 16px 18px;
}

/* Пустое состояние в точности как в iBox */
.ibox-empty-state {
  padding: 48px 20px;
  text-align: center;
}

.ibox-empty-state svg {
  color: #94a3b8;
  opacity: 0.7;
}

.ibox-empty-text {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

/* Список касс */
.cash-list {
  display: flex;
  flex-direction: column;
}

.cash-card-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.cash-card-item:last-child {
  border-bottom: none;
}

.cash-icon-wrapper {
  width: 36px;
  height: 36px;
  background: #f1f5f9;
  color: #475569;
  border-radius: 6px;
  display: grid;
  place-items: center;
}

body.theme-dark .cash-icon-wrapper {
  background: #16223b;
  color: #94a3b8;
}

.cash-info {
  display: flex;
  flex-direction: column;
}

.cash-name {
  font-size: 12px;
  color: var(--text-muted);
}

.cash-sum {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.cash-sum small {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

.cash-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.cash-row:last-child {
  border-bottom: none;
}

.balance-negative {
  color: #ef4444;
  font-weight: 600;
}

/* Общий пустой блок для списков */
.empty {
  padding: 48px 20px;
  text-align: center;
}

.empty-icon {
  margin-bottom: 12px;
  color: #94a3b8;
  display: flex;
  justify-content: center;
}

.empty h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--text-main);
}

.empty p {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 16px;
}

/* 7. ГРАФИК ПРОДАЖ */
.sales-panel {
  margin-bottom: 24px;
}

.ibox-chart {
  height: 140px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 16px 10px 0;
  border-bottom: 1px solid var(--line);
}

.ibox-chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  gap: 6px;
}

.ibox-chart-bar {
  width: 100%;
  max-width: 24px;
  background: #186be8;
  border-radius: 3px 3px 0 0;
  min-height: 4px;
  transition: all 0.2s;
}

.ibox-chart-col:hover .ibox-chart-bar {
  background: #2563eb;
  transform: scaleY(1.05);
}

.ibox-chart-label {
  font-size: 10px;
  color: var(--text-light);
  white-space: nowrap;
}

/* 8. ТАБЛИЦЫ ДАННЫХ iBox */
/* ===== ERP TABLE CONTAINER ===== */
.erp-table-container {
  position: relative;
}

/* --- Toolbar --- */
.erp-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  position: relative;
  gap: 12px;
}
.erp-table-summary {
  font-size: 12px;
  color: var(--text-muted, #64748b);
  font-weight: 500;
  white-space: nowrap;
}
.erp-table-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Column visibility menu --- */
.erp-col-menu {
  position: absolute;
  top: 100%;
  right: 16px;
  z-index: 200;
  background: var(--bg, #fff);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 12px;
  min-width: 200px;
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: fadeIn 0.12s ease;
}
body.theme-dark .erp-col-menu {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.erp-col-menu-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: 6px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.erp-col-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 4px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-main);
  transition: background 0.1s;
}
.erp-col-menu-item:hover {
  background: rgba(24, 107, 232, 0.06);
}
.erp-col-menu-item input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary-blue, #186be8);
  cursor: pointer;
  flex-shrink: 0;
}

/* --- Table wrap with sticky header support --- */
.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 260px);
  scrollbar-width: thin;
}
.table-wrap::-webkit-scrollbar { width: 6px; height: 6px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }
.table-wrap::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
body.theme-dark .table-wrap::-webkit-scrollbar-thumb { background: #475569; }

table, .erp-table {
  border-collapse: collapse;
  width: 100%;
  white-space: nowrap;
  font-size: 12px;
  table-layout: auto;
}

/* --- Sticky header --- */
.erp-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

th, .erp-th {
  font-weight: 600;
  font-size: 11px;
  color: #475569;
  background: #f8fafc;
  text-align: left;
  padding: 11px 16px;
  border-bottom: 2px solid var(--line);
  position: relative;
  user-select: none;
  white-space: nowrap;
}
.erp-th {
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.erp-th:hover {
  background: #eef2f7;
  color: #1e40af;
}
.erp-th-sorted {
  background: #eff6ff !important;
  color: #1e40af !important;
  border-bottom-color: #3b82f6 !important;
}
.erp-th-check, .erp-th-actions {
  background: #f8fafc;
}

body.theme-dark th,
body.theme-dark .erp-th {
  background: #141f36;
  color: #94a3b8;
  border-bottom-color: #1e293b;
}
body.theme-dark .erp-th:hover {
  background: #1e293b;
  color: #93c5fd;
}
body.theme-dark .erp-th-sorted {
  background: #172554 !important;
  color: #93c5fd !important;
  border-bottom-color: #3b82f6 !important;
}
body.theme-dark .erp-th-check,
body.theme-dark .erp-th-actions {
  background: #141f36;
}

/* --- TH content and sort label --- */
.erp-th-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.erp-th-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Column resize handle --- */
.erp-th-resize {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  cursor: col-resize;
  background: transparent;
  transition: background 0.15s;
  z-index: 5;
}
.erp-th-resize:hover,
.erp-th-resize:active {
  background: var(--primary-blue, #186be8);
  opacity: 0.5;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--text-main);
}

tbody tr:hover td {
  background: rgba(24, 107, 232, 0.04);
}

tbody tr.table-row {
  cursor: pointer;
  transition: background 0.1s ease;
}

tbody tr.row-selected td {
  background: #eff6ff !important;
}

body.theme-dark tbody tr.row-selected td {
  background: #1e293b !important;
}

.row-menu-btn {
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 17px;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 4px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s;
}
tbody tr:hover .row-menu-btn {
  opacity: 1;
}
.row-menu-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

body.theme-dark .row-menu-btn:hover {
  background: #334155;
  color: #ffffff;
}

/* --- Selection bar --- */
.ibox-selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 8px 16px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #1e40af;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

body.theme-dark .ibox-selection-bar {
  background: #1e293b;
  border-color: #3b82f6;
  color: #93c5fd;
}

.selection-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* --- Pagination --- */
.erp-table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-muted, #64748b);
  background: var(--bg, #fff);
}
body.theme-dark .erp-table-pagination {
  background: #0f172a;
}
.pagination-info {
  font-weight: 500;
}
.pagination-btns {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pagination-current {
  font-weight: 600;
  font-size: 12px;
  padding: 0 8px;
  color: var(--text-main);
}
.pagination-btns .btn {
  min-width: 28px;
  padding: 4px 8px;
  font-size: 13px;
}
.pagination-btns .btn:disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* --- Skeleton loading for tables --- */
.erp-table-skeleton {
  padding: 0;
}
.erp-table-skeleton .skeleton-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.erp-table-skeleton .skeleton-row .skeleton-cell {
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 400% 100%;
  animation: shimmer 1.5s ease infinite;
}
body.theme-dark .erp-table-skeleton .skeleton-row .skeleton-cell {
  background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
  background-size: 400% 100%;
}

/* --- Context menu (right-click) --- */
.erp-ctx-menu {
  position: fixed;
  z-index: 9999;
  background: var(--bg, #fff);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.15);
  padding: 6px;
  min-width: 180px;
  animation: fadeIn 0.1s ease;
}
body.theme-dark .erp-ctx-menu {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 8px 28px rgba(0,0,0,0.4);
}
.erp-ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 12px;
  border: none;
  background: none;
  color: var(--text-main);
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  text-align: left;
  transition: background 0.1s;
  white-space: nowrap;
}
.erp-ctx-item:hover {
  background: rgba(24, 107, 232, 0.08);
}
.erp-ctx-item.danger {
  color: #dc2626;
}
.erp-ctx-item.danger:hover {
  background: rgba(220, 38, 38, 0.08);
}
body.theme-dark .erp-ctx-item.danger {
  color: #f87171;
}
.erp-ctx-sep {
  height: 1px;
  background: var(--line);
  margin: 4px 8px;
}

.card-add-cashbox {
  border: 2px dashed #cbd5e1 !important;
  background: transparent !important;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  min-height: 90px;
  transition: all 0.2s ease;
}

.card-add-cashbox:hover {
  border-color: #186be8 !important;
  background: rgba(24, 107, 232, 0.04) !important;
}

body.theme-dark .card-add-cashbox {
  border-color: #334155 !important;
}

body.theme-dark .card-add-cashbox:hover {
  border-color: #3b82f6 !important;
  background: rgba(59, 130, 246, 0.08) !important;
}

.add-cashbox-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #186be8;
  font-weight: 600;
  font-size: 13px;
}

.add-cashbox-inner .plus-icon {
  font-size: 22px;
  line-height: 1;
}

.status-pill-badge {
  cursor: pointer;
  user-select: none;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.strong {
  font-weight: 600;
}

.subline {
  font-size: 11px;
  color: var(--text-light);
  display: block;
  margin-top: 2px;
}

/* Бейджи статусов */
.badge {
  display: inline-block;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 3px;
  background: #eff6ff;
  color: #1d4ed8;
  white-space: nowrap;
}

.badge.green { color: #047857; background: #ecfdf5; }
.badge.orange { color: #b45309; background: #fffbeb; }
.badge.red { color: #b91c1c; background: #fef2f2; }
.badge.blue { color: #1d4ed8; background: #eff6ff; }
body.theme-dark .badge.blue { color: #93c5fd; background: rgba(59, 130, 246, 0.15); }

/* Панели списков и форм */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.panel-head {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: var(--panel-head);
}

.panel-body {
  padding: 20px;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  align-items: center;
  background: var(--panel-head);
}

.toolbar input[type=search] {
  min-width: 220px;
  flex: 1;
  max-width: 400px;
}

.toolbar select {
  width: auto;
  min-width: 150px;
}

.count {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

/* Поля ввода */
input, select, textarea {
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #ffffff;
  padding: 7px 11px;
  color: #1e293b;
  width: 100%;
  font-size: 12px;
  min-height: 34px;
}

body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
  background: #0f172a;
  border-color: #26354f;
  color: #f8fafc;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(24, 107, 232, 0.15);
}

label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

label input, label select, label textarea {
  margin-top: 5px;
}

/* Вкладки */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}

.tabs button {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  padding: 6px 14px;
  color: #475569;
  font-size: 12px;
  font-weight: 500;
  border-radius: 4px;
}

.tabs button.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
}

/* Сетка отчетов */
.report-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.report-link {
  padding: 20px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  text-align: left;
  color: var(--text-main);
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.report-link:hover {
  border-color: var(--blue);
}

.report-symbol {
  color: var(--blue);
  font-size: 22px;
  display: block;
  margin-bottom: 10px;
}

.report-link h3 { margin: 0 0 4px; font-size: 14px; }
.report-link p { margin: 0; font-size: 11px; color: var(--text-muted); }

/* Модальные окна */
dialog {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0;
  max-width: 900px;
  width: calc(100% - 40px);
  max-height: 90vh;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  background: #ffffff;
  color: #1e293b;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.5);
}

#submodal {
  max-width: 600px;
  width: calc(100% - 30px);
  z-index: 1000;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

#submodal::backdrop {
  background: rgba(15, 23, 42, 0.65);
}

body.theme-dark dialog,
body.theme-dark #submodal {
  background: #151d2f;
  border-color: #2b3956;
  color: #f1f5f9;
}

body.theme-dark .modal-head {
  border-bottom-color: #2b3956;
}

body.theme-dark .modal-head h2 {
  color: #ffffff;
}

body.theme-dark .modal-head .close {
  color: #94a3b8;
}

body.theme-dark .modal-head .close:hover {
  color: #ffffff;
}

.input-action-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 5px;
}

.input-action-row select {
  flex: 1;
  min-width: 0;
  margin-top: 0 !important;
}

.btn-quick-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 34px;
  white-space: nowrap;
  background: #eff6ff;
  color: #186be8;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  flex-shrink: 0;
}

.btn-quick-add:hover {
  background: #186be8;
  color: #ffffff;
  border-color: #186be8;
}

body.theme-dark .btn-quick-add {
  background: #1e293b;
  color: #60a5fa;
  border-color: #334155;
}

body.theme-dark .btn-quick-add:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.modal-head {
  padding: 16px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e2e8f0;
}

.modal-head h2 { font-size: 17px; margin: 0; }
.modal-content { padding: 22px; }

.close {
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 20px;
  cursor: pointer;
}

.close:hover { color: #0f172a; }

.line-table td { padding: 6px; }
.line-table input.qty { width: 80px; }
.line-table input.price { width: 110px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.span-two { grid-column: 1 / -1; }

.form-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

.notice {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 12px;
  margin-bottom: 14px;
}
.notice.info {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}
.notice.warn {
  background: #fffbeb;
  border-color: #fde68a;
  color: #b45309;
}
body.theme-dark .notice.info {
  background: #172554;
  border-color: #1e40af;
  color: #93c5fd;
}
body.theme-dark .notice.warn {
  background: #451a03;
  border-color: #78350f;
  color: #fde68a;
}

/* ==========================================================================
   SPRINT 3: НОВЫЙ ИНТЕРФЕЙС ДОКУМЕНТА (ERP DOCUMENT MODAL & STICKY ACTIONS)
   ========================================================================== */

/* Широкое окно документа */
dialog.modal-doc {
  max-width: 1240px;
  width: min(1240px, 96vw);
  height: min(92vh, 880px);
  max-height: 94vh;
  margin: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.24);
  padding: 0;
}

dialog.modal-doc #modal-body {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

dialog.modal-doc .modal-head {
  flex-shrink: 0;
  padding: 12px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

dialog.modal-doc .modal-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  min-height: 0;
}

dialog.modal-doc #document-form {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Заголовок документа */
.doc-title-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 700;
}
.doc-title-kind {
  color: var(--primary-blue, #186be8);
}
.doc-title-num {
  color: var(--text-main);
  font-weight: 600;
}

/* Скроллируемая центральная область документа */
.doc-scroll-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
}
.doc-scroll-area::-webkit-scrollbar { width: 6px; }
.doc-scroll-area::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
body.theme-dark .doc-scroll-area::-webkit-scrollbar-thumb { background: #475569; }

/* 1. Верх документа: Шапка / Header Card */
.doc-header-card {
  background: var(--surface, #ffffff);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.doc-header-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line, #e2e8f0);
}

.doc-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 4px;
  padding: 4px 10px;
}
.doc-chip .chip-label {
  color: var(--text-muted, #64748b);
  font-weight: 500;
}

.doc-fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  align-items: start;
}

.form-group {
  display: flex;
  flex-direction: column;
}
.form-group label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-main);
}
.field-hint {
  font-size: 11px;
  color: var(--text-muted, #64748b);
  margin-top: 3px;
}

.doc-partner-info-box {
  margin-top: 5px;
  font-size: 11px;
  color: var(--text-muted, #64748b);
  min-height: 18px;
}

/* 2. Центр: Таблица товаров / Line items */
.doc-lines-card {
  background: var(--surface, #ffffff);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.doc-lines-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.doc-lines-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.doc-lines-title h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}
.doc-lines-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  background: #e2e8f0;
  color: #475569;
  font-weight: 600;
}

.doc-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 6px;
  max-height: 380px;
  scrollbar-width: thin;
}

.doc-line-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}

.doc-line-table th {
  background: #f8fafc;
  font-weight: 600;
  font-size: 11px;
  color: #475569;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line, #e2e8f0);
  position: sticky;
  top: 0;
  z-index: 5;
  text-align: left;
}

.doc-line-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line, #e2e8f0);
  vertical-align: middle;
}

.doc-line-table tbody tr:hover td {
  background: rgba(24, 107, 232, 0.03);
}

.doc-line-select {
  width: 100%;
  min-width: 220px;
  height: 32px;
  font-size: 12px;
  margin: 0 !important;
}

.doc-product-cell-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}
.doc-product-cell-wrap .doc-line-select {
  flex: 1;
}

.btn-quick-create-prod {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary-blue, #186be8);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.12s ease;
}
.btn-quick-create-prod:hover {
  background: var(--primary-blue, #186be8);
  color: #ffffff;
  border-color: var(--primary-blue, #186be8);
}
body.theme-dark .btn-quick-create-prod {
  background: #1e293b;
  color: #60a5fa;
  border-color: #334155;
}
body.theme-dark .btn-quick-create-prod:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.opt-create-new {
  color: var(--primary-blue, #186be8);
  font-weight: 600;
  background: #f0f7ff;
}
body.theme-dark .opt-create-new {
  color: #60a5fa;
  background: #1e293b;
}

.line-input-wrap {
  display: flex;
  align-items: center;
  position: relative;
  width: 100%;
}
.line-qty-input {
  width: 100% !important;
  height: 32px !important;
  margin: 0 !important;
  padding-right: 30px !important;
}
.line-price-input {
  width: 100% !important;
  height: 32px !important;
  margin: 0 !important;
}
.line-disc-input {
  width: 100% !important;
  height: 32px !important;
  margin: 0 !important;
  padding-right: 22px !important;
}
.line-cost-input {
  width: 100% !important;
  height: 32px !important;
  margin: 0 !important;
}
.line-unit-label {
  position: absolute;
  right: 8px;
  font-size: 11px;
  color: var(--text-muted, #64748b);
  pointer-events: none;
}

.btn-del-line {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 16px;
  cursor: pointer;
  border-radius: 4px;
  padding: 3px 8px;
  line-height: 1;
  transition: all 0.12s;
}
.btn-del-line:hover {
  background: #fee2e2;
  color: #dc2626;
}

/* 3. Низ: Сводка, взаиморасчеты, примечание */
.doc-bottom-section {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
  align-items: start;
}

.doc-bottom-left {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.doc-note-label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  font-weight: 500;
  gap: 6px;
}
.doc-note-label textarea {
  resize: vertical;
  min-height: 64px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  font-family: inherit;
  background: var(--bg, #ffffff);
  color: var(--text-main);
}

.doc-debt-card {
  background: var(--surface, #ffffff);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 12px;
}
.doc-debt-head {
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted, #64748b);
  margin-bottom: 6px;
}
.debt-calc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 4px;
}
.debt-calc-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.debt-calc-lbl {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted, #64748b);
  font-weight: 600;
}

.doc-totals-card {
  background: var(--surface, #ffffff);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.doc-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-main);
}
.doc-total-divider {
  height: 1px;
  background: var(--line, #e2e8f0);
  margin: 4px 0;
}
.doc-grand-row {
  font-size: 15px;
  font-weight: 700;
  padding-top: 4px;
}
.doc-grand-val {
  font-size: 18px;
  color: var(--primary-blue, #186be8);
  font-weight: 800;
}

/* 4. Снизу: STICKY ACTION BAR (Фиксированная панель действий) */
.doc-sticky-bar {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg, #ffffff);
  border-top: 2px solid var(--line, #e2e8f0);
  box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.07);
}

.doc-sticky-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted, #64748b);
}
.doc-sticky-summary strong {
  color: var(--text-main);
}
.doc-sticky-total-num {
  color: var(--primary-blue, #186be8) !important;
  font-size: 15px;
}
.dot-sep {
  opacity: 0.5;
  font-weight: bold;
}

.doc-sticky-btns {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Dark Theme Overrides for Sprint 3 Document Modal */
body.theme-dark dialog.modal-doc {
  background: #141c2e;
  border-color: #2b3956;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}
body.theme-dark .doc-header-card,
body.theme-dark .doc-lines-card,
body.theme-dark .doc-totals-card,
body.theme-dark .doc-debt-card {
  background: #182238;
  border-color: #2b3956;
}
body.theme-dark .doc-chip {
  background: #1e2b45;
  border-color: #2b3956;
}
body.theme-dark .doc-lines-badge {
  background: #25334e;
  color: #94a3b8;
}
body.theme-dark .doc-table-wrap {
  border-color: #2b3956;
}
body.theme-dark .doc-line-table th {
  background: #131c30;
  color: #94a3b8;
  border-bottom-color: #2b3956;
}
body.theme-dark .doc-line-table td {
  border-bottom-color: #2b3956;
}
body.theme-dark .btn-del-line:hover {
  background: #3b181e;
  color: #f87171;
}
body.theme-dark .doc-sticky-bar {
  background: #111726;
  border-top-color: #2b3956;
  box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.35);
}
body.theme-dark .doc-note-label textarea {
  background: #111726;
  border-color: #2b3956;
}

@media (max-width: 900px) {
  .doc-bottom-section {
    grid-template-columns: 1fr;
  }
  .debt-calc-grid {
    grid-template-columns: 1fr;
  }
}

#toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 4px;
  background: #1e293b;
  color: #ffffff;
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 2000;
  display: none;
}

#toast.error { background: #b91c1c; }

footer {
  padding: 16px 24px;
  font-size: 11px;
  color: var(--text-light);
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  margin-top: auto;
}

/* iBox Header & Actions */
.ibox-action-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.ibox-action-header h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.ibox-header-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-star {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #94a3b8;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-star:hover {
  color: #f59e0b;
  border-color: #f59e0b;
}

.btn-star.starred {
  color: #f59e0b;
}

.btn-more {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #475569;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-size: 16px;
  cursor: pointer;
}

/* iBox Filter Bar */
.ibox-filter-bar {
  background: #ffffff;
  border: 1px solid var(--panel-border);
  border-radius: 4px 4px 0 0;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
}

body.theme-dark .ibox-filter-bar {
  background: #111a2e;
}

.btn-folder {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 4px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 200px;
  flex: 1;
  max-width: 320px;
}

.search-input-wrap input {
  padding-left: 32px;
  padding-right: 32px;
  height: 32px;
  font-size: 12px;
}

.search-input-wrap .search-icon {
  position: absolute;
  left: 9px;
  color: #94a3b8;
  pointer-events: none;
  display: grid;
  place-items: center;
}

.search-input-wrap .tune-icon {
  position: absolute;
  right: 9px;
  color: #f59e0b;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.filter-select {
  width: auto;
  min-width: 120px;
  height: 32px;
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
}

.status-pill-badge {
  border: 1px solid #3b82f6;
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
}

.status-pill-badge .clear-status {
  cursor: pointer;
  opacity: 0.6;
}

.status-pill-badge .clear-status:hover {
  opacity: 1;
}

.filter-funnel-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  color: #3b82f6;
  height: 32px;
}

.funnel-badge {
  background: #f97316;
  color: #ffffff;
  font-size: 10px;
  font-weight: bold;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
}

/* Empty Tutorial Card */
.empty-tutorial-card {
  padding: 48px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.empty-icon-circle {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(24, 107, 232, 0.08);
  display: grid;
  place-items: center;
  color: var(--blue, #186be8);
  margin-bottom: 18px;
}

body.theme-dark .empty-icon-circle {
  background: rgba(37, 99, 235, 0.16);
  color: #60a5fa;
}

.empty-tutorial-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}

.empty-tutorial-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

/* Product Creation / Edit Layout */
.product-create-container {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.product-top-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
}

.product-left-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.photo-dropzone {
  border: 2px dashed #93c5fd;
  background: #f8fafc;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}

body.theme-dark .photo-dropzone {
  background: #141f36;
  border-color: #2563eb;
}

.photo-dropzone:hover {
  border-color: #3b82f6;
  background: #eff6ff;
}

.dropzone-icon {
  color: #3b82f6;
  margin-bottom: 8px;
}

.dropzone-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 4px;
}

.dropzone-link {
  color: #2563eb;
  font-weight: 600;
  text-decoration: underline;
}

.dropzone-hint {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
  max-width: 200px;
}

.accordion-box {
  background: #ffffff;
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  overflow: hidden;
}

body.theme-dark .accordion-box {
  background: #111a2e;
}

.accordion-header {
  padding: 9px 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main);
}

body.theme-dark .accordion-header {
  background: #141f36;
}

.accordion-body {
  padding: 14px;
}

.barcode-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.barcode-visual {
  background: #ffffff;
  padding: 12px 18px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: fit-content;
}

.barcode-number {
  font-family: Consolas, monospace;
  font-size: 12px;
  letter-spacing: 2px;
  color: #0f172a;
  margin-top: 4px;
}

/* iBox Partner (Client/Supplier) Form Styles (Screenshot match) */
.partner-form-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ibox-fieldset {
  position: relative;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #ffffff;
  padding: 0 10px;
  min-height: 42px;
  display: flex;
  align-items: center;
}

body.theme-dark .ibox-fieldset {
  background: #0f172a;
  border-color: #334155;
}

.ibox-fieldset.focused,
.ibox-fieldset:focus-within {
  border-color: #186be8;
}

.ibox-fieldset-label {
  position: absolute;
  top: -8px;
  left: 10px;
  background: #ffffff;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
  line-height: 1;
}

body.theme-dark .ibox-fieldset-label {
  background: #151d2f;
  color: #94a3b8;
}

.ibox-fieldset select {
  border: none !important;
  outline: none !important;
  background: transparent !important;
  width: 100%;
  padding: 8px 0;
  font-size: 13px;
  margin: 0 !important;
  color: var(--text-main);
  box-shadow: none !important;
}

.ibox-fieldset input.ibox-fieldset-input {
  border: none !important;
  outline: none !important;
  background: transparent !important;
  width: 100%;
  padding: 8px 0;
  font-size: 13px;
  margin: 0 !important;
  color: var(--text-main);
  box-shadow: none !important;
}

.ibox-phone-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.ibox-country-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  color: #334155;
  user-select: none;
}

body.theme-dark .ibox-country-badge {
  color: #cbd5e1;
}

.country-flag {
  font-size: 16px;
  line-height: 1;
}

.country-caret {
  font-size: 9px;
  color: #64748b;
}

.country-prefix {
  font-weight: 500;
  font-size: 13px;
}

.ibox-phone-input {
  border: none !important;
  outline: none !important;
  background: transparent !important;
  flex: 1;
  font-size: 13px;
  padding: 8px 0 !important;
  margin: 0 !important;
  box-shadow: none !important;
  color: var(--text-main);
}

.ibox-field-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 14px;
  display: grid;
  place-items: center;
  transition: all 0.15s;
}

.ibox-field-btn:hover {
  color: #186be8;
  background: #f1f5f9;
}

.ibox-partner-accordion {
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 2px;
}

.ibox-partner-acc-header {
  background: #f1f5f9;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 4px;
  user-select: none;
  transition: background 0.12s ease;
}

.ibox-partner-acc-header:hover {
  background: #e2e8f0;
}

body.theme-dark .ibox-partner-acc-header {
  background: #1a243a;
  color: #cbd5e1;
}

body.theme-dark .ibox-partner-acc-header:hover {
  background: #23314e;
}

.ibox-partner-acc-arrow {
  font-size: 10px;
  color: #64748b;
  width: 12px;
  display: inline-block;
  text-align: center;
}

.ibox-partner-acc-body {
  padding: 12px 2px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.partner-sub-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  margin-top: 6px;
}

body.theme-dark .partner-sub-title {
  color: #f1f5f9;
}

.sub-icon {
  font-size: 15px;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon .input-icon {
  position: absolute;
  left: 10px;
  font-size: 13px;
  color: #94a3b8;
  pointer-events: none;
}

.input-with-icon input {
  padding-left: 32px;
}

.bank-accounts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bank-account-item {
  display: grid;
  grid-template-columns: 2fr 1.5fr 1fr 32px;
  gap: 8px;
  align-items: center;
  background: #f8fafc;
  padding: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
}

body.theme-dark .bank-account-item {
  background: #0f172a;
  border-color: #334155;
}

.btn-remove-bank {
  border: none;
  background: transparent;
  color: #ef4444;
  font-size: 16px;
  cursor: pointer;
  border-radius: 4px;
  height: 32px;
  display: grid;
  place-items: center;
}

.btn-remove-bank:hover {
  background: #fee2e2;
}

.btn-add-bank-row {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #186be8;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-add-bank-row:hover {
  background: #eff6ff;
  border-color: #93c5fd;
}

body.theme-dark .btn-add-bank-row {
  background: #111a2e;
  border-color: #334155;
}

/* ==========================================================================
   EXCEL & CSV IMPORT STYLES
   ========================================================================== */
.excel-import-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.excel-upload-zone {
  border: 2px dashed #93c5fd;
  border-radius: 8px;
  padding: 30px 20px;
  text-align: center;
  background: #f8fafc;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.excel-upload-zone.dragover,
.excel-upload-zone:hover {
  border-color: var(--primary-blue, #186be8);
  background: #eff6ff;
}
body.theme-dark .excel-upload-zone {
  background: #151f33;
  border-color: #334155;
}
body.theme-dark .excel-upload-zone.dragover,
body.theme-dark .excel-upload-zone:hover {
  background: #1e293b;
  border-color: #3b82f6;
}
.excel-upload-icon {
  font-size: 38px;
  line-height: 1;
}
.excel-upload-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}
.excel-upload-sub {
  font-size: 12px;
  color: var(--text-muted, #64748b);
}
.excel-upload-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.excel-preview-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.excel-mapping-card {
  background: var(--surface, #ffffff);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 6px;
  padding: 14px 16px;
}
body.theme-dark .excel-mapping-card {
  background: #182238;
  border-color: #2b3956;
}
.excel-mapping-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 10px;
}
.excel-preview-table-card {
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 6px;
  overflow: hidden;
}
body.theme-dark .excel-preview-table-card {
  border-color: #2b3956;
}
.excel-preview-head {
  padding: 8px 12px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line, #e2e8f0);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
body.theme-dark .excel-preview-head {
  background: #131c30;
  border-bottom-color: #2b3956;
}
.excel-preview-head h4 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
}

/* Подсказки и переключение склада в строках документа */
.stock-badge-wrap {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.btn-switch-wh-hint {
  display: inline-block;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px dashed #93c5fd;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  line-height: 1.25;
  margin-top: 2px;
}
.btn-switch-wh-hint:hover {
  background: #dbeafe;
  border-color: #2563eb;
  color: #1e40af;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.2);
}
body.theme-dark .btn-switch-wh-hint {
  background: rgba(37, 99, 235, 0.18);
  color: #93c5fd;
  border-color: #3b82f6;
}
body.theme-dark .btn-switch-wh-hint:hover {
  background: rgba(37, 99, 235, 0.35);
  border-color: #60a5fa;
  color: #dbeafe;
}

/* Печать */
@media print {
  .ibox-topbar, .ibox-sidebar, footer, .btn, .toolbar, .tabs, .actions, #toast, .close, .form-footer {
    display: none !important;
  }
  .app-layout { margin-top: 0; }
  .workspace { margin-left: 0; background: white; }
  main { padding: 0; }
  body { background: white; color: black; }
  .ibox-panel, .panel { border: 0; box-shadow: none; }
}

/* ===== Бухгалтерия ===== */
.acc-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.acc-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  min-width: 160px;
}

.acc-stamp {
  padding: 10px 20px 0;
  color: var(--text-muted);
}

#acc-body .notice {
  margin: 12px 20px;
}

.acc-table td,
.acc-table th {
  white-space: nowrap;
}

.acc-table td:nth-child(2) {
  white-space: normal;
}

.acc-group-row td {
  background: var(--surface-subtle);
  font-weight: 600;
  color: var(--text-secondary);
}

.acc-total-row td,
.acc-total-row {
  font-weight: 700;
  background: var(--surface-subtle);
}

.acc-click {
  cursor: pointer;
}

.acc-click:hover td {
  background: var(--primary-subtle);
}

.acc-diff-row td {
  background: #fff7ed;
}

body.theme-dark .acc-diff-row td {
  background: #431407;
}

.acc-entry {
  margin: 12px 20px;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-x: auto;
}

#submodal .acc-entry {
  margin: 0 0 12px;
}

.acc-entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface-subtle);
  font-size: 13px;
}

.acc-entry-date {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.acc-entry-sum {
  margin-left: auto;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.acc-lines {
  width: 100%;
}

.acc-lines td,
.acc-lines th {
  padding: 6px 12px;
  font-size: 12px;
}

.acc-balance {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  padding: 16px 20px;
}

.acc-balance-side h3 {
  font-size: 14px;
  margin: 8px 0;
}

.acc-balance-sum {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
}

.btn-link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--primary-blue);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
}

.acc-balance-side {
  min-width: 0;
}

.acc-balance .acc-table {
  width: 100%;
  table-layout: fixed;
}

.acc-balance .acc-table td:first-child {
  white-space: normal;
}

.acc-balance .acc-table td.num {
  width: 130px;
}

/* ===== Профиль контрагента ===== */
dialog.modal-profile {
  max-width: 1120px;
  width: min(1120px, 96vw);
  max-height: 92vh;
  margin: auto;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.28);
  overflow: hidden;
  background: var(--surface);
}

dialog.modal-profile #modal-body {
  display: flex;
  flex-direction: column;
  max-height: 92vh;
}

dialog.modal-profile .modal-head {
  flex-shrink: 0;
  padding: 12px 24px;
  background: var(--surface);
}

dialog.modal-profile .modal-head h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

dialog.modal-profile .modal-content {
  padding: 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  background: var(--bg);
}

.profile-hero {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  flex-wrap: wrap;
  padding: 22px 24px;
  background: linear-gradient(135deg, var(--primary-subtle) 0%, var(--surface) 70%);
  border-bottom: 1px solid var(--border);
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(30, 64, 175, 0.28);
}

.profile-avatar.supplier {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  box-shadow: 0 6px 16px rgba(217, 119, 6, 0.28);
}

.profile-main {
  flex: 1;
  min-width: 260px;
}

.profile-name {
  margin: 0 0 8px;
  font-size: 22px;
  line-height: 1.2;
  color: var(--text-primary);
  word-break: break-word;
}

.profile-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.profile-chip {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.profile-chip.primary {
  background: var(--primary-blue);
  border-color: var(--primary-blue);
  color: #fff;
}

.profile-chip.danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-text);
}

.profile-contacts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 13px;
  color: var(--text-secondary);
}

.profile-contacts span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.profile-contacts i {
  font-style: normal;
  font-size: 12px;
}

.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.profile-kpis {
  display: grid;
  grid-template-columns: 1.4fr repeat(4, 1fr);
  gap: 12px;
  padding: 18px 24px 4px;
}

@media (max-width: 900px) {
  .profile-kpis { grid-template-columns: repeat(2, 1fr); }
}

.profile-kpi {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.profile-kpi span {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
}

.profile-kpi strong {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  white-space: nowrap;
}

.profile-kpi strong small {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.profile-kpi.debt {
  border-left-width: 4px;
}

.profile-kpi.debt strong {
  font-size: 22px;
}

.profile-kpi.debt.danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  border-left-color: var(--danger);
}

.profile-kpi.debt.danger strong { color: var(--danger-text); }

.profile-kpi.debt.success {
  background: var(--success-bg);
  border-color: var(--success-border);
  border-left-color: var(--success);
}

.profile-kpi.debt.success strong { color: var(--success-text); }

.profile-kpi.debt.neutral {
  border-left-color: var(--border-strong);
}

.profile-notice {
  margin: 12px 24px 0;
}

.profile-tabs {
  display: flex;
  gap: 4px;
  padding: 14px 24px 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
}

.profile-tab {
  border: 0;
  background: none;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.profile-tab:hover {
  color: var(--text-primary);
}

.profile-tab.active {
  color: var(--primary-blue);
  border-bottom-color: var(--primary-blue);
  font-weight: 600;
}

.profile-tab-count {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--surface-active);
  color: var(--text-secondary);
  text-align: center;
}

.profile-tab.active .profile-tab-count {
  background: var(--primary-blue);
  color: #fff;
}

.profile-body {
  padding: 18px 24px 24px;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 16px;
}

.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  min-width: 0;
}

.profile-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.profile-card-head h4 {
  margin: 0;
  font-size: 14px;
}

.profile-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.profile-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  padding: 8px 16px;
  background: var(--surface-subtle);
}

.profile-table td {
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}

.profile-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.profile-table .nowrap,
.act-table .nowrap {
  white-space: nowrap;
}

.profile-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.profile-empty-state svg {
  width: 36px;
  height: 36px;
  opacity: 0.5;
}

.profile-act-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.profile-presets {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--surface-subtle);
  border-radius: 8px;
  flex-wrap: wrap;
}

.profile-preset {
  border: 0;
  background: none;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

.profile-preset:hover {
  color: var(--text-primary);
}

.profile-preset.active {
  background: var(--surface);
  color: var(--primary-blue);
  box-shadow: var(--shadow-xs);
  font-weight: 600;
}

.profile-act-toolbar .acc-filter {
  min-width: 150px;
}

.profile-act-buttons {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.act-sheet {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px 32px;
  box-shadow: var(--shadow-sm);
}

.act-title {
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

.act-subtitle {
  text-align: center;
  margin: 6px 0 20px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.act-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.act-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid var(--border-strong);
}

.act-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}

.act-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.act-strong td {
  font-weight: 600;
  background: var(--surface-subtle);
}

.act-final td {
  font-weight: 700;
  border-top: 2px solid var(--border-strong);
  border-bottom: 0;
}

.act-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 18px !important;
}

.act-conclusion {
  margin: 20px 0 8px;
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
}

.act-conclusion.danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-text);
}

.act-conclusion.warning {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning-text);
}

.act-note {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* Страница входа */
.login-body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.login-logo {
  width: 56px;
  height: 56px;
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--primary);
}

.login-logo img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.login-brand {
  margin: -6px 0 0;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.login-card h1 {
  margin: 0;
  font-size: 18px;
  text-align: center;
  color: var(--text-primary);
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.login-card input {
  padding: 9px 10px;
  font-size: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-primary);
}

.login-card input:focus {
  outline: 2px solid var(--border-focus);
  outline-offset: -1px;
}

.login-card .btn {
  justify-content: center;
  padding: 10px;
}

.login-error {
  margin: 0;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.login-password {
  position: relative;
  display: flex;
  margin-top: -8px;
}

.login-password input {
  flex: 1;
  min-width: 0;
  padding-right: 40px;
}

.login-eye {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 0 6px 6px 0;
}

.login-eye:hover,
.login-eye:focus-visible {
  color: var(--primary);
}

.login-eye[aria-pressed="false"] .login-eye-off {
  display: none;
}

.login-hint {
  margin: -6px 0 0;
  font-size: 12px;
  color: #b45309;
}
