:root {
  --accent: #ee4d2d;
  --accent-dark: #d0391b;
  --accent-soft: #fff1ee;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --side: #1f2329;
  --side-2: #2a2f36;
  --side-text: #c9ced6;
  --text: #1f2329;
  --muted: #6b7280;
  --border: #e3e6eb;
  --border-strong: #cfd4db;
  --ok: #1a7f37;
  --ok-soft: #e8f5ec;
  --warn: #9a6700;
  --warn-soft: #fff8e1;
  --danger: #c62828;
  --danger-soft: #fdecec;
  --info-soft: #eef4ff;
  --radius: 6px;
  --sidebar-w: 248px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  margin: 0;
  height: 100%;
}

h2,
h3 {
  margin: 0;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 14px;
}

p {
  margin: 4px 0;
}

code {
  font-family: var(--mono);
  font-size: 12px;
  background: #f0f2f5;
  border-radius: 3px;
  padding: 0 4px;
  margin-right: 4px;
}

/* ---------------------------------------------------------- controls */

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

input,
select,
textarea {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 5px 8px;
  background: #fff;
  min-width: 0;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(238, 77, 45, 0.15);
}

input[type="checkbox"] {
  accent-color: var(--accent);
  margin: 0;
}

textarea {
  resize: vertical;
}

.mono,
textarea.mono {
  font-family: var(--mono);
  font-size: 12px;
}

button {
  border: 1px solid var(--border-strong);
  background: #fff;
  border-radius: var(--radius);
  padding: 5px 12px;
  cursor: pointer;
  white-space: nowrap;
}

button:hover:not(:disabled) {
  background: #f3f4f6;
}

button:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #a51f1f;
}

.btn-danger-outline {
  border-color: var(--danger);
  color: var(--danger);
  background: transparent;
}

.btn-ghost,
.btn-ghost-danger {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.btn-ghost-danger {
  color: var(--danger);
}

.btn-small {
  padding: 3px 8px;
  font-size: 12px;
}

button.link {
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
}

/* ---------------------------------------------------------- layout */

.layout {
  display: flex;
  height: 100%;
}

.boot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 8px;
}

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--side);
  color: var(--side-text);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 10px 120px;
  overflow-y: auto;
}

.sidebar button {
  color: inherit;
}

.sidebar .btn-small {
  background: var(--side-2);
  border-color: #3a4049;
}

.sidebar .btn-small:hover:not(:disabled) {
  background: #363c45;
}

.sidebar .btn-ghost-danger {
  color: #ff8a80;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: #fff;
  font-size: 15px;
  padding: 2px 4px;
}

.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.pause-box {
  border: 1px solid #3a4049;
  border-radius: var(--radius);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pause-box.is-paused {
  border-color: var(--accent);
  background: rgba(238, 77, 45, 0.12);
}

.pause-state {
  font-size: 12px;
}

.sidebar .btn-danger-outline {
  color: #ff8a80;
  border-color: #ff8a80;
}

.sidebar .btn-primary {
  color: #fff;
}

.side-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: #8b929c;
  padding: 6px 4px 4px;
}

.shop-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.shop-item,
.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 6px 8px;
  border-radius: var(--radius);
}

.sidebar .shop-item:hover,
.sidebar .nav-item:hover {
  background: var(--side-2);
}

.sidebar .shop-item.active {
  background: var(--side-2);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar .nav-item.active {
  background: var(--accent);
  color: #fff;
}

.shop-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.small-actions {
  padding: 4px 4px 0;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.rec {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--danger);
  border-radius: 3px;
  padding: 1px 5px;
  letter-spacing: 0.04em;
}

.main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.view {
  padding: 16px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 1200px;
  width: 100%;
}

.view-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

/* ---------------------------------------------------------- helpers */

.row {
  display: flex;
  align-items: center;
}

.row.top {
  align-items: flex-start;
}

.gap {
  gap: 8px;
}

.wrap {
  flex-wrap: wrap;
}

.grow {
  flex: 1;
  min-width: 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.center {
  text-align: center;
}

.right {
  text-align: right;
}

.pad {
  padding: 24px;
}

.nowrap {
  white-space: nowrap;
}

.break {
  word-break: break-word;
}

.ellipsis {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.error-text {
  color: var(--danger);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* ---------------------------------------------------------- cards and forms */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px 14px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

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

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
}

.field-hint {
  font-size: 12px;
  color: var(--muted);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-weight: normal;
}

.hint {
  border-radius: var(--radius);
  padding: 8px 10px;
  background: var(--info-soft);
  border: 1px solid #d6e4ff;
  font-size: 12px;
  line-height: 1.5;
}

.hint-warn {
  background: var(--warn-soft);
  border-color: #f3dc9c;
}

.hint-danger {
  background: var(--danger-soft);
  border-color: #f5c2c2;
}

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  background: #eef0f3;
  color: #374151;
  white-space: nowrap;
}

.badge-ok,
.badge-info {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge-err,
.badge-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.runtime {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 12px;
  padding: 6px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card .runtime {
  background: #fafbfc;
}

.kv {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.kv-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(180px, 2fr) auto;
  gap: 6px;
  width: 100%;
  align-items: start;
}

.kv-head {
  font-size: 11px;
  color: var(--muted);
}

.mapping {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 10px;
  background: #fcfcfd;
}

.mapping-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 8px;
  align-items: center;
}

.mapping-row .row > input {
  flex: 1;
}

.mapping-preview {
  margin-top: 4px;
}

.rule {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fcfcfd;
}

.rule-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.rule-name {
  font-weight: 600;
  min-width: 260px;
}

.conds {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.conds input[type="number"],
.rule input[type="number"] {
  width: 110px;
}

.days {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.daypart {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.sub-section {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filters {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
}

.steps {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 16px 16px 36px;
  margin: 0;
  line-height: 1.7;
  font-size: 14px;
}

.steps li + li {
  margin-top: 8px;
}

.copy-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.copy-row:last-child {
  border-bottom: none;
}

.prose {
  white-space: pre-wrap;
  font-family: inherit;
  margin: 0;
  line-height: 1.6;
}

/* ---------------------------------------------------------- tables and code */

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}

.table-wrap.limit {
  max-height: 360px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.table th {
  position: sticky;
  top: 0;
  background: #f7f8fa;
  text-align: left;
  font-weight: 600;
  color: #4b5563;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  z-index: 1;
}

.table td {
  padding: 5px 8px;
  border-bottom: 1px solid #f0f1f4;
  vertical-align: top;
}

.table tbody tr:nth-child(even) td {
  background: #fbfbfc;
}

.table-click tbody tr {
  cursor: pointer;
}

.table tbody tr:hover td {
  background: #f4f6f9;
}

.table tbody tr.selected td {
  background: var(--accent-soft);
}

.logs tr.log-warn td {
  background: #fffbea;
}

.logs tr.log-error td {
  background: #fff4f4;
}

.code {
  font-family: var(--mono);
  font-size: 11.5px;
  background: #f6f8fa;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  margin: 4px 0 0;
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
}

.result {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.split {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
  gap: 10px;
  min-height: 300px;
}

.capture-list {
  max-height: 480px;
}

.capture-detail {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  max-height: 480px;
  overflow: auto;
}

/* ---------------------------------------------------------- shop browser */

.browser {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
  min-height: 0;
}

.browser-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.address {
  flex: 1;
  display: flex;
}

.address input {
  flex: 1;
  font-family: var(--mono);
  font-size: 12px;
}

.browser-shop {
  font-weight: 600;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rec-button {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.browser-hint {
  padding: 4px 12px;
  font-size: 12px;
  color: var(--muted);
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
}

.browser-view {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}

/* ---------------------------------------------------------- modal and toast */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 22, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal {
  background: var(--panel);
  border-radius: 10px;
  width: min(480px, calc(100vw - 40px));
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  color: var(--text);
}

.modal-head {
  padding: 14px 16px 6px;
}

.modal-body {
  padding: 8px 16px;
  overflow: auto;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px 14px;
}

.toasts {
  position: fixed;
  left: 8px;
  bottom: 8px;
  width: calc(var(--sidebar-w) - 16px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 100;
}

.toast {
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
  background: #fff;
  color: var(--text);
  border-left: 4px solid #6b7280;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  word-break: break-word;
}

.toast-success {
  border-left-color: var(--ok);
}

.toast-error {
  border-left-color: var(--danger);
  background: #fff6f6;
}

.action-select {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.record-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid #f5c2b8;
  border-radius: 6px;
  background: #fff4f1;
}

.record-status span:nth-child(2) {
  flex: 1;
  min-width: 240px;
}

.pre {
  white-space: pre-line;
}

.between {
  justify-content: space-between;
  align-items: flex-start;
}

.warn-text {
  color: var(--warn);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.kpi-label {
  color: var(--muted);
  font-size: 12px;
}

.kpi-value {
  font-size: 20px;
  font-weight: 600;
  margin: 2px 0;
}

.kpi-delta {
  font-size: 11px;
  color: var(--muted);
}

.kpi-delta.good {
  color: var(--ok);
}

.kpi-delta.bad {
  color: var(--danger);
}

.chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 180px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.chart-col {
  flex: 1 0 14px;
  min-width: 14px;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.chart-bars {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 1px;
}

.chart-bar {
  flex: 1;
  min-height: 1px;
  border-radius: 2px 2px 0 0;
}

.chart-bar.revenue,
.legend.revenue {
  background: #f5b3a4;
}

.chart-bar.profit,
.legend.profit {
  background: var(--ok);
}

.chart-bar.profit.neg {
  background: var(--danger);
}

.chart-label {
  font-size: 9px;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
}

.legend {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.good-text {
  color: var(--ok);
  font-weight: 600;
}

.login {
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
}

.login label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.brand-login {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.remote-wrap {
  position: relative;
  flex: 1;
  overflow: auto;
  background: #e9ebef;
}

.remote-wrap img {
  display: block;
  max-width: 100%;
  cursor: pointer;
  outline: none;
  user-select: none;
}

.remote-wrap img:focus {
  box-shadow: 0 0 0 2px var(--accent);
}

.user-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  margin: 0 8px 8px;
  font-size: 12px;
  color: var(--side-text);
}
