:root {
  --bg: #eceef1;
  --card: #ffffff;
  --text: #14161a;
  --hint: #8b929c;
  --line: #e6e8ec;
  --accent: #5b6cff;
  --accent-2: #8a5bff;
  --accent-soft: #eef0ff;
  --price: #e8890c;
  --danger: #ff3b30;
  --danger-soft: #ffecea;
  --chip: #f1f3f6;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 4px 16px rgba(20, 22, 26, 0.06);
}

[data-theme="dark"] {
  --bg: #14171c;
  --card: #1d2128;
  --text: #f3f5f7;
  --hint: #8a93a0;
  --line: #2a2f38;
  --accent: #6c7bff;
  --accent-2: #9a6bff;
  --accent-soft: #23262f;
  --price: #ffb44d;
  --danger: #ff6b60;
  --danger-soft: #3a2422;
  --chip: #262b33;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 0 14px 48px;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* ----- top bar ----- */
.topbar {
  position: sticky;
  top: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 0 10px;
  z-index: 5;
}
.topbar h1 { font-size: 24px; font-weight: 800; margin: 0; letter-spacing: -0.3px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 42px; height: 42px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow);
}

/* ----- tabs ----- */
.tabs {
  position: sticky;
  top: 62px;
  z-index: 4;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 46px;
  padding: 6px 8px;
  border: none;
  border-radius: 13px;
  background: transparent;
  color: var(--hint);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tab svg { flex: none; }
.tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 6px 14px rgba(91, 108, 255, 0.35);
}
/* Admin has 5 tabs — labels no longer fit, so show icons only. */
.tabs.compact .tab { gap: 0; padding: 6px 4px; }
.tabs.compact .tab span { display: none; }
.tabs.compact .tab svg { width: 22px; height: 22px; }

/* ----- search ----- */
.search-row { position: relative; margin: 4px 0 12px; }
.search-icon {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  color: var(--hint); pointer-events: none;
}
.search-row input { padding-left: 44px; }

input, textarea, select {
  width: 100%;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font-size: 15px;
  box-shadow: var(--shadow);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }

/* Date inputs: consistent height, calendar icon, whole field opens the picker. */
input[type="date"] {
  position: relative;
  color: var(--text);
  min-height: 50px;
  -webkit-appearance: none;
  appearance: none;
  background-color: var(--card);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%238b929c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 44px;
}
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
input[type="date"]::-webkit-calendar-picker-indicator {
  position: absolute; inset: 0; width: auto; height: auto;
  margin: 0; padding: 0; opacity: 0; cursor: pointer;
}

.status { color: var(--hint); font-size: 14px; padding: 4px 2px 10px; }

/* ----- catalog cards (photo left, content right) ----- */
.grid { display: flex; flex-direction: column; gap: 12px; }

.card {
  position: relative;
  display: flex;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.card .thumb {
  flex: none;
  width: 96px; height: 96px;
  border-radius: 14px;
  object-fit: cover;
  background: var(--chip);
}
.card .thumb.placeholder {
  display: flex; align-items: center; justify-content: center;
  color: var(--hint);
}
.card .body { flex: 1; min-width: 0; padding-right: 44px; display: flex; flex-direction: column; }
.card .name {
  font-size: 16px; font-weight: 700; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card .attrs {
  margin-top: 5px; color: var(--hint); font-size: 13px; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card .price-row { margin-top: auto; padding-top: 8px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.card .price { font-size: 17px; font-weight: 800; color: var(--price); }
.card .deadline { font-size: 13px; color: var(--hint); }

.card .card-actions {
  position: absolute; top: 12px; right: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.act-btn {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--hint);
  border-radius: 11px;
  cursor: pointer;
}
.act-btn.danger { background: var(--danger-soft); border-color: var(--danger-soft); color: var(--danger); }
.act-btn.on { color: var(--accent); border-color: var(--accent); }

/* ----- pager ----- */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 18px; gap: 10px;
}
.pager span { color: var(--hint); font-size: 13px; }

/* ----- buttons ----- */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border: none; border-radius: 14px;
  padding: 11px 18px; font-size: 15px; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 14px rgba(91, 108, 255, 0.35);
}
.btn-primary.block { width: 100%; padding: 15px; margin-top: 12px; }
.btn-primary:disabled { opacity: 0.6; }
.btn-ghost {
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow);
}
.btn-ghost.block { width: 100%; justify-content: center; margin: 8px 0 12px; }
.btn-ghost:disabled { opacity: 0.45; cursor: default; }
.back { margin: 6px 0 16px; }

/* ----- detail ----- */
#detailContent .hero {
  width: 100%; border-radius: var(--radius); margin-bottom: 14px;
  max-height: 60vh; object-fit: cover;
}
#detailContent .hero.placeholder {
  aspect-ratio: 16 / 10; background: var(--card); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 48px; color: var(--hint);
}
#detailContent h2 { margin: 6px 0; }
#detailContent .price-big { font-size: 24px; font-weight: 800; color: var(--price); margin: 4px 0 10px; }
#detailContent .attrs { color: var(--hint); font-size: 14px; margin-bottom: 14px; line-height: 1.5; }
#detailContent .desc { white-space: pre-wrap; line-height: 1.55; color: var(--text); }

/* ----- forms ----- */
form label { display: block; margin: 12px 0 0; font-size: 14px; font-weight: 600; color: var(--hint); }
form label input, form label textarea { margin-top: 6px; font-weight: 400; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#preview { margin-top: 12px; width: 100%; border-radius: var(--radius); max-height: 240px; object-fit: cover; }
.form-error { color: var(--danger); font-size: 14px; margin-top: 10px; min-height: 18px; }
.notice {
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  margin: 10px 0 12px;
  padding: 12px 14px;
}
.invite-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}
.invite-actions button {
  width: 100%;
}
.notice.status-card {
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  margin-top: 4px;
}
.notice.status-pending {
  background: #fff7df;
  border-color: #ffe19a;
}
.notice.status-verified {
  background: #e9f9ef;
  border-color: #9ee2b6;
}
.notice.status-rejected {
  background: var(--danger-soft);
  border-color: rgba(255, 59, 48, 0.24);
}
[data-theme="dark"] .notice.status-pending {
  background: #332b18;
  border-color: #6b5420;
}
[data-theme="dark"] .notice.status-verified {
  background: #193126;
  border-color: #275b40;
}

/* ----- lists (deals / admin) ----- */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.list-title { font-size: 15px; font-weight: 700; line-height: 1.35; }
.meta { color: var(--hint); font-size: 13px; line-height: 1.4; margin-top: 4px; }
.list-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.list-item.current-chat { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.chat-history {
  margin-top: 10px;
  display: flex; flex-direction: column; gap: 6px;
  max-height: 280px; overflow-y: auto;
  padding: 10px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
}
.chat-history.hidden { display: none; }
.chat-msg {
  max-width: 85%;
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 10px;
}
.chat-msg.mine {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #fff;
}
.chat-msg-body { font-size: 13px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }
.hist-media { display: block; max-width: 100%; max-height: 220px; border-radius: 10px; margin: 2px 0 4px; }
.hist-audio { width: 100%; min-width: 180px; margin: 2px 0 4px; }
.hist-file { display: inline-block; margin: 2px 0 4px; color: inherit; text-decoration: underline; font-size: 13px; }
.chat-msg-meta { font-size: 11px; color: var(--hint); margin-top: 2px; }
.chat-msg.mine .chat-msg-meta { color: rgba(255, 255, 255, .78); }
.chat-badge {
  display: inline-block;
  font-size: 11px; font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  padding: 2px 8px;
  vertical-align: middle;
  white-space: nowrap;
}

.kyc {
  margin-top: 10px; padding: 10px 12px;
  background: var(--accent-soft); border-radius: var(--radius-sm);
}
.kyc .meta { color: var(--text); }
.doc-row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.doc-thumb {
  width: 84px; height: 84px; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--line); display: block;
}

.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 16px; }
.summary div {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px; box-shadow: var(--shadow);
}
.summary b { display: block; font-size: 22px; }
.summary span { color: var(--hint); font-size: 12px; }

.inline-form { display: grid; grid-template-columns: 1fr 92px auto; gap: 8px; align-items: center; }
.inline-form select, .inline-form input { min-width: 0; }
.segmented { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-bottom: 12px; }
.segment {
  min-height: 40px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--hint); font-size: 13px; font-weight: 600; cursor: pointer;
}
.segment.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }

/* per-user role switch in the admin "Пользователи" section */
.role-switch { display: flex; gap: 6px; margin-top: 12px; }
.role-opt {
  flex: 1; min-height: 38px; padding: 0 4px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--hint);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.role-opt.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #fff; cursor: default;
}
.role-opt:disabled { opacity: 1; }
.filters { margin-bottom: 10px; }
h2 { font-size: 18px; font-weight: 800; }
a { color: var(--accent); word-break: break-all; }

/* ----- route on cards ----- */
.card .route {
  display: flex; align-items: center; gap: 5px;
  margin-top: 5px; color: var(--accent); font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card .route svg { flex: none; }

/* ----- filters ----- */
.filters-bar { margin: 0 0 12px; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow);
}
.chip-btn.active { border-color: var(--accent); color: var(--accent); }
.chip-count {
  background: var(--accent); color: #fff; border-radius: 999px;
  min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.filters-panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.filters-actions { display: flex; gap: 8px; margin-top: 14px; }
.filters-actions .btn-primary, .filters-actions .btn-ghost { flex: 1; justify-content: center; }

/* ----- detail: route + chips + description ----- */
.route-block {
  display: flex; align-items: center; gap: 10px;
  background: var(--accent-soft); border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 12px;
}
.route-pt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.route-pt b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route-lbl { color: var(--hint); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.route-arrow { color: var(--accent); flex: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  background: var(--chip); color: var(--text);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600;
}

.desc-block {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 14px;
}
.desc-label { color: var(--hint); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }

@media (max-width: 400px) {
  .tab span { display: none; }
  .tab { min-height: 44px; }
}
