:root {
  --bg: #eef7ff;
  --panel: rgba(255, 255, 255, 0.74);
  --ink: #102a65;
  --muted: #6380b3;
  --line: rgba(178, 207, 246, 0.48);
  --accent: #3179ff;
  --accent-2: #39c7cf;
  --accent-3: #f6b348;
  --accent-4: #8a6dff;
  --soft: rgba(229, 241, 255, 0.86);
  --warn: rgba(255, 249, 240, 0.84);
  --shadow: 0 20px 58px rgba(55, 117, 204, 0.14);
  --soft-shadow: 0 12px 34px rgba(70, 132, 214, 0.12);
  --glass: linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(241, 248, 255, 0.62));
}

* { box-sizing: border-box; }

@keyframes fadeRise {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes popIn {
  0% { opacity: 0; transform: translateY(18px) scale(0.96); }
  68% { opacity: 1; transform: translateY(-2px) scale(1.01); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes drawerIn {
  from { opacity: 0; transform: translateX(26px) scale(0.985); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes shimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

@keyframes breathing {
  0%, 100% { transform: scale(1); opacity: 0.72; }
  50% { transform: scale(1.08); opacity: 1; }
}

body.app-ready .brief-card,
body.app-ready .forecast-top-deck,
body.app-ready .toolbar,
body.app-ready .notice,
body.app-ready .template-head,
body.app-ready .selected-products-panel,
body.app-ready .template-library,
body.app-ready .candidate-products,
body.app-ready .chart-panel,
body.app-ready .weather-grid > div,
body.app-ready .data-card {
  animation: popIn 0.54s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.is-loading {
  position: relative;
  overflow: hidden;
}

.is-loading::before {
  content: attr(data-loading-text);
  position: absolute;
  left: 50%;
  top: 92px;
  transform: translateX(-50%);
  z-index: 10;
  min-width: 118px;
  padding: 10px 18px 10px 42px;
  border-radius: 999px;
  color: #082b71;
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(188, 215, 248, 0.72);
  box-shadow: 0 18px 42px rgba(70, 132, 214, 0.18);
  backdrop-filter: blur(14px);
  pointer-events: none;
}

.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  background:
    radial-gradient(circle at calc(50% - 52px) 110px, #3179ff 0 5px, transparent 6px),
    radial-gradient(circle at calc(50% - 34px) 110px, #39c7cf 0 5px, transparent 6px),
    radial-gradient(circle at calc(50% - 16px) 110px, #f6b348 0 5px, transparent 6px),
    linear-gradient(110deg, rgba(244, 250, 255, 0.2) 0%, rgba(255, 255, 255, 0.5) 42%, rgba(244, 250, 255, 0.2) 74%);
  animation: shimmer 1.15s ease-in-out infinite;
}

.brief-card,
.toolbar,
.notice,
.template-head,
.template-library,
.selected-products-panel,
.candidate-products,
.chart-panel,
.weather-grid > div,
.data-card {
  position: relative;
  overflow: hidden;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease, background 0.22s ease;
}

.brief-card::before,
.toolbar::before,
.notice::before,
.template-head::before,
.template-library::before,
.selected-products-panel::before,
.candidate-products::before,
.chart-panel::before,
.weather-grid > div::before,
.data-card::before {
  content: "";
  position: absolute;
  width: 150px;
  height: 150px;
  right: -72px;
  top: -74px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.78), rgba(77, 182, 255, 0.22) 46%, transparent 72%);
  opacity: 0;
  transform: scale(0.78);
  transition: opacity 0.22s ease, transform 0.28s ease;
  pointer-events: none;
}

.brief-card:hover,
.toolbar:hover,
.notice:hover,
.template-head:hover,
.template-library:hover,
.selected-products-panel:hover,
.candidate-products:hover,
.chart-panel:hover,
.weather-grid > div:hover,
.data-card:hover {
  transform: translateY(-2px);
  border-color: rgba(126, 195, 255, 0.62);
  box-shadow: 0 22px 62px rgba(55, 117, 204, 0.18);
}

.brief-card:hover::before,
.toolbar:hover::before,
.notice:hover::before,
.template-head:hover::before,
.template-library:hover::before,
.selected-products-panel:hover::before,
.candidate-products:hover::before,
.chart-panel:hover::before,
.weather-grid > div:hover::before,
.data-card:hover::before {
  opacity: 1;
  transform: scale(1.08);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 12%, rgba(97, 178, 255, 0.20), transparent 28%),
    radial-gradient(circle at 88% 4%, rgba(129, 198, 255, 0.34), transparent 26%),
    radial-gradient(circle at 8% 92%, rgba(91, 211, 225, 0.16), transparent 28%),
    linear-gradient(135deg, #f7fbff 0%, #edf7ff 44%, #f8fcff 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  display: grid;
  grid-template-columns: 228px 1fr;
}

body.login-active .sidebar,
body.login-active main {
  opacity: 0;
  pointer-events: none;
}

.app-loading {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 12%, rgba(81, 190, 236, 0.20), transparent 30%),
    linear-gradient(135deg, rgba(247, 251, 255, 0.86), rgba(232, 246, 255, 0.92));
  backdrop-filter: blur(16px);
}

.app-loading[hidden] {
  display: none;
}

.loading-card {
  width: min(340px, calc(100vw - 32px));
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 26px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.86);
  box-shadow: 0 28px 80px rgba(67, 132, 204, 0.22);
  animation: fadeRise 0.44s ease both;
}

.loading-card img,
.login-card img {
  width: 76px;
  height: 76px;
  border-radius: 22px;
  object-fit: cover;
  box-shadow: 0 18px 38px rgba(239, 75, 132, 0.20);
}

.loading-card strong {
  font-size: 18px;
}

.loading-card span {
  color: var(--muted);
  font-size: 13px;
}

.loading-card i {
  width: 178px;
  height: 5px;
  margin-top: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #3179ff, #39c7cf, #f6b348);
  animation: breathing 1.1s ease-in-out infinite;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 18% 16%, rgba(78, 179, 255, 0.20), transparent 28%),
    radial-gradient(circle at 86% 8%, rgba(255, 190, 218, 0.32), transparent 25%),
    linear-gradient(135deg, #f7fbff 0%, #edf8ff 52%, #fff7fb 100%);
}

.login-screen[hidden] {
  display: none;
}

.login-card {
  width: min(430px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.88);
  box-shadow: 0 30px 90px rgba(55, 117, 204, 0.22);
  backdrop-filter: blur(22px);
  animation: popIn 0.58s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.login-card h1 {
  font-size: 28px;
}

.login-card p {
  margin: -6px 0 4px;
}

.login-card button {
  min-height: 46px;
}

#loginMessage {
  min-height: 18px;
  color: #b4233a;
  font-size: 13px;
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(217, 237, 255, 0.54)),
    radial-gradient(circle at 12% 86%, rgba(77, 182, 255, 0.22), transparent 36%);
  color: var(--ink);
  padding: 22px 18px;
  min-height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, 0.74);
  box-shadow: 16px 0 46px rgba(75, 134, 204, 0.10);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(239, 75, 132, 0.18);
}

.mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav {
  text-align: left;
  border: 0;
  color: #22407c;
  background: transparent;
  padding: 11px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 15px;
}

.nav.active,
.nav[aria-current="page"] {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 14px 34px rgba(70, 132, 214, 0.14);
  font-weight: 800;
}

.nav:hover:not(.active):not([aria-current="page"]) {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.52);
}

main {
  min-width: 0;
  padding: 24px 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.topbar-right {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 12px;
}

h1 {
  margin: 0;
  font-size: 27px;
  letter-spacing: 0;
  color: #09276a;
}

h2 {
  margin: 0 0 12px;
  font-size: 17px;
}

p {
  margin: 6px 0 0;
  color: var(--muted);
}

.actions {
  display: grid;
  justify-items: end;
  gap: 6px;
  min-width: 320px;
}

.action-row {
  display: flex;
  gap: 10px;
}

.account-menu {
  position: relative;
  z-index: 12;
}

.account-button {
  min-height: 46px;
  display: grid;
  grid-template-columns: 32px auto auto;
  align-items: center;
  gap: 9px;
  padding: 7px 12px 7px 8px;
  border-radius: 16px;
  color: #09276a;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.88);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(16px);
}

.account-button img {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  object-fit: cover;
}

.account-button em {
  color: var(--muted);
  font-style: normal;
  font-size: 13px;
}

.account-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 138px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.84);
  box-shadow: 0 18px 48px rgba(55, 117, 204, 0.18);
  backdrop-filter: blur(18px);
}

.account-dropdown[hidden] {
  display: none;
}

.account-dropdown button {
  width: 100%;
}

#updateHint {
  color: var(--muted);
  line-height: 1.35;
  text-align: right;
  max-width: 520px;
}

button {
  border: 0;
  background: linear-gradient(135deg, #2f76ff, #49c9d4);
  color: white;
  border-radius: 12px;
  padding: 11px 15px;
  cursor: pointer;
  font-weight: 650;
  position: relative;
  overflow: hidden;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

button::after {
  content: "";
  position: absolute;
  inset: -34px auto -34px -62px;
  width: 50px;
  transform: rotate(18deg);
  background: rgba(255, 255, 255, 0.42);
  opacity: 0;
  transition: transform 0.34s ease, opacity 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(49, 121, 255, 0.22);
}

button:hover::after {
  opacity: 1;
  transform: translateX(220px) rotate(18deg);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
  box-shadow: none;
}

button.secondary {
  background: linear-gradient(135deg, #244a8f, #406bb4);
}

button.ghost {
  background: rgba(232, 242, 255, 0.9);
  color: #22407c;
}

button.tiny,
button.icon-btn {
  padding: 6px 9px;
  border-radius: 9px;
  font-size: 12px;
}

button.icon-btn {
  min-width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: rgba(232, 242, 255, 0.9);
  color: var(--accent-2);
}

.daily-brief {
  display: grid;
  grid-template-columns: minmax(250px, 0.66fr) minmax(520px, 1.58fr) minmax(260px, 0.76fr);
  gap: 12px;
  margin-bottom: 14px;
}

.brief-card {
  min-height: 138px;
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 16px;
  box-shadow: var(--soft-shadow);
  padding: 16px;
  backdrop-filter: blur(18px);
}

.today-card {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 12px;
  align-items: center;
}

.calendar-tile {
  height: 88px;
  display: grid;
  align-content: center;
  justify-items: center;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(232, 243, 255, 0.86));
  border: 1px solid rgba(182, 211, 248, 0.55);
  box-shadow: inset 0 -10px 24px rgba(49, 121, 255, 0.08);
}

.calendar-tile span,
.calendar-tile em,
.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.calendar-tile strong {
  color: var(--accent);
  font-size: 34px;
  line-height: 1;
  margin: 3px 0;
}

.brief-card h2 {
  font-size: 18px;
  margin: 4px 0 6px;
}

.brief-card p {
  font-size: 13px;
  line-height: 1.55;
}

.brief-tags {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.brief-tags span {
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(223, 244, 255, 0.88);
  color: #0e5fbf;
  font-size: 12px;
  font-weight: 700;
}

.brief-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.weather-brief {
  display: grid;
  align-content: stretch;
  padding: 14px;
}

.weather-brief-body {
  display: grid;
  grid-template-columns: 188px minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

.weather-mini-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-content: start;
}

.weather-mini {
  min-width: 0;
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(194, 218, 249, 0.56);
  padding: 10px 11px;
}

.weather-place,
.rain-column {
  display: block;
  min-width: 0;
}

.weather-place {
  display: grid;
  gap: 3px;
}

.weather-place strong {
  font-size: 15px;
}

.weather-place span {
  color: var(--ink);
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.weather-place small {
  color: var(--muted);
  font-size: 11px;
}

.rain-column {
  flex: 0 0 58px;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 7px 6px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(77, 202, 216, 0.18), rgba(47, 118, 255, 0.08));
}

.rain-column em {
  color: #1971d4;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.rain-column small {
  color: var(--muted);
  font-size: 11px;
}

.brief-forecast {
  min-width: 0;
  margin-top: 0;
  border-radius: 8px;
  border: 1px solid rgba(194, 218, 249, 0.56);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(239, 248, 255, 0.68));
  overflow: hidden;
}

.brief-forecast canvas {
  width: 100%;
  height: 174px;
  display: block;
}

.brief-forecast-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 0 12px 10px;
  color: var(--muted);
  font-size: 12px;
}

.brief-forecast-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.brief-forecast-legend i {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  display: inline-block;
  flex: 0 0 auto;
}

.brief-forecast-legend .rain-dot {
  background: rgba(72, 190, 219, 0.48);
}

.brief-forecast-legend .event-dot {
  background: var(--accent-3);
}

.next-holiday-card {
  display: grid;
  align-content: center;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.status-strip div {
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  position: relative;
  overflow: hidden;
}

.status-strip div::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}

.status-strip span,
.status-strip small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.status-strip strong {
  display: block;
  font-size: 16px;
  margin: 4px 0;
}

.kpis div,
.chart-panel,
.split > div,
.data-grid > div,
.data-grid > details,
.notice {
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.kpis div {
  padding: 10px 14px;
}

.kpis span {
  color: var(--muted);
  font-size: 13px;
}

.kpis strong {
  display: block;
  font-size: 19px;
  margin-top: 4px;
}

.view { display: none; }
.view.active {
  display: block;
  animation: fadeRise 0.34s ease both;
}

.toolbar {
  display: grid;
  grid-template-columns: 240px 190px 1fr;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 16px;
  box-shadow: var(--soft-shadow);
  padding: 12px;
}

.forecast-toolbar {
  grid-template-columns: 220px 170px minmax(220px, 1fr) 220px;
}

label {
  color: var(--muted);
  display: grid;
  gap: 5px;
  font-size: 13px;
}

select,
input {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(178, 207, 246, 0.58);
  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  font: inherit;
}

input[type="checkbox"] {
  width: auto;
  min-height: 0;
  accent-color: var(--accent);
}

.notice {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  background: rgba(255, 250, 242, 0.72);
  margin-bottom: 12px;
  box-shadow: none;
  color: #7a4c12;
}

.notice span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(246, 179, 72, 0.35);
  font-size: 13px;
}

.forecast-top-deck {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.forecast-top-deck .notice {
  margin-bottom: 0;
}

.template-workbench {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(320px, 0.96fr) minmax(260px, 0.8fr);
  gap: 12px;
  align-items: stretch;
}

.forecast-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  min-width: 0;
}

.forecast-board-grid {
  display: grid;
  grid-template-columns: minmax(420px, 0.9fr) minmax(560px, 1.1fr);
  gap: 12px;
  align-items: stretch;
  min-width: 0;
}

.forecast-ops-panel {
  display: grid;
  grid-template-rows: auto minmax(420px, 1fr);
  gap: 12px;
  min-width: 0;
}

.template-head {
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: end;
  min-width: 0;
}

.template-actions {
  display: grid;
  grid-template-columns: minmax(128px, 1fr) minmax(160px, 1fr);
  gap: 8px;
  align-items: center;
}

.template-manager {
  display: grid;
  grid-template-columns: minmax(150px, 0.9fr) minmax(180px, 1.1fr);
  gap: 10px;
  align-items: end;
}

.template-buttons {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 8px;
}

#templateHint {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.danger-ghost {
  color: #b4233a;
  background: rgba(255, 238, 244, 0.92);
}

button.danger {
  background: #c43d55;
}

.selection-board {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 12px;
}

.candidate-products {
  min-width: 0;
}

.product-picker {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 460px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 12px;
  border-radius: 16px;
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  transform-origin: center;
  animation: popIn 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}

body.app-ready .product-picker {
  animation: popIn 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.product-picker[hidden] {
  display: none;
}

.product-picker::before {
  content: "";
  position: absolute;
  width: 150px;
  height: 150px;
  right: -72px;
  top: -74px;
  z-index: 0;
  opacity: 0;
  transform: scale(0.78);
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.78), rgba(77, 182, 255, 0.22) 46%, transparent 72%);
  backdrop-filter: none;
  transition: opacity 0.22s ease, transform 0.28s ease;
  pointer-events: none;
}

.product-picker:hover::before {
  opacity: 1;
  transform: scale(1.08);
}

.candidate-head {
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin-bottom: 10px;
  display: grid;
  grid-template-columns: minmax(160px, 0.7fr) minmax(280px, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.product-picker .table-wrap {
  max-height: 620px;
  height: 100%;
  overflow: auto;
  border-radius: 14px;
}

.candidate-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.product-list-filters {
  display: grid;
  grid-template-columns: minmax(150px, 0.72fr) minmax(180px, 1fr);
  gap: 10px;
}

.candidate-head span {
  color: var(--muted);
  font-size: 12px;
}

.compact-action {
  min-width: 116px;
  padding-inline: 12px;
  white-space: nowrap;
}

.template-library,
.selected-products-panel {
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 12px;
}

.forecast-selected-panel {
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  min-height: 700px;
}

.forecast-selected-panel .board-head {
  display: grid;
  gap: 12px;
  margin-bottom: 0;
}

.selected-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.selected-clear-action {
  min-width: 0;
  width: 100%;
  height: 42px;
  align-self: end;
  white-space: nowrap;
}

.export-screenshot-action {
  min-width: 0;
  width: 100%;
  height: 42px;
  align-self: end;
  white-space: nowrap;
}

button:disabled,
input[readonly] {
  cursor: not-allowed;
}

button:disabled {
  opacity: 0.56;
  filter: saturate(0.7);
}

input[readonly] {
  background: rgba(239, 247, 255, 0.72);
  color: var(--muted);
}

.selected-products-panel.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(49, 121, 255, 0.14), var(--shadow);
}

.board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.board-head h2 {
  margin-bottom: 2px;
}

.board-head span,
.template-choice em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.board-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-action {
  min-width: 120px;
  background: linear-gradient(135deg, #3179ff, #39c7cf);
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(8px);
}

.confirm-overlay[hidden] {
  display: none;
}

.confirm-dialog {
  width: min(420px, 100%);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.24);
  padding: 18px;
}

.confirm-dialog p {
  line-height: 1.65;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.template-multi-list {
  display: flex;
  align-items: center;
  align-content: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  max-height: 180px;
  overflow: auto;
}

.selected-product-list {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  max-height: 205px;
  overflow: auto;
  padding-right: 2px;
}

.forecast-selected-panel .selected-product-list {
  max-height: none;
  min-height: 0;
  align-content: flex-start;
}

.selected-product-list.template-sectioned {
  display: grid;
  grid-template-columns: 1fr;
}

.selected-template-section {
  border: 1px solid rgba(188, 215, 248, 0.6);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.84), rgba(235, 248, 255, 0.72));
  box-shadow: 0 14px 32px rgba(70, 132, 214, 0.11);
  padding: 8px;
  display: grid;
  gap: 8px;
  min-width: 0;
  position: relative;
}

.selected-template-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 2px 2px 0;
}

.selected-template-section-head[draggable="true"] {
  cursor: grab;
}

.selected-template-section-head[draggable="true"]:active {
  cursor: grabbing;
}

.selected-template-section-head em,
.selected-template-section-head strong {
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
}

.selected-template-section-head strong {
  margin-left: auto;
  color: #2456d6;
}

.selected-template-bubble {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 6px 12px;
  border-radius: 999px;
  color: #17417f;
  font-weight: 800;
  background: linear-gradient(135deg, rgba(228, 240, 255, 0.96), rgba(225, 251, 252, 0.92));
  border: 1px solid rgba(92, 155, 246, 0.3);
}

.selected-template-section-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.forecast-selected-panel .selected-product,
.forecast-selected-panel .selected-group {
  flex-basis: 100%;
}

.template-choice {
  display: inline-grid;
  grid-template-columns: auto auto;
  gap: 8px;
  align-items: center;
  width: auto;
  max-width: 220px;
  padding: 8px 10px;
  border: 1px solid rgba(188, 215, 248, 0.58);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  cursor: grab;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.template-choice:has(input:checked) {
  border-color: rgba(49, 121, 255, 0.42);
  background: linear-gradient(135deg, rgba(232, 242, 255, 0.96), rgba(229, 250, 252, 0.94));
  box-shadow: 0 12px 28px rgba(70, 132, 214, 0.14);
}

.template-choice:hover {
  transform: translateY(-2px) scale(1.01);
  border-color: rgba(49, 121, 255, 0.38);
  box-shadow: 0 12px 28px rgba(70, 132, 214, 0.16);
  background: rgba(255, 255, 255, 0.92);
}

.template-choice span,
.template-choice strong {
  display: block;
}

.template-choice span {
  min-width: 0;
}

.template-choice strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-product {
  display: grid;
  grid-template-columns: 24px minmax(230px, 1fr) minmax(74px, 78px) minmax(82px, 86px) minmax(70px, 0.35fr) 28px;
  flex: 1 1 270px;
  max-width: 100%;
  gap: 8px;
  align-items: center;
  padding: 7px;
  border: 1px solid rgba(188, 215, 248, 0.58);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  cursor: grab;
  min-width: 0;
  position: relative;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.selected-product:hover {
  transform: translateY(-1px);
  border-color: rgba(49, 121, 255, 0.32);
  box-shadow: 0 10px 24px rgba(70, 132, 214, 0.13);
}

.selected-product div {
  min-width: 0;
}

.selected-product.inside-group {
  background: rgba(255, 255, 255, 0.92);
}

.selected-product.drop-combine,
.selected-group.drop-combine {
  border-color: var(--accent);
  background: rgba(231, 241, 255, 0.88);
  box-shadow: 0 0 0 3px rgba(49, 121, 255, 0.14);
}

.selected-product.drop-before,
.selected-product.drop-after,
.selected-group.drop-before,
.selected-group.drop-after,
.selected-template-section.drop-before,
.selected-template-section.drop-after {
  border-color: rgba(49, 121, 255, 0.54);
  box-shadow: 0 0 0 3px rgba(49, 121, 255, 0.12), var(--shadow);
}

.selected-product.drop-before,
.selected-group.drop-before,
.selected-template-section.drop-before {
  transform: translateY(-2px);
}

.selected-product.drop-after,
.selected-group.drop-after,
.selected-template-section.drop-after {
  transform: translateY(2px);
}

.selected-product.drop-before::before,
.selected-product.drop-after::after,
.selected-group.drop-before::before,
.selected-group.drop-after::after,
.selected-template-section.drop-before::before,
.selected-template-section.drop-after::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, #3179ff, #20c4d2);
  box-shadow: 0 0 14px rgba(49, 121, 255, 0.35);
}

.selected-product.drop-before::before,
.selected-group.drop-before::before,
.selected-template-section.drop-before::before {
  top: -5px;
}

.selected-product.drop-after::after,
.selected-group.drop-after::after,
.selected-template-section.drop-after::after {
  bottom: -5px;
}

.selected-product:active {
  cursor: grabbing;
}

.selected-product span,
.selected-product strong {
  display: block;
}

.selected-product div span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.selected-product em {
  color: var(--accent-2);
  font-style: normal;
  font-weight: 800;
  white-space: nowrap;
  display: grid;
  gap: 1px;
  justify-items: end;
  line-height: 1.15;
}

.selected-product .remove-selected {
  grid-column: 6;
}

.selected-product em small,
.selected-group-total small,
.selected-group-forecast small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.order-num {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(224, 241, 255, 0.92);
  color: var(--accent);
  font-weight: 800;
  font-size: 12px;
}

.selected-group {
  display: grid;
  flex: 1 1 560px;
  max-width: 100%;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(188, 215, 248, 0.58);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 252, 246, 0.92), rgba(248, 252, 255, 0.9));
  min-width: 0;
  position: relative;
}

.selected-group.collapsed {
  background: rgba(255, 255, 255, 0.72);
}

.selected-group.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(49, 121, 255, 0.14);
}

.selected-group-head {
  display: grid;
  grid-template-columns: 24px minmax(230px, 1fr) minmax(74px, 78px) minmax(82px, 86px) minmax(70px, 0.35fr) 28px;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.selected-group-main {
  display: grid;
  grid-template-columns: minmax(120px, 260px) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.selected-group-count {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.selected-group-total,
.selected-group-forecast {
  color: var(--accent-2);
  font-size: 13px;
  white-space: nowrap;
  text-align: right;
}

.selected-group-forecast {
  color: var(--accent);
}

.selected-group-name {
  width: 100%;
  max-width: 260px;
  min-width: 0;
  min-height: 32px;
  padding: 6px 8px;
  font-weight: 700;
}

.selected-group-head .group-toggle {
  grid-column: 6;
}

.selected-group-items {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  padding-left: 0;
  max-height: 108px;
  overflow: auto;
}

.selected-group.collapsed .selected-group-items,
.selected-group-items[hidden] {
  display: none;
}

.empty-state {
  border: 1px dashed rgba(126, 169, 226, 0.68);
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.62);
  font-size: 13px;
}

.template-builder {
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(188, 215, 248, 0.58);
  border-radius: 16px;
  padding: 10px 12px;
}

.template-builder summary,
.technical-details summary,
.result-details summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 800;
}

.template-builder-body {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 12px;
}

.group-tools {
  display: grid;
  gap: 8px;
  align-self: start;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(188, 215, 248, 0.58);
  border-radius: 8px;
  padding: 10px;
}

.template-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.template-group {
  min-height: 118px;
  border: 1px solid rgba(188, 215, 248, 0.58);
  background: rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  padding: 10px;
}

.template-group.drag-over {
  border-color: var(--accent);
  background: rgba(231, 241, 255, 0.88);
  box-shadow: 0 0 0 3px rgba(49, 121, 255, 0.14);
}

.group-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.group-head input {
  min-height: 32px;
  padding: 6px 8px;
  font-weight: 700;
}

.group-head strong {
  color: var(--accent);
  font-size: 13px;
  white-space: nowrap;
}

.drop-zone {
  border: 1px dashed #a8bdc9;
  border-radius: 8px;
  padding: 9px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.template-items {
  display: grid;
  gap: 7px;
}

.template-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(188, 215, 248, 0.58);
}

.template-item strong,
.template-item span {
  display: block;
}

.template-item span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.template-item em {
  color: var(--accent-2);
  font-style: normal;
  font-weight: 800;
  white-space: nowrap;
}

.table-wrap {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 16px;
  overflow: auto;
  max-height: calc(100vh - 280px);
  box-shadow: var(--soft-shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(216, 229, 247, 0.72);
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: rgba(243, 248, 255, 0.96);
  z-index: 1;
  color: #344054;
}

tr[draggable="true"] {
  cursor: pointer;
}

tbody tr:hover {
  background: rgba(237, 247, 255, 0.64);
}

tr[draggable="true"]:active { cursor: grabbing; }

.candidate-products th:nth-child(4),
td.qty {
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.candidate-products table {
  table-layout: fixed;
}

.candidate-products th:nth-child(1),
.candidate-products td:nth-child(1) {
  width: 34px;
  padding-right: 6px;
}

.candidate-products th:nth-child(2),
.candidate-products td:nth-child(2) {
  width: 160px;
}

.candidate-products th:nth-child(3),
.candidate-products td:nth-child(3) {
  width: 92px;
}

.candidate-products th:nth-child(4),
.candidate-products td:nth-child(4) {
  width: 108px;
}

.candidate-products th:nth-child(5),
.candidate-products td:nth-child(5) {
  width: 126px;
}

.product-cell {
  white-space: normal;
}

.category-cell {
  color: var(--muted);
  white-space: normal;
}

.product-cell strong,
.product-cell span {
  display: block;
}

.product-cell strong {
  line-height: 1.35;
}

.product-cell span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.qty-stack {
  display: inline-grid;
  justify-items: center;
  gap: 3px;
  min-width: 72px;
}

.muted {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.reason-cell {
  white-space: normal;
  min-width: 220px;
  line-height: 1.45;
}

.table-empty {
  text-align: center;
  padding: 28px 12px;
  color: var(--muted);
}

.table-empty strong,
.table-empty span {
  display: block;
  margin-bottom: 8px;
}

.trend {
  display: inline-block;
  font-weight: 800;
}

.trend.up { color: #4b72ff; }
.trend.down { color: #168bc5; }
.trend.flat { color: #64748b; }

.pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(225, 244, 255, 0.9);
  color: #0e5fbf;
  font-weight: 700;
}

.chart-panel {
  padding: 18px;
  margin-bottom: 14px;
}

canvas {
  width: 100%;
  height: 360px;
}

.weather-toolbar {
  grid-template-columns: 220px 180px minmax(210px, 1fr);
}

.range-readout,
.weight-readout {
  min-height: 38px;
  display: grid;
  align-content: center;
  border: 1px solid rgba(178, 207, 246, 0.58);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  padding: 7px 10px;
}

.range-readout strong,
.weight-readout strong {
  color: var(--accent);
  font-size: 16px;
}

.range-readout span,
.weight-readout span {
  color: var(--muted);
  font-size: 12px;
}

.weather-chart-panel {
  padding: 16px;
}

.weather-chart-panel canvas {
  height: 420px;
  cursor: zoom-in;
  touch-action: none;
}

.weather-insight-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.weather-insight-bar span {
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border: 1px solid rgba(188, 215, 248, 0.58);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
}

.weather-insight-bar strong {
  color: #0e5fbf;
  font-size: 16px;
}

.weather-insight-bar em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.35;
}

.weather-grid {
  display: grid;
  grid-template-columns: minmax(340px, 0.9fr) minmax(360px, 1.1fr);
  gap: 14px;
}

.weather-grid > div {
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.event-form {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.form-actions {
  display: flex;
  gap: 8px;
}

.weather-node-list {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
}

.weather-node {
  display: grid;
  gap: 4px;
  text-align: left;
  width: 100%;
  background: rgba(255, 255, 255, 0.68);
  color: var(--ink);
  border: 1px solid rgba(188, 215, 248, 0.58);
  border-radius: 8px;
  padding: 10px;
  box-shadow: none;
}

.weather-node:hover,
.weather-node.active {
  background: rgba(239, 248, 255, 0.92);
  border-color: rgba(49, 121, 255, 0.36);
  box-shadow: 0 12px 28px rgba(70, 132, 214, 0.16);
}

.weather-node span {
  color: var(--muted);
  font-weight: 500;
  line-height: 1.45;
}

input[type="range"] {
  accent-color: var(--accent-2);
}

.split,
.data-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.split > div,
.data-grid > div,
.data-grid > details {
  padding: 16px;
}

.data-card.wide {
  grid-column: 1 / -1;
}

.technical-details p {
  line-height: 1.55;
}

.result-details {
  margin-top: 10px;
  border-top: 1px solid #edf0f4;
  padding-top: 10px;
}

.rank-list {
  display: grid;
  gap: 8px;
}

.rank-row {
  display: grid;
  grid-template-columns: 1fr 90px 90px;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #edf0f4;
  font-size: 13px;
}

.advice {
  color: var(--muted);
  line-height: 1.7;
}

.status-details,
.holiday-list {
  display: grid;
  gap: 10px;
}

.backtest-actions {
  margin: 12px 0;
}

.status-line,
.holiday-row {
  border-bottom: 1px solid #edf0f4;
  padding-bottom: 10px;
  line-height: 1.5;
}

.status-line strong,
.holiday-row strong {
  display: block;
  font-size: 14px;
}

.status-line span,
.holiday-row span {
  color: var(--muted);
  font-size: 13px;
}

code {
  color: #394150;
  background: #eef2f6;
  padding: 2px 5px;
  border-radius: 4px;
}

  @media (max-width: 1180px) {
  .daily-brief {
    grid-template-columns: 1fr 1fr;
  }
  .weather-brief {
    grid-column: 1 / -1;
  }
  .next-holiday-card {
    grid-column: auto;
  }
  .forecast-workspace,
  .forecast-board-grid {
    grid-template-columns: 1fr;
  }
  .template-workbench {
    grid-template-columns: 1fr;
  }
  .forecast-toolbar,
  .weather-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; }
  main { padding: 16px; }
  .topbar,
  .daily-brief,
  .split,
  .data-grid,
  .weather-grid,
  .forecast-workspace,
  .forecast-board-grid,
  .forecast-ops-panel,
  .template-workbench,
  .template-head,
  .selection-board,
  .template-builder-body,
  .status-strip { grid-template-columns: 1fr; display: grid; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .toolbar,
  .weather-mini-grid,
  .weather-brief-body,
  .template-actions,
  .template-manager,
  .template-buttons,
  .selected-group-head,
  .forecast-selected-panel { grid-template-columns: 1fr; }
  .selected-group-head .group-toggle { grid-column: auto; }
  .actions { justify-items: stretch; min-width: 0; }
  .topbar-right {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .account-button {
    width: 100%;
    grid-template-columns: 32px minmax(0, 1fr) auto;
  }
  .action-row { display: grid; grid-template-columns: 1fr 1fr; }
  #updateHint { text-align: left; }
  .today-card { grid-template-columns: 1fr; }
  .selected-group-items { padding-left: 0; }
}

@media (max-width: 720px) {
  body {
    background:
      radial-gradient(circle at 50% 0%, rgba(97, 178, 255, 0.16), transparent 30%),
      linear-gradient(135deg, #f7fbff 0%, #edf7ff 48%, #f8fcff 100%);
  }

  .sidebar {
    padding: 14px 14px 10px;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.74);
  }

  .brand {
    margin-bottom: 12px;
  }

  nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .nav {
    text-align: center;
    padding: 10px 6px;
    font-size: 14px;
  }

  main {
    padding: 14px 12px 24px;
  }

  .topbar {
    display: grid;
    gap: 12px;
  }

  h1 {
    font-size: 22px;
  }

  .actions {
    justify-items: stretch;
  }

  .daily-brief {
    display: none;
  }

  .toolbar {
    position: sticky;
    top: 0;
    z-index: 8;
    margin-inline: -4px;
    border-radius: 14px;
    padding: 10px;
  }

  .notice {
    padding: 9px;
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .notice span {
    flex: 0 0 auto;
  }

  .template-head,
  .template-library,
  .selected-products-panel,
  .candidate-head,
  .weather-grid > div,
  .chart-panel {
    border-radius: 14px;
    padding: 12px;
  }

  .template-head p {
    display: none;
  }

  .board-head,
  .candidate-head {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .board-actions,
  .form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .compact-action {
    width: 100%;
  }

  .forecast-selected-panel {
    min-height: 360px;
  }

  .product-picker {
    position: relative;
    inset: auto;
    width: 100%;
    min-height: 560px;
    padding: 10px;
    border-radius: 14px;
    grid-template-rows: auto minmax(360px, 1fr);
  }

  .candidate-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .product-list-filters,
  .selected-controls {
    grid-template-columns: 1fr;
  }

  .selected-template-section-head strong {
    width: 100%;
    margin-left: 0;
  }

  .template-multi-list {
    display: grid;
    grid-template-columns: 1fr;
    max-height: 230px;
  }

  .template-choice {
    width: 100%;
    max-width: none;
    border-radius: 10px;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .selected-product {
    grid-template-columns: 24px minmax(0, 1fr) auto;
    align-items: start;
    padding: 10px;
  }

  .selected-product .remove-selected {
    grid-column: 3;
    grid-row: 1 / span 3;
  }

  .selected-product em {
    grid-column: 2 / 3;
    white-space: normal;
    justify-items: start;
  }

  .selected-group-head {
    grid-template-columns: 24px minmax(0, 1fr) 32px;
  }

  .selected-group-main {
    grid-column: 2 / 3;
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .selected-group-head .group-toggle {
    grid-column: 3;
    grid-row: 1;
  }

  .selected-group-main .selected-group-count {
    grid-column: auto;
  }

  .selected-group-count,
  .selected-group-forecast,
  .selected-group-total {
    grid-column: 2 / 3;
  }

  .selected-group-forecast,
  .selected-group-total {
    white-space: normal;
    text-align: left;
  }

  .table-wrap {
    max-height: none;
    overflow: visible;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  #forecastRows tr[data-forecast-key] {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px 10px;
    padding: 11px;
    border: 1px solid rgba(255, 255, 255, 0.76);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: var(--soft-shadow);
  }

  #forecastRows tr[data-forecast-key] td {
    border: 0;
    padding: 0;
    white-space: normal;
  }

  #forecastRows .check-cell {
    grid-row: 1 / span 2;
    width: 32px;
    padding-top: 3px;
  }

  #forecastRows .product-cell {
    grid-column: 2;
  }

  #forecastRows td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
  }

  #forecastRows .check-cell::before,
  #forecastRows .product-cell::before {
    display: none;
  }

  #forecastRows .qty,
  #forecastRows .category-cell,
  #forecastRows tr[data-forecast-key] td:nth-child(5),
  #forecastRows .reason-cell {
    grid-column: 2;
  }

  .qty-stack {
    justify-items: start;
  }

  .weather-insight-bar {
    grid-template-columns: 1fr 1fr;
  }

  .weather-chart-panel canvas {
    height: 310px;
  }

  .weather-node-list {
    max-height: none;
  }
}

@media (max-width: 420px) {
  .action-row,
  .board-actions,
  .form-actions,
  .weather-insight-bar {
    grid-template-columns: 1fr;
  }

  .kpis {
    grid-template-columns: 1fr;
  }

  .rank-row {
    grid-template-columns: 1fr;
  }
}
