:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-red: #ef4444;
  --accent-green: #10b981;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #334155;
  --kasima: #06b6d4;
  --rjmart: #10b981;
  --dingxiang: #f59e0b;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  font-family: "IBM Plex Sans", sans-serif;
  background: radial-gradient(circle at top right, rgba(59, 130, 246, 0.12), transparent 30%),
    linear-gradient(160deg, #020617 0%, #0f172a 45%, #111827 100%);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

a {
  color: inherit;
  text-decoration: none;
}

.header {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.98) 0%, rgba(15, 23, 42, 0.98) 100%);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-content {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.logo-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 30px rgba(6, 182, 212, 0.25);
}

.logo-icon svg {
  width: 24px;
  height: 24px;
  fill: white;
}

.logo h1,
.section-title {
  font-family: "Syne", sans-serif;
}

.logo h1 {
  font-size: 1.45rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn {
  padding: 0.7rem 1.15rem;
  border-radius: 10px;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

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

.btn-primary {
  color: white;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  box-shadow: 0 10px 24px rgba(59, 130, 246, 0.25);
}

.btn-secondary {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.btn-ghost {
  color: var(--text-secondary);
  background: transparent;
  border: 1px dashed var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-link {
  color: var(--accent-cyan);
  background: transparent;
  border: none;
  padding: 0;
  font-weight: 600;
}

.btn-danger {
  color: #fecaca;
}

.main-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 2rem;
}

.platform-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.platform-card,
.control-card,
.table-container {
  background: rgba(30, 41, 59, 0.92);
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.25);
}

.platform-card {
  padding: 1.35rem;
  position: relative;
  overflow: hidden;
}

.platform-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  height: 4px;
  width: 100%;
}

.platform-card.kasima::before {
  background: var(--kasima);
}

.platform-card.rjmart::before {
  background: var(--rjmart);
}

.platform-card.dingxiang::before {
  background: var(--dingxiang);
}

.platform-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.platform-name {
  font-family: "Syne", sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
}

.kasima .platform-name {
  color: var(--kasima);
}

.rjmart .platform-name {
  color: var(--rjmart);
}

.dingxiang .platform-name {
  color: var(--dingxiang);
}

.platform-badge {
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  font-size: 0.78rem;
  background: rgba(16, 185, 129, 0.14);
  color: #6ee7b7;
}

.platform-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
}

.stat-item {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 0.85rem;
  text-align: center;
}

.stat-value {
  font-family: "Syne", sans-serif;
  font-size: 1.55rem;
  font-weight: 700;
}

.stat-label,
.section-caption,
.field-note,
.field-hint {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.control-card {
  padding: 1.35rem;
  margin-bottom: 1.5rem;
}

.settings-intro {
  margin-bottom: 1.25rem;
}

.settings-intro .section-caption {
  margin-top: 0.25rem;
}

.settings-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.settings-control-grid .control-card {
  margin-bottom: 0;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-title {
  font-size: 1.18rem;
  font-weight: 700;
}

.section-title.small {
  font-size: 1.08rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1rem;
}

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

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

.catalog-form {
  padding: 0 1.3rem 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

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

.field-full {
  grid-column: 1 / -1;
}

.field-actions {
  display: flex;
  align-items: end;
  gap: 0.75rem;
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.field-inline-short {
  max-width: 260px;
}

.field-unit {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.schedule-weekdays {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.schedule-weekdays legend {
  margin-bottom: 0.45rem;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.weekday-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
}

.weekday-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.72);
  color: var(--text-primary);
  cursor: pointer;
}

.weekday-option:has(input:checked) {
  border-color: rgba(6, 182, 212, 0.72);
  background: rgba(6, 182, 212, 0.12);
}

.weekday-option input {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  accent-color: var(--accent-cyan);
}

.import-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.input,
select.input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-primary);
  padding: 0.82rem 0.95rem;
  font-size: 0.92rem;
  outline: none;
}

.input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}

.file-input {
  padding: 0.7rem 0.85rem;
}

.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.filter-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  padding: 0.55rem 0.95rem;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.88rem;
  transition: all 0.2s ease;
}

.filter-tab.active,
.filter-tab:hover {
  color: var(--accent-cyan);
  border-color: rgba(6, 182, 212, 0.4);
  background: rgba(6, 182, 212, 0.08);
}

.count {
  margin-left: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.table-container {
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  padding: 1.1rem 1.3rem 0;
}

.table-search {
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.table-wrapper {
  overflow-x: auto;
  padding: 1rem 0 0;
}

.compact-table {
  padding-top: 0;
}

table {
  width: 100%;
  min-width: 1100px;
  border-collapse: collapse;
}

thead {
  background: rgba(255, 255, 255, 0.025);
}

th,
td {
  padding: 1rem 1.2rem;
  vertical-align: top;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

th {
  font-size: 0.74rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sort-header {
  color: inherit;
  border: none;
  background: transparent;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.sort-header.active,
.sort-header:hover {
  color: var(--accent-cyan);
}

tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

tr:last-child td {
  border-bottom: none;
}

.cell-title {
  font-weight: 600;
  color: var(--text-primary);
}

.cell-meta {
  margin-top: 0.2rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.sku-code {
  display: inline-flex;
  align-items: center;
  padding: 0.26rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-size: 0.82rem;
  white-space: nowrap;
}

.platform-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.62rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.platform-tag.casmart {
  background: rgba(6, 182, 212, 0.15);
  color: var(--kasima);
}

.platform-tag.rjmart {
  background: rgba(16, 185, 129, 0.15);
  color: var(--rjmart);
}

.platform-tag.dingxiang {
  background: rgba(245, 158, 11, 0.15);
  color: var(--dingxiang);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.32rem 0.72rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-ok {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}

.status-alert,
.status-open {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.status-error,
.status-not_found,
.status-login_required {
  background: rgba(245, 158, 11, 0.15);
  color: #fdba74;
}

.status-resolved {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.price-strong {
  font-family: "Syne", sans-serif;
  font-weight: 700;
  font-size: 1.02rem;
}

.price-muted {
  color: var(--text-muted);
  font-size: 0.84rem;
}

.drop-good {
  color: #6ee7b7;
}

.drop-bad {
  color: #fca5a5;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
}

.empty-state.compact {
  padding: 1.4rem;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.55rem;
  padding: 0 1.3rem 1.2rem;
  color: var(--text-secondary);
  font-size: 0.86rem;
}

.page-btn {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: rgba(15, 23, 42, 0.72);
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.42rem 0.7rem;
}

.page-btn:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.page-info {
  color: var(--text-muted);
}

.page-size {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  color: var(--text-muted);
}

.page-size-select {
  width: 74px;
  padding: 0.42rem 0.55rem;
  border-radius: 9px;
}

.log-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.log-summary-card,
.sales-log-card {
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: var(--radius-md);
  background:
    linear-gradient(145deg, rgba(14, 165, 233, 0.1), transparent 44%),
    rgba(15, 23, 42, 0.76);
  box-shadow: var(--shadow-soft);
}

.log-summary-card {
  min-height: 132px;
  padding: 1.25rem;
}

.log-summary-card span {
  display: block;
  color: var(--text-muted);
  font-size: 0.86rem;
  margin-bottom: 0.85rem;
}

.log-summary-card strong {
  display: block;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.2vw, 2.15rem);
  line-height: 1.15;
}

.log-summary-card em {
  display: block;
  margin-top: 0.45rem;
  color: var(--text-secondary);
  font-style: normal;
  font-size: 0.88rem;
}

.sales-log-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  padding: 1rem;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.sales-log-card {
  padding: 1rem;
}

.sales-log-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.sales-log-head strong,
.sales-log-head span {
  display: block;
}

.sales-log-head strong {
  color: var(--text-primary);
  font-size: 1rem;
}

.sales-log-head span {
  color: var(--text-muted);
  margin-top: 0.2rem;
  font-size: 0.82rem;
}

.sales-log-head em {
  flex: 0 0 auto;
  padding: 0.35rem 0.62rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-style: normal;
  font-weight: 800;
}

.mail-sent {
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.18);
}

.mail-pending {
  color: #fed7aa;
  background: rgba(245, 158, 11, 0.16);
}

.sales-log-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
  color: var(--text-secondary);
}

.sales-log-metrics span {
  padding: 0.48rem 0.7rem;
  border-radius: 11px;
  background: rgba(15, 23, 42, 0.72);
}

.sales-log-metrics b {
  color: var(--accent-cyan);
}

.sales-company-list {
  display: grid;
  gap: 0.55rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sales-company-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  color: var(--text-secondary);
  font-size: 0.86rem;
}

.sales-company-list strong {
  color: var(--text-primary);
  white-space: nowrap;
}

.sales-more {
  color: var(--text-muted);
  font-style: italic;
}

.log-panel {
  min-height: 560px;
  max-height: 72vh;
  margin: 0;
  padding: 1.2rem 1.35rem;
  overflow: auto;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(2, 6, 23, 0.34);
}

.log-empty {
  color: var(--text-muted);
  padding: 2rem;
  text-align: center;
}

.log-empty.compact {
  grid-column: 1 / -1;
  padding: 1.4rem;
}

.log-event {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: start;
  padding: 0.95rem 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-left-width: 4px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.62);
}

.log-running {
  border-left-color: var(--accent-blue);
}

.log-success {
  border-left-color: var(--accent-green);
}

.log-mail {
  border-left-color: var(--accent-cyan);
}

.log-error {
  border-left-color: var(--accent-red);
}

.log-info,
.log-raw {
  border-left-color: var(--text-muted);
}

.log-event-title {
  font-weight: 800;
  margin-bottom: 0.25rem;
}

.log-event-detail {
  color: var(--text-secondary);
  font-size: 0.9rem;
  word-break: break-word;
}

.log-event-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.toast-container {
  position: fixed;
  right: 1.2rem;
  top: 1.2rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  min-width: 300px;
  max-width: 420px;
  padding: 1rem 1.1rem;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.94);
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.4);
  animation: slideIn 0.25s ease;
}

.toast-title {
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.toast-message {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.86rem;
  padding: 2rem 1rem 2.4rem;
}

.fade-in {
  animation: fadeIn 0.45s ease;
}

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

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (max-width: 980px) {
  .header-content,
  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .control-grid,
  .settings-control-grid,
  .compact-grid,
  .form-grid.settings-form-grid,
  .form-grid,
  .log-summary-grid,
  .sales-log-grid {
    grid-template-columns: 1fr;
  }

  .field-wide,
  .field-full {
    grid-column: auto;
  }
}

@media (max-width: 768px) {
  .header,
  .main-container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .header-actions,
  .field-actions,
  .import-actions {
    width: 100%;
    flex-wrap: wrap;
  }

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

  .btn,
  .btn-ghost {
    width: 100%;
    justify-content: center;
  }

  .toast-container {
    left: 1rem;
    right: 1rem;
  }

  .toast {
    min-width: auto;
    max-width: none;
  }

  .weekday-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
