:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --ink: #172026;
  --muted: #69757d;
  --line: #d9e1e5;
  --panel: #ffffff;
  --accent: #0f6f76;
  --accent-2: #e11d48;
  --accent-3: #f59e0b;
  --accent-4: #2563eb;
  --warn: #b45309;
  --bad: #b91c1c;
  --shadow: 0 14px 34px rgba(20, 33, 45, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
}

.topbar {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 36px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(20, 33, 45, 0.05);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand, .topbar a { color: var(--ink); text-decoration: none; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
  font-weight: 800;
}
.brand-logo {
  width: 210px;
  height: 54px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.brand-logo img {
  width: 210px;
  height: 54px;
  object-fit: contain;
  display: block;
  transform: scale(2.35);
  transform-origin: center;
}
.brand span {
  white-space: nowrap;
  font-size: 18px;
}
.topbar nav { display: flex; gap: 8px; align-items: center; }
.topbar nav a {
  padding: 9px 12px;
  border-radius: 6px;
  color: #40515a;
  font-weight: 650;
}
.topbar nav a:hover { background: #eef3f5; color: var(--ink); }

.page { max-width: 1440px; margin: 0 auto; padding: 24px; }
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
h1, h2 { margin: 0; }
h1 { font-size: 30px; letter-spacing: 0; }
h2 { font-size: 18px; margin-bottom: 14px; }
p { color: var(--muted); }

.filters, .block, .kpis article, .login-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.filters {
  display: grid;
  grid-template-columns: 210px minmax(220px, 1.25fr) minmax(430px, 2fr) auto;
  gap: 16px;
  align-items: stretch;
  padding: 18px;
  margin-bottom: 22px;
  position: relative;
  z-index: 12;
  overflow: visible;
}

.filter-panel {
  border: 0;
  background:
    linear-gradient(135deg, rgba(15, 111, 118, 0.08), rgba(255,255,255,0) 35%),
    linear-gradient(315deg, rgba(225, 29, 72, 0.06), rgba(255,255,255,0) 34%),
    #fff;
}

.filter-panel:has(.multi-select[open]) {
  z-index: 60;
}

.filter-title {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 126px;
  padding: 14px;
  border-radius: 8px;
  background: #102d34;
  color: #fff;
}
.filter-title strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
  line-height: 1.1;
}
.filter-title small {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255,255,255,.14);
  color: #d9eef1;
  font-weight: 700;
}
.eyebrow {
  color: #91d8dd;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.store-filter {
  padding: 12px;
  border: 1px solid #dce7eb;
  border-radius: 8px;
  background: rgba(255,255,255,.72);
}

.filter-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  align-content: center;
  padding: 12px;
  border: 1px solid #dce7eb;
  border-radius: 8px;
  background: rgba(255,255,255,.72);
}

.filter-actions {
  display: grid;
  gap: 10px;
  align-content: center;
  min-width: 132px;
}

label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.field-label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

.store-filter select {
  min-height: 96px;
  border-color: transparent;
  background: #f7fafb;
}

.multi-select {
  position: relative;
}
.multi-select summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 6px;
  padding: 10px 12px;
  background: #f7fafb;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
}
.multi-select summary::-webkit-details-marker { display: none; }
.multi-select summary b {
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
}
.multi-select[open] summary {
  outline: 2px solid rgba(15, 111, 118, .18);
}
.multi-options {
  position: absolute;
  z-index: 100;
  top: calc(100% + 8px);
  left: 0;
  width: min(360px, 80vw);
  max-height: 320px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 42px rgba(20, 33, 45, 0.16);
}
.check-option {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
}
.check-option:hover { background: #eef6f7; }
.check-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}
.check-option span {
  overflow-wrap: anywhere;
}

.filter-fields input {
  min-height: 44px;
  background: #f7fafb;
}

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}
button:hover, .button:hover { filter: brightness(0.95); }

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  background: #fff;
  color: #40515a;
  font-weight: 700;
  text-decoration: none;
}
.ghost-button:hover { background: #f4f7f8; }

.danger-button {
  background: var(--bad);
}

.notices {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}
.notice {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #bfe3d5;
  border-radius: 6px;
  background: #e7f7ef;
  color: #166534;
  font-weight: 650;
}
.notice.error {
  border-color: #fecaca;
  background: #fee2e2;
  color: var(--bad);
}

.user-create {
  margin-bottom: 18px;
}
.user-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) 160px 140px auto;
  gap: 12px;
  align-items: end;
}
.users-table input,
.users-table select {
  min-width: 150px;
}
.user-actions {
  align-items: flex-start;
  min-width: 320px;
}
.password-reset {
  position: relative;
}
.password-reset summary {
  list-style: none;
  cursor: pointer;
}
.password-reset summary::-webkit-details-marker { display: none; }
.password-reset form {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 30;
  width: 280px;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 42px rgba(20, 33, 45, 0.16);
}

.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.kpi-card {
  min-height: 154px;
  padding: 18px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.kpi-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: var(--kpi);
}
.kpi-card::after {
  content: "";
  position: absolute;
  right: -32px;
  top: -32px;
  width: 106px;
  height: 106px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--kpi) 18%, transparent);
}
.kpi-card span {
  display: block;
  color: #53656e;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  margin-bottom: 10px;
  text-transform: uppercase;
}
.kpi-card strong {
  display: block;
  max-width: 100%;
  font-size: clamp(24px, 2vw, 34px);
  line-height: 1.05;
  overflow-wrap: anywhere;
}
.kpi-card small {
  color: var(--muted);
  display: block;
  font-weight: 650;
  margin-top: 12px;
}
.accent-a { --kpi: #0f6f76; }
.accent-b { --kpi: #e11d48; }
.accent-c { --kpi: #7c3aed; }
.accent-d { --kpi: #f59e0b; }
.accent-e { --kpi: #2563eb; }
.accent-f { --kpi: #16a34a; }

.grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.block { padding: 18px; margin-bottom: 18px; }

.bars { display: grid; gap: 10px; }
.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 150px) 1fr 70px 70px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.bar-row.compact { grid-template-columns: 60px 1fr 70px; }
.store-bars .bar-row { grid-template-columns: minmax(160px, 240px) 1fr 80px; }
.bar-track { height: 12px; background: #e8eef1; border-radius: 999px; overflow: hidden; }
.bar-track i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-4)); }
.bar-row em { color: var(--muted); font-style: normal; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; vertical-align: top; }
th { background: #eef4f6; color: #334148; position: sticky; top: 0; }
.empty { text-align: center; color: var(--muted); padding: 28px; }
.message { max-width: 420px; white-space: pre-wrap; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.status { font-weight: 700; }
.status.completed { color: var(--accent); }
.status.completed_with_errors { color: var(--warn); }
.status.failed { color: var(--bad); }
.status.running { color: var(--accent-2); }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(135deg, rgba(15, 111, 118, 0.16), transparent 42%),
    linear-gradient(315deg, rgba(225, 29, 72, 0.12), transparent 38%),
    var(--bg);
}
.login-box {
  width: min(420px, 100%);
  padding: 28px;
  display: grid;
  gap: 16px;
}
.login-box h1 { text-align: center; }
.login-logo {
  width: min(220px, 80%);
  max-height: 82px;
  object-fit: contain;
  justify-self: center;
}
.alert {
  margin: 0;
  padding: 10px;
  border-radius: 6px;
  background: #fee2e2;
  color: var(--bad);
}

@media (max-width: 980px) {
  .filters, .filter-fields, .kpis, .grid.two, .user-form { grid-template-columns: 1fr; }
  .panel-head { display: grid; }
  .bar-row, .bar-row.compact, .store-bars .bar-row { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; display: grid; gap: 10px; }
  .brand-logo { width: 172px; height: 48px; }
  .brand-logo img { width: 172px; height: 48px; transform: scale(2.25); }
  .topbar nav { flex-wrap: wrap; }
  .password-reset form { left: 0; right: auto; }
}
