:root {
  color-scheme: light;
  --ink: #17211b;
  --muted: #6c776f;
  --line: #dce4de;
  --paper: #ffffff;
  --canvas: #f1f5f2;
  --green: #176b43;
  --green-soft: #e0f1e7;
  --red: #a33a35;
  --red-soft: #f9e7e5;
  --shadow: 0 16px 45px rgba(34, 55, 43, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
}
main { width: min(1180px, calc(100% - 40px)); margin: 86px auto 48px; }
.top-left {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 5;
}
.top-right {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
}
header { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 10px; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .16em; }
h1 { margin: 0; font-size: clamp(38px, 6vw, 64px); line-height: .95; letter-spacing: -.055em; }
.subtitle { margin: 16px 0 0; color: var(--muted); font-size: 16px; }
button { border: 0; border-radius: 12px; font: inherit; font-weight: 650; cursor: pointer; transition: .18s ease; }
button:hover { transform: translateY(-1px); }
.primary { padding: 14px 20px; background: var(--ink); color: white; box-shadow: var(--shadow); }
.primary:disabled { opacity: .55; cursor: wait; transform: none; }
.button-dot { display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: #66e397; }

/* Header actions — tunnel chip + sync button */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.tunnel-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: 10px;
  background: var(--green-soft);
  border: 1px solid #b6d9c5;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  max-width: 280px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: .18s ease;
}
.tunnel-chip:hover {
  background: #d0eddb;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(23, 107, 67, .12);
}
.tunnel-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}
.tunnel-copy {
  padding: 8px 10px;
  background: var(--green-soft);
  border: 1px solid #b6d9c5;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: .15s ease;
}
.tunnel-copy:hover {
  background: #d0eddb;
  transform: translateY(-1px);
}

.summary { display: grid; grid-template-columns: repeat(3, 1fr) 1.55fr; gap: 12px; margin-bottom: 18px; }
.summary article { min-height: 105px; padding: 20px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,255,255,.62); }
.summary span { display: block; margin-bottom: 13px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.summary strong { font-size: 29px; letter-spacing: -.04em; }
.last-sync strong { font-size: 17px; letter-spacing: -.015em; }

.panel { overflow: hidden; border: 1px solid var(--line); border-radius: 19px; background: var(--paper); box-shadow: var(--shadow); }
.hidden { display: none; }
.toolbar { display: flex; align-items: center; gap: 12px; padding: 15px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.search { display: flex; flex: 1; align-items: center; gap: 9px; min-width: 220px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 11px; background: #f8faf8; }
.search span { color: var(--muted); font-size: 21px; }
.search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit; }
.filters { display: flex; gap: 4px; padding: 4px; border-radius: 11px; background: var(--canvas); }
.filter { padding: 8px 12px; background: transparent; color: var(--muted); font-size: 13px; }
.filter.active { background: white; color: var(--ink); box-shadow: 0 2px 8px rgba(20,40,28,.08); }
.secondary { padding: 10px 14px; background: white; border: 1px solid var(--line); color: var(--ink); }

.settings-panel { margin-bottom: 18px; }
.settings-head { padding: 20px; border-bottom: 1px solid var(--line); background: #f8faf8; }
.settings-head h2 { margin: 0; font-size: 28px; letter-spacing: -.04em; }
.settings-grid { display: grid; gap: 12px; padding: 15px; }
.setting-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.setting-card strong { display: block; margin-bottom: 6px; font-size: 16px; }
.setting-card span { display: block; color: var(--muted); font-size: 13px; line-height: 1.45; }
.mode-card select {
  min-width: 150px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #f8faf8;
  color: var(--ink);
  font: inherit;
  font-weight: 650;
}
.status-box { display: grid; gap: 10px; padding: 15px; }
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
}
.status-row span { color: var(--muted); font-size: 13px; font-weight: 700; }
.status-row strong { font-size: 18px; }
.status-note {
  padding: 13px 16px;
  border-radius: 13px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 13px;
  font-weight: 650;
}
.status-note.warning { background: #fff3d8; color: #8a5a00; }
.status-note.error { background: var(--red-soft); color: var(--red); }

/* Sentos refresh button */
.sentos-refresh {
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--green-soft) 0%, #d0eddb 100%);
  border: 1px solid #b6d9c5;
  color: var(--green);
  font-size: 13px;
  white-space: nowrap;
}
.sentos-refresh:hover {
  background: linear-gradient(135deg, #d0eddb 0%, #bce5cc 100%);
  box-shadow: 0 2px 8px rgba(23, 107, 67, .15);
}
.sentos-refresh:disabled {
  opacity: .6;
  cursor: wait;
  transform: none;
}

.table-wrap { max-height: 600px; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th { position: sticky; top: 0; z-index: 1; padding: 12px 20px; background: #f8faf8; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; letter-spacing: .08em; text-align: left; text-transform: uppercase; }
td { padding: 14px 20px; border-bottom: 1px solid #edf1ee; vertical-align: middle; }
tbody tr:hover { background: #fafcfb; }
.product-code { display: block; margin-bottom: 4px; font-weight: 750; }
.product-name { display: block; max-width: 610px; overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.stock { font-variant-numeric: tabular-nums; font-weight: 750; }
.virtual-stock {
  display: grid;
  align-items: center;
  gap: 7px;
  min-width: 82px;
}
.virtual-stock-input {
  width: 72px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8faf8;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 750;
}
.mini-switch { position: relative; display: inline-block; width: 38px; height: 22px; }
.mini-switch input { opacity: 0; width: 0; height: 0; }
.mini-slider { position: absolute; inset: 0; border-radius: 22px; background: #c9d1cb; cursor: pointer; transition: .2s; }
.mini-slider::before { position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: white; box-shadow: 0 2px 5px rgba(0,0,0,.18); content: ""; transition: .2s; }
.mini-switch input:checked + .mini-slider { background: var(--green); }
.mini-switch input:checked + .mini-slider::before { transform: translateX(16px); }
.mini-switch input:disabled + .mini-slider,
.virtual-stock-input:disabled { opacity: .45; cursor: not-allowed; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 20px; font-size: 11px; font-weight: 750; }
.badge::before { width: 6px; height: 6px; border-radius: 50%; content: ""; }
.matched { background: var(--green-soft); color: var(--green); }
.matched::before { background: var(--green); }
.unmatched { background: var(--red-soft); color: var(--red); }
.unmatched::before { background: var(--red); }
.web-closed { background: #fff3d8; color: #8a5a00; }
.web-closed::before { background: #c98400; }
.switch { position: relative; display: inline-block; width: 48px; height: 27px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; border-radius: 30px; background: #c9d1cb; cursor: pointer; transition: .2s; }
.slider::before { position: absolute; left: 3px; top: 3px; width: 21px; height: 21px; border-radius: 50%; background: white; box-shadow: 0 2px 5px rgba(0,0,0,.18); content: ""; transition: .2s; }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(21px); }
.empty { padding: 60px; color: var(--muted); text-align: center; }
footer { display: flex; justify-content: space-between; gap: 20px; padding: 13px 20px; background: #f8faf8; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
#toast { position: fixed; right: 24px; bottom: 24px; max-width: 360px; padding: 13px 16px; border-radius: 12px; background: var(--ink); color: white; opacity: 0; pointer-events: none; transform: translateY(10px); transition: .2s; box-shadow: var(--shadow); }
#toast.show { opacity: 1; transform: translateY(0); }
@media (max-width: 800px) {
  main { width: min(100% - 22px, 1180px); margin: 24px auto; }
  main { margin-top: 92px; }
  .top-left, .top-right { position: absolute; }
  .top-right { left: 18px; right: auto; top: 58px; }
  header { align-items: start; flex-direction: column; }
  .header-actions { flex-wrap: wrap; }
  .tunnel-chip { max-width: 100%; }
  .summary { grid-template-columns: 1fr 1fr; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .filters { justify-content: space-between; }
  th:nth-child(3), td:nth-child(3), th:nth-child(4), td:nth-child(4) { display: none; }
  td, th { padding: 12px; }
}
