:root {
  --blue: #0058a3;
  --yellow: #fecb00;
  --ink: #121212;
  --ink-soft: #4d4d4d;
  --panel: #ffffff;
  --panel-alt: #f6f7f9;
  --border: #d7dbe2;
  --radius: 16px;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.08);
  --right-column-width: 420px;
  --palette-dock-height: 180px;
  --palette-dock-collapsed-height: 88px;
  --palette-dock-list-height: 110px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: var(--palette-dock-height);
  overflow-x: hidden;
  font-family: "Assistant", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 10% 10%, #fff8d1 0%, transparent 35%),
    radial-gradient(circle at 90% 0%, #dbe9ff 0%, transparent 40%),
    linear-gradient(135deg, #f3f4f7 0%, #ffffff 45%, #f1f3f6 100%);
}

body.palette-collapsed {
  padding-bottom: var(--palette-dock-collapsed-height);
}

body.modal-open {
  overflow: hidden;
}

body.is-resizing-palette {
  cursor: ns-resize;
  user-select: none;
}

body.is-module-reordering,
body.is-module-reordering * {
  cursor: grabbing !important;
}

body[data-bank-mode="SingleSided"] .bank-side[data-side="B"] {
  display: none;
}

.app {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px;
}

.app-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: fade-up 0.6s ease both;
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--yellow), #ffd84e);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.08);
}

.brand-title {
  font-size: 20px;
  font-weight: 700;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--ink-soft);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--right-column-width);
  gap: 20px;
  margin-top: 20px;
  align-items: stretch;
  min-width: 0;
}

.layout > * {
  min-width: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  animation: fade-up 0.7s ease both;
}

.panel h2,
.panel h3 {
  margin: 0;
}

.panel h2 {
  font-size: 18px;
  font-weight: 700;
}

.panel h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
}

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

.message {
  min-height: 24px;
  margin-top: 12px;
  padding: 0 4px;
  font-size: 13px;
  color: var(--blue);
}

.message.error {
  color: #b42318;
}

.message.warn {
  color: #b54708;
}

.filter-info {
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-soft);
}

.palette-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.palette-bottom {
  grid-column: 1 / -1;
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 12px;
  width: auto;
  max-width: none;
  z-index: 40;
  padding: 10px 14px;
}

.palette-resizer {
  height: 10px;
  margin: -2px 0 6px;
  border-radius: 999px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0.1));
  cursor: ns-resize;
}

.palette-bottom.is-collapsed {
  padding-bottom: 14px;
}

.palette-bottom.is-collapsed .palette-resizer,
.palette-bottom.is-collapsed .filter-info,
.palette-bottom.is-collapsed .palette-list {
  display: none;
}

.palette .palette-list {
  grid-auto-flow: column;
  grid-auto-columns: minmax(240px, 260px);
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 6px;
}

.palette-bottom .palette-list {
  margin-top: 8px;
  grid-auto-columns: max-content;
  height: var(--palette-dock-list-height);
  min-height: 56px;
  align-items: start;
}

.palette-bottom .palette-item {
  width: max-content;
  min-width: 150px;
  min-height: 0;
  padding: 8px;
  gap: 8px;
  grid-template-columns: var(--preview-width, 48px) minmax(120px, max-content);
  align-content: start;
}

.palette-bottom .palette-preview {
  max-width: none;
  max-height: none;
}

.palette-bottom .palette-details {
  gap: 4px;
}

.palette-bottom .palette-item .palette-meta:last-child {
  display: none;
}

.palette-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--panel-alt);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  cursor: grab;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.palette-item.is-disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.palette-item:active {
  cursor: grabbing;
}

.palette-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.08);
}

.palette-item.is-disabled:hover {
  transform: none;
  box-shadow: none;
}

.palette-preview {
  width: var(--preview-width, 48px);
  height: var(--preview-height, 48px);
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.palette-item.is-disabled .palette-preview {
  border-style: dashed;
}

.palette-details {
  display: grid;
  gap: 6px;
}

.palette-item .palette-title {
  font-weight: 600;
}

.palette-item .palette-meta {
  font-size: 12px;
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
}

.bank {
  min-height: 500px;
  min-width: 0;
  overflow: hidden;
}

.bank-controls {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(200px, 1fr));
  gap: 12px;
  align-items: end;
}

.empty-state {
  margin-top: 16px;
  padding: 18px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.7);
}

.bank-grids {
  display: grid;
  gap: 20px;
  margin-top: 16px;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.bank-side {
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.bank-grid {
  display: flex;
  gap: 16px;
  align-items: start;
  overflow-x: scroll;
  overflow-y: hidden;
  padding-bottom: 10px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  flex-wrap: nowrap;
  scrollbar-gutter: stable both-edges;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: #aeb6c5 #e9edf3;
}

.bank-grid::-webkit-scrollbar {
  height: 12px;
}

.bank-grid::-webkit-scrollbar-track {
  background: #e9edf3;
  border-radius: 999px;
}

.bank-grid::-webkit-scrollbar-thumb {
  background: #aeb6c5;
  border-radius: 999px;
  border: 2px solid #e9edf3;
}

.bank-grid::-webkit-scrollbar-thumb:hover {
  background: #8f99aa;
}

.bank-side[data-side="B"] .bank-grid {
  padding-bottom: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.bank-side[data-side="B"] .bank-grid::-webkit-scrollbar {
  display: none;
}

.module-column {
  display: grid;
  gap: 10px;
  flex: 0 0 auto;
  width: var(--column-width, auto);
  min-width: 0;
}

.module-reorder-slot {
  display: none;
  width: 22px;
  align-items: stretch;
  justify-content: center;
  position: relative;
  flex: 0 0 auto;
}

body.is-module-reordering .module-reorder-slot {
  display: flex;
  pointer-events: all;
}

.module-reorder-slot::before {
  content: "";
  width: 2px;
  background: var(--border);
  border-radius: 999px;
  margin: 6px 0;
  flex: 1;
}

.module-reorder-slot span {
  position: absolute;
  top: 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--ink-soft);
}

.module-reorder-slot.is-drop-target::before {
  background: var(--yellow);
}

.module-reorder-slot.is-drop-target span {
  border-color: var(--yellow);
  color: var(--ink);
}

.module-header {
  background: var(--panel-alt);
  border-radius: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  display: grid;
  gap: 4px;
  min-width: 0;
}

.module-title {
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
  overflow-wrap: anywhere;
}

.module-drag-handle {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--ink-soft);
}

.module-reorder-button {
  font-family: inherit;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  cursor: grab;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  box-shadow: none;
  transition: none;
}

.module-reorder-button:hover {
  transform: none;
}

.module-reorder-button:active {
  cursor: grabbing;
}

.module-reorder-ghost {
  position: fixed;
  top: 0;
  left: 0;
  transform: translate(-9999px, -9999px);
  pointer-events: none;
  z-index: 120;
  border-radius: 12px;
  border: 1px solid #aeb6c5;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.16);
  overflow: hidden;
}

.module-reorder-ghost-header {
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
  border-bottom: 1px solid #d7dbe2;
  background: rgba(246, 247, 249, 0.95);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.module-reorder-ghost-body {
  height: calc(100% - 36px);
  display: grid;
  place-items: center;
  padding: 4px;
  background: rgba(248, 249, 251, 0.92);
}

.module-reorder-ghost-preview {
  position: relative;
}

.module-reorder-ghost-side {
  position: absolute;
  border-radius: 8px;
  border: 1px solid #c9d0dc;
  background-color: #f0f2f5;
  background-image: linear-gradient(rgba(0, 0, 0, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
  background-size: var(--ghost-grid-x, 16px) var(--ghost-grid-y, 16px);
  overflow: hidden;
}

.module-reorder-ghost-placement {
  position: absolute;
  border-radius: 4px;
  box-sizing: border-box;
}

.module-reorder-ghost-empty {
  width: 100%;
  height: 100%;
}

.module-width {
  font-size: 12px;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

.module-column.is-default-module .module-header {
  border-color: var(--yellow);
  box-shadow: 0 0 0 2px rgba(254, 203, 0, 0.2);
}

.module-canvas.is-locked {
  border-style: dashed;
  background-color: #f5f6f8;
}

.module-meta {
  font-size: 12px;
  color: var(--ink-soft);
}

.module-canvas {
  width: var(--module-width, 240px);
  height: var(--module-height, 320px);
  position: relative;
  box-sizing: content-box;
  border-radius: 12px;
  border: 2px solid var(--border);
  background-color: #f0f2f5;
  background-image: linear-gradient(rgba(0, 0, 0, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
  background-size: var(--grid-x, 24px) var(--grid-y, 24px);
  overflow: hidden;
}

.module-canvas.drag-over {
  border-color: var(--yellow);
  box-shadow: 0 0 0 2px rgba(254, 203, 0, 0.25);
}

.blocked-rect {
  position: absolute;
  border-radius: 8px;
  border: 1px dashed rgba(0, 0, 0, 0.2);
  background: rgba(0, 0, 0, 0.08);
  z-index: 1;
  pointer-events: none;
}

.module-status {
  font-size: 12px;
  color: #b54708;
  margin-top: 2px;
}

.drag-ghost {
  position: absolute;
  top: -9999px;
  left: -9999px;
  box-sizing: border-box;
  border-radius: 10px;
  border: 2px solid var(--ghost-border, rgba(0, 0, 0, 0.55));
  background: var(--ghost-fill, rgba(232, 235, 240, 0.35));
  pointer-events: none;
}

.drag-footprint {
  position: absolute;
  border-radius: 8px;
  border: 2px solid rgba(0, 0, 0, 0.78);
  background: rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
  pointer-events: none;
  z-index: 8;
}

.drag-footprint.is-invalid {
  border-color: #b42318;
  background: rgba(180, 35, 24, 0.12);
  box-shadow: none;
}

.locker-card {
  position: absolute;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--locker-color, #e8ebf0);
  color: var(--locker-text-color, var(--ink));
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 4px;
  cursor: grab;
  overflow: hidden;
}

.locker-card.is-locked {
  cursor: not-allowed;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.12);
}

.placement-card {
  z-index: 2;
}

.locker-card:active {
  cursor: grabbing;
}

.locker-name {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.locker-meta {
  font-size: 11px;
  color: var(--locker-meta-color, var(--ink-soft));
  display: flex;
  justify-content: space-between;
}

.locker-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-top: auto;
  min-width: 0;
}

.depth-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--locker-badge-bg, rgba(0, 0, 0, 0.08));
  color: var(--locker-action-color, var(--ink));
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.depth-badge.locked {
  background: rgba(0, 0, 0, 0.18);
}

.placement-card .depth-badge.is-double {
  background: #101418;
  color: #ffffff;
}

.locker-actions button {
  border: none;
  background: var(--locker-action-bg, rgba(0, 0, 0, 0.08));
  color: var(--locker-action-color, var(--ink));
  border-radius: 8px;
  padding: 2px 6px;
  font-size: 10px;
  line-height: 1.1;
  white-space: nowrap;
  cursor: pointer;
}

.locker-card.is-compact .locker-name {
  font-size: 10px;
}

.locker-card.is-tiny .locker-name {
  display: none;
}

.locker-card.is-tiny .locker-actions {
  gap: 2px;
}

.locker-card.is-tiny .depth-badge {
  font-size: 8px;
  padding: 1px 4px;
}

.locker-card.is-tiny .locker-actions button {
  font-size: 8px;
  padding: 1px 4px;
  border-radius: 6px;
}

.right-column {
  display: grid;
  gap: 18px;
  align-content: start;
  min-width: 0;
  align-self: stretch;
}

.sidebar-section {
  display: grid;
  gap: 10px;
}

.quote-panel {
  position: sticky;
  top: 14px;
  z-index: 4;
}

.field {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.field input,
.field select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-family: inherit;
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  font-family: inherit;
  padding: 8px 12px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button.primary {
  background: var(--blue);
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(0, 88, 163, 0.2);
}

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink);
}

button:hover {
  transform: translateY(-1px);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.properties-content {
  min-height: 80px;
  padding: 12px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: var(--panel-alt);
  font-size: 13px;
}

.properties-content .properties-grid {
  display: grid;
  gap: 10px;
}

.properties-content .properties-title {
  font-weight: 600;
}

.trash-zone {
  padding: 12px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  color: var(--ink-soft);
  text-align: center;
}

.trash-zone.drag-over {
  border-color: #b42318;
  color: #b42318;
}

.pricing-summary {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.pricing-row {
  display: flex;
  justify-content: space-between;
}

.pricing-total {
  font-weight: 700;
  font-size: 15px;
  margin-top: 6px;
}

.quotes-list {
  display: grid;
  gap: 8px;
  font-size: 13px;
}

.quote-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: grid;
  gap: 6px;
}

.quote-actions {
  display: flex;
  gap: 8px;
}

.admin {
  margin-top: 20px;
}

.admin summary {
  font-weight: 600;
  cursor: pointer;
}

.admin-content {
  margin-top: 12px;
  display: grid;
  gap: 12px;
  font-size: 13px;
}

.admin-section {
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel-alt);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.admin-default-layout {
  display: grid;
  grid-template-columns: minmax(200px, 260px) 1fr;
  gap: 16px;
  align-items: start;
}

.admin-default-bank {
  display: grid;
  gap: 8px;
}

.admin-default-palette .palette-list {
  max-height: 360px;
  overflow-y: auto;
}

.admin-subtitle {
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.admin-grids .bank-grid {
  gap: 12px;
}

.admin-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.file-input {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-alt);
  font-size: 12px;
  cursor: pointer;
}

.file-input input {
  display: block;
  margin-top: 6px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(0, 0, 0, 0.36);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(420px, calc(100vw - 40px));
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
  display: grid;
  gap: 10px;
}

.preview-modal-card {
  width: min(1200px, calc(100vw - 48px));
}

.locker-preview-content {
  background: #f8f9fb;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  overflow: auto;
  max-height: calc(100vh - 200px);
}

.locker-preview-svg {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
}

.locker-preview-actions {
  justify-content: flex-end;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .bank-controls {
    grid-template-columns: 1fr;
  }

  .right-column {
    order: 3;
  }

  .quote-panel {
    position: static;
  }

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

@media (max-width: 700px) {
  .app {
    padding: 16px;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .palette-bottom {
    left: 8px;
    right: 8px;
    width: auto;
    bottom: 8px;
  }

  body {
    padding-bottom: var(--palette-dock-height);
  }

  body.palette-collapsed {
    padding-bottom: var(--palette-dock-collapsed-height);
  }
}
