:root {
  --bg: #11121e;
  --bg-soft: #171927;
  --surface: rgba(36, 39, 56, 0.86);
  --surface-strong: #25293a;
  --surface-light: #31364a;
  --text: #f7f3ff;
  --muted: #a9aec3;
  --line: rgba(255,255,255,0.08);
  --accent: #f4bc7f;
  --accent-2: #ffdb9a;
  --green: #36d185;
  --blue: #5b6cff;
  --red: #ff5a6b;
  --yellow: #ffcc36;
  --shadow: 0 24px 70px rgba(0,0,0,.36);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* { box-sizing: border-box; }
[v-cloak] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(244,188,127,.18), transparent 28%),
    radial-gradient(circle at top right, rgba(91,108,255,.16), transparent 24%),
    linear-gradient(135deg, #11121e 0%, #171525 48%, #0e1019 100%);
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: auto auto 0 0;
  width: 430px;
  height: 160px;
  background: repeating-linear-gradient(160deg, rgba(244,188,127,.5), rgba(244,188,127,.5) 5px, transparent 5px, transparent 18px);
  opacity: .25;
  transform: skewY(-12deg) translate(-60px, 70px);
  pointer-events: none;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
input, select, textarea {
  width: 100%;
  color: var(--text);
  background: rgba(9, 12, 22, 0.62);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 15px;
  outline: none;
  transition: .2s ease;
}
input:focus, select:focus, textarea:focus { border-color: rgba(244,188,127,.65); box-shadow: 0 0 0 4px rgba(244,188,127,.09); }
textarea { min-height: 98px; resize: vertical; }
label { color: var(--muted); font-size: 13px; font-weight: 700; }
img { max-width: 100%; display: block; }
.surface {
  background: linear-gradient(180deg, rgba(39,43,61,.92), rgba(27,30,45,.92));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.material-symbols-rounded { font-size: 22px; vertical-align: middle; }

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 460px) minmax(320px, 620px);
  gap: 26px;
  align-items: center;
  justify-content: center;
  padding: 32px;
}
.login-card, .login-preview { border-radius: var(--radius-xl); padding: 34px; }
.brand-row { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; }
.brand-mark {
  width: 58px; height: 58px; border-radius: 18px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent-2), #ea8f5f);
  color: #1a1420;
  box-shadow: 0 12px 36px rgba(244,188,127,.28);
}
.brand-mark .material-symbols-rounded { font-size: 30px; }
.login-card h1 { margin: 0; font-size: 28px; }
.login-card p, .login-preview p { color: var(--muted); line-height: 1.65; }
.login-form { display: grid; gap: 12px; }
.primary-btn, .ghost-btn {
  border: none;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  transition: transform .2s ease, filter .2s ease, background .2s ease;
}
.primary-btn {
  padding: 14px 18px;
  color: #1d1521;
  background: linear-gradient(135deg, var(--accent-2), #f0a36e);
  box-shadow: 0 16px 38px rgba(244,188,127,.22);
}
.primary-btn:hover, .ghost-btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.primary-btn:disabled { opacity: .65; cursor: wait; }
.ghost-btn {
  padding: 12px 14px;
  color: var(--text);
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
}
.ghost-btn.compact { padding: 10px 12px; font-size: 13px; }
.hint { font-size: 13px; }
.error-text, .error-banner { color: #ffd5da; }
.error-banner, .toast {
  margin: 0 0 18px 0;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.08);
}
.error-banner { background: rgba(255,90,107,.13); }
.toast { background: rgba(54,209,133,.13); color: #caffdf; }
.login-preview { min-height: 470px; position: relative; overflow: hidden; }
.login-preview::after {
  content: ""; position: absolute; inset: auto -80px -130px auto; width: 350px; height: 350px;
  border-radius: 50%; background: radial-gradient(circle, rgba(244,188,127,.42), transparent 68%);
}
.preview-topline { color: var(--accent-2); font-weight: 800; text-transform: uppercase; letter-spacing: .13em; font-size: 12px; }
.login-preview h2 { font-size: clamp(34px, 5vw, 64px); margin: 28px 0 12px; line-height: .98; }
.preview-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 38px; }
.preview-grid div { border-radius: 20px; padding: 20px; background: rgba(255,255,255,.05); border: 1px solid var(--line); }
.preview-grid b { font-size: 32px; display: block; color: var(--accent-2); }
.preview-grid span { color: var(--muted); font-size: 13px; }

.app-shell { display: grid; grid-template-columns: 96px 1fr; min-height: 100vh; padding: 18px; gap: 18px; }
.sidebar { border-radius: 28px; padding: 18px 12px; display: flex; flex-direction: column; align-items: center; gap: 10px; position: sticky; top: 18px; height: calc(100vh - 36px); }
.sidebar-logo { margin-bottom: 12px; }
.sidebar-logo .brand-mark { width: 50px; height: 50px; border-radius: 16px; }
.nav-btn {
  width: 70px; min-height: 64px; border: none; border-radius: 20px;
  color: var(--muted); background: transparent;
  display: grid; place-items: center; gap: 2px;
}
.nav-btn small { font-size: 10px; font-weight: 700; }
.nav-btn.active { color: #19121d; background: linear-gradient(135deg, var(--accent-2), #f0a36e); box-shadow: 0 12px 28px rgba(244,188,127,.22); }
.nav-btn.logout { margin-top: auto; }
.workspace { min-width: 0; padding: 12px 8px 40px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.eyebrow { color: var(--accent-2); font-size: 12px; text-transform: uppercase; letter-spacing: .14em; font-weight: 800; }
.topbar h1 { margin: 6px 0 0; font-size: clamp(28px, 3vw, 46px); letter-spacing: -.04em; }
.topbar-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.period-switch { display: flex; gap: 8px; padding: 6px; border-radius: 16px; background: rgba(255,255,255,.05); border: 1px solid var(--line); }
.period-switch button { color: var(--muted); background: transparent; border: none; border-radius: 12px; padding: 9px 12px; font-weight: 800; }
.period-switch button.active { color: #1d1521; background: var(--accent-2); }
.user-pill { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-radius: 18px; background: rgba(255,255,255,.05); color: var(--muted); }

.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(160px, 1fr)); gap: 16px; margin-bottom: 18px; }
.kpi-card { border-radius: 24px; padding: 18px; display: flex; align-items: center; gap: 14px; background: linear-gradient(180deg, rgba(39,43,61,.96), rgba(30,33,49,.96)); border: 1px solid var(--line); box-shadow: 0 18px 54px rgba(0,0,0,.22); }
.kpi-card.highlight { background: linear-gradient(135deg, #ffd79c, #ef9d69); color: #221622; }
.kpi-card.danger { background: linear-gradient(180deg, rgba(83,42,55,.92), rgba(38,31,44,.92)); }
.kpi-card > .material-symbols-rounded { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; background: rgba(255,255,255,.08); }
.kpi-card.highlight > .material-symbols-rounded { background: rgba(0,0,0,.08); }
.kpi-card p { margin: 0 0 4px; color: inherit; opacity: .72; font-size: 13px; }
.kpi-card strong { font-size: 28px; letter-spacing: -.04em; }
.pulse { animation: pulse 1.8s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 18px 54px rgba(0,0,0,.22); } 50% { box-shadow: 0 0 0 7px rgba(255,90,107,.08), 0 18px 54px rgba(0,0,0,.22); } }

.dashboard-grid { display: grid; grid-template-columns: minmax(340px, 1.35fr) minmax(300px, .75fr) minmax(300px, .75fr); gap: 18px; align-items: start; }
.panel { border-radius: var(--radius-lg); padding: 22px; min-width: 0; }
.wide-panel { grid-column: span 2; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.panel h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.panel p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.inline-controls { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-controls select { width: auto; min-width: 160px; padding: 10px 12px; }
.stock-table { display: grid; gap: 10px; max-height: 530px; overflow: auto; padding-right: 4px; }
.stock-row { display: grid; grid-template-columns: 62px minmax(130px, 1.2fr) minmax(120px, 1fr) 86px; gap: 14px; align-items: center; padding: 10px; border-radius: 18px; background: rgba(255,255,255,.045); border: 1px solid rgba(255,255,255,.055); }
.stock-row img { width: 62px; height: 52px; object-fit: cover; border-radius: 14px; }
.stock-main strong { display: block; font-size: 15px; }
.stock-main span, .progress-wrap small { color: var(--muted); font-size: 12px; }
.progress-line { height: 9px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; }
.progress-line i { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.progress-line i.low { background: var(--yellow); }
.progress-line i.critical { background: var(--red); }
.stock-count { text-align: right; font-size: 18px; }
.stock-count.low { color: var(--yellow); }
.stock-count.critical { color: var(--red); }
.map-box { width: 100%; height: 330px; border-radius: 20px; overflow: hidden; background: rgba(0,0,0,.16); }
.leaflet-container { background: #1b1f2b; }
.ingredient-grid-mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.ingredient-mini { padding: 14px; border-radius: 18px; background: rgba(255,255,255,.045); border: 1px solid var(--line); }
.ingredient-mini span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.ingredient-mini strong { display: block; margin: 8px 0; font-size: 14px; }
.ingredient-mini b { color: var(--accent-2); }
.ingredient-mini.low { border-color: rgba(255,204,54,.28); }
.ingredient-mini.critical { border-color: rgba(255,90,107,.35); }
.event-list { display: grid; gap: 12px; max-height: 330px; overflow: auto; padding-right: 4px; }
.event-list.tall { max-height: 560px; }
.event-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 18px; background: rgba(255,255,255,.045); border: 1px solid var(--line); }
.event-item .material-symbols-rounded { color: var(--accent-2); }
.event-item strong { display: block; font-size: 14px; }
.event-item small { display: block; color: var(--muted); margin-top: 4px; line-height: 1.4; }

.section-grid { display: grid; gap: 18px; }
.cards-3 { grid-template-columns: repeat(3, minmax(250px, 1fr)); }
.machine-card, .product-card { border-radius: var(--radius-lg); padding: 20px; }
.card-headline { display: grid; grid-template-columns: 16px 1fr; gap: 10px; align-items: center; }
.card-headline small { grid-column: 2; color: var(--muted); }
.status-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 6px rgba(255,255,255,.04); }
.status-dot.ok, .status-dot.active { background: var(--green); }
.status-dot.maintenance { background: var(--yellow); }
.status-dot.offline { background: var(--red); }
.machine-card p { color: var(--muted); min-height: 42px; }
.machine-stat { display: flex; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line); }
.machine-stat span { color: var(--muted); }
.product-card { overflow: hidden; padding: 0; }
.product-card img { width: 100%; aspect-ratio: 16/10; object-fit: cover; }
.product-info { padding: 18px; }
.product-info small { color: var(--accent-2); font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.product-info h3 { margin: 8px 0; font-size: 22px; }
.product-info p { color: var(--muted); min-height: 58px; line-height: 1.55; }
.product-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }
.product-bottom b { font-size: 22px; color: var(--accent-2); }
.product-bottom span { color: var(--muted); }
.data-table { display: grid; gap: 8px; }
.table-row { display: grid; grid-template-columns: 110px 1.4fr 1fr 120px 120px 110px; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 15px; background: rgba(255,255,255,.04); border: 1px solid var(--line); }
.table-row.header { background: transparent; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.status-chip { display: inline-flex; justify-content: center; border-radius: 999px; padding: 7px 10px; font-size: 12px; font-weight: 800; background: rgba(54,209,133,.12); color: #bfffd8; }
.status-chip.low { background: rgba(255,204,54,.13); color: #ffec9d; }
.status-chip.critical { background: rgba(255,90,107,.14); color: #ffd5da; }
.form-grid { display: grid; grid-template-columns: minmax(320px, 470px) 1fr; gap: 18px; align-items: start; }
.stack-form { display: grid; gap: 12px; }
.form-panel { position: sticky; top: 18px; }

@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .wide-panel { grid-column: span 2; }
  .cards-3 { grid-template-columns: repeat(2, minmax(250px, 1fr)); }
}
@media (max-width: 860px) {
  .login-shell { grid-template-columns: 1fr; padding: 18px; }
  .app-shell { grid-template-columns: 1fr; padding: 10px; }
  .sidebar { position: static; height: auto; flex-direction: row; overflow-x: auto; justify-content: flex-start; }
  .nav-btn.logout { margin-top: 0; margin-left: auto; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .kpi-grid, .dashboard-grid, .cards-3, .form-grid, .ingredient-grid-mini { grid-template-columns: 1fr; }
  .wide-panel { grid-column: span 1; }
  .stock-row { grid-template-columns: 54px 1fr 82px; }
  .progress-wrap { grid-column: 2 / 4; }
  .table-row { grid-template-columns: 1fr; }
  .table-row.header { display: none; }
}

/* v1.0.4 — картки залишків у каталозі продукції */
.product-summary-panel { margin-bottom: 18px; }
.product-catalog-grid .product-card { position: relative; border-color: rgba(255,255,255,.09); transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease; }
.product-catalog-grid .product-card:hover { transform: translateY(-3px); border-color: rgba(244,188,127,.28); }
.product-catalog-grid .product-card.low { border-color: rgba(255,204,54,.25); }
.product-catalog-grid .product-card.critical { border-color: rgba(255,90,107,.36); box-shadow: 0 0 0 1px rgba(255,90,107,.08), var(--shadow); }
.product-stock-panel {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 12px;
  margin: -4px 0 14px;
  padding: 14px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(54,209,133,.16), rgba(255,255,255,.045));
  border: 1px solid rgba(54,209,133,.22);
}
.product-stock-panel.low { background: linear-gradient(135deg, rgba(255,204,54,.18), rgba(255,255,255,.045)); border-color: rgba(255,204,54,.28); }
.product-stock-panel.critical { background: linear-gradient(135deg, rgba(255,90,107,.18), rgba(255,255,255,.045)); border-color: rgba(255,90,107,.35); }
.product-stock-panel > .material-symbols-rounded {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: rgba(255,255,255,.075);
  color: var(--accent-2);
}
.product-stock-panel small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.product-stock-panel strong {
  display: block;
  margin-top: 2px;
  font-size: 34px;
  line-height: .95;
  letter-spacing: -.06em;
  color: var(--text);
}
.product-stock-panel em {
  justify-self: end;
  max-width: 110px;
  border-radius: 999px;
  padding: 8px 10px;
  background: rgba(255,255,255,.075);
  color: #dfffe9;
  font-style: normal;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
}
.product-stock-panel.low em { color: #ffec9d; }
.product-stock-panel.critical em { color: #ffd5da; }
.product-stock-progress {
  height: 9px;
  border-radius: 999px;
  margin: 0 0 14px;
  background: rgba(255,255,255,.08);
  overflow: hidden;
}
.product-stock-progress i { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.product-stock-progress i.low { background: var(--yellow); }
.product-stock-progress i.critical { background: var(--red); }
.product-stock-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.product-stock-details span {
  min-height: 52px;
  border-radius: 15px;
  padding: 10px 12px;
  background: rgba(255,255,255,.045);
  border: 1px solid rgba(255,255,255,.055);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}
.product-stock-details b {
  display: block;
  margin-bottom: 2px;
  color: var(--accent-2);
  font-size: 18px;
}
@media (max-width: 860px) {
  .product-stock-panel { grid-template-columns: 46px 1fr; }
  .product-stock-panel em { grid-column: 1 / 3; justify-self: stretch; max-width: none; }
  .product-stock-details { grid-template-columns: 1fr; }
}

/* v1.0.7 — розширена аналітика та стабільна висота графіків */
.dashboard-grid-analytics { grid-template-columns: minmax(360px, 1.25fr) minmax(320px, .9fr) minmax(320px, .9fr); }
.chart-box {
  position: relative;
  width: 100%;
  height: 300px;
  min-height: 260px;
  padding: 6px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.012));
  border: 1px solid rgba(255,255,255,.045);
  overflow: hidden;
}
.chart-box.chart-small { height: 285px; }
.chart-box.chart-wide { height: 330px; }
.chart-box canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}
.panel:has(.chart-box) { min-height: 395px; }
.wide-panel:has(.chart-wide) { min-height: 430px; }
@media (max-width: 1280px) {
  .dashboard-grid-analytics { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .chart-box, .chart-box.chart-small, .chart-box.chart-wide { height: 280px; }
  .panel:has(.chart-box), .wide-panel:has(.chart-wide) { min-height: auto; }
}

/* v1.0.7 — нормальні Chart.js-графіки без саморобних HTML-діаграм */
.chart-box {
  min-height: 315px;
  padding: 18px 18px 12px;
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 201, 121, .08), transparent 32%),
    linear-gradient(145deg, rgba(255,255,255,.045), rgba(255,255,255,.018));
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 22px;
}
.chart-box.chart-small { min-height: 285px; }
.chart-box.chart-wide { min-height: 360px; }
.chart-box canvas {
  width: 100% !important;
  height: 100% !important;
  min-height: 255px;
}
.chart-box.chart-wide canvas { min-height: 310px; }
.chart-debug-banner {
  display: grid;
  gap: 6px;
  margin: 0 0 18px;
  padding: 14px 18px;
  border-radius: 16px;
  color: #ffd8dd;
  background: rgba(255, 90, 107, .16);
  border: 1px solid rgba(255, 90, 107, .28);
  font-weight: 700;
}
.chart-debug-banner span { font-size: 13px; opacity: .9; }
