/* ─── Reset ──────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Calibri, 'Segoe UI', Arial, sans-serif;
  background: #ffffff;
  color: #1a2b4a;
  font-size: 14px;
}

/* ─── Top nav ────────────────────────────────────────────────────────────── */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 38px;
  background: #1a2b4a;
  border-bottom: 2px solid #2e4a7a;
}
.topnav-links { display: flex; gap: 2px; }
.topnav-links a {
  color: #a0b8d8;
  text-decoration: none;
  padding: 5px 14px;
  border-radius: 4px;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}
.topnav-links a:hover  { background: #2e4a7a; color: #fff; }
.topnav-links a.active { background: #2e4a7a; color: #fff; font-weight: 600; }
.btn-upload-nav {
  background: #2e7d32;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 5px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-upload-nav:hover { background: #388e3c; }

/* ─── Page wrapper ───────────────────────────────────────────────────────── */
.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 18px 40px;
}

/* ─── Pulse header ───────────────────────────────────────────────────────── */
.pulse-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 4px;
}
.pulse-title {
  font-size: 28px;
  font-weight: 700;
  color: #1a2b4a;
  letter-spacing: 0.5px;
}
.pulse-date {
  font-size: 13px;
  color: #78909c;
  margin-top: 3px;
}
.pulse-right {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #1a2b4a;
  padding-top: 6px;
}
.health-dot { font-size: 18px; }
.health-dot.green  { color: #2e7d32; }
.health-dot.yellow { color: #f9a825; }
.health-dot.red    { color: #c62828; }
.health-text { font-size: 13px; }

.pulse-divider {
  height: 2px;
  background: #1a2b4a;
  margin: 6px 0 12px;
}

/* ─── KPI grid ───────────────────────────────────────────────────────────── */
.kgrid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

/* ─── KPI block ──────────────────────────────────────────────────────────── */
.kblock {
  background: #e4eaf2;
  padding: 10px 13px 0;
  display: flex;
  flex-direction: column;
  min-height: 260px;
}

.kblock-header {
  font-size: 12px;
  font-weight: 700;
  color: #1a2b4a;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
  text-transform: uppercase;
}

.kblock-main-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}

.kblock-main {
  font-size: 34px;
  font-weight: 700;
  color: #1a2b4a;
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.kblock-secondary {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  text-align: right;
}

.kblock-sublabel-row {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
}

.sublabel {
  font-size: 11px;
  color: #546e7a;
}
.sublabel.italic { font-style: italic; }
#k6-plan { font-size: 18px; font-weight: 600; }
.sublabel.green  { color: #2e7d32; }
.sublabel.muted  { color: #78909c; }

.kblock-spacer { flex: 1; }

.kblock-status {
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
}

.kblock-delta-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 2px;
}

/* ─── Delta values ───────────────────────────────────────────────────────── */
.kdelta {
  font-size: 13px;
  font-weight: 700;
  margin-top: 3px;
}
.kdelta.green  { color: #2e7d32; }
.kdelta.red    { color: #c62828; }
.kdelta.orange { color: #e65100; }
.kdelta.muted  { color: #78909c; }

.kdelta-label {
  font-size: 11px;
  color: #78909c;
}

/* ─── Color utilities ────────────────────────────────────────────────────── */
.green  { color: #2e7d32 !important; }
.blue   { color: #1565c0 !important; }
.red    { color: #c62828 !important; }
.orange { color: #e65100 !important; }
.muted  { color: #78909c !important; }

/* ─── Mini chart area ────────────────────────────────────────────────────── */
.kblock-chart {
  height: 62px;
  margin: 4px -13px 0;
}

/* ─── К2 progress bar ────────────────────────────────────────────────────── */
.k2-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}
.k2-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.k2-progress-bar {
  width: 160px;
  height: 20px;
  background: radial-gradient(circle, #b0bec5 0.8px, transparent 0.8px) 0 0 / 3px 3px #eceff1;
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}
.k2-progress-bar.bad {
  background: radial-gradient(circle, #e65100 0.8px, transparent 0.8px) 0 0 / 3px 3px #ffffff;
}
.k2-progress-bar.good {
  background: radial-gradient(circle, #2e7d32 0.8px, transparent 0.8px) 0 0 / 3px 3px #e8f5e9;
}
.k2-progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}
.k2-pct {
  font-size: 13px;
  font-weight: 600;
  color: #546e7a;
}
.k2-pct.red   { color: #e65100; }
.k2-pct.green { color: #2e7d32; }
.k2-plan-detail { margin-bottom: 4px; display: flex; justify-content: space-between; align-items: baseline; }
.k2-progress-label {
  font-size: 18px;
  font-weight: 600;
  color: #546e7a;
}
.k2-progress-label.red   { color: #e65100; }
.k2-progress-label.green { color: #2e7d32; }

/* ─── К4 specific ────────────────────────────────────────────────────────── */
.k4-dz-total {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 2px;
}
.k4-bucket {
  font-size: 12px;
  font-weight: 600;
  margin-top: 2px;
}
.k4-bucket.orange { color: #e65100; }
.k4-bucket.red    { color: #c62828; }

/* ─── К5 specific ────────────────────────────────────────────────────────── */
.k5-avg {
  font-size: 13px;
  font-weight: 700;
  margin-top: 3px;
}

/* ─── К6 specific ────────────────────────────────────────────────────────── */
.k6-circle        { font-size: 60px; line-height: 1; color: #2e7d32; }
.k6-circle.green  { color: #2e7d32; }
.k6-circle.yellow { color: #f9a825; }
.k6-circle.orange { color: #e65100; }
.k6-circle.red    { color: #c62828; }

/* ─── К3 dash ────────────────────────────────────────────────────────────── */
.k3-dash {
  font-size: 18px;
  color: #f9a825;
  margin-top: 4px;
  letter-spacing: 2px;
}

/* ─── Rules section ──────────────────────────────────────────────────────── */
.rules-section { margin-top: 10px; }

.rules-title {
  font-size: 14px;
  font-weight: 700;
  color: #1a2b4a;
  margin-bottom: 6px;
}

.rules-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.rules-table th, .rules-table td {
  border: 1px solid #b0bec5;
  padding: 5px 8px;
  vertical-align: top;
}
.rules-table thead th { font-weight: 700; color: #fff; font-size: 12px; }
.col-card  { background: #1a2b4a; width: 11%; }
.col-watch { background: #1a2b4a; width: 14%; }
.col-yellow { background: #f9a825; color: #1a2b4a; width: 20%; }
.col-red    { background: #c62828; width: 27%; }
.col-dark   { background: #7b1a1a; width: 28%; }
.rules-table tbody td { background: #fff; color: #1a2b4a; }
.rules-table tbody tr:nth-child(even) td { background: #f5f7fa; }

/* ─── Upload modal ───────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal.hidden { display: none; }
.modal-box {
  background: #fff;
  border: 1px solid #b0bec5;
  border-radius: 8px;
  padding: 24px 28px;
  width: 400px;
  max-width: 95vw;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.modal-title { font-size: 16px; font-weight: 700; color: #1a2b4a; margin-bottom: 4px; }
.upload-hint { font-size: 11px; color: #78909c; margin-bottom: 14px; }
.upload-row  { margin-bottom: 12px; }
.upload-row label { display: block; font-size: 12px; color: #546e7a; margin-bottom: 4px; font-weight: 600; }
.upload-row input[type="file"] {
  width: 100%; background: #f5f7fa;
  border: 1px solid #b0bec5; border-radius: 4px;
  padding: 6px 8px; color: #1a2b4a; font-size: 13px; font-family: inherit;
}
.upload-msg { border-radius: 4px; padding: 7px 10px; font-size: 13px; margin-bottom: 10px; }
.upload-msg.hidden  { display: none; }
.upload-msg.info    { background: #e3f2fd; color: #1565c0; }
.upload-msg.success { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.upload-msg.error   { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }
.upload-msg.warning { background: #fff8e1; color: #e65100; border: 1px solid #ffe082; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.btn-ok {
  background: #1a2b4a; color: #fff; border: none;
  border-radius: 4px; padding: 7px 20px;
  font-weight: 700; font-size: 13px; cursor: pointer; font-family: inherit;
}
.btn-ok:hover { background: #2e4a7a; }
.btn-cancel {
  background: #e0e0e0; color: #546e7a; border: none;
  border-radius: 4px; padding: 7px 18px;
  font-size: 13px; cursor: pointer; font-family: inherit;
}
.btn-cancel:hover { background: #bdbdbd; }

/* ─── Авто-загрузка ──────────────────────────────────────────────────────── */
.autoload-section { border-top: 1px solid #e0e0e0; margin-top: 16px; padding-top: 12px; }
.autoload-title   { font-size: 13px; font-weight: 700; color: #1a2b4a; margin-bottom: 6px; }
.autoload-status  { font-size: 12px; color: #546e7a; background: #f5f7fa; border-radius: 4px;
                    padding: 6px 10px; margin-bottom: 8px; min-height: 28px; }
.autoload-row     { display: flex; gap: 6px; align-items: center; }
.autoload-input   { flex: 1; background: #f5f7fa; border: 1px solid #b0bec5; border-radius: 4px;
                    padding: 6px 8px; color: #1a2b4a; font-size: 12px; font-family: inherit; }

/* ─── Analytics page ─────────────────────────────────────────────────────── */
.anpage { max-width: 1280px; margin: 0 auto; padding: 14px 18px 40px; }
.an-section-title {
  font-size: 13px; font-weight: 700; color: #1a2b4a;
  text-transform: uppercase; letter-spacing: 0.5px;
  margin: 16px 0 8px; padding-bottom: 4px;
  border-bottom: 2px solid #1a2b4a;
}
.chart-card {
  background: #f0f3f8;
  border: 1px solid #cfd8dc;
  border-radius: 4px;
  padding: 12px 16px;
  margin-bottom: 12px;
}
.chart-card-title { font-size: 13px; font-weight: 700; color: #1a2b4a; margin-bottom: 8px; }
.chart-full { height: 260px; }

/* ─── History page ───────────────────────────────────────────────────────── */
.hpage { max-width: 1280px; margin: 0 auto; padding: 14px 18px 40px; }
.h-title { font-size: 15px; font-weight: 700; color: #1a2b4a; margin-bottom: 10px; text-transform: uppercase; }
.log-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.log-table th {
  background: #1a2b4a; color: #fff; text-align: left;
  padding: 8px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
}
.log-table td { padding: 8px 12px; border-bottom: 1px solid #e0e0e0; color: #1a2b4a; }
.log-table tr:hover td { background: #f5f7fa; }
.badge { border-radius: 3px; padding: 2px 7px; font-size: 11px; font-weight: 700; }
.badge-success { background: #e8f5e9; color: #2e7d32; }
.badge-error   { background: #ffebee; color: #c62828; }
.fname { font-size: 11px; color: #78909c; }

/* ─── Plan page ──────────────────────────────────────────────────────────── */
.ppage { max-width: 860px; margin: 0 auto; padding: 14px 18px 40px; }
.p-title { font-size: 15px; font-weight: 700; color: #1a2b4a; margin-bottom: 12px; text-transform: uppercase; }
.plan-form-wrap { display: flex; gap: 32px; flex-wrap: wrap; }
.plan-form { flex: 1; min-width: 280px; }
.plan-row { margin-bottom: 14px; }
.plan-row label { display: block; font-size: 12px; color: #546e7a; margin-bottom: 4px; font-weight: 600; }
.plan-row input {
  width: 100%; background: #f5f7fa; border: 1px solid #b0bec5;
  border-radius: 4px; padding: 8px 10px; color: #1a2b4a;
  font-size: 14px; font-family: inherit;
}
.plan-row input:focus { outline: none; border-color: #1a2b4a; }
.plan-actions { margin-top: 6px; }
.plan-current {
  background: #e4eaf2; border-radius: 4px; padding: 16px 18px;
  flex: 1; min-width: 200px; max-width: 320px; align-self: flex-start;
  line-height: 2;
}
.plan-saved-title { font-weight: 700; color: #1a2b4a; margin-bottom: 6px; }
.plan-saved-date  { font-size: 11px; color: #78909c; margin-top: 6px; }

/* ─── Sub-pages (Касса / Склад / Детализация) ────────────────────────────── */
.subpage { max-width: 1280px; margin: 0 auto; padding: 14px 18px 40px; }
.sub-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.sub-title  { font-size: 22px; font-weight: 700; color: #1a2b4a; text-transform: uppercase; letter-spacing: 0.5px; }
.sub-date   { font-size: 13px; color: #78909c; }
.sub-divider { height: 2px; background: #1a2b4a; margin: 6px 0 14px; }

/* ─── Summary tiles ──────────────────────────────────────────────────────── */
.sum-tiles {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.stile { background: #e4eaf2; padding: 10px 14px; border-radius: 2px; }
.stile-label { font-size: 11px; color: #546e7a; font-weight: 600; text-transform: uppercase; margin-bottom: 4px; }
.stile-value { font-size: 22px; font-weight: 700; color: #1a2b4a; }

/* ─── Wide scrollable table ──────────────────────────────────────────────── */
.tscroll { overflow-x: auto; overflow-y: auto; max-height: calc(100vh - 210px); margin-bottom: 16px; }
.wide-table { border-collapse: collapse; font-size: 12px; white-space: nowrap; width: 100%; }
.wide-table th {
  background: #1a2b4a; color: #fff;
  padding: 6px 10px; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.3px;
  position: sticky; top: 0; z-index: 1; font-weight: 700;
}
.wide-table td { padding: 5px 10px; border-bottom: 1px solid #e0e0e0; color: #1a2b4a; }
.wide-table tr:hover td { background: #f5f7fa; }
.wide-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.wide-table .sticky-col { position: sticky; left: 0; z-index: 2; background: #fff; border-right: 2px solid #e0e0e0; }
.wide-table thead .sticky-col { background: #1a2b4a; z-index: 3; }
.wide-table tr:hover .sticky-col { background: #f5f7fa; }

/* ─── Details filter ─────────────────────────────────────────────────────── */
.det-filter {
  display: flex; align-items: center; gap: 12px;
  background: #e4eaf2; padding: 10px 14px;
  border-radius: 4px; margin-bottom: 14px; flex-wrap: wrap;
}
.det-filter label { font-size: 12px; color: #546e7a; font-weight: 600; }
.det-filter input[type="date"] {
  border: 1px solid #b0bec5; border-radius: 3px;
  padding: 4px 8px; font-size: 12px; font-family: inherit;
  color: #1a2b4a; background: #fff;
}
.det-filter-count { font-size: 12px; color: #78909c; margin-left: auto; }

/* ─── Sklad 7-day snapshot ───────────────────────────────────────────────── */
.sklad-snap { background: #e4eaf2; padding: 14px 16px; border-radius: 4px; margin-bottom: 16px; }
.sklad-snap-title { font-size: 12px; font-weight: 700; text-transform: uppercase; color: #1a2b4a; margin-bottom: 10px; }
.sklad-snap-grid {
  display: grid; grid-template-columns: 90px repeat(7, 1fr);
  gap: 4px; font-size: 12px;
}
.ssnap-cell  { padding: 4px 8px; text-align: center; }
.ssnap-head  { font-weight: 700; color: #546e7a; font-size: 11px; }
.ssnap-label { font-weight: 700; color: #1a2b4a; text-align: left; }
.ssnap-in    { color: #2e7d32; }
.ssnap-out   { color: #c62828; }

@media (max-width: 900px) {
  .sum-tiles { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .sum-tiles { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Forecast legend ────────────────────────────────────────────────────── */
.fc-legend { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 14px; }
.fc-leg-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #546e7a; }
.fc-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ─── Hidden ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f0f3f8; }
::-webkit-scrollbar-thumb { background: #b0bec5; border-radius: 3px; }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .kgrid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .kgrid { grid-template-columns: 1fr; }
  .pulse-title { font-size: 20px; }
}
