:root {
  --ink: #12212f;
  --muted: #6d7885;
  --panel: rgba(255, 255, 255, 0.88);
  --line: rgba(18, 33, 47, 0.12);
  --accent: #0f766e;
  --accent-2: #d97706;
  --bg-a: #f5f1e8;
  --bg-b: #dce8df;
}

body {
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, rgba(217, 119, 6, 0.18), transparent 28rem),
    radial-gradient(circle at 85% 5%, rgba(15, 118, 110, 0.2), transparent 26rem),
    linear-gradient(135deg, var(--bg-a), var(--bg-b));
  font-family: "Avenir Next", "Segoe UI", "PingFang SC", sans-serif;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 28px 20px;
  background: rgba(18, 33, 47, 0.94);
  color: #fff;
}

.brand {
  margin-bottom: 28px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.sidebar .nav-link {
  margin: 4px 0 4px 10px;
  border-radius: 14px;
  color: rgba(255, 255, 255, 0.76);
}

.nav-group {
  margin: 16px 0;
}

.nav-group-title {
  color: rgba(255, 255, 255, 0.46);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 0 10px 4px;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.content {
  padding: 30px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding: 22px 26px;
  border-radius: 28px;
  color: #fff;
  background: linear-gradient(135deg, #12343b, #0f766e 56%, #d97706);
  box-shadow: 0 18px 40px rgba(18, 33, 47, 0.22);
}

.topbar h1 {
  margin: 0;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #d97706;
}

.topbar .eyebrow {
  color: rgba(255, 255, 255, 0.78);
}

.panel,
.login-card,
.cashier-card {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: 0 20px 60px rgba(18, 33, 47, 0.12);
  backdrop-filter: blur(18px);
}

.panel {
  padding: 24px;
}

.login-page,
.cashier-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card,
.cashier-card {
  width: min(460px, 100%);
  padding: 34px;
}

.captcha-row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 12px;
  align-items: center;
}

.captcha-image {
  width: 120px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  cursor: pointer;
}

#specialArea .poster-drop {
  display: grid;
  place-items: center;
  min-height: 240px;
  border: 2px dashed rgba(15, 118, 110, 0.36);
  border-radius: 24px;
  background: rgba(15, 118, 110, 0.06);
}

#chart {
  height: 360px;
}

.form-section-title {
  margin-top: 6px;
  padding: 10px 12px;
  border-left: 4px solid #0f766e;
  border-radius: 10px;
  background: rgba(15, 118, 110, 0.08);
  color: #115e59;
  font-weight: 700;
}

.list-toolbar {
  min-height: 34px;
}

.list-toolbar .btn {
  white-space: nowrap;
}

#searchBtn {
  min-width: 72px;
}

.table-viewport {
  min-height: 560px;
  overflow-x: auto;
}

#dataTable {
  margin-bottom: 0 !important;
}

#dataTable thead th {
  white-space: nowrap;
}

#dataTable tbody tr {
  height: 52px;
}

.modal-wide {
  width: 1000px;
  max-width: calc(100% - 48px);
}

.modal-wide .modal-body {
  max-height: calc(100vh - 190px);
  overflow-y: auto;
}

.channel-config-panel {
  width: min(860px, 100%);
}

.merchant-channel-config-panel {
  --bs-offcanvas-width: 1000px;
  width: 1000px;
  max-width: 100%;
}

.route-promo-panel {
  --bs-offcanvas-width: 1000px;
  width: 1000px;
  max-width: 100%;
}

.merchant-config-search {
  display: flex;
  gap: 10px;
  align-items: center;
}

.merchant-config-search .form-control {
  max-width: 220px;
}

.merchant-channel-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.merchant-channel-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 14px;
  border: 1px solid rgba(18, 33, 47, 0.12);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

.merchant-channel-card.active {
  border-color: #f97316;
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.16);
}

.merchant-channel-logo {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: #e8f8ee;
  color: #16a34a;
  font-weight: 800;
}

.merchant-channel-radio {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
}

.merchant-channel-code {
  color: #4b5563;
  font-size: 12px;
}

.merchant-channel-state {
  color: #2563eb;
  font-size: 12px;
}

.merchant-channel-state.configured {
  color: #16a34a;
}

.merchant-channel-state.disabled {
  color: #dc2626;
}

.merchant-channel-state.pending {
  color: #6b7280;
}

.merchant-channel-status {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
}

.merchant-code-row {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.merchant-code-upload-box {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.merchant-code-upload-trigger {
  flex: 0 0 auto;
}

.merchant-code-preview {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: zoom-in;
}

.merchant-code-preview[src=""] {
  display: none;
}

.merchant-code-file-name {
  position: absolute;
  left: 0;
  top: 50%;
  z-index: 4;
  display: none;
  max-width: 240px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.9);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transform: translateY(-50%);
  pointer-events: none;
}

.merchant-code-upload-box:hover .merchant-code-file-name:not(:empty) {
  display: block;
}

.merchant-code-verify-status {
  min-height: 31px;
  display: flex;
  align-items: center;
  font-size: 12px;
}

.route-promo-section {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.route-promo-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.route-promo-stage-wrap,
.route-promo-result {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.route-promo-result {
  min-height: 420px;
}

.route-promo-empty {
  display: grid;
  min-height: 420px;
  place-items: center;
  color: var(--muted);
  border: 2px dashed rgba(15, 118, 110, 0.2);
  border-radius: 16px;
  background: rgba(15, 118, 110, 0.04);
}

.route-promo-stage {
  position: relative;
  display: inline-block;
  width: 100%;
  text-align: center;
}

.route-promo-template {
  width: 100%;
  max-height: 640px;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid rgba(18, 33, 47, 0.08);
  background: #fff;
}

.route-promo-qr {
  position: absolute;
  left: 0;
  top: 0;
  width: 160px;
  height: 160px;
  cursor: move;
  border: 2px solid rgba(249, 115, 22, 0.76);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
  background: rgba(255, 255, 255, 0.96);
}

.route-promo-config {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.route-promo-result img {
  width: 100%;
  max-height: 640px;
  object-fit: contain;
  background: #fff;
}

.dual-channel-picker {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 18px;
  align-items: stretch;
}

.channel-picker-column {
  min-width: 0;
}

.channel-option-list {
  min-height: 520px;
  max-height: calc(100vh - 230px);
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.62);
}

.channel-option {
  display: block;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid rgba(18, 33, 47, 0.12);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
}

.channel-option:hover {
  border-color: rgba(15, 118, 110, 0.38);
  background: rgba(15, 118, 110, 0.06);
}

.channel-picker-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}

.table-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 14px;
  padding-top: 16px;
}

.table-footer .dataTables_length,
.table-footer .dataTables_info,
.table-footer .dataTables_paginate {
  float: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.route-code-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  flex: 0 0 56px;
  font-size: 12px;
}

.route-rule-code-card {
  min-height: 112px;
  height: auto;
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.route-rule-code-card.is-draggable {
  cursor: grab;
}

.route-rule-code-drag {
  flex: 0 0 18px;
  cursor: grab;
  font-size: 18px;
  line-height: 1;
}

.route-rule-code-title {
  white-space: normal;
  word-break: break-all;
  line-height: 1.35;
  max-height: 2.8em;
  overflow: hidden;
}

.route-rule-code-dragging .route-rule-code-card {
  opacity: .55;
  transform: scale(.99);
}

.route-rule-code-drop-target .route-rule-code-card {
  border-color: #f97316 !important;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, .16);
}

.route-rule-province-box {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: linear-gradient(180deg, #fafafa 0%, #f5f7fb 100%);
}

.route-rule-province-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.route-rule-province-switch-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  flex-wrap: nowrap;
}

.route-rule-province-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  white-space: nowrap;
  color: #111827;
  cursor: pointer;
}

.route-rule-province-label .form-check-input {
  float: none;
  margin: 0;
}

.route-rule-province-summary {
  display: inline-block;
  flex: 1;
  min-width: 0;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
}

.route-rule-province-summary.is-enabled {
  color: #2563eb;
}

.route-rule-province-trigger {
  max-width: 100%;
  border-radius: 999px;
  text-align: left;
  white-space: normal;
  word-break: break-all;
}

.route-rule-province-drawer {
  display: none;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #d1d5db;
}

.route-rule-province-drawer.is-open {
  display: block;
}

.route-rule-province-drawer-body {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.route-rule-province-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #fff;
  color: #374151;
  cursor: pointer;
  user-select: none;
  transition: all .15s ease;
}

.route-rule-province-chip input {
  margin: 0;
}

.route-rule-province-chip.is-selected {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
}

.route-rule-province-tip {
  margin-top: 8px;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .content {
    padding: 18px;
  }

  .modal-wide {
    width: calc(100% - 24px);
    max-width: none;
    margin-right: auto;
    margin-left: auto;
  }

  .dual-channel-picker {
    grid-template-columns: 1fr;
  }

  .merchant-channel-list {
    grid-template-columns: 1fr;
  }

  .route-promo-editor {
    grid-template-columns: 1fr;
  }

  .merchant-config-search {
    align-items: stretch;
    flex-direction: column;
  }

  .merchant-config-search .form-control {
    max-width: none;
  }

  .channel-picker-actions {
    flex-direction: row;
  }
}
