:root {
  --bg: #f4f5f9;
  --card: #ffffff;
  --text: #1a1d2e;
  --muted: #8b93a7;
  --purple: #7b61ff;
  --purple-dark: #6347f5;
  --purple-light: #f3efff;
  --purple-soft: #ebe4ff;
  --accent: var(--purple);
  --danger: #ef4444;
  --ok: #22c55e;
  --warn: #f59e0b;
  --info: #3b82f6;
  --border: #eceef4;
  --sidebar: #ffffff;
  --sidebar-text: #5c6378;
  --sidebar-active: linear-gradient(135deg, #7b61ff, #9d7bff);
  --shadow: 0 8px 30px rgba(88, 63, 200, 0.06);
  --radius: 16px;
}
* { box-sizing: border-box; }
body { margin:0; font-family: 'Inter', system-ui, sans-serif; background:var(--bg); color:var(--text); }
.wrap { max-width: 460px; margin: 0 auto; padding: 24px; }
.app-shell { display:flex; min-height:100vh; }
.sidebar {
  width: 260px; flex-shrink:0; background:var(--sidebar);
  border-right:1px solid var(--border);
  display:flex; flex-direction:column; padding:24px 16px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display:flex; align-items:center; gap:12px;
  font-size:20px; font-weight:800; margin-bottom:28px; padding:0 8px;
}
.sidebar-logo {
  width:42px; height:42px; border-radius:12px;
  background: linear-gradient(135deg, var(--purple), #9d7bff);
  color:#fff; display:flex; align-items:center; justify-content:center;
  font-size:11px; font-weight:800;
}
.sidebar-nav { display:flex; flex-direction:column; gap:4px; flex:1; }
.sidebar-nav button, .sidebar-nav a.nav-link {
  width:100%; text-align:left; background:transparent; color:var(--sidebar-text);
  border:none; padding:12px 14px; border-radius:12px; font-weight:600;
  cursor:pointer; font-size:14px; display:flex; align-items:center; gap:10px;
  text-decoration:none;
}
.sidebar-nav button:hover, .sidebar-nav a.nav-link:hover { background:#f7f7fb; color:var(--text); }
.sidebar-nav button.active {
  background: var(--sidebar-active); color:#fff;
  box-shadow: 0 8px 20px rgba(123, 97, 255, 0.28);
}
.nav-icon { width:20px; text-align:center; font-size:15px; opacity:.9; }
.nav-badge {
  margin-left:auto; background:var(--purple-light); color:var(--purple-dark);
  font-size:11px; font-weight:700; padding:2px 8px; border-radius:999px;
}
.sidebar-nav button.active .nav-badge { background:rgba(255,255,255,.22); color:#fff; }
.sidebar-user {
  margin-top:auto; padding:14px; border-radius:14px; background:#f8f9fc;
  border:1px solid var(--border); display:flex; gap:12px; align-items:center;
}
.sidebar-avatar {
  width:40px; height:40px; border-radius:50%;
  background: linear-gradient(135deg, #c4b5fd, #7b61ff);
  color:#fff; display:flex; align-items:center; justify-content:center; font-weight:700;
}
.sidebar-user-meta { min-width:0; flex:1; }
.sidebar-user-name { font-weight:700; font-size:14px; }
.sidebar-user-email { font-size:12px; color:var(--muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sidebar-footer { margin-top:12px; }
.sidebar-footer button { width:100%; }

.app-shell.is-booting .topbar,
.app-shell.is-booting .content-area,
.app-shell.is-booting .app-footer-banner {
  visibility: hidden;
}
.topbar {
  display:flex; align-items:flex-start; justify-content:space-between; gap:20px;
  padding:28px 32px 0; flex-wrap:wrap;
}
.topbar-greeting h1 { margin:0 0 6px; font-size:28px; font-weight:800; }
.topbar-greeting p { margin:0; color:var(--muted); font-size:14px; }
.topbar-actions { display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
.store-select-wrap { position:relative; }
.store-select-btn {
  display:flex; align-items:center; gap:10px; padding:10px 14px;
  border:1px solid var(--border); border-radius:12px; background:#fff;
  font-weight:600; cursor:pointer; min-width:220px; color:var(--text);
}
.store-select-label {
  flex:1; min-width:0; text-align:left;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.store-dot { width:10px; height:10px; border-radius:50%; background:var(--ok); flex-shrink:0; }
.store-dot.inactive { background:#d1d5db; }
.store-dropdown {
  position:absolute; right:0; top:calc(100% + 8px); width:min(320px, 90vw);
  background:#fff; border:1px solid var(--border); border-radius:14px;
  box-shadow:var(--shadow); padding:12px; z-index:40; display:none;
}
.store-dropdown.open { display:block; }
.store-dropdown input {
  width:100%; padding:10px 12px; border:1px solid var(--border);
  border-radius:10px; margin-bottom:8px;
}
.store-option {
  display:flex; align-items:center; gap:10px; padding:10px 12px;
  border-radius:10px; cursor:pointer; border:none; background:transparent;
  width:100%; text-align:left; font:inherit;
}
.store-option:hover, .store-option.active { background:var(--purple-light); }
.store-option { color:var(--text); }
.date-select-wrap { position:relative; }
.date-select-btn {
  display:flex; align-items:center; gap:8px; padding:10px 14px;
  border:1px solid var(--border); border-radius:12px; background:#fff;
  font-weight:600; font-size:13px; cursor:pointer; color:var(--text);
  min-width:190px; white-space:nowrap;
}
.date-dropdown {
  position:absolute; right:0; top:calc(100% + 8px); width:min(280px, 90vw);
  background:#fff; border:1px solid var(--border); border-radius:14px;
  box-shadow:var(--shadow); padding:12px; z-index:40; display:none;
}
.date-dropdown.open { display:block; }
.date-preset {
  width:100%; text-align:left; padding:10px 12px; border-radius:10px;
  border:none; background:transparent; font:inherit; font-weight:600;
  cursor:pointer; color:var(--text);
}
.date-preset:hover, .date-preset.active { background:var(--purple-light); color:var(--purple-dark); }
.pill-btn {
  padding:10px 14px; border:1px solid var(--border); border-radius:12px;
  background:#fff; font-weight:600; font-size:13px; cursor:pointer; color:var(--text);
}
.icon-btn {
  width:42px; height:42px; border:1px solid var(--border); border-radius:12px;
  background:#fff; cursor:pointer; font-size:18px; color:var(--text);
}

.content-area { padding:24px 32px 32px; flex:1; width:100%; min-width:0; }
.main-panel {
  flex:1; min-width:0; width:100%;
  display:flex; flex-direction:column;
}
.page-shell { width:100%; min-width:0; }
#integrationsPage .card,
#integrationsPage .onboarding-banner { width:100%; max-width:none; }
.page-header { margin-bottom:20px; }
.page-header h1 { margin:0; font-size:24px; font-weight:800; }
h1,h2 { margin: 0 0 16px; }
.card {
  background:var(--card); border:1px solid var(--border); border-radius:var(--radius);
  padding:20px; margin-bottom:16px; box-shadow:var(--shadow);
}
.card-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:16px; }
.card-head h2, .card-head h3 { margin:0; font-size:16px; font-weight:700; }
.card-link { color:var(--purple); font-size:13px; font-weight:600; text-decoration:none; }
.card-link:hover { text-decoration:underline; }

input, button, select, textarea {
  font: inherit; padding:10px 12px; border-radius:10px;
  border:1px solid var(--border); background:#fff; color:var(--text);
}
button {
  background:var(--accent); border:none; cursor:pointer; font-weight:600; color:#fff;
}
button.secondary { background:#fff; color:var(--text); border:1px solid var(--border); }
button.danger { background:#fee2e2; color:#b91c1c; border:none; }
button.linkish { background:transparent; border:none; color:var(--purple); padding:0; font-weight:600; cursor:pointer; text-align:left; }

/* Нейтральні кнопки в шапці та списках — після загального button */
.topbar-actions button.store-select-btn,
.topbar-actions button.date-select-btn,
.topbar-actions button.icon-btn,
button.store-option,
button.date-preset,
button.modal-close,
button.platform-card,
.sidebar-nav button,
.sidebar-footer button.secondary {
  background:#fff;
  border:1px solid var(--border);
  color:var(--text);
}
.sidebar-nav button.active { background:var(--sidebar-active); border:none; color:#fff; }
#selectedStoreLabel,
#dateRangeLabel,
.store-select-label {
  color:var(--text) !important;
}
.kpi-label { color:#5c6378; }
.kpi-value { color:var(--text); }
.card-head h2, .card-head h3, .card h2, .card h3 { color:var(--text); }
.donut span { color:var(--text); position:relative; z-index:1; }
.row { display:flex; gap:12px; flex-wrap:wrap; align-items:end; }
.row > * { flex:1; min-width:140px; }
table { width:100%; border-collapse:collapse; }
th, td { text-align:left; padding:12px 10px; border-bottom:1px solid var(--border); font-size:14px; vertical-align:top; }
th { color:var(--muted); font-size:12px; font-weight:600; text-transform:uppercase; letter-spacing:.03em; }
.muted { color:var(--muted); font-size:13px; }
.hidden { display: none !important; }
.badge { display:inline-block; padding:4px 10px; border-radius:999px; font-size:12px; font-weight:600; background:#eef2ff; color:#4338ca; }
.badge.ok, .status-picked { background:#dcfce7; color:#166534; }
.badge.picking, .status-picking { background:var(--purple-light); color:var(--purple-dark); }
.badge.new, .status-new { background:#dbeafe; color:#1d4ed8; }
.error { color:#dc2626; margin-top:8px; }
.success { color:#16a34a; margin-top:8px; }
.tabs { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:16px; }
.tabs button { background:#f3f4f6; color:var(--text); }
.tabs button.active { background:var(--purple); color:#fff; }
.log-toolbar { display:flex; gap:12px; align-items:center; justify-content:space-between; flex-wrap:wrap; margin-bottom:16px; }
.lightbox { position:fixed; inset:0; background:rgba(0,0,0,.85); display:flex; align-items:center; justify-content:center; z-index:1000; padding:24px; }
.lightbox img { max-width:100%; max-height:90vh; border-radius:12px; }
.lightbox button { position:absolute; top:24px; right:24px; }
.achievement-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(280px,1fr)); gap:16px; }
.achievement-card { background:#fff; border:1px solid var(--border); border-radius:var(--radius); padding:16px; }
.achievement-card img, .achievement-placeholder { width:100%; height:160px; object-fit:cover; border-radius:12px; background:#f3f4f6; display:flex; align-items:center; justify-content:center; color:var(--muted); margin-bottom:12px; }
.achievement-value { font-size:28px; font-weight:700; margin:8px 0; }
.store-checks { display:flex; flex-wrap:wrap; gap:12px 20px; margin-top:8px; }
.store-checks label { display:flex; align-items:center; gap:6px; margin:0; color:var(--text); cursor:pointer; }
input[readonly] { opacity: 0.65; cursor: not-allowed; }
.form-actions { display:flex; gap:8px; flex-wrap:wrap; margin-top:16px; align-items:center; }
.modal-backdrop { position:fixed; inset:0; background:rgba(15,23,42,.45); display:flex; align-items:center; justify-content:center; z-index:1100; padding:24px; }
.modal { background:var(--card); border:1px solid var(--border); border-radius:18px; width:100%; max-width:520px; max-height:90vh; overflow:auto; padding:24px; box-shadow:0 24px 48px rgba(0,0,0,.15); }
.modal-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin-bottom:16px; }
.modal-head h2 { margin:0; font-size:20px; }
.modal-close { background:#fff; border:1px solid var(--border); color:var(--muted); padding:6px 10px; line-height:1; }
.modal .row > * { min-width:100%; }
.modal input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.modal select,
.modal textarea {
  width:100%;
  display:block;
  box-sizing:border-box;
}
.modal label + input:not([type="checkbox"]):not([type="radio"]),
.modal label + select,
.modal label + textarea,
.modal p + input:not([type="checkbox"]):not([type="radio"]),
.modal p + select {
  margin-bottom:12px;
}
.modal .field-copy-row { width:100%; }
.modal-actions { display:flex; gap:8px; flex-wrap:wrap; margin-top:20px; }
.packing-thumb { width:72px; height:72px; object-fit:cover; border-radius:8px; cursor:pointer; background:#f3f4f6; }
.packing-thumb.placeholder { display:flex; align-items:center; justify-content:center; color:var(--muted); font-size:11px; }
.detail-head { display:flex; gap:12px; align-items:center; flex-wrap:wrap; }
.detail-head h1 { margin:0; flex:1; font-size:22px; }
label { display:block; font-size:13px; color:var(--muted); margin-bottom:4px; font-weight:600; }
.log-view { background:#0f172a; color:#e2e8f0; padding:16px; border-radius:12px; overflow:auto; max-height:480px; font-size:12px; line-height:1.5; }

/* Login */
.login-screen {
  min-height:100vh; display:flex; align-items:center; justify-content:center;
  padding:24px; background: linear-gradient(180deg, #f7f7fb 0%, #ece9ff 100%);
}
.login-card {
  width:min(440px, 100%); background:#fff; border:1px solid var(--border);
  border-radius:20px; padding:36px; box-shadow:var(--shadow);
}
.login-card .brand-row { display:flex; align-items:center; gap:12px; margin-bottom:24px; }
.login-card h1 { margin:0 0 8px; font-size:26px; }

/* Dashboard */
.kpi-grid { display:grid; grid-template-columns:repeat(4, 1fr); gap:16px; margin-bottom:20px; }
.kpi-card {
  background:#fff; border:1px solid var(--border); border-radius:var(--radius);
  padding:18px 20px; box-shadow:var(--shadow);
}
.kpi-label { font-size:13px; color:var(--muted); margin-bottom:8px; }
.kpi-value { font-size:28px; font-weight:800; margin-bottom:8px; }
.kpi-trend { font-size:12px; font-weight:600; color:var(--ok); }
.kpi-trend.neutral { color:var(--muted); }
.kpi-spark { height:36px; margin-top:12px; border-radius:8px; opacity:.85; }

.dash-grid { display:grid; grid-template-columns:1.1fr 1fr 0.9fr; gap:16px; margin-bottom:16px; }
.dash-grid-2 { display:grid; grid-template-columns:1fr 1fr 1fr 1fr; gap:16px; }
.store-row {
  display:flex; align-items:center; gap:12px; padding:12px 0;
  border-bottom:1px solid var(--border);
}
.store-row:last-child { border-bottom:none; }
.store-icon {
  width:40px; height:40px; border-radius:10px; background:var(--purple-light);
  display:flex; align-items:center; justify-content:center; font-weight:700; color:var(--purple);
}
.store-row-main { flex:1; min-width:0; }
.store-row-name { font-weight:600; }
.store-row-url { font-size:12px; color:var(--muted); }
.store-row-stats { text-align:right; font-size:13px; }
.store-row-stats strong { display:block; font-size:15px; }

.order-mini { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:10px 0; border-bottom:1px solid var(--border); }
.order-mini:last-child { border-bottom:none; }
.order-mini-id { font-weight:700; }
.order-mini-time { font-size:12px; color:var(--muted); }

.donut-wrap { display:flex; align-items:center; gap:20px; }
.donut {
  width:120px; height:120px; border-radius:50%;
  background: conic-gradient(var(--purple) 0 var(--donut-pct, 98%), #e8e8ef var(--donut-pct, 98%) 100%);
  display:flex; align-items:center; justify-content:center; position:relative; flex-shrink:0;
}
.donut::after {
  content:''; width:78px; height:78px; border-radius:50%; background:#fff; position:absolute;
}
.donut span { position:relative; z-index:1; font-weight:800; font-size:18px; }
.donut-legend { font-size:13px; }
.donut-legend div { display:flex; justify-content:space-between; gap:16px; padding:4px 0; }
.info-banner {
  margin-top:14px; padding:12px 14px; border-radius:12px;
  background:#eff6ff; color:#1e40af; font-size:13px;
}

.integration-row { display:flex; align-items:center; gap:10px; padding:10px 0; border-bottom:1px solid var(--border); }
.integration-row:last-child { border-bottom:none; }
.dot-ok { width:8px; height:8px; border-radius:50%; background:var(--ok); }

.scanner-widget { text-align:center; }
.scanner-illustration {
  width:100%; max-width:180px; margin:0 auto 12px;
  padding:20px; border-radius:14px; background:linear-gradient(180deg,#f8f9fc,#eef2ff);
}
.scanner-illustration svg { width:100%; height:auto; }

.timeline { display:flex; flex-direction:column; gap:14px; }
.timeline-item { display:flex; gap:12px; align-items:flex-start; }
.timeline-dot {
  width:32px; height:32px; border-radius:10px; flex-shrink:0;
  display:flex; align-items:center; justify-content:center; font-size:14px;
}
.timeline-dot.ok { background:#dcfce7; }
.timeline-dot.warn { background:#fef3c7; }
.timeline-dot.info { background:var(--purple-light); }
.timeline-text { font-size:13px; }
.timeline-text strong { display:block; margin-bottom:2px; }

.quick-actions { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.quick-btn {
  display:flex; flex-direction:column; align-items:flex-start; gap:8px;
  padding:16px; border-radius:14px; border:none; cursor:pointer; font-weight:700;
  color:#fff; text-align:left; min-height:88px;
}
.quick-btn.purple { background:linear-gradient(135deg,#7b61ff,#9d7bff); }
.quick-btn.green { background:linear-gradient(135deg,#22c55e,#4ade80); }
.quick-btn.orange { background:linear-gradient(135deg,#f59e0b,#fbbf24); color:#422006; }
.quick-btn.blue { background:linear-gradient(135deg,#3b82f6,#60a5fa); }
.quick-btn span { font-size:22px; }

.app-footer-banner {
  margin:0 32px 24px; padding:14px 20px; border-radius:14px;
  background: linear-gradient(135deg, #7b61ff, #9d7bff);
  color:#fff; display:flex; align-items:center; justify-content:space-between; gap:16px; flex-wrap:wrap;
  font-size:14px;
}
.app-footer-banner a { color:#fff; font-weight:700; text-decoration:none; }
.app-footer-banner a:hover { text-decoration:underline; }

.placeholder-page { text-align:center; padding:60px 24px; }
.placeholder-page .ph-icon {
  width:72px; height:72px; border-radius:18px; margin:0 auto 16px;
  background:var(--purple-light); display:flex; align-items:center; justify-content:center;
  font-size:32px;
}
.settings-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr)); gap:12px; }
.settings-tile {
  padding:18px; border:1px solid var(--border); border-radius:14px; background:#fff;
  cursor:pointer; text-align:left; transition:border-color .15s;
}
.settings-tile:hover { border-color:#d8ccff; }
.settings-tile strong { display:block; margin-bottom:4px; }

.dashboard-empty {
  text-align:center; padding:72px 24px; max-width:520px; margin:40px auto;
}
.dashboard-empty .empty-icon {
  width:88px; height:88px; border-radius:22px; margin:0 auto 20px;
  background:var(--purple-light); display:flex; align-items:center; justify-content:center; font-size:36px;
}
.dashboard-empty h2 { margin:0 0 10px; font-size:26px; }
.dashboard-empty p { color:var(--muted); margin:0 0 24px; }

.sidebar-nav button.locked-out {
  opacity:.45; pointer-events:none;
}
.onboarding-banner {
  background:#fff7ed; border:1px solid #fed7aa; color:#9a3412;
  border-radius:14px; padding:14px 18px; margin-bottom:16px; font-size:14px;
}

.integration-card {
  border:1px solid var(--border); border-radius:16px; padding:18px 20px; margin-bottom:12px;
  background:#fff;
}
.integration-card-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin-bottom:14px; }
.integration-card-title { display:flex; align-items:center; gap:12px; }
.integration-logo {
  width:44px; height:44px; border-radius:12px; background:#f3efff;
  display:flex; align-items:center; justify-content:center; font-weight:800; color:var(--purple);
}
.integration-actions { display:flex; flex-wrap:wrap; gap:8px; margin-top:14px; }
.status-inactive { background:#fee2e2; color:#b91c1c; }
.status-awaiting { background:#fef3c7; color:#b45309; }

.platform-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin:16px 0; }
.platform-card {
  border:1px solid var(--border); border-radius:14px; padding:16px; text-align:left;
  background:#fff; cursor:pointer; position:relative;
}
.platform-card:hover:not(:disabled) { border-color:#d8ccff; background:var(--purple-light); }
.platform-card:disabled { opacity:.55; cursor:not-allowed; }
.platform-card .dev-badge {
  position:absolute; top:10px; right:10px; font-size:10px; font-weight:700;
  background:#f3f4f6; color:var(--muted); padding:3px 8px; border-radius:999px;
}
.keys-reveal { margin-top:16px; padding:16px; border-radius:12px; background:#f8f9fc; border:1px solid var(--border); }
.keys-reveal input { width:100%; margin-top:6px; margin-bottom:12px; }
.field-copy-row { display:flex; gap:8px; align-items:center; margin-bottom:12px; }
.field-copy-row input { flex:1; margin:6px 0 0; font-family:ui-monospace, SFMono-Regular, Menlo, monospace; font-size:13px; }
.field-copy-row button { margin-top:6px; white-space:nowrap; }

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns:repeat(2, 1fr); }
  .dash-grid { grid-template-columns:1fr; }
  .dash-grid-2 { grid-template-columns:1fr 1fr; }
}
@media (max-width: 768px) {
  .sidebar { display:none; }
  .topbar, .content-area, .app-footer-banner { padding-left:16px; padding-right:16px; }
  .kpi-grid, .dash-grid-2 { grid-template-columns:1fr; }
}
