:root {
  --bg: #f4f6fa;
  --surface: #ffffffcc;
  --surface-strong: #ffffff;
  --border: #e2e4e8;
  --text: #2c2d30;
  --text-light: #6b6f76;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --radius: 10px;
  --transition: 0.25s cubic-bezier(0.25, 1, 0.5, 1);
  --shadow-soft: 0 4px 10px rgba(0, 0, 0, 0.08);
  --shadow-strong: 0 8px 30px rgba(0, 0, 0, 0.1);
}

/* ===== БАЗА ===== */
* {
  box-sizing: border-box;
  transition: all var(--transition);
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, #e8ebf2, #fefefe);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  padding: 32px;
  animation: fadeIn 0.6s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== ТАБЛИЦА ===== */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(6px);
  transition: all 0.3s ease;
}

th, td {
  padding: 12px 16px;
  text-align: center;      /* горизонтальное выравнивание */
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  background: linear-gradient(to bottom, #f8fafc, #f1f5f9);
  color: var(--text-light);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

tbody tr {
  transition: transform 0.25s ease, background 0.25s ease;
}

tbody tr:hover {
  background: rgba(59, 130, 246, 0.08);
  transform: scale(1.01);
  cursor: pointer;
}

/* ===== СТАТУСЫ ЗАКАЗОВ ===== */
.unfinished {
  background: rgba(255, 99, 71, 0.2);
  box-shadow: 0 3px 10px rgba(255, 99, 71, 0.3);
}
.unfinished:hover {
  background: rgba(255, 99, 71, 0.35);
  box-shadow: 0 6px 20px rgba(255, 99, 71, 0.5);
}

.finished {
  background: rgba(34, 197, 94, 0.2);
  box-shadow: 0 3px 10px rgba(34, 197, 94, 0.3);
}
.finished:hover {
  background: rgba(34, 197, 94, 0.35);
  box-shadow: 0 6px 20px rgba(34, 197, 94, 0.5);
}

/* ===== КНОПКИ ===== */
button {
  appearance: none;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  color: #fff;
  font-weight: 500;
  font-size: 14px;
  padding: 9px 16px;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(59, 130, 246, 0.3);

  /* Центровка кнопки */
  display: block;
  margin: 0 auto;
}

button:hover {
  background: linear-gradient(135deg, var(--accent-hover), #4338ca);
  transform: translateY(-1px);
  box-shadow: 0 5px 18px rgba(59, 130, 246, 0.4);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.6;
  box-shadow: none;
  cursor: not-allowed;
}

/* ===== МОДАЛЬНЫЕ ОКНА ===== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(5px);
  z-index: 1000;
  overflow-y: auto;
  padding: 60px 16px;
  animation: fadeIn 0.3s ease;
}

.modal-content {
  background: var(--surface-strong);
  max-width: 960px;
  margin: auto;
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow-strong);
  position: relative;
  animation: popUp 0.4s ease forwards;
}

@keyframes popUp {
  from { opacity: 0; transform: scale(0.92) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.close {
  position: absolute;
  right: 20px;
  top: 16px;
  font-size: 24px;
  color: var(--text-light);
  cursor: pointer;
}
.close:hover {
  color: var(--accent);
  transform: rotate(90deg);
}

/* ===== ТАБЛИЦЫ ВНУТРИ МОДАЛОК ===== */
#parcelsContainer table {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}
#parcelsContainer th {
  background: #f3f4f6;
  color: var(--text-light);
  text-transform: uppercase;
  font-size: 12px;
}
#parcelsContainer td {
  font-size: 13px;
}

/* ===== ПОЛЯ И SELECT ===== */
input, select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  background: #f9fafb;
  transition: all 0.25s ease;
}
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  background: #fff;
}

/* ===== ГАБАРИТЫ ===== */
.dimensions-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

#dimensionsModal .modal-content {
  max-width: 400px;
  padding: 28px 32px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-strong);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

#dimensionsModal h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

/* === Поля формы === */
#dimensionsModal .dimensions-form {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 14px;
  align-items: center;
}

#dimensionsModal .dimensions-form input {
  width: 100%;
  max-width: 260px;
  padding: 10px 12px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f9fafb;
  transition: all 0.25s ease;
  text-align: center;
}

#dimensionsModal .dimensions-form input:focus {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
  outline: none;
}

/* === Кнопка сохранения === */
#dimensionsModal .dimensions-form button {
  width: 100%;
  max-width: 260px;
  padding: 10px 12px;
  margin-top: 6px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  transition: all 0.25s ease;
}

#dimensionsModal .dimensions-form button:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, var(--accent-hover), #4338ca);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.45);
}

#dimensionsModal .dimensions-form button:active {
  transform: translateY(0);
}

/* ===== БАРКОД ===== */
.barcode-container img {
  max-width: 260px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  padding: 10px;
  box-shadow: var(--shadow-soft);
  transition: all 0.25s ease;
}
.barcode-container img:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-strong);
}

/* ===== АДАПТИВ ===== */
@media (max-width: 800px) {
  body { padding: 16px; }
  table, th, td { font-size: 13px; padding: 10px 8px; }
  .modal-content { padding: 20px; }
  button { font-size: 13px; padding: 7px 12px; }
}

#addOrderFormContainer .dimensions-form {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* два столбца */
  gap: 16px 20px;                        /* вертикальные и горизонтальные отступы */
  margin-top: 10px;
}

#addOrderFormContainer .dimensions-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface);
  transition: all 0.25s ease;
}

#addOrderFormContainer .dimensions-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
  outline: none;
}

/* Адаптив: на узких экранах всё в один столбец */
@media (max-width: 640px) {
  #addOrderFormContainer .dimensions-form {
    grid-template-columns: 1fr;
  }
}

td[contenteditable="true"],
td:has(select) {
  background: rgba(59, 130, 246, 0.06); /* лёгкий намёк цвета акцента */
  border-radius: 6px;
  transition: background 0.25s ease, box-shadow 0.25s ease;
  cursor: text;
  position: relative;
}

/* Подсветка при наведении */
td[contenteditable="true"]:hover,
td:has(select):hover {
  background: rgba(59, 130, 246, 0.12);
}

/* Эффект фокуса (при редактировании или выборе в select) */
td[contenteditable="true"]:focus,
td[contenteditable="true"]:focus-visible,
td:has(select:focus) {
  background: rgba(59, 130, 246, 0.18);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

/* Визуальная вспышка при обновлении */
td[contenteditable="true"].updated,
td:has(select).updated {
  animation: flashSuccess 1.2s ease;
}

@keyframes flashSuccess {
  0% { background: rgba(34,197,94,0.25); }
  100% { background: rgba(59,130,246,0.06); }
}

/* Пустая ячейка — лёгкий индикатор */
td[contenteditable="true"]:empty::before {
  content: "—";
  color: var(--text-light);
  opacity: 0.4;
}

/* === Для select внутри таблицы === */
td:has(select) {
  cursor: pointer;
}
td:has(select) select {
  width: 100%;
  background: transparent;
  border: none;
  font-size: 13px;
  color: var(--text);
  padding: 4px 0;
  cursor: pointer;
  outline: none;
}

/* Убираем стандартную стрелку у select */
td:has(select) select::-ms-expand {
  display: none;
}

table,
#ordersTable,
#parcelsContainer table,
#orderProductsTable {
  border-radius: 0 !important;
  overflow: visible !important;
}

/* Все ячейки — без скруглений */
th,
td,
#parcelsContainer th,
#parcelsContainer td,
#orderProductsTable th,
#orderProductsTable td {
  border-radius: 0 !important;
}

/* Убираем скругление для редактируемых ячеек и ячеек с select */
td[contenteditable="true"],
td:has(select) {
  border-radius: 0 !important;
}

/* Для модалок, если в них есть таблицы */
.modal table th,
.modal table td {
  border-radius: 0 !important;
}

/* Небольшое выравнивание визуального стиля */
th {
  background-clip: padding-box;
}
td {
  background-clip: padding-box;
}

#ordersTable {
  font-size: 11px;           /* уменьшенный шрифт */
  border-collapse: collapse;
  width: 100%;
}

#ordersTable th,
#ordersTable td {
  padding: 4px 8px;          /* уменьшенный padding */
  text-align: center;      /* горизонтальное выравнивание */
  vertical-align: middle;
  white-space: nowrap;        /* чтобы текст не переносился */
}

#ordersTable th {
  font-size: 10px;            /* ещё меньше для заголовков */
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-light);
  background: #f3f4f6;
}

#ordersTable td {
  font-size: 11px;
}

/* Hover эффект для строк */
#ordersTable tbody tr:hover {
  background: rgba(59, 130, 246, 0.08);
  transform: scale(1.01);
  cursor: pointer;
}

/* Редактируемые ячейки */
#ordersTable td[contenteditable="true"],
#ordersTable td:has(select) {
  background: rgba(59, 130, 246, 0.06);
  border-radius: 0;
  padding: 3px 6px;
  font-size: 11px;
}

#ordersTable td[contenteditable="true"]:hover,
#ordersTable td:has(select):hover {
  background: rgba(59, 130, 246, 0.12);
}

#ordersTable td[contenteditable="true"]:focus,
#ordersTable td[contenteditable="true"]:focus-visible,
#ordersTable td:has(select:focus) {
  background: rgba(59, 130, 246, 0.18);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

/* Адаптив для маленьких экранов */
@media (max-width: 800px) {
  #ordersTable th, 
  #ordersTable td {
    font-size: 10px;
    padding: 3px 5px;
  }
}