:root {
  --bg: #f3f3f7;
  --shell: #ededf3;
  --card: #f8f8fb;
  --surface: #ffffff;
  --line: #d9dbe3;
  --line-strong: #cbced8;
  --text: #191923;
  --muted: #6e7283;
  --accent: #c49a61;
  --accent-soft: #efe4d1;
  --danger: #df5a5a;
  --blue-soft: #eaf1ff;
  --shadow: 0 18px 36px rgba(22, 24, 35, 0.08);
  --radius-xl: 26px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --sidebar-w: 284px;
  --sidebar-collapsed-w: 86px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 14% 10%, #fbfbfe 0%, var(--bg) 46%, #ececf2 100%);
}

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

button {
  cursor: pointer;
}

.password-input-wrap {
  display: block;
  position: relative;
  width: 100%;
}

.password-input-wrap input {
  width: 100%;
  box-sizing: border-box;
  padding-right: 2.2rem;
}

.password-toggle-btn {
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0.2rem;
}

.hidden {
  display: none !important;
}

.page {
  min-height: 100vh;
  padding: 0;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-card {
  width: min(440px, 100%);
  background: rgba(248, 248, 251, 0.96);
  border: 1px solid rgba(203, 206, 216, 0.6);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 24px;
}

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

.login-logo {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  object-fit: cover;
  display: block;
}

.login-brand {
  font-weight: 700;
}

.login-sub {
  font-size: 13px;
  color: var(--muted);
}

.login-card h1 {
  margin: 4px 0 16px;
  font-size: 28px;
  line-height: 1.1;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.login-form input {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  height: 44px;
  padding: 0 12px;
}

.login-form input:focus {
  outline: 2px solid rgba(196, 154, 97, 0.25);
  border-color: var(--accent);
}

.login-form button[type='submit'] {
  margin-top: 4px;
  border: 0;
  border-radius: 12px;
  height: 46px;
  color: #fff;
  font-weight: 600;
  background: linear-gradient(180deg, #cda06a, #b78548);
}

.shell {
  height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 0;
  background: rgba(236, 236, 243, 0.93);
  border: 0;
  border-radius: 26px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.shell.sidebar-collapsed {
  grid-template-columns: var(--sidebar-collapsed-w) 1fr;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 26px 22px 20px;
  background: rgba(247, 247, 251, 0.96);
  border-right: 1px solid rgba(212, 214, 223, 0.8);
  overflow: hidden;
}

.sidebar-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 0;
  object-fit: contain;
  display: block;
}

.brand-copy {
  min-width: 0;
}

.brand-title {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.15;
}

.brand-subtitle {
  font-size: 13px;
  color: var(--muted);
}

.brand-customer-name {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 700;
  color: #2a3140;
}

.sidebar-label {
  font-size: 13px;
  font-weight: 700;
  color: #2b2d38;
  margin-top: 6px;
}

.sidebar-nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 12px;
  min-height: 46px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: left;
  color: #404454;
}

.nav-item:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.72);
  border-color: rgba(210, 214, 224, 0.65);
}

.nav-item.active {
  background: rgba(237, 237, 245, 0.95);
  border-color: rgba(214, 216, 226, 0.95);
  color: #191923;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.nav-item:disabled,
.nav-item.is-disabled {
  opacity: 0.55;
  cursor: default;
}

.nav-item-icon {
  width: 22px;
  text-align: center;
  color: #777b8b;
  font-size: 17px;
  line-height: 1;
}

.sidebar-toggle-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  flex: 0 0 auto;
}

.logout-btn {
  margin-top: auto;
  border: 1px solid rgba(216, 182, 139, 0.65);
  background: linear-gradient(180deg, #f3e6d3, #ecdabb);
  color: #5b4328;
  border-radius: 12px;
  min-height: 44px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.sidebar-build-meta {
  margin-top: 4px;
  border-top: 1px solid rgba(212, 214, 223, 0.8);
  padding-top: 10px;
  display: grid;
  gap: 2px;
}

.sidebar-build-line {
  font-size: 11px;
  line-height: 1.35;
  color: #7a7f8f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-icon {
  font-size: 15px;
  line-height: 1;
}

.shell.sidebar-collapsed .sidebar {
  padding: 20px 10px 16px;
  gap: 14px;
}

.shell.sidebar-collapsed .sidebar-brand {
  justify-content: center;
}

.shell.sidebar-collapsed .brand-copy,
.shell.sidebar-collapsed .sidebar-label,
.shell.sidebar-collapsed .nav-item-text,
.shell.sidebar-collapsed .logout-label,
.shell.sidebar-collapsed .sidebar-build-meta {
  display: none !important;
}

.shell.sidebar-collapsed .sidebar-nav {
  justify-items: center;
}

.shell.sidebar-collapsed .nav-item {
  width: 48px;
  min-height: 42px;
  padding: 8px;
  justify-content: center;
  gap: 0;
}

.shell.sidebar-collapsed .nav-item-icon {
  width: auto;
}

.shell.sidebar-collapsed .nav-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  margin-left: 0;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 10px;
}

.shell.sidebar-collapsed .logout-btn {
  width: 48px;
  min-height: 42px;
  margin-top: auto;
  margin-left: auto;
  margin-right: auto;
}

.content {
  padding: 22px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.topbar {
  height: 72px;
  border: 1px solid rgba(213, 216, 226, 0.7);
  background: rgba(239, 239, 245, 0.9);
  border-radius: 18px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ghost-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(212, 214, 224, 0.8);
  background: rgba(255, 255, 255, 0.7);
  display: grid;
  place-items: center;
  color: #6f7381;
}

.crumb {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.crumb-icon {
  color: #767a8b;
}

.toolbar-btn {
  border: 1px solid rgba(211, 214, 224, 0.95);
  background: rgba(255, 255, 255, 0.88);
  color: #2d3040;
  border-radius: 12px;
  min-height: 38px;
  padding: 0 14px;
  font-weight: 600;
}

.toolbar-btn:hover {
  background: #fff;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(215, 218, 228, 0.95);
  background: rgba(255, 255, 255, 0.86);
}

.flash {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(920px, calc(100vw - 32px));
  z-index: 5000;
  box-shadow: 0 10px 24px rgba(22, 24, 35, 0.12);
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid transparent;
  font-size: 14px;
  pointer-events: none;
}

.flash.success {
  background: #eef8ef;
  border-color: #c7e7ca;
  color: #245d29;
}

.flash.error {
  background: #fff0f0;
  border-color: #f1caca;
  color: #8a2f2f;
}

.screen-panel {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.panel-card {
  background: rgba(248, 248, 251, 0.96);
  border: 1px solid rgba(211, 214, 224, 0.9);
  border-radius: 22px;
  padding: 22px;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 14px;
  overflow: auto;
  overscroll-behavior: contain;
}

#admin-customers-screen .panel-card,
#admin-wines-screen .panel-card {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

#admin-orders-screen .panel-card {
  grid-template-rows: auto auto 1fr auto;
}

#admin-orders-screen .table-footer {
  display: flex;
  padding-top: 0;
}

.panel-header h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.panel-header .search-box {
  margin-left: auto;
}

.orders-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.orders-mode-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: nowrap;
  flex: 0 0 auto;
}

.orders-mode-switch {
  display: inline-flex;
  gap: 8px;
}

.orders-mode-btn {
  min-height: 36px;
  border: 1px solid rgba(211, 214, 224, 0.95);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.85);
  color: #4e5363;
  padding: 0 12px;
  font-weight: 600;
}

.orders-mode-btn.active {
  background: linear-gradient(180deg, #c99454, #b47639);
  border-color: rgba(183, 118, 57, 0.85);
  color: #fff;
}

.orders-calendar-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #666e7d;
  font-size: 13px;
}

.orders-calendar-wrap input {
  border: 1px solid rgba(211, 214, 224, 0.95);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  min-height: 36px;
  padding: 0 10px;
}

.notify-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  position: relative;
}

.notify-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: #d85252;
  border: 1px solid rgba(255, 255, 255, 0.7);
}

.notifications-menu {
  position: absolute;
  top: 46px;
  right: 0;
  width: min(360px, calc(100vw - 110px));
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(211, 214, 224, 0.95);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 12px 36px rgba(38, 44, 59, 0.16);
  z-index: 20;
}

.notify-menu-item {
  border: 1px solid rgba(225, 228, 236, 0.95);
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
  text-align: left;
  display: grid;
  gap: 2px;
  cursor: pointer;
}

.notify-menu-item:hover {
  background: #f9fafc;
}

.notify-menu-item-title {
  font-size: 14px;
  font-weight: 600;
  color: #27313a;
}

.notify-menu-item-sub {
  font-size: 12px;
  color: #6a747f;
}

.notify-menu-empty {
  padding: 6px 4px;
  color: #6f7a85;
  font-size: 13px;
}

.panel-toolbar {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  align-items: center;
  flex-wrap: nowrap;
}

#orders-panel-toolbar .search-box {
  flex: 1 1 360px;
  width: auto;
  max-width: 560px;
}

.search-box {
  width: min(420px, 100%);
  height: 44px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.78);
  border-radius: 12px;
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  overflow: hidden;
}

.search-icon {
  display: grid;
  place-items: center;
  color: #7a7e8e;
  font-size: 18px;
}

.search-box input {
  border: 0;
  background: transparent;
  height: 100%;
  padding: 0 12px 0 0;
}

.search-box input:focus {
  outline: none;
}

.data-table {
  border: 1px solid rgba(210, 213, 223, 0.95);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.65);
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.orders-table {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.table-head,
.table-row {
  display: grid;
  align-items: center;
  min-width: 0;
}

.order-grid {
  grid-template-columns: 1.25fr 0.85fr 1.55fr 0.8fr 0.95fr;
}

.customer-grid {
  grid-template-columns: 1.55fr 1fr 0.95fr 0.7fr 0.8fr;
}

.order-grid-customer {
  grid-template-columns: 1.65fr 0.9fr 0.95fr;
}

.wine-grid {
  grid-template-columns: 0.95fr 1.8fr 0.8fr 0.8fr;
}

.table-head {
  min-height: 0;
  border-bottom: 1px solid rgba(210, 213, 223, 0.9);
  background: rgba(244, 244, 249, 0.9);
  color: #545867;
  font-weight: 600;
}

.table-head > div {
  padding: 8px 14px;
  min-width: 0;
  line-height: 1.15;
}

.table-sort-btn {
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.table-body {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.table-row {
  min-height: 0;
  border-bottom: 1px solid rgba(223, 225, 233, 0.95);
  background: transparent;
}

.table-row:last-child {
  border-bottom: 0;
}

.table-row:hover {
  background: rgba(255, 255, 255, 0.58);
}

.order-row-clickable {
  cursor: pointer;
}

.order-row-clickable:focus-visible {
  outline: 2px solid rgba(188, 135, 76, 0.45);
  outline-offset: -2px;
}

.order-row-urgent {
  background: rgba(255, 239, 239, 0.55);
  box-shadow: inset 3px 0 0 #c14f4f;
}

.order-row-urgent .cell-delivery {
  color: #7f2b2b;
  font-weight: 700;
}

.order-section-row {
  min-height: 0;
  display: flex;
  align-items: center;
  padding: 5px 14px;
  border-bottom: 1px solid rgba(219, 222, 230, 0.95);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.order-section-open {
  color: #4b5a67;
  background: rgba(245, 247, 250, 0.95);
}

.order-section-unpaid {
  color: #8a6a21;
  background: rgba(255, 247, 229, 0.9);
}

.order-section-done {
  color: #6e7882;
  background: rgba(243, 245, 248, 0.9);
}

.order-date-row {
  min-height: 0;
  display: flex;
  align-items: center;
  padding: 4px 14px;
  border-bottom: 1px solid rgba(223, 225, 233, 0.95);
  color: #566071;
  background: rgba(251, 252, 254, 0.9);
  font-size: 13px;
  font-weight: 600;
}

.customer-row-clickable {
  cursor: pointer;
}

.wine-row-clickable {
  cursor: pointer;
}

.wine-row-clickable:focus-visible {
  outline: 2px solid rgba(188, 135, 76, 0.45);
  outline-offset: -2px;
}

.customer-row-clickable:focus-visible {
  outline: 2px solid rgba(188, 135, 76, 0.45);
  outline-offset: -2px;
}

.cell {
  padding: 6px 14px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.15;
}

.cell.mono {
  font-variant-numeric: tabular-nums;
}

.cell-document {
  font-size: 13px;
  line-height: 1.2;
  white-space: normal;
  overflow: hidden;
  text-overflow: clip;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

.cell-delivery {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.cell-created {
  display: grid;
  gap: 2px;
  white-space: normal;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.stack-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stack-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 2px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 700;
  max-width: none;
  white-space: normal;
  text-align: center;
  overflow-wrap: anywhere;
}

.status-badge.is-new {
  background: var(--accent-soft);
  border-color: #dec4a0;
  color: #7a582f;
}

.status-badge.is-progress {
  background: #eff2ff;
  border-color: #cfd8ff;
  color: #44529a;
}

.status-badge.is-prepared {
  background: #e7f5f1;
  border-color: #b7e2d6;
  color: #246d57;
}

.status-badge.is-warning {
  background: #fff4e7;
  border-color: #f1d4a8;
  color: #8b5c1d;
}

.status-badge.is-done {
  background: #edf8ef;
  border-color: #cae7cf;
  color: #2f6c3a;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(212, 215, 225, 0.95);
  background: rgba(255, 255, 255, 0.88);
  display: grid;
  place-items: center;
}

.icon-btn:hover {
  background: #fff;
}

.icon-btn.danger {
  color: var(--danger);
  border-color: rgba(238, 199, 199, 0.95);
  background: rgba(255, 245, 245, 0.95);
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 2px;
}

.customer-orders-layout {
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.customer-orders-layout .orders-mode-row {
  display: none;
}

.customer-orders-layout #orders-panel-toolbar {
  display: none;
}

.customer-orders-layout #orders-panel-header {
  display: grid;
  grid-template-columns: auto minmax(260px, 420px) auto auto;
  align-items: center;
  gap: 10px;
}

.customer-orders-layout #orders-panel-header .orders-header-actions {
  margin-left: 0;
}

.customer-orders-layout #orders-panel-header .search-box {
  margin-left: 0;
}

.customer-orders-layout .orders-table {
  height: 100%;
}

.customer-orders-layout .table-footer {
  display: none;
}

.footer-info {
  color: var(--muted);
  font-size: 14px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.page-btn {
  min-width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(212, 215, 225, 0.95);
  background: rgba(255, 255, 255, 0.85);
  color: #424657;
  padding: 0 10px;
}

.page-btn.active {
  background: #fff;
  border-color: rgba(170, 174, 186, 0.95);
  color: #14151d;
  font-weight: 700;
}

.page-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.page-gap {
  color: var(--muted);
  padding: 0 4px;
}

.empty-state {
  padding: 22px 16px;
  color: var(--muted);
  text-align: center;
}

.customer-order-composer {
  border: 1px solid rgba(211, 214, 224, 0.9);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.62);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.customer-order-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.customer-order-head h2 {
  margin: 0;
  font-size: 22px;
}

.customer-order-summary {
  font-size: 13px;
  color: #5f6875;
  font-weight: 600;
}

.customer-order-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.customer-order-grid label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: #5f6875;
}

.customer-order-grid label.full {
  grid-column: 1 / -1;
}

#admin-order-customer-wrap {
  position: relative;
}

.customer-order-grid select,
.customer-order-grid input,
.customer-order-grid textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 9px 10px;
}

.admin-order-customer-combobox {
  position: relative;
  width: 100%;
}

.admin-order-customer-combobox input {
  width: 100%;
  padding-right: 34px;
}

.admin-order-customer-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  color: #697086;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1;
}

.admin-order-customer-toggle:hover {
  background: #f3f5fa;
}

.admin-order-customer-results {
  display: none;
  margin-top: 0;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  border: 1px solid rgba(211, 214, 224, 0.9);
  border-radius: 10px;
  background: #fff;
  max-height: 180px;
  overflow: auto;
  z-index: 90;
  box-shadow: 0 10px 20px rgba(22, 24, 35, 0.12);
}

.admin-order-customer-results.open {
  display: block;
}

.admin-order-customer-option {
  width: 100%;
  border: 0;
  border-bottom: 1px solid rgba(225, 227, 235, 0.9);
  background: transparent;
  padding: 8px 10px;
  text-align: left;
  display: grid;
  gap: 2px;
}

.admin-order-customer-option:last-child {
  border-bottom: 0;
}

.admin-order-customer-option .title {
  font-weight: 600;
  color: #222633;
}

.admin-order-customer-option .meta {
  font-size: 12px;
  color: var(--muted);
}

.admin-order-customer-option:hover {
  background: #f5f7fb;
}

.admin-order-customer-option.active {
  background: #eef3ff;
}

.customer-catalog-wrap {
  border: 1px solid rgba(211, 214, 224, 0.9);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  overflow: hidden;
}

.customer-catalog-list {
  max-height: 330px;
  overflow: auto;
}

.customer-catalog-row {
  min-height: 62px;
  border-bottom: 1px solid rgba(223, 225, 233, 0.95);
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 1fr 90px 112px;
  gap: 8px;
  align-items: center;
}

.customer-catalog-row:last-child {
  border-bottom: 0;
}

.customer-catalog-row input,
.customer-catalog-row select {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  min-height: 38px;
  padding: 0 10px;
}

.customer-catalog-title {
  font-weight: 600;
  color: #20262e;
}

.customer-catalog-sub {
  margin-top: 2px;
  font-size: 12px;
  color: #6a747f;
}

.customer-catalog-subline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.customer-catalog-warning {
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.2;
  color: #8a6516;
  font-weight: 600;
}

.customer-order-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toolbar-btn.secondary {
  background: rgba(255, 255, 255, 0.88);
}

.unsupported-card {
  min-height: 220px;
  grid-template-rows: auto auto;
  align-content: start;
}

.unsupported-card h2 {
  margin: 0;
  font-size: 24px;
}

.unsupported-card p {
  margin: 0;
  color: var(--muted);
}

.order-dialog {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: min(1240px, calc(100vw - 20px));
  width: 1240px;
  max-height: 100vh;
  overflow: hidden;
}

.order-dialog::backdrop {
  background: rgba(18, 20, 30, 0.35);
  backdrop-filter: blur(2px);
}

.order-dialog-card {
  border: 1px solid rgba(208, 212, 223, 0.92);
  background: rgba(249, 249, 252, 0.98);
  border-radius: 18px;
  padding: 22px;
  display: grid;
  gap: 14px;
  box-shadow: 0 20px 42px rgba(17, 19, 29, 0.18);
  max-height: min(90vh, 980px);
  overflow: auto;
  overscroll-behavior: contain;
}

.order-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.order-dialog-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.order-dialog-head h3 {
  margin: 0;
  font-size: 20px;
}

.order-dialog .order-dialog-head h3 {
  margin: 0;
  font-size: 38px;
  line-height: 1.02;
  letter-spacing: -0.03em;
}

.muted {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.order-dialog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.order-dialog-grid label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.order-dialog-top-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.order-dialog-left-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.order-dialog-left-pair label,
.order-dialog-top-row #order-dialog-document-number-field {
  min-width: 0;
}

.order-dialog-top-row #order-dialog-document-number-field {
  margin: 0;
}

.order-dialog-grid label.full {
  grid-column: 1 / -1;
}

.order-dialog-grid .full {
  grid-column: 1 / -1;
}

.order-dialog-grid label.half {
  grid-column: auto;
}

.order-dialog-grid input,
.order-dialog-grid select,
.order-dialog-grid textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px 12px;
}

.order-dialog-grid textarea {
  resize: vertical;
}

#order-dialog-planned-delivery-field {
  margin: 0;
  position: relative;
}

.order-dialog-head-date {
  display: inline-flex;
  align-items: center;
}

.order-date-hidden-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.order-date-btn {
  min-width: 210px;
  justify-content: center;
}

.order-date-btn.is-empty {
  color: var(--muted);
}

.order-dialog-notes-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.order-dialog-notes-row label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.order-dialog-notes-row textarea {
  min-height: 68px;
  padding: 8px 10px;
}

.customer-summary-row {
  font-size: 13px;
  color: #4e5965;
  line-height: 1.45;
}

.customer-summary-row strong {
  color: #2b3540;
}

.order-doc-number-split {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 170px));
  gap: 8px;
  justify-content: start;
  align-items: end;
}

.order-doc-number-slot {
  display: grid;
  gap: 6px;
}

.order-doc-number-slot span {
  font-size: 13px;
  color: var(--muted);
}

.order-doc-number-vinoteka {
  grid-column: auto;
}

.order-items {
  border: 1px solid rgba(218, 221, 230, 0.95);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.75);
  overflow: hidden;
}

.order-items-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(220, 223, 232, 0.95);
  background: rgba(249, 249, 252, 0.95);
}

.order-items-search {
  height: 38px;
  max-width: 560px;
  flex: 1 1 360px;
}

.order-items-add-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

#order-dialog-items {
  display: grid;
  gap: 6px;
  padding: 8px;
}

.order-items-title {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-weight: 600;
  border-bottom: 1px solid rgba(220, 223, 232, 0.95);
  background: rgba(245, 245, 250, 0.9);
}

.order-item-editor {
  border: 1px solid rgba(220, 223, 232, 0.95);
  border-radius: 10px;
  background: #fff;
  padding: 6px 10px;
  display: block;
  cursor: pointer;
}

.order-item-editor.is-selected {
  border-color: rgba(206, 152, 85, 0.9);
  box-shadow: inset 0 0 0 1px rgba(206, 152, 85, 0.35);
}

.order-item-line {
  display: grid;
  grid-template-columns: minmax(110px, 0.9fr) minmax(220px, 2fr) minmax(120px, 0.8fr) minmax(170px, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 24px;
}

.order-item-substitution {
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.2;
  color: #7a4650;
  font-weight: 600;
}

.order-item-code {
  display: grid;
  gap: 1px;
  min-width: 0;
  font-size: 13px;
  font-weight: 700;
  color: #7a7267;
}

.order-item-name {
  display: grid;
  gap: 1px;
  font-size: 13px;
  font-weight: 600;
  color: #20262e;
  line-height: 1.2;
  min-width: 0;
}

.order-item-meta-main {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.order-item-meta-original {
  display: block;
  font-size: 11px;
  line-height: 1.1;
  color: #7f8794;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.order-item-qty {
  font-size: 13px;
  color: #414958;
  font-weight: 600;
  white-space: nowrap;
}

.item-toggle-btn {
  border: 1px solid rgba(204, 209, 222, 0.95);
  border-radius: 999px;
  background: #fff;
  color: #4c5560;
  padding: 0 11px;
  min-height: 28px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.item-toggle-btn.is-active {
  background: #eef3ff;
  border-color: #ccdbff;
  color: #3f5294;
}

.item-toggle-btn.danger.is-active {
  background: #fff0f0;
  border-color: #f2c7c7;
  color: #8c2f2f;
}

.item-vinoteka-summary {
  min-height: 0;
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  color: #67727e;
  font-weight: 700;
  white-space: nowrap;
  justify-self: end;
}

.customer-catalog-search {
  height: 38px;
  max-width: 520px;
  margin-bottom: 8px;
}

.item-vinoteka-summary.is-ready {
  color: #2f7a52;
}

.item-vinoteka-summary.is-pending {
  color: #8d2f3a;
}

#order-dialog-items.is-readonly .order-item-editor {
  background: rgba(250, 250, 253, 0.9);
  cursor: default;
}

.order-item-editor.is-readonly {
  cursor: default;
}

.order-item-dialog .entity-form {
  border: 1px solid rgba(208, 212, 223, 0.92);
  background: rgba(249, 249, 252, 0.98);
  border-radius: 18px;
  padding: 16px;
  display: grid;
  gap: 12px;
  box-shadow: 0 20px 42px rgba(17, 19, 29, 0.18);
}

.order-item-dialog .entity-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.order-item-dialog .entity-header h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
}

.order-item-dialog .entity-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.order-item-dialog .entity-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.order-item-dialog .entity-grid label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: #5f6875;
}

.order-item-dialog .entity-grid input,
.order-item-dialog .entity-grid select {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
}

.order-item-dialog-qty-row,
.order-item-dialog-replacement-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.order-item-dialog-replacement-row .toolbar-btn {
  min-height: 36px;
}

.order-item-dialog .order-item-dialog-toggles {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.order-item-dialog .entity-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.order-item-dialog .entity-actions .spacer {
  flex: 1;
}

.order-item-dialog .entity-actions button {
  min-height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(211, 214, 224, 0.95);
  background: #fff;
  padding: 0 12px;
  font-weight: 600;
}

.order-item-dialog .entity-actions button[type='submit'] {
  background: linear-gradient(180deg, #d0a068, #bc874c);
  color: #fff;
  border-color: rgba(188, 135, 76, 0.75);
}

.order-item-dialog .entity-actions .danger {
  color: var(--danger);
  background: rgba(255, 245, 245, 0.95);
  border-color: rgba(238, 199, 199, 0.95);
}

.order-item-picker-dialog .entity-form {
  width: 100%;
  max-width: 100%;
  max-height: calc(100vh - 96px);
  border: 1px solid rgba(208, 212, 223, 0.92);
  background: rgba(249, 249, 252, 0.98);
  border-radius: 18px;
  padding: 16px;
  display: grid;
  gap: 10px;
}

.order-item-picker-dialog .entity-header {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 10px;
}

.order-item-picker-dialog .entity-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.order-item-picker-dialog .entity-actions .spacer {
  flex: 1;
}

.order-item-picker-dialog .entity-actions button {
  min-height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(211, 214, 224, 0.95);
  background: #fff;
  padding: 0 12px;
  font-weight: 600;
}

.order-item-picker-results {
  border: 1px solid rgba(220, 223, 232, 0.95);
  border-radius: 10px;
  background: #fff;
  overflow: auto;
  max-height: min(60vh, 620px);
  min-height: 280px;
}

.order-item-picker-row {
  width: 100%;
  border: 0;
  border-bottom: 1px solid rgba(236, 238, 245, 0.95);
  background: #fff;
  text-align: left;
  padding: 7px 10px;
  display: grid;
  grid-template-columns: minmax(170px, 0.75fr) minmax(0, 1.7fr);
  gap: 10px;
  align-items: center;
}

.order-item-picker-row:hover,
.order-item-picker-row:focus-visible {
  background: rgba(243, 246, 253, 0.95);
}

.order-item-picker-code {
  font-size: 13px;
  font-weight: 700;
  color: #7a7267;
}

.order-item-picker-name {
  font-size: 13px;
  font-weight: 600;
  color: #20262e;
}

body.dialog-open {
  overflow: hidden;
}

.order-dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.order-dialog-actions .spacer {
  flex: 1;
}

.order-dialog-actions button {
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(211, 214, 224, 0.95);
  background: #fff;
  padding: 0 14px;
  font-weight: 600;
}

.order-dialog-actions button[type='submit'] {
  background: linear-gradient(180deg, #d0a068, #bc874c);
  color: #fff;
  border-color: rgba(188, 135, 76, 0.75);
}

.order-dialog-actions .secondary {
  background: rgba(255, 255, 255, 0.88);
}

.order-dialog-actions .danger {
  color: var(--danger);
  background: rgba(255, 245, 245, 0.95);
  border-color: rgba(238, 199, 199, 0.95);
}

.order-dialog-customer-extra {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: start;
}

#order-dialog-customer-summary,
#order-dialog-complaints-card,
#order-dialog-complaint-form {
  align-self: start;
}

#order-dialog-complaint-form {
  grid-column: 1 / -1;
}

.order-dialog-customer-card {
  border: 1px solid rgba(218, 221, 230, 0.95);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.76);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.order-dialog-customer-title {
  font-weight: 700;
  color: #2c3442;
}

.order-dialog-complaints-list {
  display: grid;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
}

.customer-complaint-item {
  border: 1px solid rgba(219, 222, 230, 0.95);
  border-radius: 10px;
  background: #fff;
  padding: 8px;
  display: grid;
  gap: 3px;
}

.customer-complaint-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.customer-complaint-type {
  font-size: 13px;
  font-weight: 600;
  color: #2c3442;
}

.customer-complaint-row-sub {
  font-size: 12px;
  color: #66727e;
}

.order-dialog-complaint-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: #5f6875;
}

.order-dialog-complaint-form select,
.order-dialog-complaint-form input,
.order-dialog-complaint-form textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 9px 10px;
}

.order-dialog-complaint-actions {
  display: flex;
  justify-content: flex-end;
}

.customer-order-item-card {
  border: 1px solid rgba(220, 223, 232, 0.95);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  display: grid;
  gap: 6px;
}

.customer-order-item-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.customer-order-item-code {
  font-size: 12px;
  color: #7a7267;
  font-weight: 700;
}

.customer-order-item-name {
  font-size: 15px;
  font-weight: 600;
  color: #20262e;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-order-item-name-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.customer-order-item-qty {
  font-size: 14px;
  font-weight: 700;
  color: #2f3a45;
  white-space: nowrap;
}

.wine-type-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.wine-type-badge.is-white {
  background: #fff6d7;
  border-color: #ecd89c;
  color: #7d6225;
}

.wine-type-badge.is-red {
  background: #ffe6ea;
  border-color: #f2bbc5;
  color: #8b2e43;
}

.wine-type-badge.is-rose {
  background: #ffeef4;
  border-color: #f2cbdd;
  color: #8f4366;
}

.wine-type-badge.is-sparkling-white {
  background: #eaf4ff;
  border-color: #c5dbf7;
  color: #25568f;
}

.wine-type-badge.is-sparkling-rose {
  background: #f5ecff;
  border-color: #d8c5f7;
  color: #5c3f8f;
}

.wine-type-badge.is-sparkling-red {
  background: #ffe8eb;
  border-color: #efbfc8;
  color: #8b2e43;
}

.wine-type-badge.is-unknown {
  background: #f1f3f7;
  border-color: #d6dbe5;
  color: #5a6576;
}

.customer-order-item-meta {
  display: flex;
  gap: 8px;
  color: #67727e;
  font-size: 12px;
}

.customer-order-item-head.single-line {
  align-items: center;
}

@media (max-width: 1360px) {
  .panel-card {
    padding: 16px;
    gap: 12px;
  }

  .panel-header h1 {
    font-size: 30px;
  }

  .order-grid {
    grid-template-columns: 1.2fr 0.8fr 1.45fr 0.8fr 0.9fr;
  }

  .order-grid-customer {
    grid-template-columns: 1.45fr 0.85fr 0.95fr;
  }

  .order-dialog {
    max-width: min(1140px, calc(100vw - 18px));
    width: 1140px;
  }

  .order-dialog .order-dialog-head h3 {
    font-size: 30px;
  }

  .order-item-line {
    grid-template-columns: minmax(100px, 0.85fr) minmax(180px, 1.65fr) minmax(100px, 0.7fr) minmax(140px, 0.9fr);
  }

  .customer-grid {
    grid-template-columns: 1.45fr 0.95fr 0.9fr 0.65fr 0.75fr;
  }

  .wine-grid {
    grid-template-columns: 0.85fr 1.2fr 0.9fr 1.2fr 0.65fr 0.65fr 0.5fr;
  }
}

@media (max-width: 1120px) {
  .page {
    padding: 0;
  }

  .shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .sidebar {
    grid-template-rows: auto auto auto auto;
    border-right: 0;
    border-bottom: 1px solid rgba(212, 214, 223, 0.8);
    gap: 12px;
  }

  .sidebar-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-item {
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    min-height: 58px;
    padding: 8px;
    font-size: 12px;
  }

  .nav-item-icon {
    width: auto;
  }

  .content {
    padding: 12px;
  }

  .topbar {
    height: auto;
    min-height: 60px;
    padding: 10px 12px;
    flex-wrap: wrap;
  }

  .panel-card {
    min-height: auto;
  }

  .orders-mode-row {
    align-items: stretch;
  }

  .orders-mode-switch {
    width: 100%;
  }

  .orders-mode-btn {
    flex: 1;
  }

  .data-table {
    overflow-x: auto;
  }

  .table-head,
  .table-row {
    min-width: 980px;
  }

  .customer-orders-layout #orders-panel-header {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .customer-orders-layout #orders-panel-header .search-box {
    width: 100%;
  }

  .table-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  #orders-panel-toolbar {
    flex-wrap: wrap;
  }

  #orders-panel-toolbar .search-box {
    flex: 1 1 100%;
    max-width: none;
  }
}

/* Extended functional UI: messages + CRUD dialogs */
.nav-item {
  position: relative;
}

.nav-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: #d85252;
  border: 1px solid rgba(255, 255, 255, 0.55);
}

.toolbar-btn.primary {
  color: #fff;
  border-color: rgba(188, 135, 76, 0.75);
  background: linear-gradient(180deg, #d0a068, #bc874c);
}

.toolbar-btn.primary:hover {
  background: linear-gradient(180deg, #d5a86f, #c08c50);
}

.panel-toolbar {
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

#orders-panel-toolbar {
  justify-content: flex-start;
  align-items: center;
  flex-wrap: nowrap;
  gap: 10px;
}

#orders-panel-toolbar .orders-mode-row {
  flex: 0 0 auto;
}

#orders-panel-toolbar .toolbar-actions {
  margin-left: auto;
  flex: 0 0 auto;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.customer-grid {
  grid-template-columns: 1.35fr 0.95fr 0.9fr 0.62fr 0.7fr;
}

.wine-grid {
  grid-template-columns: 0.8fr 1.15fr 0.8fr 1.15fr 0.65fr 0.62fr 0.5fr 0.72fr;
}

.cell-actions {
  overflow: visible;
}

.inline-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  min-height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: #8e2d2d;
  background: #ffe9e9;
  border: 1px solid #f2c8c8;
}

.messages-panel-card {
  grid-template-rows: auto 1fr;
}

.customer-messages-card {
  grid-template-rows: auto 1fr;
}

.customer-thread-panel {
  min-height: calc(100vh - 36px - 44px - 72px - 28px - 44px);
}

.messages-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 14px;
}

.messages-customers-panel,
.messages-thread-panel {
  border: 1px solid rgba(210, 213, 223, 0.95);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.65);
  min-height: 0;
}

.messages-customers-panel {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 10px;
  padding: 12px;
}

.messages-panel-head {
  font-weight: 700;
  padding: 4px 2px 0;
}

.messages-search-box {
  width: 100%;
}

.messages-customers-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 8px;
}

.message-customer-item {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(214, 217, 227, 0.95);
  background: rgba(255, 255, 255, 0.7);
  border-radius: 12px;
  padding: 8px 10px;
  display: block;
}

.message-customer-item:hover {
  background: rgba(255, 255, 255, 0.92);
}

.message-customer-item.active {
  border-color: rgba(196, 154, 97, 0.6);
  background: rgba(246, 237, 223, 0.55);
}

.message-customer-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.message-customer-title {
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-unread-badge {
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: #d85252;
}

.message-customer-preview,
.message-customer-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.message-customer-preview {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.messages-thread-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
}

.messages-thread-head {
  padding: 14px 14px 10px;
  border-bottom: 1px solid rgba(218, 221, 230, 0.95);
}

.messages-thread-title {
  font-weight: 700;
  font-size: 18px;
}

.messages-thread-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.messages-thread-body {
  min-height: 0;
  overflow: auto;
  padding: 12px;
  display: grid;
  align-content: start;
  gap: 10px;
}

.message-row {
  display: flex;
}

.message-row.is-admin {
  justify-content: flex-end;
}

.message-row.is-customer {
  justify-content: flex-start;
}

.message-bubble {
  max-width: min(78%, 680px);
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(215, 218, 228, 0.95);
  background: rgba(255, 255, 255, 0.92);
}

.message-row.is-admin .message-bubble {
  background: rgba(244, 234, 218, 0.75);
  border-color: rgba(220, 198, 164, 0.9);
}

.message-meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.message-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.messages-form {
  border-top: 1px solid rgba(218, 221, 230, 0.95);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.messages-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px 12px;
}

.messages-form textarea:disabled {
  background: rgba(244, 245, 250, 0.8);
}

.messages-form-actions {
  display: flex;
  justify-content: flex-end;
}

.entity-dialog {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: min(840px, calc(100vw - 24px));
  width: 840px;
}

#customer-dialog.entity-dialog {
  max-width: min(980px, calc(100vw - 24px));
  width: 980px;
}

.entity-dialog.customer-wine-card-dialog {
  width: min(1760px, calc(100vw - 12px));
  max-width: min(1760px, calc(100vw - 12px));
}

#order-item-picker-dialog.entity-dialog {
  width: min(1040px, calc(100vw - 80px));
  max-width: min(1040px, calc(100vw - 80px));
}

.entity-dialog.customer-history-dialog {
  width: min(1500px, calc(100vw - 24px));
  max-width: min(1500px, calc(100vw - 24px));
}

.entity-dialog::backdrop {
  background: rgba(18, 20, 30, 0.35);
  backdrop-filter: blur(2px);
}

.entity-dialog-card {
  border: 1px solid rgba(208, 212, 223, 0.92);
  background: rgba(249, 249, 252, 0.98);
  border-radius: 18px;
  padding: 18px;
  display: grid;
  gap: 14px;
  box-shadow: 0 20px 42px rgba(17, 19, 29, 0.18);
}

.entity-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.entity-form-grid label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.entity-form-grid label.full {
  grid-column: 1 / -1;
}

.entity-form-grid > .full {
  grid-column: 1 / -1;
}

.customer-history-dialog-card {
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  max-height: min(90vh, 980px);
}

.customer-history-toolbar {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 180px 230px;
  gap: 10px;
  align-items: end;
}

.customer-history-toolbar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.customer-history-list {
  min-height: 320px;
}

.customer-history-table {
  height: min(58vh, 620px);
}

.customer-history-table .table-head,
.customer-history-table .table-row {
  min-width: 0;
}

.customer-history-grid {
  grid-template-columns: 150px 180px 220px 180px 1fr;
}

.customer-history-row {
  cursor: pointer;
}

.customer-history-row:focus-visible {
  outline: 2px solid rgba(188, 135, 76, 0.45);
  outline-offset: -2px;
}

.customer-history-row .cell-created {
  font-size: 13px;
}

.customer-history-items {
  white-space: normal;
  overflow: hidden;
  text-overflow: clip;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.25;
}

.customer-meta-row {
  display: grid;
  gap: 12px;
}

.customer-meta-row-top {
  grid-template-columns: minmax(280px, 1fr) 150px 110px;
}

.customer-meta-row-top > label:nth-child(2),
.customer-meta-row-top > label:nth-child(3) {
  justify-self: start;
  width: 100%;
}

.customer-meta-row-top > label:nth-child(2) {
  max-width: 150px;
}

.customer-meta-row-top > label:nth-child(3) {
  max-width: 110px;
}

#customer-form input[name='operationNumber'] {
  max-width: 150px;
}

#customer-form input[name='estimatedServiceMinutes'] {
  max-width: 110px;
}

.customer-meta-row-second,
.customer-meta-row-third {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.customer-meta-row-fourth {
  grid-template-columns: 1fr;
}

.wine-type-fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  gap: 6px;
}

.wine-type-fieldset legend {
  padding: 0;
  font-size: 13px;
  color: var(--muted);
}

.wine-type-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.wine-type-option {
  position: relative;
}

.wine-type-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.wine-type-option span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(204, 209, 222, 0.95);
  border-radius: 999px;
  background: #fff;
  color: #4c5560;
  padding: 0 12px;
  min-height: 32px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.wine-type-option input:checked + span {
  background: #eef3ff;
  border-color: #ccdbff;
  color: #3f5294;
}

.entity-form-grid input,
.entity-form-grid select,
.entity-form-grid textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px 12px;
}

.customer-wine-card-dialog-card {
  width: 100%;
  max-height: calc(100vh - 12px);
  min-height: min(860px, calc(100vh - 12px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.customer-wine-card-toolbar {
  display: grid;
  grid-template-columns: minmax(320px, 560px) 1fr;
  align-items: center;
  gap: 10px;
}

.customer-wine-card-toolbar input {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  height: 42px;
  padding: 0 12px;
}

.customer-wine-card-toolbar .muted {
  justify-self: end;
  margin: 0;
}

.customer-wine-card-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
}

.customer-wine-card-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
}

.customer-wine-card-panel-head {
  font-size: 13px;
  font-weight: 700;
  color: #4f5968;
}

.customer-wine-card-list {
  border: 1px solid rgba(218, 221, 230, 0.95);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  overflow: auto;
  min-height: 0;
  max-height: none;
}

.customer-wine-card-row {
  display: grid;
  grid-template-columns: minmax(90px, 0.9fr) minmax(160px, 1.7fr) minmax(70px, 0.65fr) minmax(92px, 0.65fr);
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 5px 10px;
  border-bottom: 1px solid rgba(223, 225, 233, 0.95);
}

.customer-wine-card-row.is-selected {
  grid-template-columns: minmax(90px, 0.9fr) minmax(160px, 1.65fr) minmax(86px, 0.8fr) minmax(96px, 0.95fr) minmax(92px, 0.65fr);
}

.customer-wine-card-row:last-child {
  border-bottom: 0;
}

.customer-wine-card-head {
  background: rgba(245, 247, 251, 0.92);
  font-size: 12px;
  font-weight: 700;
  color: #5d6674;
}

.customer-wine-card-row .code {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.customer-wine-card-row .name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-wine-card-row .dryness {
  color: #566071;
}

.customer-wine-card-row .type {
  display: flex;
  align-items: center;
}

.customer-wine-card-row .price-wrap input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  height: 32px;
  padding: 0 10px;
}

.customer-wine-card-row .actions {
  display: flex;
  justify-content: flex-end;
}

.toolbar-btn.mini,
.secondary.mini {
  min-height: 30px;
  height: 30px;
  padding: 0 10px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 600;
}

.secondary.mini {
  border: 1px solid rgba(211, 214, 224, 0.95);
  background: rgba(255, 255, 255, 0.86);
}

.customer-doc-types-field {
  margin: 0;
  border: 1px solid rgba(219, 222, 230, 0.95);
  border-radius: 10px;
  padding: 10px;
  width: 100%;
  grid-column: 1 / -1;
  box-sizing: border-box;
}

.customer-doc-types-field legend {
  padding: 0 6px;
  font-size: 13px;
  color: #525a68;
}

.customer-doc-types-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  width: 100%;
  align-items: flex-start;
}

.customer-doc-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  border: 1px solid rgba(214, 217, 227, 0.95);
  border-radius: 9px;
  padding: 4px 8px;
  background: #fff;
  font-size: 12px;
  line-height: 1.2;
  color: #444c5a;
  flex: 0 1 auto;
  max-width: 100%;
  white-space: nowrap;
}

.customer-doc-option-code {
  font-weight: 700;
}

.customer-doc-option input {
  margin: 0;
}

.settings-panel-card {
  grid-template-rows: auto 1fr;
}

.settings-sections {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 12px;
}

.settings-card {
  border: 1px solid rgba(210, 213, 223, 0.95);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.settings-card h2 {
  margin: 0;
  font-size: 21px;
}

.settings-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.settings-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.settings-fields label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.settings-fields label.full {
  grid-column: 1 / -1;
}

.settings-fields input,
.settings-fields textarea,
.settings-doc-type-row input:not([type="checkbox"]) {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 9px 10px;
}

.settings-fields textarea {
  resize: vertical;
}

.settings-weekdays-field {
  margin: 0;
  border: 1px solid rgba(219, 222, 230, 0.95);
  border-radius: 10px;
  padding: 10px;
}

.settings-weekdays-field legend {
  padding: 0 6px;
  font-size: 13px;
  color: #4f5662;
}

.settings-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.settings-weekdays label {
  min-height: 34px;
  border: 1px solid rgba(214, 217, 227, 0.95);
  border-radius: 10px;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  color: #4d5562;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.settings-actions.split {
  justify-content: space-between;
}

.settings-employee-perms {
  margin: 0;
  border: 1px solid rgba(219, 222, 230, 0.95);
  border-radius: 10px;
  padding: 10px;
}

.settings-employee-perms legend {
  padding: 0 6px;
  font-size: 13px;
  color: #4f5662;
}

.settings-employee-perm-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 110px;
  gap: 6px 8px;
  align-items: center;
}

.settings-employee-perm-head {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.settings-employee-perm-label {
  min-height: 30px;
  border: 1px solid rgba(214, 217, 227, 0.95);
  border-radius: 9px;
  background: #fff;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  font-size: 13px;
  color: #4d5562;
}

.settings-employee-perm-check {
  min-height: 30px;
  border: 1px solid rgba(214, 217, 227, 0.95);
  border-radius: 9px;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.settings-employees-list {
  display: grid;
  gap: 6px;
}

.settings-employee-row {
  border: 1px solid rgba(214, 217, 227, 0.95);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.85);
  padding: 8px 10px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.settings-employee-row.is-selected {
  border-color: rgba(196, 154, 97, 0.75);
  box-shadow: inset 0 0 0 1px rgba(196, 154, 97, 0.3);
}

.settings-employee-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.settings-employee-title {
  font-weight: 700;
  font-size: 14px;
}

.settings-employee-meta {
  color: var(--muted);
  font-size: 12px;
}

.settings-employee-right {
  display: inline-flex;
  gap: 8px;
}

.settings-doc-types-head {
  overflow: hidden;
}

.settings-doc-types-labels,
.settings-doc-type-main {
  display: grid;
  grid-template-columns: 120px minmax(260px, 1fr) 88px 50px;
  gap: 8px;
  align-items: center;
}

.settings-doc-types-labels {
  color: #5f6474;
  font-size: 12px;
  font-weight: 700;
  padding: 0 0 2px;
}

.settings-doc-types-list {
  display: grid;
  gap: 8px;
}

.settings-doc-type-row {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(219, 222, 230, 0.95);
  border-radius: 10px;
  background: #fff;
}

.settings-doc-type-advanced {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  padding-top: 2px;
  align-items: center;
}

.settings-doc-type-advanced input[type="text"] {
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  font-size: 14px;
}

.settings-doc-type-advanced label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #5f6474;
  font-size: 12px;
  min-height: 34px;
}

.settings-doc-col-1 {
  grid-column: span 1;
}

.settings-doc-col-2 {
  grid-column: span 2;
}

.settings-doc-col-3 {
  grid-column: span 3;
}

.settings-doc-type-active {
  display: inline-flex;
  justify-content: center;
}

.settings-doc-type-active input {
  width: 18px;
  height: 18px;
}

.settings-doc-remove-btn {
  width: 36px;
  height: 36px;
}

@media (max-width: 1360px) {
  .customer-grid {
    grid-template-columns: 1.25fr 0.88fr 0.85fr 0.58fr 0.64fr;
  }

  .wine-grid {
    grid-template-columns: 0.74fr 1.02fr 0.76fr 1.02fr 0.58fr 0.56fr 0.46fr 0.68fr;
  }
}

@media (max-width: 1200px) {
  .customer-meta-row-top,
  .customer-meta-row-second,
  .customer-meta-row-third {
    grid-template-columns: 1fr;
  }

  .messages-layout {
    grid-template-columns: 1fr;
  }

  .messages-customers-panel {
    max-height: 300px;
  }
}

@media (max-width: 1120px) {
  .panel-toolbar {
    align-items: stretch;
  }

  .toolbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .messages-layout {
    grid-template-columns: 1fr;
  }

  .messages-thread-panel {
    min-height: 420px;
  }

  .entity-form-grid {
    grid-template-columns: 1fr;
  }

  .entity-form-grid label.full {
    grid-column: auto;
  }

  .settings-fields {
    grid-template-columns: 1fr;
  }

  .settings-fields label.full {
    grid-column: auto;
  }

  .settings-weekdays {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .settings-employee-perm-grid {
    grid-template-columns: minmax(0, 1fr) 90px 90px;
  }

  .settings-doc-types-labels {
    display: none;
  }

  .settings-doc-type-main,
  .settings-doc-type-row,
  .settings-doc-type-advanced {
    grid-template-columns: 1fr;
  }

  .settings-doc-col-1,
  .settings-doc-col-2,
  .settings-doc-col-3 {
    grid-column: auto;
  }

  .settings-doc-type-active {
    justify-content: flex-start;
  }

  .settings-actions.split {
    flex-direction: column;
    align-items: stretch;
  }

  .settings-employee-row {
    grid-template-columns: 1fr;
  }

  .settings-employee-right {
    justify-content: flex-start;
  }

  .table-head,
  .table-row {
    min-width: 1160px;
  }

  .customer-order-grid {
    grid-template-columns: 1fr;
  }

  .customer-order-grid label.full {
    grid-column: auto;
  }

  .customer-catalog-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .order-dialog {
    max-width: calc(100vw - 12px);
    width: calc(100vw - 12px);
  }

  .order-dialog-card {
    padding: 14px;
    max-height: 94vh;
  }

  .order-dialog-grid {
    grid-template-columns: 1fr;
  }

  .order-dialog-top-row {
    grid-template-columns: 1fr;
  }

  .order-dialog-left-pair {
    grid-template-columns: 1fr;
  }

  .order-dialog-notes-row {
    grid-template-columns: 1fr;
  }

  .order-dialog-grid label.half {
    grid-column: auto;
  }

  .order-dialog .order-dialog-head h3 {
    font-size: 28px;
  }

  .order-date-btn {
    min-width: 170px;
  }

  .order-item-line {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .order-dialog-customer-extra {
    grid-template-columns: 1fr;
  }

  .customer-wine-card-toolbar {
    grid-template-columns: 1fr;
  }

  .customer-wine-card-toolbar .muted {
    justify-self: start;
  }

  .customer-wine-card-columns {
    grid-template-columns: 1fr;
  }

  .customer-wine-card-row {
    grid-template-columns: minmax(110px, 1fr) minmax(130px, 1.5fr) minmax(84px, 0.7fr) minmax(88px, 0.7fr);
    gap: 8px;
    padding: 6px 8px;
  }

  .customer-wine-card-row.is-selected {
    grid-template-columns: minmax(110px, 1fr) minmax(130px, 1.4fr) minmax(84px, 0.7fr) minmax(110px, 0.8fr) minmax(88px, 0.7fr);
  }

  .customer-doc-types-list {
    grid-template-columns: 1fr;
  }
}

/* Final table density/layout overrides */
.table-head {
  min-height: 0 !important;
}

.table-head > div {
  padding-top: 7px !important;
  padding-bottom: 7px !important;
  line-height: 1.15;
}

.table-row {
  min-height: 0 !important;
}

.table-row .cell {
  padding-top: 5px !important;
  padding-bottom: 5px !important;
  line-height: 1.15;
}

.table-row.customer-grid .stack-sub {
  margin-top: 0;
}

.order-section-row,
.order-date-row {
  min-height: 0 !important;
  padding-top: 4px !important;
  padding-bottom: 4px !important;
}

.cell-created {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  line-height: 1.1;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  flex-wrap: nowrap;
}

.cell-created span {
  white-space: nowrap;
}

@media (max-width: 1360px) {
  .wine-grid {
    grid-template-columns: 0.9fr 1.5fr 0.8fr 0.8fr;
  }
}

@media (max-width: 1120px) {
  .table-head > div {
    padding-top: 6px !important;
    padding-bottom: 6px !important;
  }

  .table-row .cell {
    padding-top: 4px !important;
    padding-bottom: 4px !important;
  }

  .cell-created {
    flex-wrap: wrap;
    gap: 2px;
  }
}

/* Final wines table column sizing */
.table-head.wine-grid,
.table-row.wine-grid {
  grid-template-columns: minmax(160px, 1.25fr) minmax(360px, 3.2fr) minmax(110px, 0.8fr) minmax(110px, 0.8fr) !important;
}

.table-row.wine-grid .cell {
  line-height: 1.2;
}

.table-row.wine-grid .cell:nth-child(2) {
  white-space: normal;
  overflow: hidden;
  text-overflow: clip;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.2;
}

@media (max-width: 1360px) {
  .table-head.wine-grid,
  .table-row.wine-grid {
    grid-template-columns: minmax(150px, 1.2fr) minmax(280px, 2.8fr) minmax(100px, 0.8fr) minmax(100px, 0.8fr) !important;
  }
}

@media (max-width: 1120px) {
  .customer-history-toolbar {
    grid-template-columns: 1fr;
  }

  .customer-history-table {
    height: min(60vh, 560px);
  }

  .customer-history-grid {
    grid-template-columns: 130px 150px 170px 150px minmax(280px, 1fr);
  }
}
