:root {
  --bg: #eef2f7; /* Мягкий светлый фон для 3D Neumorphism теней */
  --panel: #f8fafc;
  --text: #1e293b; /* Slate-800 */
  --muted: #64748b; /* Slate-500 */
  --line: rgba(203, 213, 225, 0.5); /* Мягкие полупрозрачные линии */
  --green: #10b981; /* Изумрудный */
  --blue: #3b82f6; /* Лазурный */
  --yellow: #f59e0b; /* Янтарный */
  --red: #ef4444; /* Коралловый */

  /* Премиальные 3D Neumorphism Тени */
  --shadow-3d-out: 8px 8px 20px rgba(163, 177, 198, 0.45), -8px -8px 20px rgba(255, 255, 255, 0.95);
  --shadow-3d-in: inset 3px 3px 7px rgba(163, 177, 198, 0.35), inset -3px -3px 7px rgba(255, 255, 255, 0.85);
  --shadow-3d-btn: 4px 4px 10px rgba(163, 177, 198, 0.4), -4px -4px 10px rgba(255, 255, 255, 0.95);
  --shadow-3d-btn-active: inset 2px 2px 5px rgba(163, 177, 198, 0.4), inset -2px -2px 5px rgba(255, 255, 255, 0.8);
  --shadow-3d-card-hover: 12px 12px 28px rgba(163, 177, 198, 0.55), -12px -12px 28px rgba(255, 255, 255, 0.98);
}

* { 
  box-sizing: border-box; 
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, background-color 0.2s ease;
}

body {
  margin: 0;
  font-family: 'Outfit', Inter, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
}

/* ── Парящий 3D Сайдбар (Glassmorphism + 3D) ── */
.sidebar {
  position: fixed;
  inset: 18px auto 18px 18px;
  width: 244px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #fff;
  padding: 26px 18px;
  overflow-y: auto;
  border-radius: 20px;
  box-shadow: 10px 10px 30px rgba(15, 23, 42, 0.2), inset 1px 1px 3px rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.05);
  z-index: 100;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 32px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35), inset 1px 1px 3px rgba(255, 255, 255, 0.4);
}

.brand small {
  display: block;
  color: #94a3b8;
  margin-top: 3px;
  font-size: 11px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 0;
  border-radius: 10px;
  padding: 12px 14px;
  color: #94a3b8;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
}

.nav-item:hover, .nav-item.active {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  transform: translateX(4px);
  box-shadow: inset 1px 1px 2px rgba(255, 255, 255, 0.1);
}

/* ── Главная Рабочая Область ── */
.app-shell {
  margin-left: 278px; /* Отступ с учетом парящего сайдбара */
  min-height: 100vh;
  padding: 32px 38px 48px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 28px;
}

h1, h2, h3, p {
  margin: 0;
}

h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #0f172a;
}

h2 {
  font-size: 18px;
  font-weight: 700;
  color: #1e293b;
}

h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}

.topbar p, .muted {
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  gap: 12px;
}

/* ── Вдавленные 3D Инпуты ── */
select, input, textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  background: #e2e8f0; /* Вдавленный цвет */
  padding: 11px 14px;
  color: var(--text);
  box-shadow: var(--shadow-3d-in);
  outline: none;
  font-weight: 500;
  transition: all 0.2s ease;
}

select:focus, input:focus, textarea:focus {
  background: #f8fafc;
  border-color: #3b82f6;
  box-shadow: inset 1px 1px 3px rgba(163, 177, 198, 0.2), 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ── Объемные 3D Клавиши / Кнопки ── */
button, .btn {
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  background: #f1f5f9;
  color: var(--text);
  padding: 11px 16px;
  font-weight: 600;
  box-shadow: var(--shadow-3d-btn);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

button:hover, .btn:hover {
  transform: translateY(-2px);
  box-shadow: 6px 6px 14px rgba(163, 177, 198, 0.55), -6px -6px 14px rgba(255, 255, 255, 0.98);
}

button:active, .btn:active {
  transform: translateY(1px);
  box-shadow: var(--shadow-3d-btn-active);
}

/* Акцентные 3D Кнопки (Изумрудный градиент) */
button.primary, .primary, .btn.primary {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: 1px solid rgba(16, 185, 129, 0.2);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3), inset 1px 1px 2px rgba(255, 255, 255, 0.35);
  font-weight: 700;
}

button.primary:hover, .primary:hover, .btn.primary:hover {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4), inset 1px 1px 2px rgba(255, 255, 255, 0.4);
  transform: translateY(-2px);
}

button.primary:active, .primary:active, .btn.primary:active {
  transform: translateY(1px);
  box-shadow: inset 2px 2px 6px rgba(0, 0, 0, 0.2), 0 2px 4px rgba(16, 185, 129, 0.2);
}

/* ── Объемные 3D Карточки Метрик и Панели ── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.metric, .panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 18px;
  box-shadow: var(--shadow-3d-out);
}

.metric {
  padding: 22px;
}

.metric:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-3d-card-hover);
}

.metric span {
  display: block;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 8px;
}

.metric strong {
  font-size: 32px;
  font-weight: 800;
  color: #0f172a;
}

.metric.warning strong { color: var(--yellow); }
.metric.danger strong { color: var(--red); }

.panel {
  overflow: hidden;
  margin-bottom: 24px;
}

.panel.padded {
  padding: 20px 24px;
}

.board-panel {
  margin-bottom: 20px;
}

/* ── 3D Канбан Доска Сделок ── */
.deal-board {
  display: grid;
  grid-template-columns: repeat(7, minmax(200px, 1fr));
  gap: 16px;
  padding: 16px;
  overflow-x: auto;
}

.board-column {
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f1f5f9;
  box-shadow: inset 2px 2px 5px rgba(163, 177, 198, 0.25), inset -2px -2px 5px rgba(255, 255, 255, 0.8);
}

.board-head {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-top: 4px solid var(--muted);
  border-bottom: 1px solid var(--line);
  background: #fff;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.board-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.board-cards {
  display: grid;
  gap: 10px;
  padding: 10px;
}

.deal-mini {
  display: grid;
  gap: 5px;
  width: 100%;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
  box-shadow: var(--shadow-3d-btn);
}

.deal-mini:hover {
  transform: translateY(-2px);
  box-shadow: 4px 4px 10px rgba(163, 177, 198, 0.45);
}

.deal-mini strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  color: #1e293b;
}

.deal-mini span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  font-weight: 800;
}

.deal-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 160px;
  gap: 10px;
  width: min(540px, 100%);
}

/* ── Декоративные Объемные Плашки ── */
.payment-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  background: #e2e8f0;
  color: var(--muted);
  box-shadow: var(--shadow-3d-in);
}

.payment-pill.paid {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.payment-pill.partial {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.payment-pill.unpaid {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.two-column, .workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}

.workspace-grid {
  grid-template-columns: minmax(320px, 0.85fr) minmax(420px, 1.15fr);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 20px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.span-2 {
  grid-column: span 2;
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  align-items: end;
}

.inline-form:last-child {
  border-bottom: 0;
}

.inline-form label {
  min-width: 0;
}

.inline-form .checkbox-line {
  align-items: center;
  display: flex;
  gap: 8px;
  min-height: 38px;
}

.inline-form .checkbox-line input {
  width: auto;
  box-shadow: none;
}

#part-form {
  grid-template-columns: 1fr 1fr 1.4fr 92px 110px auto;
}

#payment-form {
  grid-template-columns: 1.2fr 120px 1fr auto;
}

.stock-doc-form {
  grid-template-columns: 150px 150px 110px 110px 1fr 90px 100px 1fr auto;
}

.table-wrap {
  overflow: auto;
  border-radius: 12px;
  box-shadow: var(--shadow-3d-in);
  background: #fff;
  margin: 10px 0;
}

/* ── 3D Объемные Таблицы ── */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
  white-space: nowrap;
  font-size: 14px;
}

th {
  font-size: 12px;
  font-weight: 800;
  color: #64748b;
  background: #f8fafc;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #e2e8f0;
}

tr.selectable {
  cursor: pointer;
}

tr.selectable:hover {
  background: #f1f9f5;
}

tr.selected {
  background: #e6f7f0;
  font-weight: 600;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ── Мягкие 3D Фильтр-Чипы ── */
.filter-chip, .chip {
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 10px;
  background: #f1f5f9;
  padding: 6px 12px;
  cursor: pointer;
  box-shadow: 2px 2px 6px rgba(163, 177, 198, 0.35), -2px -2px 6px rgba(255, 255, 255, 0.85);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.filter-chip:hover {
  transform: translateY(-1px);
  box-shadow: 4px 4px 10px rgba(163, 177, 198, 0.45), -4px -4px 10px rgba(255, 255, 255, 0.9);
}

.filter-chip.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  box-shadow: inset 1px 1px 3px rgba(0, 0, 0, 0.2);
}

.filter-chip.warning.active {
  background: var(--yellow);
  color: #fff;
  border-color: var(--yellow);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  max-width: 190px;
  padding: 6px 10px;
  border-radius: 10px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  text-overflow: ellipsis;
}

.attention-list, .event-list, .list {
  display: grid;
  gap: 12px;
  padding: 18px 24px;
}

.attention, .event, .list-row {
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 12px;
  padding: 14px;
  background: #fff;
  box-shadow: var(--shadow-3d-btn);
}

.attention strong, .event strong {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
}

.attention.critical {
  border-color: #fca5a5;
  background: #fef2f2;
}

.attention.warning {
  border-color: #fde047;
  background: #fefce8;
}

.event-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.settings-grid {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 20px;
  padding: 20px;
}

.deal-card {
  margin-top: 20px;
}

.deal-card-body {
  padding: 20px;
}

/* ── Объемные Табы Сделок ── */
.deal-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 18px 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.deal-tab {
  border: 0;
  border-radius: 10px 10px 0 0;
  padding: 10px 16px;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 600;
  cursor: pointer;
}

.deal-tab.active {
  background: #e6f4ee;
  color: var(--green);
  font-weight: 700;
  box-shadow: inset 0 2px 4px rgba(16, 185, 129, 0.1);
}

.deal-quick-forms {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.deal-quick-forms form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.deal-quick-forms #call-form,
.deal-quick-forms #recommendation-form,
.deal-quick-forms #file-form {
  grid-template-columns: 1fr 1fr auto;
}

.empty-state {
  color: var(--muted);
  font-weight: 500;
}

.deal-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.deal-card-grid section {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: #f8fafc;
  box-shadow: inset 1px 1px 3px rgba(163, 177, 198, 0.1);
}

.deal-lines {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.tab-section {
  display: none;
}

.tab-section.active {
  display: block;
}

.line-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.deal-actionbar {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
}

/* ── 3D Всплывающий Тост ── */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  min-width: 280px;
  max-width: 420px;
  padding: 14px 18px;
  border-radius: 14px;
  background: #1e293b;
  color: #fff;
  box-shadow: 8px 8px 24px rgba(15, 23, 42, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 2000;
  font-weight: 600;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ── 3D Модальные Окна ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-box {
  background: var(--panel);
  border-radius: 20px;
  padding: 24px;
  min-width: 380px;
  max-width: 540px;
  width: 90%;
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 12px 12px 30px rgba(15, 23, 42, 0.2), -12px -12px 30px rgba(255, 255, 255, 0.95);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2rem;
}

.modal-head h2 { margin: 0; font-size: 1.2rem; font-weight: 800; }

/* Ряды инлайн-редактирования в таблицах заказов */
.inline-edit-row { background: #f8fafc; }
.inline-edit-form { padding: .6rem 0; }

/* ── Адаптивность ── */
@media (max-width: 980px) {
  .sidebar {
    position: static;
    width: auto;
    inset: auto;
    margin: 18px;
  }

  .app-shell {
    margin-left: 0;
    padding: 18px;
  }

  .topbar, .two-column, .workspace-grid, .settings-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }

  .deal-filters {
    grid-template-columns: 1fr;
  }

  .inline-form, #part-form, #payment-form, .stock-doc-form {
    grid-template-columns: 1fr;
  }

  .deal-card-grid, .deal-lines, .deal-quick-forms, .deal-quick-forms form,
  .deal-quick-forms #call-form, .deal-quick-forms #recommendation-form, .deal-quick-forms #file-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .metric-grid, .form-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }
}
