// Live Google Sheet preview (Settings tab). Pure HTML/CSS/SVG, never writes anything.

.ssgsw-react .ssgsw-an-app .ssgsw-sp {
	--sp-green: #1fa463;
	--sp-line: #dadce0;
	--sp-text: #3c4043;
	font-size: 12px;
	color: var(--sp-text);

	&__chip {
		display: inline-flex;
		align-items: center;
		gap: 6px;
		padding: 5px 12px;
		margin-bottom: 10px;
		border-radius: 999px;
		background: var(--an-brand-soft);
		color: var(--an-brand-strong);
		font-weight: 600;
		font-size: 12px;
		line-height: 1.3;
	}

	&__stage {
		display: grid;
		gap: 14px;
	}

	&__caption {
		margin: 10px 0 0;
		padding: 8px 10px;
		border-radius: 8px;
		background: var(--an-warning-soft);
		color: var(--an-warning);
		font-size: 12px;
	}

	&__note {
		margin: 10px 2px 0;
		font-size: 11.5px;
		color: var(--an-text-3);
	}

	&__replay {
		display: inline-flex;
		align-items: center;
		gap: 6px;
		margin-top: 8px;
		padding: 5px 10px;
		border: 1px dashed #c4c8e6;
		border-radius: 8px;
		background: #fff;
		color: var(--an-brand-strong);
		font: inherit;
		font-size: 12px;
		cursor: pointer;

		&:hover {
			background: var(--an-brand-soft);
		}
	}
}

// ---- Sheet window ---------------------------------------------------------------------------
.ssgsw-react .ssgsw-an-app .ssgsw-sw {
	position: relative;
	background: #fff;
	border: 1px solid var(--sp-line, #dadce0);
	border-radius: 10px;
	box-shadow: 0 6px 20px rgba(30, 33, 64, 0.09);
	overflow: hidden;
	font-size: 11px;

	&__title {
		display: flex;
		align-items: center;
		gap: 8px;
		padding: 7px 10px;
		background: #f8f9fa;
		border-bottom: 1px solid var(--sp-line, #dadce0);
	}

	&__name {
		font-size: 12px;
		font-weight: 500;
		color: #202124;
	}

	&__star {
		color: #9aa0a6;
	}

	&__share {
		margin-left: auto;
		padding: 3px 12px;
		border-radius: 999px;
		background: #c2e7ff;
		color: #001d35;
		font-weight: 500;
	}

	&__menubar {
		position: relative;
		display: flex;
		gap: 12px;
		padding: 5px 10px;
		background: #f8f9fa;
		border-bottom: 1px solid var(--sp-line, #dadce0);
		color: #3c4043;
		white-space: nowrap;
		overflow: visible;
	}

	&__stocksync {
		padding: 0 6px;
		margin: 0 -6px;
		border-radius: 4px;
		color: var(--an-brand-strong);
		font-weight: 600;

		&.is-open {
			background: var(--an-brand-soft);
		}
	}

	&__dropdown {
		position: absolute;
		z-index: 4;
		top: 24px;
		left: 220px;
		display: flex;
		flex-direction: column;
		min-width: 150px;
		padding: 4px;
		background: #fff;
		border: 1px solid var(--sp-line, #dadce0);
		border-radius: 8px;
		box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);

		span {
			display: flex;
			align-items: center;
			gap: 6px;
			padding: 5px 8px;
			border-radius: 5px;
		}
	}

	&__dd-an {
		max-height: 0;
		padding-top: 0 !important;
		padding-bottom: 0 !important;
		opacity: 0;
		overflow: hidden;
		color: var(--an-brand-strong);
		font-weight: 600;
		transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s;

		&.is-visible {
			max-height: 30px;
			opacity: 1;
			padding: 5px 8px !important;
			background: var(--an-brand-soft);
		}
	}

	&__body {
		position: relative;
		display: flex;
		min-height: 190px;
	}

	&__sheet {
		flex: 1;
		min-width: 0;
		padding: 0;
		overflow: hidden;
		transition: opacity 0.2s;

		&.is-dimmed {
			opacity: 0.4;
		}
	}

	&__sidebar {
		width: 0;
		overflow: hidden;
		border-left: 0 solid var(--sp-line, #dadce0);
		background: #fff;
		transition: width 0.35s ease;

		&.is-open {
			width: 44%;
			border-left-width: 1px;
		}
	}

	&__caption {
		margin: 0;
		padding: 6px 10px;
		color: var(--an-text-2);
		background: #fafafa;
		border-top: 1px solid #eee;
		font-size: 11px;
	}

	&__totals {
		display: flex;
		justify-content: space-between;
		padding: 7px 10px;
		background: #f1f3f4;
		border-top: 1px solid var(--sp-line, #dadce0);
		font-size: 11.5px;

		strong {
			color: #202124;
		}
	}

	&__off {
		position: absolute;
		inset: 0;
		display: grid;
		place-items: center;
		background: rgba(246, 247, 251, 0.72);
		backdrop-filter: grayscale(1);

		span {
			padding: 6px 14px;
			border-radius: 999px;
			background: #fff;
			border: 1px solid var(--an-border);
			font-weight: 600;
			color: var(--an-text-2);
			box-shadow: var(--an-shadow);
		}
	}

	&__tabs {
		display: flex;
		align-items: flex-end;
		gap: 2px;
		padding: 4px 8px 0;
		background: #f1f3f4;
		border-top: 1px solid var(--sp-line, #dadce0);
		overflow-x: auto;
		scrollbar-width: none;
	}

	&__plus {
		padding: 3px 8px;
		color: #5f6368;
		font-size: 14px;
	}

	&__tab {
		padding: 4px 10px;
		border: 0;
		border-radius: 6px 6px 0 0;
		background: transparent;
		font: inherit;
		color: #5f6368;
		white-space: nowrap;

		&.is-active {
			background: #fff;
			color: #0b6b3a;
			font-weight: 600;
			box-shadow: inset 0 -2px 0 var(--sp-green, #1fa463);
		}

		&.is-fs {
			animation: sp-in 0.3s ease both;

			&:not(.is-active) {
				color: #137333;
			}
		}

		&[tabindex='0'] {
			cursor: pointer;

			&:hover {
				background: #e8eaed;
			}
		}
	}
}

@keyframes sp-in {
	from {
		opacity: 0;
		transform: translateY(4px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

// ---- Grid -----------------------------------------------------------------------------------
.ssgsw-react .ssgsw-an-app .ssgsw-grid {
	width: 100%;
	border-collapse: collapse;
	table-layout: fixed;
	margin: 0;
	font-size: 10.5px;

	th,
	td {
		padding: 2px 6px;
		border: 1px solid #e3e5e8;
		height: 20px;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		text-align: left;
		font-weight: 400;
		color: #202124;
	}

	th:first-child {
		width: 22px;
		padding: 2px;
		text-align: center;
		background: #f8f9fa;
		color: #80868b;
	}

	&__letters th {
		background: #f8f9fa;
		color: #80868b;
		text-align: center;
		height: 17px;
	}

	&__head td {
		background: #f3f0ff;
		font-weight: 600;
		color: #3c2e9c;
	}

	.is-num {
		text-align: right;
	}

	tr.is-row {
		animation: sp-in 0.28s ease both;
	}

	tr.is-hl td {
		background: #f4f2ff;
		box-shadow: inset 0 0 0 9999px rgba(104, 109, 224, 0.04);
	}

	.is-up {
		color: #137333;
	}

	.is-down {
		color: #c5221f;
	}

	.is-muted {
		color: #9aa0a6;
	}

	.st-out_of_stock {
		color: #c5221f;
		font-weight: 600;
	}

	.st-low_stock,
	.st-at_risk {
		color: #b06000;
		font-weight: 600;
	}

	.st-overstock {
		color: #1a5fd4;
		font-weight: 600;
	}

	.st-dead_stock {
		color: #80868b;
		font-weight: 600;
	}
}

// ---- Sidebar panel ----------------------------------------------------------------------------
.ssgsw-react .ssgsw-an-app .ssgsw-side {
	min-width: 150px;
	padding: 8px 10px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	height: 100%;

	&__head {
		display: flex;
		align-items: center;
		gap: 6px;
		color: var(--an-brand-strong);
		font-size: 11.5px;
	}

	&__x {
		margin-left: auto;
		color: #9aa0a6;
	}

	&__kpis {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 6px;

		div {
			padding: 6px 8px;
			border: 1px solid var(--an-border);
			border-radius: 7px;
			display: flex;
			flex-direction: column;
		}

		small {
			color: var(--an-text-3);
			font-size: 10px;
		}

		strong {
			font-size: 13px;
			color: var(--an-text);
		}
	}
}

.ssgsw-react .ssgsw-an-app .ssgsw-bars {
	width: 100%;
	height: 54px;
	display: block;

	rect {
		fill: #aab0f2;
	}

	rect:nth-last-child(-n + 7) {
		fill: var(--an-brand);
	}
}

.ssgsw-react .ssgsw-an-app .ssgsw-dashmini {
	padding: 10px;
	display: grid;
	gap: 8px;
}

.ssgsw-react .ssgsw-an-app .ssgsw-insmini {
	padding: 10px 12px;
	display: grid;
	gap: 6px;

	p {
		margin: 0;
		font-size: 11.5px;
	}

	b {
		display: inline-block;
		margin-right: 6px;
		padding: 0 7px;
		border-radius: 999px;
		font-size: 10px;
		color: #fff;
	}

	.is-crit {
		background: #c5221f;
	}

	.is-warn {
		background: #e37400;
	}

	.is-info {
		background: #1a73e8;
	}
}

// ---- WordPress mini window ------------------------------------------------------------------
.ssgsw-react .ssgsw-an-app .ssgsw-wp {
	border: 1px solid var(--an-border);
	border-radius: 10px;
	background: #fff;
	overflow: hidden;
	box-shadow: var(--an-shadow);

	&__bar {
		display: flex;
		align-items: center;
		gap: 5px;
		padding: 6px 10px;
		background: #f1f2f6;
	}

	&__dot {
		width: 7px;
		height: 7px;
		border-radius: 50%;
		background: #cfd2dc;
	}

	&__url {
		margin-left: 8px;
		padding: 1px 10px;
		border-radius: 999px;
		background: #fff;
		font-size: 10px;
		color: var(--an-text-3);
	}

	&__body {
		display: flex;
		min-height: 84px;
	}

	&__menu {
		width: 34px;
		padding: 8px 6px;
		background: #1d2327;
		display: flex;
		flex-direction: column;
		gap: 6px;

		span {
			height: 6px;
			border-radius: 3px;
			background: #50575e;
		}

		.is-on {
			background: var(--an-brand);
		}
	}

	&__main {
		flex: 1;
		padding: 10px 12px;
		display: grid;
		gap: 6px;
		align-content: start;

		strong {
			font-size: 12px;
		}
	}

	&__tabs {
		display: flex;
		gap: 12px;
		border-bottom: 1px solid var(--an-border);
		font-size: 11px;
		color: var(--an-text-3);

		span {
			padding: 2px 0 4px;
		}

		.is-active {
			color: var(--an-brand-strong);
			font-weight: 600;
			box-shadow: inset 0 -2px 0 var(--an-brand);
		}
	}

	&__an {
		max-width: 0;
		opacity: 0;
		overflow: hidden;
		transition: max-width 0.35s ease, opacity 0.35s ease;

		&.is-visible {
			max-width: 80px;
			opacity: 1;
			color: var(--an-brand-strong);
			font-weight: 600;
		}
	}

	&__lines {
		display: grid;
		gap: 4px;

		span {
			height: 6px;
			border-radius: 3px;
			background: #eceef4;

			&:nth-child(2) {
				width: 70%;
			}

			&:nth-child(3) {
				width: 45%;
			}
		}
	}

	&__label {
		margin: 0;
		padding: 6px 12px;
		border-top: 1px solid var(--an-border);
		font-size: 11px;
		color: var(--an-text-2);
		background: #fafbfe;
	}
}

// ---- Sync flow / timeline -------------------------------------------------------------------
.ssgsw-react .ssgsw-an-app .ssgsw-flow {
	padding: 12px 14px;
	background: #fff;
	border: 1px solid var(--an-border);
	border-radius: 10px;

	&__who {
		display: flex;
		align-items: center;
		gap: 8px;

		&.is-muted {
			opacity: 0.45;
		}
	}

	&__node {
		padding: 5px 10px;
		border-radius: 8px;
		background: var(--an-brand-soft);
		color: var(--an-brand-strong);
		font-weight: 600;

		&.is-sheet {
			background: #e5f5ec;
			color: #137333;
		}
	}

	&__arrow {
		color: var(--an-text-3);
	}
}

.ssgsw-react .ssgsw-an-app .ssgsw-timeline {
	list-style: none;
	margin: 12px 0 0;
	padding: 0 0 0 6px;
	border-left: 2px solid var(--an-border);
	display: grid;
	gap: 7px;

	li {
		position: relative;
		margin: 0;
		padding-left: 14px;
		animation: sp-in 0.3s ease both;

		&.is-muted {
			color: var(--an-text-3);
		}
	}

	&__dot {
		position: absolute;
		left: -11px;
		top: 4px;
		width: 8px;
		height: 8px;
		border-radius: 50%;
		background: var(--an-brand);
		box-shadow: 0 0 0 3px #fff;
	}

	.is-order .ssgsw-timeline__dot {
		background: #e37400;
	}

	.is-fix .ssgsw-timeline__dot {
		background: #1fa463;
	}
}

// ---- Stock rules card -------------------------------------------------------------------------
.ssgsw-react .ssgsw-an-app .ssgsw-sk {
	background: #fff;
	border: 1px solid var(--an-border);
	border-radius: 12px;
	box-shadow: var(--an-shadow);
	padding: 16px;
	font-size: 12.5px;

	&__head {
		display: flex;
		justify-content: space-between;
		align-items: flex-start;
		gap: 10px;

		strong {
			display: block;
			font-size: 14px;
			color: var(--an-text);
		}

		small {
			color: var(--an-text-3);
		}
	}

	&__inputs {
		display: grid;
		grid-template-columns: repeat(3, 1fr);
		gap: 8px;
		margin: 14px 0;
	}

	&__in {
		display: flex;
		flex-direction: column;
		gap: 3px;
		color: var(--an-text-3);
		font-size: 11.5px;

		input {
			min-height: 32px;
			border: 1px solid #d5d8e6;
			border-radius: 7px;
			padding: 2px 8px;
			font: inherit;
			color: var(--an-text);
			width: 100%;
		}
	}

	&__stats {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 8px;

		div {
			padding: 10px 12px;
			background: var(--an-page);
			border-radius: 9px;
			display: flex;
			flex-direction: column;
		}

		small {
			color: var(--an-text-3);
		}

		strong {
			font-size: 17px;
			color: var(--an-text);
		}
	}

	&__formula {
		margin: 12px 0 0;
		padding: 8px 10px;
		border-radius: 8px;
		background: var(--an-brand-soft);
		color: var(--an-brand-strong);
		font-variant-numeric: tabular-nums;
	}

	&__flag {
		display: flex;
		gap: 6px;
		align-items: center;
		margin: 10px 0 0;
		color: var(--an-warning);
		font-weight: 600;
	}
}

.ssgsw-react .ssgsw-an-app .ssgsw-chipst {
	display: inline-flex;
	padding: 3px 10px;
	border-radius: 999px;
	font-size: 11.5px;
	font-weight: 600;
	white-space: nowrap;
	transition: background 0.2s, color 0.2s;
	background: var(--an-success-soft);
	color: var(--an-success);

	&--out_of_stock {
		background: var(--an-danger-soft);
		color: var(--an-danger);
	}

	&--low_stock,
	&--at_risk {
		background: var(--an-warning-soft);
		color: var(--an-warning);
	}

	&--overstock {
		background: var(--an-info-soft);
		color: var(--an-info);
	}

	&--dead_stock {
		background: #eceef2;
		color: #5b6078;
	}
}

// ---- Forecast and margin ----------------------------------------------------------------------
.ssgsw-react .ssgsw-an-app .ssgsw-fc,
.ssgsw-react .ssgsw-an-app .ssgsw-mg,
.ssgsw-react .ssgsw-an-app .ssgsw-mail,
.ssgsw-react .ssgsw-an-app .ssgsw-slack {
	background: #fff;
	border: 1px solid var(--an-border);
	border-radius: 12px;
	box-shadow: var(--an-shadow);
	padding: 14px 16px;
}

.ssgsw-react .ssgsw-an-app .ssgsw-fc {
	&__head,
	&.ssgsw-mg__head {
		display: flex;
		justify-content: space-between;
		align-items: baseline;

		small {
			color: var(--an-text-3);
		}
	}

	svg {
		width: 100%;
		height: auto;
		display: block;
		margin-top: 6px;
	}

	&__now {
		stroke: #c9cde0;
		stroke-dasharray: 3 3;
	}

	&__hist {
		stroke: #aab0f2;
		stroke-width: 2;
	}

	&__line {
		stroke: var(--an-brand);
		stroke-width: 2.2;
		stroke-dasharray: 5 3;
	}

	&__band {
		fill: rgba(104, 109, 224, 0.14);
	}

	&__legend {
		display: flex;
		gap: 14px;
		margin-top: 6px;
		color: var(--an-text-2);
		font-size: 11px;

		span {
			display: inline-flex;
			align-items: center;
			gap: 5px;
		}

		i {
			width: 14px;
			height: 4px;
			border-radius: 2px;
			display: inline-block;
		}

		.is-hist {
			background: #aab0f2;
		}

		.is-fc {
			background: var(--an-brand);
		}

		.is-band {
			background: rgba(104, 109, 224, 0.25);
			height: 8px;
		}
	}

	&__out {
		display: flex;
		gap: 6px;
		align-items: center;
		margin: 10px 0 0;
		padding: 8px 10px;
		border-radius: 8px;
		background: var(--an-warning-soft);
		color: var(--an-warning);
		font-weight: 600;

		&.is-muted {
			background: var(--an-page);
			color: var(--an-text-3);
		}
	}

	&.is-off svg {
		opacity: 0.5;
	}
}

.ssgsw-react .ssgsw-an-app .ssgsw-mg {
	&__head {
		display: flex;
		justify-content: space-between;
		align-items: baseline;

		small {
			color: var(--an-text-3);
		}
	}

	&__grid {
		display: grid;
		grid-template-columns: repeat(3, 1fr);
		gap: 8px;
		margin-top: 10px;

		div {
			padding: 8px 10px;
			background: var(--an-page);
			border-radius: 9px;
			display: flex;
			flex-direction: column;
		}

		small {
			color: var(--an-text-3);
		}

		strong {
			font-size: 16px;
		}

		.is-up {
			color: var(--an-success);
		}
	}

	&__from {
		margin: 8px 0 0;
		color: var(--an-text-3);
		font-size: 11.5px;
	}
}

// ---- AI panel ---------------------------------------------------------------------------------
.ssgsw-react .ssgsw-an-app .ssgsw-ai {
	&__empty {
		display: grid;
		gap: 4px;
		justify-items: center;
		text-align: center;
		padding: 18px 8px;
		color: var(--an-text-2);
		font-size: 11px;
		animation: sp-in 0.3s ease both;

		svg {
			color: var(--an-brand);
		}

		strong {
			color: var(--an-text);
			font-size: 12px;
		}
	}

	&__chat {
		display: grid;
		gap: 6px;
		animation: sp-in 0.3s ease both;
	}

	&__q {
		margin: 0;
		justify-self: end;
		max-width: 90%;
		padding: 6px 9px;
		border-radius: 10px 10px 2px 10px;
		background: var(--an-brand);
		color: #fff;
		font-size: 11px;
	}

	&__a {
		margin: 0;
		padding: 7px 9px;
		border-radius: 10px 10px 10px 2px;
		background: var(--an-page);
		font-size: 11px;
		line-height: 1.4;
	}

	&__sent {
		margin: 0;
		display: flex;
		gap: 5px;
		align-items: center;
		color: var(--an-text-3);
		font-size: 10px;
	}

	&__meter {
		margin-top: auto;
		height: 5px;
		border-radius: 3px;
		background: #eceef4;
		overflow: hidden;

		span {
			display: block;
			height: 100%;
			background: var(--an-brand);
			transition: width 0.3s ease;
		}
	}

	&__metertxt {
		color: var(--an-text-3);
		font-size: 10px;
	}
}

// ---- Alerts ------------------------------------------------------------------------------------
.ssgsw-react .ssgsw-an-app .ssgsw-al {
	display: grid;
	gap: 12px;

	&.is-off .ssgsw-mail,
	&.is-off .ssgsw-slack {
		opacity: 0.45;
	}

	&__off {
		margin: 0;
		padding: 8px 12px;
		border-radius: 8px;
		background: var(--an-page);
		color: var(--an-text-2);
		font-weight: 600;
	}
}

.ssgsw-react .ssgsw-an-app .ssgsw-mail {
	animation: sp-in 0.3s ease both;

	&__head {
		display: flex;
		align-items: center;
		gap: 7px;
		color: var(--an-text);

		small {
			margin-left: auto;
			color: var(--an-text-3);
		}
	}

	&__to {
		display: block;
		margin: 4px 0 6px;
		color: var(--an-text-3);
	}

	p {
		margin: 8px 0 0;
		color: var(--an-text-2);
	}

	ul {
		margin: 6px 0 0 16px;
		padding: 0;
		color: var(--an-text-2);

		li {
			margin: 2px 0;
		}
	}
}

.ssgsw-react .ssgsw-an-app .ssgsw-slack {
	display: flex;
	gap: 10px;
	animation: sp-in 0.3s ease both;

	&__av {
		flex: none;
		width: 32px;
		height: 32px;
		border-radius: 7px;
		display: grid;
		place-items: center;
		background: var(--an-brand);
		color: #fff;
		font-weight: 700;
		font-size: 11px;
	}

	strong small {
		margin-left: 4px;
		padding: 0 4px;
		border-radius: 3px;
		background: #e8e8e8;
		color: #616061;
		font-size: 9px;
	}

	p {
		margin: 2px 0 0;
		color: var(--an-text-2);
	}
}

.ssgsw-react .ssgsw-an-app .ssgsw-quiet {
	padding: 12px 14px;
	background: #fff;
	border: 1px solid var(--an-border);
	border-radius: 12px;

	&__strip {
		display: grid;
		grid-template-columns: repeat(24, 1fr);
		gap: 2px;
		margin-top: 8px;

		span {
			height: 16px;
			border-radius: 3px;
			background: #cfeedd;
			transition: background 0.2s;

			&.is-quiet {
				background: #5a5f86;
			}
		}
	}

	&__scale {
		display: flex;
		justify-content: space-between;
		margin-top: 3px;
		color: var(--an-text-3);
		font-size: 10px;
	}
}

// ---- Vendors ----------------------------------------------------------------------------------
.ssgsw-react .ssgsw-an-app .ssgsw-two {
	display: grid;
	gap: 14px;

	&__label {
		margin: 0 0 6px;
		font-weight: 600;
		color: var(--an-text-2);
	}
}

@media (max-width: 1199px) {
	.ssgsw-react .ssgsw-an-app .ssgsw-sp {
		max-width: 640px;
	}
}
