:root {
  --bg: #0c0e12;
  --bg-2: #11141a;
  --panel: #141920;
  --panel-2: #1a202a;
  --line: #232b36;
  --line-2: #2e3947;
  --text: #e7ecf3;
  --muted: #8b97a6;
  --muted-2: #5f6b7a;
  --green: #34d399;
  --green-dim: #1fae83;
  --red: #f4546a;
  --amber: #f5b14c;
  --blue: #56a6ff;
  --accent: #f5b14c;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --sans: "Space Grotesk", system-ui, sans-serif;
  --r: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(1000px 500px at 85% -10%, rgba(86, 166, 255, 0.08), transparent 60%),
    linear-gradient(180deg, #0e1116 0%, var(--bg) 40%);
  overflow-x: hidden;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 1;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
  background: rgba(12, 14, 18, 0.72);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  position: relative;
  width: 42px; height: 42px;
  border-radius: 10px;
  background:
    conic-gradient(from 210deg, var(--green), var(--green-dim) 25%, var(--amber) 60%, transparent 90%) padding-box,
    linear-gradient(135deg, rgba(52, 211, 153, 0.5), rgba(245, 177, 76, 0.3)) border-box;
  border: 1px solid transparent;
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4), 0 8px 24px -8px rgba(52,211,153,0.4);
}
.brand-grid {
  width: 24px; height: 24px;
  background-image:
    linear-gradient(90deg, var(--bg) 1px, transparent 1px),
    linear-gradient(var(--bg) 1px, transparent 1px);
  background-size: 8px 8px;
  border-radius: 3px;
}

.brand-name {
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 15px;
}
.brand-sub {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.topbar-right { display: flex; align-items: center; gap: 16px; }

.conn {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  white-space: nowrap;
}
.conn.ok { color: var(--green); border-color: rgba(52,211,153,0.4); }
.conn.bad { color: var(--amber); border-color: rgba(245,177,76,0.4); }

.btn {
  position: relative;
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 10px;
  color: #06120d;
  background: linear-gradient(135deg, var(--green), var(--green-dim));
  box-shadow: 0 6px 20px -6px rgba(52,211,153,0.7);
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.05); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { cursor: not-allowed; filter: grayscale(0.7); opacity: 0.55; box-shadow: none; }
.btn .btn-glow {
  position: absolute; inset: 0;
  border-radius: inherit;
  background: radial-gradient(120px 40px at 50% 0%, rgba(255,255,255,0.35), transparent);
  pointer-events: none;
}
.btn.busy { pointer-events: none; opacity: 0.75; }

.icon-btn {
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
  width: 32px; height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }

.layout {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 22px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 28px 60px;
}

.side { display: grid; gap: 18px; align-content: start; }

.panel {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px;
}
.panel-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted-2);
  font-family: var(--mono);
  margin-bottom: 14px;
}

.kv { display: grid; gap: 10px; margin: 0; }
.kv > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 9px;
  border-bottom: 1px dashed var(--line);
}
.kv > div:last-child { border-bottom: none; padding-bottom: 0; }
.kv dt { color: var(--muted); font-size: 12px; }
.kv dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  text-align: right;
  max-width: 60%;
  word-break: break-word;
}

.rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.rules li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
}
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 0 8px currentColor;
}
.dot-red { background: var(--red); color: var(--red); }
.dot-amber { background: var(--amber); color: var(--amber); }
.dot-blue { background: var(--blue); color: var(--blue); }
.dot-green { background: var(--green); color: var(--green); }

.log-list { display: grid; gap: 10px; max-height: 340px; overflow: auto; }
.log-item {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(0,0,0,0.18);
  font-size: 12px;
}
.log-item .t { color: var(--muted-2); font-family: var(--mono); font-size: 11px; }
.log-item .s { margin-top: 3px; color: var(--text); }
.log-item .q { display: flex; gap: 8px; margin-top: 5px; flex-wrap: wrap; }
.log-item .q .chip {
  font-family: var(--mono); font-size: 10px;
  padding: 2px 7px; border-radius: 6px;
  background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--line);
}
.log-empty { color: var(--muted-2); font-size: 13px; padding: 4px 0; }

.content { min-width: 0; }
.content-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
}
.content-head h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.content-meta { color: var(--muted); font-family: var(--mono); font-size: 12px; }

.state-banner {
  background: rgba(245,177,76,0.08);
  border: 1px solid rgba(245,177,76,0.3);
  color: var(--amber);
  padding: 14px 18px;
  border-radius: var(--r);
  margin-bottom: 18px;
  font-size: 14px;
}

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }

.card {
  position: relative;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--card-accent, var(--green));
  opacity: 0.85;
}
.card:hover {
  border-color: var(--line-2);
  transform: translateY(-2px);
  box-shadow: 0 12px 30px -14px rgba(0,0,0,0.7);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.card-shop { font-weight: 600; font-size: 15px; line-height: 1.25; }
.card-shop small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; margin-top: 3px; }

.verdict {
  flex: none;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  padding: 5px 9px;
  border-radius: 7px;
  border: 1px solid;
}
.verdict.good { color: var(--green); border-color: rgba(52,211,153,0.4); background: rgba(52,211,153,0.06); }
.verdict.warn { color: var(--amber); border-color: rgba(245,177,76,0.4); background: rgba(245,177,76,0.06); }
.verdict.bad { color: var(--red); border-color: rgba(244,84,106,0.4); background: rgba(244,84,106,0.06); }

.card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0 12px;
}
.stat {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px;
  text-align: center;
}
.stat b { display: block; font-family: var(--mono); font-size: 17px; }
.stat span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat.good b { color: var(--green); }
.stat.warn b { color: var(--amber); }
.stat.warn2 b { color: var(--blue); }

.card-progress {
  height: 5px;
  border-radius: 5px;
  background: var(--panel-2);
  overflow: hidden;
  margin-bottom: 12px;
}
.card-progress i {
  display: block;
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--green), var(--green-dim));
  transition: width 0.4s ease;
}

.fail-list { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
.fail-list li {
  font-size: 12px;
  color: var(--red);
  display: flex;
  gap: 7px;
  align-items: baseline;
}
.fail-list li::before { content: "—"; color: var(--muted-2); }
.fail-list .miss-photo { color: var(--blue); }
.card-none { color: var(--muted-2); font-size: 13px; }

.loading { grid-column: 1 / -1; color: var(--muted-2); font-family: var(--mono); padding: 40px; text-align: center; }
.empty { grid-column: 1 / -1; color: var(--muted); text-align: center; padding: 60px 20px; font-size: 15px; }

/* Tabs */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.tab {
  appearance: none;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.tab:hover { color: var(--text); }
.tab.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* Shift pane */
.shift-pane { display: grid; gap: 16px; }
.shift-pane[hidden] { display: none; }
.shift-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.shift-title h2 { margin: 0 0 4px; font-size: 18px; }
.shift-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.select {
  appearance: none;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: 9px;
  padding: 9px 32px 9px 12px;
  font-family: var(--sans);
  font-size: 13px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b97a6' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.btn-ghost {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line-2);
  box-shadow: none;
}
.btn-ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.shift-preview {
  display: grid;
  gap: 14px;
}
.shift-preview[hidden] { display: none; }
.shift-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.shift-stat {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}
.shift-stat b { display: block; font-family: var(--mono); font-size: 22px; }
.shift-stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.shift-stat.good b { color: var(--green); }
.shift-stat.warn b { color: var(--amber); }
.shift-stat.bad b { color: var(--red); }
.shift-stat.neutral b { color: var(--blue); }

.shift-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
}
.shift-card h3 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted-2);
  font-family: var(--mono);
}
.shift-list { display: grid; gap: 6px; }
.shift-list .row {
  font-size: 13px;
  color: var(--text);
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(0,0,0,0.15);
}
.shift-list .row::before { content: "•"; color: var(--muted-2); }
.shift-list .row.miss { color: var(--red); }
.shift-list .row.miss::before { content: "−"; color: var(--red); }
.shift-none { color: var(--muted-2); font-size: 13px; }

.shift-text {
  background: #0a0d11;
  border: 1px solid var(--line);
  border-left: 3px solid var(--green);
  border-radius: 10px;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.shift-text a { color: var(--green); text-decoration: none; }
.shift-text a:hover { text-decoration: underline; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6,8,11,0.7);
  backdrop-filter: blur(4px);
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 760px;
  max-height: 88vh;
  overflow: auto;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 18px;
  box-shadow: 0 40px 80px -30px rgba(0,0,0,0.8);
  animation: pop 0.22s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 22px 24px 14px;
  border-bottom: 1px solid var(--line);
}
.modal-kicker { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; }
.modal-head h2 { margin: 6px 0 0; font-size: 20px; font-weight: 600; }
.modal-body { padding: 20px 24px 26px; display: grid; gap: 22px; }

.m-section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--muted-2); font-family: var(--mono); margin-bottom: 11px;
}
.m-checks { display: grid; gap: 7px; }
.m-checks .row {
  display: flex; gap: 10px; align-items: baseline;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px;
  background: rgba(0,0,0,0.15);
}
.m-checks .row.ok { border-color: rgba(52,211,153,0.18); }
.m-checks .row.bad { border-color: rgba(244,84,106,0.28); }
.m-checks .mark { width: 12px; flex: none; font-family: var(--mono); font-size: 13px; }
.row.ok .mark { color: var(--green); }
.row.bad .mark { color: var(--red); }
.m-checks .lbl { font-size: 13px; color: var(--text); }
.m-checks .row.bad .lbl { color: var(--red); }

.m-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.m-meta .cell { padding: 10px 12px; background: rgba(0,0,0,0.18); border: 1px solid var(--line); border-radius: 9px; }
.m-meta .cell dt { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted-2); }
.m-meta .cell dd { margin: 4px 0 0; font-size: 14px; color: var(--text); }

.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 11px;
  font-size: 14px;
  box-shadow: 0 20px 40px -16px rgba(0,0,0,0.8);
  animation: pop 0.2s ease;
}
.toast[hidden] { display: none; }
.toast.err { border-color: rgba(244,84,106,0.5); }

@media (max-width: 940px) {
  .layout { grid-template-columns: 1fr; }
  .side { grid-template-columns: 1fr 1fr; }
  .m-meta { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .side { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .topbar-right { justify-content: space-between; }
}

/* Shift: дата и группировка по локациям */
.shift-date {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text);
  background: rgba(0,0,0,0.18);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
}
.shift-location-group {
  display: grid;
  gap: 6px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}
.shift-location-group:last-child { border-bottom: none; }
.shift-location-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  padding: 2px 0 4px;
}
.shift-location-title .urs {
  font-weight: 400;
  color: var(--accent);
  font-size: 12px;
}

/* Поле выбора даты */
.date-field {
  display: flex;
  align-items: center;
  gap: 8px;
}
.date-field span {
  font-size: 12px;
  color: var(--muted);
}
.date-input {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: 9px;
  padding: 8px 10px;
  font-family: var(--sans);
  font-size: 13px;
}
.date-input::-webkit-calendar-picker-indicator {
  filter: invert(0.8) sepia(0.3) hue-rotate(180deg);
  cursor: pointer;
}
.shift-source {
  color: var(--muted-2);
  font-size: 12px;
}
